1 /*--------------------------------------------------------------------------
2 * Copyright 2007 utgenome.org
3 *
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
7 *
8 * http://www.apache.org/licenses/LICENSE-2.0
9 *
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
15 *--------------------------------------------------------------------------*/
16 //--------------------------------------
17 // utgb-core Project
18 //
19 // SVGPanel.java
20 // Since: 2007/11/26
21 //
22 // $URL$
23 // $Author$
24 //--------------------------------------
25 package org.utgenome.gwt.utgb.client.ui;
26
27 import com.google.gwt.user.client.DOM;
28 import com.google.gwt.user.client.ui.Composite;
29 import com.google.gwt.user.client.ui.SimplePanel;
30
31 /**
32 * @author leo
33 *
34 */
35 public class SVGPanel extends Composite {
36 private static final String idPrefix = "svgpanel";
37 private static int panelCount = 1;
38
39 private final SimplePanel basePanel = new SimplePanel();
40 private final int panelID;
41
42 public SVGPanel() {
43 panelID = panelCount++;
44 init();
45 }
46
47 public SVGPanel(String url) {
48 panelID = panelCount++;
49 init();
50
51 setSVGFromURL(url);
52 }
53
54 protected void init() {
55 DOM.setElementAttribute(basePanel.getElement(), "id", idPrefix + panelID);
56 initWidget(basePanel);
57 }
58
59 public void setSVGFromURL(String url) {
60 setSVGFromURL_internal(idPrefix + panelID, url);
61 }
62
63 protected native void setSVGFromURL_internal(String id, String url) /*-{
64 new $wnd.Ajax.Updater(id, url, { method: 'get' });
65 }-*/;
66
67 /*
68 * { HTTPRequest.asyncGet(url, new ResponseTextHandler() { public void onCompletion(String svg) { setSVG(svg); } } ); }
69 */
70
71 }