Index: src/org/openstreetmap/josm/plugins/openLayers/ShowOpenLayersAction.java =================================================================== --- src/org/openstreetmap/josm/plugins/openLayers/ShowOpenLayersAction.java (revision 10660) +++ src/org/openstreetmap/josm/plugins/openLayers/ShowOpenLayersAction.java (working copy) @@ -9,7 +9,7 @@ public class ShowOpenLayersAction extends JosmAction { public ShowOpenLayersAction(String name) { - super(name, "OpenLayers", "Show layer" + name, 0, 0, false); + super(name, "OpenLayers", "Show layer " + name, 0, 0, false); } public void actionPerformed(ActionEvent e) { Index: src/org/openstreetmap/josm/plugins/openLayers/Browser.java =================================================================== --- src/org/openstreetmap/josm/plugins/openLayers/Browser.java (revision 10660) +++ src/org/openstreetmap/josm/plugins/openLayers/Browser.java (working copy) @@ -27,9 +27,11 @@ Dimension oldSize = null; - public Browser(String uri) { + public Browser(String uri, MyHtmlBlockPanel.ViewUpdateListener vul) { super(); + view_update_listener = vul; + UserAgentContext ucontext = new CacheableUserAgentContext(); rcontext = new SimpleHtmlRendererContext(this, ucontext); addNotify(); @@ -98,12 +100,22 @@ return null; } + MyHtmlBlockPanel.ViewUpdateListener view_update_listener; /** * Overrided to hide hardcoded scrollbars and insets */ @Override protected HtmlBlockPanel createHtmlBlockPanel(UserAgentContext ucontext, HtmlRendererContext rcontext) { - return new MyHtmlBlockPanel(java.awt.Color.WHITE, true, ucontext, rcontext, this); + return new MyHtmlBlockPanel(java.awt.Color.WHITE, true, + ucontext, rcontext, this, view_update_listener); } + + /** + * Get page loading status from the bottom status bar. + */ + public String getStatus() { + /* TODO */ + return "Tile loaded"; + } } Index: src/org/openstreetmap/josm/plugins/openLayers/MyHtmlBlockPanel.java =================================================================== --- src/org/openstreetmap/josm/plugins/openLayers/MyHtmlBlockPanel.java (revision 10660) +++ src/org/openstreetmap/josm/plugins/openLayers/MyHtmlBlockPanel.java (working copy) @@ -17,6 +17,11 @@ private static final long serialVersionUID = -4778865358510293592L; + public interface ViewUpdateListener { + void region_update(int x, int y, int w, int h); + } + ViewUpdateListener view_update_listener; + /** * Constructor * @param background @@ -25,8 +30,10 @@ * @param rcontext * @param frameContext */ - public MyHtmlBlockPanel(Color background, boolean opaque, UserAgentContext pcontext, HtmlRendererContext rcontext, FrameContext frameContext) { + public MyHtmlBlockPanel(Color background, boolean opaque, UserAgentContext pcontext, HtmlRendererContext rcontext, FrameContext frameContext, + ViewUpdateListener vul) { super(background, opaque, pcontext, rcontext, frameContext); + view_update_listener = vul; } /** @@ -47,4 +54,9 @@ this.validateAll(); this.repaint(); } -} \ No newline at end of file + + public void repaint(int x, int y, int width, int height) { + super.repaint(x, y, width, height); + view_update_listener.region_update(x, y, width, height); + } +} Index: src/org/openstreetmap/josm/plugins/openLayers/OpenLayersLayer.java =================================================================== --- src/org/openstreetmap/josm/plugins/openLayers/OpenLayersLayer.java (revision 10660) +++ src/org/openstreetmap/josm/plugins/openLayers/OpenLayersLayer.java (working copy) @@ -24,7 +24,9 @@ * @author Francisco R. Santos * */ -public class OpenLayersLayer extends Layer implements PreferenceChangedListener, PropertyChangeListener { +public class OpenLayersLayer extends Layer + implements PreferenceChangedListener, PropertyChangeListener, + MyHtmlBlockPanel.ViewUpdateListener { private Browser browser; @@ -33,9 +35,10 @@ */ public OpenLayersLayer() { super("OpenLayers"); - - this.browser = new Browser(OpenLayersPlugin.pluginDir + "yahoo.html"); - + + this.browser = new Browser(OpenLayersPlugin.pluginDir + "yahoo.html", + this); + if( Main.map != null ) { LatLon bottomLeft = Main.map.mapView.getLatLon(0,Main.map.mapView.getHeight()); @@ -129,18 +132,18 @@ LatLon bottomLeft = Main.map.mapView.getLatLon(0,Main.map.mapView.getHeight()); LatLon topRight = Main.map.mapView.getLatLon(Main.map.mapView.getWidth(), 0); Object value = browser.executeScript("zoomMapToExtent(" + bottomLeft.lon() + "," + bottomLeft.lat() + "," + topRight.lon() + "," + topRight.lat() + ")"); - if( value != null && false) - { - // TODO wrong calculations - + if (value != null && false) { + // TODO: should not be touching Main.map.mapView here as this + // causes endless recurrency - should do the scalling ourselves + // Get actual extent from browser NativeArray array = (NativeArray)value; double left = ((Double)array.get(0, null)).doubleValue(); double bottom = ((Double)array.get(1, null)).doubleValue(); double right = ((Double)array.get(2, null)).doubleValue(); double top = ((Double)array.get(3, null)).doubleValue(); - bottomLeft = new LatLon( bottom, left ); - topRight = new LatLon( top, right); + bottomLeft = new LatLon(bottom, left); + topRight = new LatLon(top, right); BoundingXYVisitor v = new BoundingXYVisitor(); v.visit(Main.proj.latlon2eastNorth(bottomLeft)); @@ -149,4 +152,12 @@ Main.map.mapView.recalculateCenterScale(v); } } + + public void region_update(int x, int y, int w, int h) { + String status = browser.getStatus(); + + org.openstreetmap.josm.Main.map.mapView.repaint(x, y, w, h); + + org.openstreetmap.josm.Main.map.statusLine.setHelpText(status); + } }