Ignore:
Timestamp:
2009-12-02T10:14:02+01:00 (15 years ago)
Author:
stotz
Message:

The name "square" in MapSquare was a bit misleading - of course rectangles are possible. All occurence of "square" has been replaced by "rectangle"

Location:
applications/viewer/jmapviewer
Files:
2 edited
1 moved

Legend:

Unmodified
Added
Removed
  • applications/viewer/jmapviewer

    • Property svn:ignore
      •  

        old new  
        1 tiles
         1JMapViewer.jar
        22JMapViewer_Demo.jar
        33JMapViewer_src.jar
        4 JMapViewer.jar
         4bin
         5tiles
  • applications/viewer/jmapviewer/src/org/openstreetmap/gui/jmapviewer/JMapViewer.java

    r18772 r18890  
    2121
    2222import org.openstreetmap.gui.jmapviewer.interfaces.MapMarker;
    23 import org.openstreetmap.gui.jmapviewer.interfaces.MapSquare;
     23import org.openstreetmap.gui.jmapviewer.interfaces.MapRectangle;
    2424import org.openstreetmap.gui.jmapviewer.interfaces.TileCache;
    2525import org.openstreetmap.gui.jmapviewer.interfaces.TileLoader;
     
    4848
    4949    protected List<MapMarker> mapMarkerList;
    50     protected List<MapSquare> mapSquareList;
     50    protected List<MapRectangle> mapRectangleList;
    5151
    5252    protected boolean mapMarkersVisible;
    53     protected boolean mapSquaresVisible;
     53    protected boolean mapRectanglesVisible;
    5454
    5555    protected boolean tileGridVisible;
     
    8888        tileController = new TileController(new OsmTileSource.Mapnik(), tileCache, this);
    8989        mapMarkerList = new LinkedList<MapMarker>();
    90         mapSquareList = new LinkedList<MapSquare>();
     90        mapRectangleList = new LinkedList<MapRectangle>();
    9191        mapMarkersVisible = true;
    92         mapSquaresVisible = true;
     92        mapRectanglesVisible = true;
    9393        tileGridVisible = false;
    9494        setLayout(null);
     
    255255     * visible.
    256256     */
    257     public void setDisplayToFitMapSquares() {
    258         if (mapSquareList == null || mapSquareList.size() == 0) {
     257    public void setDisplayToFitMapRectangle() {
     258        if (mapRectangleList == null || mapRectangleList.size() == 0) {
    259259            return;
    260260        }
     
    264264        int y_max = Integer.MIN_VALUE;
    265265        int mapZoomMax = tileController.getTileSource().getMaxZoom();
    266         for (MapSquare 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));
    271271        }
    272272        int height = Math.max(0, getHeight());
     
    448448        // g.drawString("Tiles in cache: " + tileCache.getTileCount(), 50, 20);
    449449
    450         if (mapSquaresVisible && mapSquareList != null) {
    451             for (MapSquare 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();
    454454                if (topLeft != null && bottomRight != null) {
    455455                    Point pTopLeft = getMapPosition(topLeft.getLat(), topLeft.getLon(), false);
    456456                    Point pBottomRight = getMapPosition(bottomRight.getLat(), bottomRight.getLon(), false);
    457457                    if (pTopLeft != null && pBottomRight != null) {
    458                         square.paint(g, pTopLeft, pBottomRight);
     458                        rectangle.paint(g, pTopLeft, pBottomRight);
    459459                    }
    460460                }
     
    522522
    523523    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)
    525526            return;
    526527        Coordinate zoomPos = getPosition(mapPoint);
     
    584585    }
    585586
    586     public void setMapSquareList(List<MapSquare> mapSquareList) {
    587         this.mapSquareList = mapSquareList;
    588         repaint();
    589     }
    590 
    591     public List<MapSquare> getMapSquareList() {
    592         return mapSquareList;
     587    public void setMapRectangleList(List<MapRectangle> mapRectangleList) {
     588        this.mapRectangleList = mapRectangleList;
     589        repaint();
     590    }
     591
     592    public List<MapRectangle> getMapRectangleList() {
     593        return mapRectangleList;
    593594    }
    594595
     
    598599    }
    599600
    600     public void addMapSquare(MapSquare square) {
    601         mapSquareList.add(square);
    602         repaint();
    603     }
    604 
    605     public void removeMapSquare(MapSquare square) {
    606         mapSquareList.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);
    607608        repaint();
    608609    }
     
    636637    }
    637638
    638     public boolean isMapSquaresVisible() {
    639         return mapSquaresVisible;
    640     }
    641 
    642     /**
    643      * Enables or disables painting of the {@link MapSquare}
     639    public boolean isMapRectanglesVisible() {
     640        return mapRectanglesVisible;
     641    }
     642
     643    /**
     644     * Enables or disables painting of the {@link MapRectangle}
    644645     *
    645646     * @param mapMarkersVisible
    646      * @see #addMapSquare(MapSquare)
    647      * @see #getMapSquareList()
    648      */
    649     public void setMapSquaresVisible(boolean mapSquaresVisible) {
    650         this.mapSquaresVisible = mapSquaresVisible;
     647     * @see #addMapRectangle(MapRectangle)
     648     * @see #getMapRectangleList()
     649     */
     650    public void setMapRectanglesVisible(boolean mapRectanglesVisible) {
     651        this.mapRectanglesVisible = mapRectanglesVisible;
    651652        repaint();
    652653    }
  • applications/viewer/jmapviewer/src/org/openstreetmap/gui/jmapviewer/interfaces/MapRectangle.java

    r18773 r18890  
    1010
    1111/**
    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.
    1313 *
    1414 * @author Stefan Zeller
    15  * @see JMapViewer#addMapSquare(MapSquare)
    16  * @see JMapViewer#getMapSquareList()
     15 * @see JMapViewer#addMapRectangle(MapRectangle)
     16 * @see JMapViewer#getMapRectangleList()
    1717 * @date 21.06.2009S
    1818 */
    19 public interface MapSquare {
     19public interface MapRectangle {
    2020
    2121    /**
    22      * @return Latitude/Longitude of top left of square
     22     * @return Latitude/Longitude of top left of rectangle
    2323     */
    2424    public Coordinate getTopLeft();
    2525
    2626    /**
    27      * @return Latitude/Longitude of bottom right of square
     27     * @return Latitude/Longitude of bottom right of rectangle
    2828     */
    2929    public Coordinate getBottomRight();
    3030
    3131    /**
    32      * Paints the map square on the map. The <code>topLeft</code> and
    33      * <code>bottomRight</code> specifies the 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>
    3434     *
    3535     * @param g
Note: See TracChangeset for help on using the changeset viewer.