Changeset 18890 in osm for applications/viewer/jmapviewer/src/org
- Timestamp:
- 2009-12-02T10:14:02+01:00 (15 years ago)
- Location:
- applications/viewer/jmapviewer
- Files:
-
- 2 edited
- 1 moved
Legend:
- Unmodified
- Added
- Removed
-
applications/viewer/jmapviewer
- Property svn:ignore
-
old new 1 tiles 1 JMapViewer.jar 2 2 JMapViewer_Demo.jar 3 3 JMapViewer_src.jar 4 JMapViewer.jar 4 bin 5 tiles
-
- Property svn:ignore
-
applications/viewer/jmapviewer/src/org/openstreetmap/gui/jmapviewer/JMapViewer.java
r18772 r18890 21 21 22 22 import org.openstreetmap.gui.jmapviewer.interfaces.MapMarker; 23 import org.openstreetmap.gui.jmapviewer.interfaces.Map Square;23 import org.openstreetmap.gui.jmapviewer.interfaces.MapRectangle; 24 24 import org.openstreetmap.gui.jmapviewer.interfaces.TileCache; 25 25 import org.openstreetmap.gui.jmapviewer.interfaces.TileLoader; … … 48 48 49 49 protected List<MapMarker> mapMarkerList; 50 protected List<Map Square> mapSquareList;50 protected List<MapRectangle> mapRectangleList; 51 51 52 52 protected boolean mapMarkersVisible; 53 protected boolean map SquaresVisible;53 protected boolean mapRectanglesVisible; 54 54 55 55 protected boolean tileGridVisible; … … 88 88 tileController = new TileController(new OsmTileSource.Mapnik(), tileCache, this); 89 89 mapMarkerList = new LinkedList<MapMarker>(); 90 map SquareList = new LinkedList<MapSquare>();90 mapRectangleList = new LinkedList<MapRectangle>(); 91 91 mapMarkersVisible = true; 92 map SquaresVisible = true;92 mapRectanglesVisible = true; 93 93 tileGridVisible = false; 94 94 setLayout(null); … … 255 255 * visible. 256 256 */ 257 public void setDisplayToFitMap Squares() {258 if (map SquareList == null || mapSquareList.size() == 0) {257 public void setDisplayToFitMapRectangle() { 258 if (mapRectangleList == null || mapRectangleList.size() == 0) { 259 259 return; 260 260 } … … 264 264 int y_max = Integer.MIN_VALUE; 265 265 int mapZoomMax = tileController.getTileSource().getMaxZoom(); 266 for (Map Square square : mapSquareList) {267 x_max = Math.max(x_max, OsmMercator.LonToX( square.getBottomRight().getLon(), mapZoomMax));268 y_max = Math.max(y_max, OsmMercator.LatToY( square.getTopLeft().getLat(), mapZoomMax));269 x_min = Math.min(x_min, OsmMercator.LonToX( square.getTopLeft().getLon(), mapZoomMax));270 y_min = Math.min(y_min, OsmMercator.LatToY( square.getBottomRight().getLat(), mapZoomMax));266 for (MapRectangle rectangle : mapRectangleList) { 267 x_max = Math.max(x_max, OsmMercator.LonToX(rectangle.getBottomRight().getLon(), mapZoomMax)); 268 y_max = Math.max(y_max, OsmMercator.LatToY(rectangle.getTopLeft().getLat(), mapZoomMax)); 269 x_min = Math.min(x_min, OsmMercator.LonToX(rectangle.getTopLeft().getLon(), mapZoomMax)); 270 y_min = Math.min(y_min, OsmMercator.LatToY(rectangle.getBottomRight().getLat(), mapZoomMax)); 271 271 } 272 272 int height = Math.max(0, getHeight()); … … 448 448 // g.drawString("Tiles in cache: " + tileCache.getTileCount(), 50, 20); 449 449 450 if (map SquaresVisible && mapSquareList != null) {451 for (Map Square square : mapSquareList) {452 Coordinate topLeft = square.getTopLeft();453 Coordinate bottomRight = square.getBottomRight();450 if (mapRectanglesVisible && mapRectangleList != null) { 451 for (MapRectangle rectangle : mapRectangleList) { 452 Coordinate topLeft = rectangle.getTopLeft(); 453 Coordinate bottomRight = rectangle.getBottomRight(); 454 454 if (topLeft != null && bottomRight != null) { 455 455 Point pTopLeft = getMapPosition(topLeft.getLat(), topLeft.getLon(), false); 456 456 Point pBottomRight = getMapPosition(bottomRight.getLat(), bottomRight.getLon(), false); 457 457 if (pTopLeft != null && pBottomRight != null) { 458 square.paint(g, pTopLeft, pBottomRight);458 rectangle.paint(g, pTopLeft, pBottomRight); 459 459 } 460 460 } … … 522 522 523 523 public void setZoom(int zoom, Point mapPoint) { 524 if (zoom > tileController.getTileSource().getMaxZoom() || zoom < tileController.getTileSource().getMinZoom() || zoom == this.zoom) 524 if (zoom > tileController.getTileSource().getMaxZoom() || zoom < tileController.getTileSource().getMinZoom() 525 || zoom == this.zoom) 525 526 return; 526 527 Coordinate zoomPos = getPosition(mapPoint); … … 584 585 } 585 586 586 public void setMap SquareList(List<MapSquare> mapSquareList) {587 this.map SquareList = mapSquareList;588 repaint(); 589 } 590 591 public List<Map Square> getMapSquareList() {592 return map SquareList;587 public void setMapRectangleList(List<MapRectangle> mapRectangleList) { 588 this.mapRectangleList = mapRectangleList; 589 repaint(); 590 } 591 592 public List<MapRectangle> getMapRectangleList() { 593 return mapRectangleList; 593 594 } 594 595 … … 598 599 } 599 600 600 public void addMap Square(MapSquare square) {601 map SquareList.add(square);602 repaint(); 603 } 604 605 public void removeMap Square(MapSquare square) {606 map SquareList.remove(square);601 public void addMapRectangle(MapRectangle rectangle) { 602 mapRectangleList.add(rectangle); 603 repaint(); 604 } 605 606 public void removeMapRectangle(MapRectangle rectangle) { 607 mapRectangleList.remove(rectangle); 607 608 repaint(); 608 609 } … … 636 637 } 637 638 638 public boolean isMap SquaresVisible() {639 return map SquaresVisible;640 } 641 642 /** 643 * Enables or disables painting of the {@link Map Square}639 public boolean isMapRectanglesVisible() { 640 return mapRectanglesVisible; 641 } 642 643 /** 644 * Enables or disables painting of the {@link MapRectangle} 644 645 * 645 646 * @param mapMarkersVisible 646 * @see #addMap Square(MapSquare)647 * @see #getMap SquareList()648 */ 649 public void setMap SquaresVisible(boolean mapSquaresVisible) {650 this.map SquaresVisible = mapSquaresVisible;647 * @see #addMapRectangle(MapRectangle) 648 * @see #getMapRectangleList() 649 */ 650 public void setMapRectanglesVisible(boolean mapRectanglesVisible) { 651 this.mapRectanglesVisible = mapRectanglesVisible; 651 652 repaint(); 652 653 } -
applications/viewer/jmapviewer/src/org/openstreetmap/gui/jmapviewer/interfaces/MapRectangle.java
r18773 r18890 10 10 11 11 /** 12 * Interface to be implemented by squares that can be displayed on the map.12 * Interface to be implemented by rectangles that can be displayed on the map. 13 13 * 14 14 * @author Stefan Zeller 15 * @see JMapViewer#addMap Square(MapSquare)16 * @see JMapViewer#getMap SquareList()15 * @see JMapViewer#addMapRectangle(MapRectangle) 16 * @see JMapViewer#getMapRectangleList() 17 17 * @date 21.06.2009S 18 18 */ 19 public interface Map Square {19 public interface MapRectangle { 20 20 21 21 /** 22 * @return Latitude/Longitude of top left of square22 * @return Latitude/Longitude of top left of rectangle 23 23 */ 24 24 public Coordinate getTopLeft(); 25 25 26 26 /** 27 * @return Latitude/Longitude of bottom right of square27 * @return Latitude/Longitude of bottom right of rectangle 28 28 */ 29 29 public Coordinate getBottomRight(); 30 30 31 31 /** 32 * Paints the map square on the map. The <code>topLeft</code> and33 * <code>bottomRight</code> specifiesthe coordinates within <code>g</code>32 * Paints the map rectangle on the map. The <code>topLeft</code> and 33 * <code>bottomRight</code> are specifying the coordinates within <code>g</code> 34 34 * 35 35 * @param g
Note:
See TracChangeset
for help on using the changeset viewer.