summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorstepan.rutz2012-05-05 18:14:43 (EDT)
committer Hallvard Traetteberg2012-06-02 09:19:26 (EDT)
commit355a48eacc1dd01a2dd547171d7247a463a67a2e (patch)
tree26765b19ddb4e20c096421e61a1b3a70272b509d
parent764c24eeeaf948f7431ad384153420fe0003d681 (diff)
downloadorg.eclipse.nebula-355a48eacc1dd01a2dd547171d7247a463a67a2e.zip
org.eclipse.nebula-355a48eacc1dd01a2dd547171d7247a463a67a2e.tar.gz
org.eclipse.nebula-355a48eacc1dd01a2dd547171d7247a463a67a2e.tar.bz2
Added more docs for GeoMap code, added constructor overload for setting the tilecache size on a per-geomap basis
-rw-r--r--widgets/geomap/org.eclipse.nebula.widgets.geomap/src/org/eclipse/nebula/widgets/geomap/GeoMap.java290
-rw-r--r--widgets/geomap/org.eclipse.nebula.widgets.geomap/src/org/eclipse/nebula/widgets/geomap/GeoMapBrowser.java78
-rw-r--r--widgets/geomap/org.eclipse.nebula.widgets.geomap/src/org/eclipse/nebula/widgets/geomap/internal/InfoPage.java64
-rw-r--r--widgets/geomap/org.eclipse.nebula.widgets.geomap/src/org/eclipse/nebula/widgets/geomap/internal/ResultsPage.java22
-rw-r--r--widgets/geomap/org.eclipse.nebula.widgets.geomap/src/org/eclipse/nebula/widgets/geomap/internal/SearchPage.java40
5 files changed, 294 insertions, 200 deletions
diff --git a/widgets/geomap/org.eclipse.nebula.widgets.geomap/src/org/eclipse/nebula/widgets/geomap/GeoMap.java b/widgets/geomap/org.eclipse.nebula.widgets.geomap/src/org/eclipse/nebula/widgets/geomap/GeoMap.java
index c72b452..90956f9 100644
--- a/widgets/geomap/org.eclipse.nebula.widgets.geomap/src/org/eclipse/nebula/widgets/geomap/GeoMap.java
+++ b/widgets/geomap/org.eclipse.nebula.widgets.geomap/src/org/eclipse/nebula/widgets/geomap/GeoMap.java
@@ -71,12 +71,16 @@ import org.eclipse.swt.widgets.Display;
* <li>{@link #computePosition(java.awt.geom.Point2D.Double)} returns the position in the map panels coordinate system
* for the given longitude and latitude. If you want to center the map around this geometric location you need
* to pass the result to the method</li>
- * </ul>
- * </p>
- *
- * <p>As mentioned above Longitude/Latitude functionality is available via the method {@link #computePosition(java.awt.geom.Point2D.Double)}.
- * If you have a GIS database you can get this info out of it for a given town/location, invoke {@link #computePosition(java.awt.geom.Point2D.Double)} to
- * translate to a position for the given zoom level and center the view around this position using {@link #setCenterPosition(Point)}.
+ * </ul>
+ * </p>
+ *
+ * <p>For performance tuning the two crucial parameters are the size of the {@link TileCache} and the
+ * number of image-loader threads.
+ * </p>
+ *
+ * <p>As mentioned above Longitude/Latitude functionality is available via the method {@link #computePosition(java.awt.geom.Point2D.Double)}.
+ * If you have a GIS database you can get this info out of it for a given town/location, invoke {@link #computePosition(java.awt.geom.Point2D.Double)} to
+ * translate to a position for the given zoom level and center the view around this position using {@link #setCenterPosition(Point)}.
* </p>
*
* <p>The properties <code>zoom</code> and <code>mapPosition</code> are bound and can be tracked via
@@ -88,12 +92,16 @@ import org.eclipse.swt.widgets.Display;
* @version $Revision$
*/
public class GeoMap extends Canvas {
-
- private static final Logger log = Logger.getLogger(GeoMap.class.getName());
-
- public static final class TileServer {
- private final String url;
- private final int maxZoom;
+
+ private static final Logger log = Logger.getLogger(GeoMap.class.getName());
+
+ /**
+ * This class encapsulates a tileserver, which has the concept
+ * of a baseurl and a maximum zoon level.
+ */
+ public static final class TileServer {
+ private final String url;
+ private final int maxZoom;
private boolean broken;
private TileServer(String url, int maxZoom) {
@@ -118,24 +126,39 @@ public class GeoMap extends Canvas {
public void setBroken(boolean broken) {
this.broken = broken;
- }
- }
-
- public static class Stats {
- public int tileCount;
- public long dt;
+ }
+ }
+
+ /**
+ * Stats class, usefull for debugging caching of tiles,
+ * also makes sure nothing is drawn (and loaded) that is
+ * not displayed.
+ * @since 3.3
+ *
+ */
+ public static class Stats {
+ public int tileCount;
+ public long dt;
private Stats() {
reset();
}
private void reset() {
tileCount = 0;
dt = 0;
- }
- }
-
- private static class Tile {
- private final String key;
- public final int x, y, z;
+ }
+ }
+
+ /**
+ * A single tile in the map. A tile has an x and y coordinate, but
+ * both only make sense in the context of a given zoom level. The
+ * tile's zoom level is given by <code>z</code>.
+ *
+ * <p>For caching the tiles support some equals and hashCode behavior
+ * that makes them suitable as key-objects in java-util collections.</p>
+ */
+ private static class Tile {
+ private final String key;
+ public final int x, y, z;
public Tile(String tileServer, int x, int y, int z) {
this.key = tileServer;
this.x = x;
@@ -171,16 +194,24 @@ public class GeoMap extends Canvas {
if (z != other.z)
return false;
return true;
- }
- }
-
- public class TileCache {
- private LinkedHashMap<Tile,AsyncImage> map = new LinkedHashMap<Tile,AsyncImage>(CACHE_SIZE, 0.75f, true) {
- protected boolean removeEldestEntry(Map.Entry<Tile,AsyncImage> eldest) {
- boolean remove = size() > CACHE_SIZE;
- if (remove)
- eldest.getValue().dispose(getDisplay());
- return remove;
+ }
+ }
+
+ /**
+ * A tile-cache holds tiles. Instances of {@link Tile} are used as keys for
+ * the cache. The actual data is held in instances of {@link AsyncImage} which
+ * is an image that automatically loads itself with one of the supplied image
+ * loader threads.
+ * @since 3.3
+ *
+ */
+ public class TileCache {
+ private LinkedHashMap<Tile,AsyncImage> map = new LinkedHashMap<Tile,AsyncImage>(cacheSize, 0.75f, true) {
+ protected boolean removeEldestEntry(Map.Entry<Tile,AsyncImage> eldest) {
+ boolean remove = size() > cacheSize;
+ if (remove)
+ eldest.getValue().dispose(getDisplay());
+ return remove;
}
};
public void put(TileServer tileServer, int x, int y, int z, AsyncImage image) {
@@ -193,21 +224,34 @@ public class GeoMap extends Canvas {
map.remove(new Tile(tileServer.getURL(), x, y, z));
}
public int getSize() {
- return map.size();
- }
- }
-
- public final class AsyncImage implements Runnable {
- private final AtomicReference<ImageData> imageData = new AtomicReference<ImageData>();
- private Image image; // might as well be thread-local
+ return map.size();
+ }
+ }
+ /**
+ * An sync image that loads itself in the background on an image-fetcher thread.
+ * Once its loaded it will trigger a redraw. Sometimes redraws that
+ * are not really necessary can be triggered, but that is not relevant in terms of
+ * performance for this swt-component.
+ *
+ */
+ public final class AsyncImage implements Runnable {
+ private final AtomicReference<ImageData> imageData = new AtomicReference<ImageData>();
+ private Image image; // might as well be thread-local
private FutureTask<Boolean> task;
private volatile long stamp = zoomStamp.longValue();
- private final TileServer tileServer;
- private final int x, y, z;
-
- public AsyncImage(TileServer tileServer, int x, int y, int z) {
- this.tileServer = tileServer;
- this.x = x;
+ private final TileServer tileServer;
+ private final int x, y, z;
+
+ /**
+ * Constructs a new <code>AsyncImage</code> instance.
+ * @param tileServer the tileserer, which is used to find out the source location
+ * @param x tile's x coordinate
+ * @param y tile's y coordinate
+ * @param z the zoom level
+ */
+ public AsyncImage(TileServer tileServer, int x, int y, int z) {
+ this.tileServer = tileServer;
+ this.x = x;
this.y = y;
this.z = z;
task = new FutureTask<Boolean>(this, Boolean.TRUE);
@@ -376,14 +420,15 @@ public class GeoMap extends Canvas {
//"Please support the effort at <a href=\"http://www.openstreetmap.org\">http://www.openstreetmap.org/</a>.\r\n";
//"Please keep in mind this application is just a alternative renderer for swt.\r\n";
-
- /* basically not be changed */
- private static final int TILE_SIZE = 256;
- public static final int CACHE_SIZE = 256;
- public static final int IMAGEFETCHER_THREADS = 4;
-
- private PropertyChangeSupport pcs = new PropertyChangeSupport(this);
- private Point mapSize = new Point(0, 0);
+
+ /* basically not be changed */
+ private static final int TILE_SIZE = 256;
+
+ public static final int DEFAULT_CACHE_SIZE = 256;
+ public static final int DEFAULT_NUMBER_OF_IMAGEFETCHER_THREADS = 4;
+
+ private PropertyChangeSupport pcs = new PropertyChangeSupport(this);
+ private Point mapSize = new Point(0, 0);
private Point mapPosition = new Point(0, 0);
private int zoom;
private AtomicLong zoomStamp = new AtomicLong();
@@ -399,22 +444,56 @@ public class GeoMap extends Canvas {
Thread t = new Thread(r);
t.setName("Async Image Loader " + t.getId() + " " + System.identityHashCode(t));
t.setDaemon(true);
- return t;
- }
- };
- private ThreadPoolExecutor executor = new ThreadPoolExecutor(IMAGEFETCHER_THREADS, 16, 2, TimeUnit.SECONDS, workQueue, threadFactory);
-
- private Color waitBackground, waitForeground;
-
- public GeoMap(Composite parent, int style) {
- this(parent, style, new Point(275091, 180145), 11);
- }
-
- public GeoMap(Composite parent, int style, Point mapPosition, int zoom) {
- super(parent, SWT.DOUBLE_BUFFERED | style);
- waitBackground = new Color(getDisplay(), 0x88, 0x88, 0x88);
- waitForeground = new Color(getDisplay(), 0x77, 0x77, 0x77);
-
+ return t;
+ }
+ };
+ private ThreadPoolExecutor executor = new ThreadPoolExecutor(DEFAULT_NUMBER_OF_IMAGEFETCHER_THREADS, 16, 2, TimeUnit.SECONDS, workQueue, threadFactory);
+ private Color waitBackground, waitForeground;
+ private final int cacheSize;
+
+
+ /**
+ * Creates a new <code>GeoMap</code> using the {@link GeoMap#DEFAULT_CACHE_SIZE} size
+ * for its internal cache of tiles. The map is showing the position <code>(275091, 180145</code>
+ * at zoom level <code>11</code>. In other words this constructor is best used only in debugging
+ * scenarios.
+ *
+ * @param parent SWT parent <code>Composite</code>
+ * @param style SWT style as in <code>Canvas</code>, since this class inherits from it. Double buffering is always enabed.
+ */
+ public GeoMap(Composite parent, int style) {
+ this(parent, style, new Point(275091, 180145), 11);
+ }
+
+ /**
+ * Creates a new <code>GeoMap</code> using the {@link GeoMap#DEFAULT_CACHE_SIZE} size
+ * for its internal cache of tiles
+ * @param parent SWT parent <code>Composite</code>
+ * @param style SWT style as in <code>Canvas</code>, since this class inherits from it. Double buffering is always enabed.
+ * @param mapPosition initial mapPosition.
+ * @param zoom initial map zoom
+ */
+ public GeoMap(Composite parent, int style, Point mapPosition, int zoom) {
+ this(parent, style, mapPosition, zoom, DEFAULT_CACHE_SIZE);
+ }
+
+ /**
+ * Creates a new <code>GeoMap</code> using the {@link GeoMap#DEFAULT_CACHE_SIZE} size
+ * for its internal cache of tiles
+ * @param parent SWT parent <code>Composite</code>
+ * @param style SWT style as in <code>Canvas</code>, since this class inherits from it. Double buffering is always enabed.
+ * @param mapPosition initial mapPosition.
+ * @param zoom initial map zoom
+ * @param cacheSize initial cache size, eg number of tile-images that are kept in cache
+ * to prevent reloading from the network.
+ */
+ public GeoMap(Composite parent, int style, Point mapPosition, int zoom, int cacheSize) {
+
+ super(parent, SWT.DOUBLE_BUFFERED | style);
+ this.cacheSize = cacheSize;
+ waitBackground = new Color(getDisplay(), 0x88, 0x88, 0x88);
+ waitForeground = new Color(getDisplay(), 0x77, 0x77, 0x77);
+
setZoom(zoom);
addDisposeListener(new DisposeListener() {
public void widgetDisposed(DisposeEvent e) {
@@ -431,12 +510,19 @@ public class GeoMap extends Canvas {
addMouseMoveListener(mouseListener);
addMouseWheelListener(mouseListener);
addMouseTrackListener(mouseListener);
- /// TODO: check tileservers
- }
-
- protected void paintControl(PaintEvent e) {
- GC gc = e.gc;
-
+ /// TODO: check tileservers
+ }
+
+ /**
+ * @return Returns the cacheSize.
+ */
+ public int getCacheSize() {
+ return cacheSize;
+ }
+
+ protected void paintControl(PaintEvent e) {
+ GC gc = e.gc;
+
getStats().reset();
long t0 = System.currentTimeMillis();
Point size = getSize();
@@ -647,27 +733,35 @@ public class GeoMap extends Canvas {
int x = lon2position(coords.x, getZoom());
int y = lat2position(coords.y, getZoom());
return new Point(x, y);
- }
-
- //-------------------------------------------------------------------------
- // utils
- public static String format(double d) {
- return String.format("%.5f", d);
- }
-
- public static double getN(int y, int z) {
- double n = Math.PI - (2.0 * Math.PI * y) / Math.pow(2.0, z);
- return n;
- }
-
- public static double position2lon(int x, int z) {
- double xmax = TILE_SIZE * (1 << z);
- return x / xmax * 360.0 - 180;
- }
-
- public static double position2lat(int y, int z) {
- double ymax = TILE_SIZE * (1 << z);
- return Math.toDegrees(Math.atan(Math.sinh(Math.PI - (2.0 * Math.PI * y) / ymax)));
+ }
+
+ //-------------------------------------------------------------------------
+ // utils, there are important when using the GeoMap
+
+ public static String format(double d) {
+ return String.format("%.5f", d);
+ }
+
+ /**
+ * Converts position to longitude.
+ * @param x position x coord (pixels in this swt control)
+ * @param z the current zoom level.
+ * @return the longitude
+ */
+ public static double position2lon(int x, int z) {
+ double xmax = TILE_SIZE * (1 << z);
+ return x / xmax * 360.0 - 180;
+ }
+
+ /**
+ * Converts position to latitude.
+ * @param y position y coord (pixels in this swt control)
+ * @param z the current zoom level.
+ * @return the latitude
+ */
+ public static double position2lat(int y, int z) {
+ double ymax = TILE_SIZE * (1 << z);
+ return Math.toDegrees(Math.atan(Math.sinh(Math.PI - (2.0 * Math.PI * y) / ymax)));
}
public static double tile2lon(int x, int z) {
diff --git a/widgets/geomap/org.eclipse.nebula.widgets.geomap/src/org/eclipse/nebula/widgets/geomap/GeoMapBrowser.java b/widgets/geomap/org.eclipse.nebula.widgets.geomap/src/org/eclipse/nebula/widgets/geomap/GeoMapBrowser.java
index 56e3cb4..5980bc5 100644
--- a/widgets/geomap/org.eclipse.nebula.widgets.geomap/src/org/eclipse/nebula/widgets/geomap/GeoMapBrowser.java
+++ b/widgets/geomap/org.eclipse.nebula.widgets.geomap/src/org/eclipse/nebula/widgets/geomap/GeoMapBrowser.java
@@ -36,13 +36,13 @@ import org.eclipse.swt.widgets.Shell;
* @author stepan.rutz@gmx.de
* @version $Revision$
*/
-public class GeoMapBrowser extends Composite {
- private SashForm sashForm;
- private PageContainer pageContainer;
- private GeoMap mapWidget;
- private SearchPage searchPage;
- private ResultsPage resultsPage;
- private InfoPage infoPage;
+public class GeoMapBrowser extends Composite {
+ private SashForm sashForm;
+ private PageContainer pageContainer;
+ private GeoMap geoMap;
+ private SearchPage searchPage;
+ private ResultsPage resultsPage;
+ private InfoPage infoPage;
public GeoMapBrowser(Composite parent, int style) {
super(parent, style);
@@ -50,41 +50,41 @@ public class GeoMapBrowser extends Composite {
setLayout(new FillLayout());
sashForm = new SashForm(this, SWT.HORIZONTAL);
- sashForm.setLayout(new FillLayout());
-
- pageContainer = new PageContainer(sashForm, SWT.NONE);
- mapWidget = new GeoMap(sashForm, SWT.NONE);
-
- sashForm.setWeights(new int[] { 100, 200 });
-
+ sashForm.setLayout(new FillLayout());
+
+ pageContainer = new PageContainer(sashForm, SWT.NONE);
+ geoMap = new GeoMap(sashForm, SWT.NONE);
+
+ sashForm.setWeights(new int[] { 100, 200 });
+
searchPage = new SearchPage(this);
resultsPage = new ResultsPage(this);
infoPage = new InfoPage(this);
- pageContainer.setPages(searchPage, resultsPage, infoPage);
- pageContainer.showPage(0);
-
- mapWidget.addPropertyChangeListener(new PropertyChangeListener() {
- public void propertyChange(PropertyChangeEvent event) {
- infoPage.updateInfos();
- }
- });
- mapWidget.addControlListener(new ControlAdapter() {
- public void controlResized(ControlEvent e) {
- infoPage.updateInfos();
- }
- });
- mapWidget.addMouseMoveListener(new MouseMoveListener() {
- public void mouseMove(MouseEvent e) {
- infoPage.updateInfos();
- }
- });
- }
-
- public GeoMap getMapWidget() {
- return mapWidget;
- }
-
- public SearchPage getSearchPage() {
+ pageContainer.setPages(searchPage, resultsPage, infoPage);
+ pageContainer.showPage(0);
+
+ geoMap.addPropertyChangeListener(new PropertyChangeListener() {
+ public void propertyChange(PropertyChangeEvent event) {
+ infoPage.updateInfos();
+ }
+ });
+ geoMap.addControlListener(new ControlAdapter() {
+ public void controlResized(ControlEvent e) {
+ infoPage.updateInfos();
+ }
+ });
+ geoMap.addMouseMoveListener(new MouseMoveListener() {
+ public void mouseMove(MouseEvent e) {
+ infoPage.updateInfos();
+ }
+ });
+ }
+
+ public GeoMap getGeoMap() {
+ return geoMap;
+ }
+
+ public SearchPage getSearchPage() {
return searchPage;
}
diff --git a/widgets/geomap/org.eclipse.nebula.widgets.geomap/src/org/eclipse/nebula/widgets/geomap/internal/InfoPage.java b/widgets/geomap/org.eclipse.nebula.widgets.geomap/src/org/eclipse/nebula/widgets/geomap/internal/InfoPage.java
index 9912a7f..d47cea6 100644
--- a/widgets/geomap/org.eclipse.nebula.widgets.geomap/src/org/eclipse/nebula/widgets/geomap/internal/InfoPage.java
+++ b/widgets/geomap/org.eclipse.nebula.widgets.geomap/src/org/eclipse/nebula/widgets/geomap/internal/InfoPage.java
@@ -33,42 +33,42 @@ import org.eclipse.swt.widgets.TableItem;
public class InfoPage extends AbstractPage implements Page {
private static final Logger log = Logger.getLogger(InfoPage.class.getName());
-
- private abstract class Spec {
- final String key;
- final GeoMap mapWidget;
- abstract String computeValue();
- Spec(String key) { this.key = key; this.mapWidget = mapBrowser.getMapWidget(); }
- }
-
-
+
+ private abstract class Spec {
+ final String key;
+ final GeoMap geoMap;
+ abstract String computeValue();
+ Spec(String key) { this.key = key; this.geoMap = mapBrowser.getGeoMap(); }
+ }
+
+
private final GeoMapBrowser mapBrowser;
private Table table;
private Spec[] specs;
- public InfoPage(GeoMapBrowser mapBrowser) {
- this.mapBrowser = mapBrowser;
- specs = new Spec[] {
- new Spec("Zoom") { public String computeValue() { return Integer.toString(mapWidget.getZoom()); }},
- new Spec("Map Size") { public String computeValue() { Point size = mapWidget.getSize(); return size.x + ", " + size.y; }},
- new Spec("Map Position") { public String computeValue() { Point position = mapWidget.getMapPosition(); return position.x + ", " + position.y; }},
- new Spec("Center Position") { public String computeValue() { Point position = mapWidget.getCenterPosition(); return position.x + ", " + position.y; }},
- new Spec("Paint time") { public String computeValue() { mapWidget.getStats(); return mapWidget.getStats().dt + " ms"; }},
- new Spec("Imagefetchers Threads") { public String computeValue() { return Integer.toString(GeoMap.IMAGEFETCHER_THREADS); }},
- new Spec("Number painted tiles") {
- public String computeValue() {
- mapWidget.getStats();
- return mapWidget.getStats().tileCount + " of " + NumberFormat.getIntegerInstance().format((long)mapWidget.getXTileCount() * mapWidget.getYTileCount());
- }
- },
- new Spec("Tilecache") { public String computeValue() { return String.format("%3d / %3d", mapWidget.getCache().getSize(), GeoMap.CACHE_SIZE); }},
- new Spec("Longitude/Latitude") {
- public String computeValue() {
- Point p = mapWidget.getCursorPosition();
- int zoom = mapWidget.getZoom();
- return GeoMap.format(GeoMap.position2lon(p.x, zoom)) + ", " + GeoMap.format(GeoMap.position2lat(p.y, zoom));
- }
- },
+ public InfoPage(GeoMapBrowser mapBrowser) {
+ this.mapBrowser = mapBrowser;
+ specs = new Spec[] {
+ new Spec("Zoom") { public String computeValue() { return Integer.toString(geoMap.getZoom()); }},
+ new Spec("Map Size") { public String computeValue() { Point size = geoMap.getSize(); return size.x + ", " + size.y; }},
+ new Spec("Map Position") { public String computeValue() { Point position = geoMap.getMapPosition(); return position.x + ", " + position.y; }},
+ new Spec("Center Position") { public String computeValue() { Point position = geoMap.getCenterPosition(); return position.x + ", " + position.y; }},
+ new Spec("Paint time") { public String computeValue() { geoMap.getStats(); return geoMap.getStats().dt + " ms"; }},
+ new Spec("Imagefetchers Threads") { public String computeValue() { return Integer.toString(GeoMap.DEFAULT_NUMBER_OF_IMAGEFETCHER_THREADS); }},
+ new Spec("Number painted tiles") {
+ public String computeValue() {
+ geoMap.getStats();
+ return geoMap.getStats().tileCount + " of " + NumberFormat.getIntegerInstance().format((long)geoMap.getXTileCount() * geoMap.getYTileCount());
+ }
+ },
+ new Spec("Tilecache") { public String computeValue() { return String.format("%3d / %3d", geoMap.getCache().getSize(), geoMap.getCacheSize()); }},
+ new Spec("Longitude/Latitude") {
+ public String computeValue() {
+ Point p = geoMap.getCursorPosition();
+ int zoom = geoMap.getZoom();
+ return GeoMap.format(GeoMap.position2lon(p.x, zoom)) + ", " + GeoMap.format(GeoMap.position2lat(p.y, zoom));
+ }
+ },
};
}
diff --git a/widgets/geomap/org.eclipse.nebula.widgets.geomap/src/org/eclipse/nebula/widgets/geomap/internal/ResultsPage.java b/widgets/geomap/org.eclipse.nebula.widgets.geomap/src/org/eclipse/nebula/widgets/geomap/internal/ResultsPage.java
index 066c646..41eb92e 100644
--- a/widgets/geomap/org.eclipse.nebula.widgets.geomap/src/org/eclipse/nebula/widgets/geomap/internal/ResultsPage.java
+++ b/widgets/geomap/org.eclipse.nebula.widgets.geomap/src/org/eclipse/nebula/widgets/geomap/internal/ResultsPage.java
@@ -139,17 +139,17 @@ public class ResultsPage extends AbstractPage implements Page {
TableItem item = table.getItem(point);
if (item == null)
return;
- int index = table.indexOf(item);
- if (index >= 0 && index < results.length) {
- SearchResult result = results[index];
- GeoMap mapWidget = mapBrowser.getMapWidget();
-// mapWidget.setZoom(result.getZoom() < 1 || result.getZoom() > mapWidget.getTileServer().getMaxZoom() ? 8 : result.getZoom());
- Point position = mapWidget.computePosition(new PointD(result.getLon(), result.getLat()));
- mapWidget.setCenterPosition(position);
- mapWidget.redraw();
- }
- }
- });
+ int index = table.indexOf(item);
+ if (index >= 0 && index < results.length) {
+ SearchResult result = results[index];
+ GeoMap geoMap = mapBrowser.getGeoMap();
+ //geoMap.setZoom(result.getZoom() < 1 || result.getZoom() > mapWidget.getTileServer().getMaxZoom() ? 8 : result.getZoom());
+ Point position = geoMap.computePosition(new PointD(result.getLon(), result.getLat()));
+ geoMap.setCenterPosition(position);
+ geoMap.redraw();
+ }
+ }
+ });
}
protected void widgetDisposed(DisposeEvent e) {
diff --git a/widgets/geomap/org.eclipse.nebula.widgets.geomap/src/org/eclipse/nebula/widgets/geomap/internal/SearchPage.java b/widgets/geomap/org.eclipse.nebula.widgets.geomap/src/org/eclipse/nebula/widgets/geomap/internal/SearchPage.java
index 7665408..333b3dd 100644
--- a/widgets/geomap/org.eclipse.nebula.widgets.geomap/src/org/eclipse/nebula/widgets/geomap/internal/SearchPage.java
+++ b/widgets/geomap/org.eclipse.nebula.widgets.geomap/src/org/eclipse/nebula/widgets/geomap/internal/SearchPage.java
@@ -120,30 +120,30 @@ public class SearchPage extends AbstractPage implements Page {
addInfoText(container, composite, "Toggling the tile-server changes the way " +
"the map is rendered. Click on the mapinfos link to see details " +
"about the currently rendered part of the map.");
-
- addActionLink(container, composite, "<a>Toggle Rendering</a>", new SelectionAdapter() {
- public void widgetSelected(SelectionEvent e) {
- GeoMap mapWidget = mapBrowser.getMapWidget();
- int next = (Arrays.asList(GeoMap.TILESERVERS).indexOf(mapWidget.getTileServer()) + 1) % GeoMap.TILESERVERS.length;
- mapWidget.setTileServer(GeoMap.TILESERVERS[next]);
- }
- });
-
+
+ addActionLink(container, composite, "<a>Toggle Rendering</a>", new SelectionAdapter() {
+ public void widgetSelected(SelectionEvent e) {
+ GeoMap geoMap = mapBrowser.getGeoMap();
+ int next = (Arrays.asList(GeoMap.TILESERVERS).indexOf(geoMap.getTileServer()) + 1) % GeoMap.TILESERVERS.length;
+ geoMap.setTileServer(GeoMap.TILESERVERS[next]);
+ }
+ });
+
addActionLink(container, composite, "Show <a>Technical Mapinfos</a>", new SelectionAdapter() {
public void widgetSelected(SelectionEvent e) {
mapBrowser.getPageContainer().showPage(mapBrowser.getPageContainer().indexOfPage(mapBrowser.getInfoPage()));
}
- });
- addActionLink(container, composite, "Show <a>Europe</a>", new SelectionAdapter() {
- public void widgetSelected(SelectionEvent e) {
- GeoMap mapWidget = mapBrowser.getMapWidget();
- mapWidget.setZoom(5);
- Point position = mapWidget.computePosition(new PointD(5.5, 52.2));
- mapWidget.setCenterPosition(position);
- mapWidget.redraw();
- }
- });
-
+ });
+ addActionLink(container, composite, "Show <a>Europe</a>", new SelectionAdapter() {
+ public void widgetSelected(SelectionEvent e) {
+ GeoMap geoMap = mapBrowser.getGeoMap();
+ geoMap.setZoom(5);
+ Point position = geoMap.computePosition(new PointD(5.5, 52.2));
+ geoMap.setCenterPosition(position);
+ geoMap.redraw();
+ }
+ });
+
addHeaderRow(container, composite, "Search location");
addInfoText(container, composite, "Enter any location or landmark site to search openstreetmap's " +
"genuine namefinder database. Hit return to perform the search.");