Ticket #1572: openlayers-repaint.txt

File openlayers-repaint.txt, 6.0 KB (added by stoecker, 18 years ago)
Line 
1Index: src/org/openstreetmap/josm/plugins/openLayers/ShowOpenLayersAction.java
2===================================================================
3--- src/org/openstreetmap/josm/plugins/openLayers/ShowOpenLayersAction.java (revision 10660)
4+++ src/org/openstreetmap/josm/plugins/openLayers/ShowOpenLayersAction.java (working copy)
5@@ -9,7 +9,7 @@
6 public class ShowOpenLayersAction extends JosmAction {
7
8 public ShowOpenLayersAction(String name) {
9- super(name, "OpenLayers", "Show layer" + name, 0, 0, false);
10+ super(name, "OpenLayers", "Show layer " + name, 0, 0, false);
11 }
12
13 public void actionPerformed(ActionEvent e) {
14Index: src/org/openstreetmap/josm/plugins/openLayers/Browser.java
15===================================================================
16--- src/org/openstreetmap/josm/plugins/openLayers/Browser.java (revision 10660)
17+++ src/org/openstreetmap/josm/plugins/openLayers/Browser.java (working copy)
18@@ -27,9 +27,11 @@
19
20 Dimension oldSize = null;
21
22- public Browser(String uri) {
23+ public Browser(String uri, MyHtmlBlockPanel.ViewUpdateListener vul) {
24 super();
25
26+ view_update_listener = vul;
27+
28 UserAgentContext ucontext = new CacheableUserAgentContext();
29 rcontext = new SimpleHtmlRendererContext(this, ucontext);
30 addNotify();
31@@ -98,12 +100,22 @@
32 return null;
33 }
34
35+ MyHtmlBlockPanel.ViewUpdateListener view_update_listener;
36
37 /**
38 * Overrided to hide hardcoded scrollbars and insets
39 */
40 @Override
41 protected HtmlBlockPanel createHtmlBlockPanel(UserAgentContext ucontext, HtmlRendererContext rcontext) {
42- return new MyHtmlBlockPanel(java.awt.Color.WHITE, true, ucontext, rcontext, this);
43+ return new MyHtmlBlockPanel(java.awt.Color.WHITE, true,
44+ ucontext, rcontext, this, view_update_listener);
45 }
46+
47+ /**
48+ * Get page loading status from the bottom status bar.
49+ */
50+ public String getStatus() {
51+ /* TODO */
52+ return "Tile loaded";
53+ }
54 }
55Index: src/org/openstreetmap/josm/plugins/openLayers/MyHtmlBlockPanel.java
56===================================================================
57--- src/org/openstreetmap/josm/plugins/openLayers/MyHtmlBlockPanel.java (revision 10660)
58+++ src/org/openstreetmap/josm/plugins/openLayers/MyHtmlBlockPanel.java (working copy)
59@@ -17,6 +17,11 @@
60
61 private static final long serialVersionUID = -4778865358510293592L;
62
63+ public interface ViewUpdateListener {
64+ void region_update(int x, int y, int w, int h);
65+ }
66+ ViewUpdateListener view_update_listener;
67+
68 /**
69 * Constructor
70 * @param background
71@@ -25,8 +30,10 @@
72 * @param rcontext
73 * @param frameContext
74 */
75- public MyHtmlBlockPanel(Color background, boolean opaque, UserAgentContext pcontext, HtmlRendererContext rcontext, FrameContext frameContext) {
76+ public MyHtmlBlockPanel(Color background, boolean opaque, UserAgentContext pcontext, HtmlRendererContext rcontext, FrameContext frameContext,
77+ ViewUpdateListener vul) {
78 super(background, opaque, pcontext, rcontext, frameContext);
79+ view_update_listener = vul;
80 }
81
82 /**
83@@ -47,4 +54,9 @@
84 this.validateAll();
85 this.repaint();
86 }
87-}
88\ No newline at end of file
89+
90+ public void repaint(int x, int y, int width, int height) {
91+ super.repaint(x, y, width, height);
92+ view_update_listener.region_update(x, y, width, height);
93+ }
94+}
95Index: src/org/openstreetmap/josm/plugins/openLayers/OpenLayersLayer.java
96===================================================================
97--- src/org/openstreetmap/josm/plugins/openLayers/OpenLayersLayer.java (revision 10660)
98+++ src/org/openstreetmap/josm/plugins/openLayers/OpenLayersLayer.java (working copy)
99@@ -24,7 +24,9 @@
100 * @author Francisco R. Santos <frsantos@gmail.com>
101 *
102 */
103-public class OpenLayersLayer extends Layer implements PreferenceChangedListener, PropertyChangeListener {
104+public class OpenLayersLayer extends Layer
105+ implements PreferenceChangedListener, PropertyChangeListener,
106+ MyHtmlBlockPanel.ViewUpdateListener {
107
108 private Browser browser;
109
110@@ -33,9 +35,10 @@
111 */
112 public OpenLayersLayer() {
113 super("OpenLayers");
114-
115- this.browser = new Browser(OpenLayersPlugin.pluginDir + "yahoo.html");
116-
117+
118+ this.browser = new Browser(OpenLayersPlugin.pluginDir + "yahoo.html",
119+ this);
120+
121 if( Main.map != null )
122 {
123 LatLon bottomLeft = Main.map.mapView.getLatLon(0,Main.map.mapView.getHeight());
124@@ -129,18 +132,18 @@
125 LatLon bottomLeft = Main.map.mapView.getLatLon(0,Main.map.mapView.getHeight());
126 LatLon topRight = Main.map.mapView.getLatLon(Main.map.mapView.getWidth(), 0);
127 Object value = browser.executeScript("zoomMapToExtent(" + bottomLeft.lon() + "," + bottomLeft.lat() + "," + topRight.lon() + "," + topRight.lat() + ")");
128- if( value != null && false)
129- {
130- // TODO wrong calculations
131-
132+ if (value != null && false) {
133+ // TODO: should not be touching Main.map.mapView here as this
134+ // causes endless recurrency - should do the scalling ourselves
135+
136 // Get actual extent from browser
137 NativeArray array = (NativeArray)value;
138 double left = ((Double)array.get(0, null)).doubleValue();
139 double bottom = ((Double)array.get(1, null)).doubleValue();
140 double right = ((Double)array.get(2, null)).doubleValue();
141 double top = ((Double)array.get(3, null)).doubleValue();
142- bottomLeft = new LatLon( bottom, left );
143- topRight = new LatLon( top, right);
144+ bottomLeft = new LatLon(bottom, left);
145+ topRight = new LatLon(top, right);
146
147 BoundingXYVisitor v = new BoundingXYVisitor();
148 v.visit(Main.proj.latlon2eastNorth(bottomLeft));
149@@ -149,4 +152,12 @@
150 Main.map.mapView.recalculateCenterScale(v);
151 }
152 }
153+
154+ public void region_update(int x, int y, int w, int h) {
155+ String status = browser.getStatus();
156+
157+ org.openstreetmap.josm.Main.map.mapView.repaint(x, y, w, h);
158+
159+ org.openstreetmap.josm.Main.map.statusLine.setHelpText(status);
160+ }
161 }