Class SteppedMapWindow

    • Constructor Detail

      • SteppedMapWindow

        public SteppedMapWindow(int width,
                                int height,
                                int zoom,
                                int tx,
                                int ty,
                                int xoff,
                                int yoff)
        Parameters:
        width - the window's width.
        height - the window's height.
        zoom - the zoom level.
        tx - the tile x coordinate.
        ty - the tile y coordinate.
        xoff - position on the tile.
        yoff - position on the tile.
      • SteppedMapWindow

        public SteppedMapWindow(int width,
                                int height,
                                int zoom,
                                double lon,
                                double lat)
        Parameters:
        width - the window's width.
        height - the window's height.
        zoom - the zoom level.
        lon - the center longitude.
        lat - the center latitude.
      • SteppedMapWindow

        public SteppedMapWindow(BBox bbox,
                                int zoom)
        Parameters:
        bbox - a bounding box to cover.
        zoom - the zoomlevel to use.
    • Method Detail

      • getCenterX

        public double getCenterX()
        Get the window's center's tile coordinate.
        Specified by:
        getCenterX in interface  TileMapWindow
        Returns:
        the center's tile coordinate.
      • getCenterY

        public double getCenterY()
        Get the window's center's tile coordinate.
        Specified by:
        getCenterY in interface  TileMapWindow
        Returns:
        the center's tile coordinate.
      • getCenterLon

        public double getCenterLon()
        Specified by:
        getCenterLon in interface  MapWindow
        Returns:
        the MapWindow's center's longitude
      • getCenterLat

        public double getCenterLat()
        Specified by:
        getCenterLat in interface  MapWindow
        Returns:
        the MapWindow's center's latitude
      • getPositionX

        public double getPositionX(int px)
        Get the tile coordinate at the given x in view space.
        Specified by:
        getPositionX in interface  TileMapWindow
        Parameters:
        px - the position in view space.
        Returns:
        the position in tile space.
      • getPositionY

        public double getPositionY(int py)
        Get the tile coordinate at the given y in view space.
        Specified by:
        getPositionY in interface  TileMapWindow
        Parameters:
        py - the position in view space.
        Returns:
        the position in tile space.
      • getPositionLon

        public double getPositionLon(int x)
        Get the longitude of the given x in view space.
        Specified by:
        getPositionLon in interface  MapWindow
        Parameters:
        x - the position in view space.
        Returns:
        the longitude of this position.
      • getPositionLat

        public double getPositionLat(int y)
        Get the latitude of the given y in view space.
        Specified by:
        getPositionLat in interface  MapWindow
        Parameters:
        y - the position in view space.
        Returns:
        the latitude of this position.
      • getBoundingBox

        public BBox getBoundingBox()
        Get the covered area as a bounding box.
        Specified by:
        getBoundingBox in interface  MapWindow
        Returns:
        the bounding box.
      • getNumTilesX

        public int getNumTilesX()
        Specified by:
        getNumTilesX in interface  TileMapWindow
        Returns:
        the number of tiles on the x-axis
      • getNumTilesY

        public int getNumTilesY()
        Specified by:
        getNumTilesY in interface  TileMapWindow
        Returns:
        the number of tiles on the y-axis
      • getZoom

        public double getZoom()
        Specified by:
        getZoom in interface  MapWindow
        Returns:
        the current zoom level.
      • getZoomLevel

        public int getZoomLevel()
      • getWidth

        public int getWidth()
        Specified by:
        getWidth in interface  MapWindow
        Returns:
        the current width.
      • getHeight

        public int getHeight()
        Specified by:
        getHeight in interface  MapWindow
        Returns:
        the current height.
      • resize

        public void resize(int newWidth,
                           int newHeight)
        Adjust the size of the window.
        Specified by:
        resize in interface  MapWindow
        Parameters:
        newWidth - the new width value.
        newHeight - the new height value.
      • move

        public void move(int dx,
                         int dy)
        Reposition the map window with the given values. Positive values move the window up and left. You may supply negative values here.
        Specified by:
        move in interface  MapWindow
        Parameters:
        dx - the amount of pixels to move to the left.
        dy - the amount of pixels to move to the top.
      • setMaxZoom

        public void setMaxZoom(int zoomMax)
        Set the maximum allowed zoomlevel.
        Specified by:
        setMaxZoom in interface  MapWindow
        Parameters:
        zoomMax - the maximum zoomlevel to allow
      • setMinZoom

        public void setMinZoom(int zoomMin)
        Set the minimum allowed zoomlevel.
        Specified by:
        setMinZoom in interface  MapWindow
        Parameters:
        zoomMin - the minimum zoomlevel to allow
      • getMaxZoom

        public int getMaxZoom()
        Specified by:
        getMaxZoom in interface  MapWindow
        Returns:
        the maximal zoom level allowed.
      • getMinZoom

        public int getMinZoom()
        Specified by:
        getMinZoom in interface  MapWindow
        Returns:
        the minimal zoom level allowed.
      • zoomIn

        public boolean zoomIn()
        zoom in to center if possible.
        Specified by:
        zoomIn in interface  MapWindow
        Returns:
        whether this operation changed the zoom level.
      • zoomOut

        public boolean zoomOut()
        zoom out from center if possible.
        Specified by:
        zoomOut in interface  MapWindow
        Returns:
        whether this operation changed the zoom level.
      • zoom

        public boolean zoom(int zoomlevel)
        zoom in to the denoted zoomlevel if possible.
        Specified by:
        zoom in interface  MapWindow
        Parameters:
        zoomlevel - the new zoomlevel to set.
        Returns:
        whether this operation changed the zoom level.
      • zoomInToPosition

        public void zoomInToPosition(int x,
                                     int y)
      • zoomOutToPosition

        public void zoomOutToPosition(int x,
                                      int y)
      • addChangeListener

        public void addChangeListener(MapWindowChangeListener listener)
        Add the given listener to the set of general change listeners. The listener will be notified on all events.
        Specified by:
        addChangeListener in interface  MapWindow
        Parameters:
        listener - the listener to add.
      • addZoomListener

        public void addZoomListener(ZoomChangedListener listener)
        Add the given listener to the set of zoom change listeners. The listener will be notified on zoom events only.
        Specified by:
        addZoomListener in interface  MapWindow
        Parameters:
        listener - the listener to add.
      • addTileSizeListener

        public void addTileSizeListener(MapWindowTileSizeListener listener)
        Add the given listener to the set of tile size change listeners. The listener will be notified on tile size events only.
        Specified by:
        addTileSizeListener in interface  TileMapWindow
        Parameters:
        listener - the listener to add.
      • addWorldScaleListener

        public void addWorldScaleListener(MapWindowWorldScaleListener listener)
        Description copied from interface: MapWindow
        Add the given listener to the set of world scale change listeners. The listener will be notified on world scale events only.
        Specified by:
        addWorldScaleListener in interface  MapWindow
        Parameters:
        listener - the listener to add.
      • longitudeToX

        public double longitudeToX(double ilon)
        Calculate the current x position of the given longitude.
        Specified by:
        longitudeToX in interface  MapWindow
        Parameters:
        ilon - the longitude.
        Returns:
        the longitude's position on this window.
      • latitudeToY

        public double latitudeToY(double ilat)
        Calculate the current y position of the given latitude.
        Specified by:
        latitudeToY in interface  MapWindow
        Parameters:
        ilat - the latitude.
        Returns:
        the latitude's position on this window.
      • mercatorToX

        public double mercatorToX(double mx)
        Calculate the current x position of the given mercator x.
        Specified by:
        mercatorToX in interface  MapWindow
        Parameters:
        mx - the mercator value in the window's zoom level dimension.
        Returns:
        the longitude's position on this window.
      • mercatorToY

        public double mercatorToY(double my)
        Calculate the current y position of the given mercator y.
        Specified by:
        mercatorToY in interface  MapWindow
        Parameters:
        my - the mercator value in the window's zoom level dimension.
        Returns:
        the latitude's position on this window.
      • gotoLonLat

        public void gotoLonLat(double longitude,
                               double latitude)
        Center the map on this position.
        Specified by:
        gotoLonLat in interface  MapWindow
        Parameters:
        longitude - the longitude.
        latitude - the latitude.
      • gotoLonLat

        public void gotoLonLat(double lon1,
                               double lon2,
                               double lat1,
                               double lat2)
        Specified by:
        gotoLonLat in interface  MapWindow
        Parameters:
        lon1 - minimum longitude.
        lon2 - maximum longitude.
        lat1 - minimum latitude.
        lat2 - maximum latitude.
      • containsPoint

        public boolean containsPoint(OverlayPoint point)
        Test whether this point is within this window.
        Specified by:
        containsPoint in interface  MapWindow
        Parameters:
        point - the point to test for.
        Returns:
        whether this point is currently within this window.
      • getX

        public double getX(double x)
      • getY

        public double getY(double y)
      • getPositionX

        public int getPositionX(SteppedMapWindow mapWindow)
        Get the position of the given window relative to this window.
        Parameters:
        mapWindow - the window to inspect.
        Returns:
        the x offset relative to this window's top left corner.
      • getPositionY

        public int getPositionY(SteppedMapWindow mapWindow)
        Get the position of the given window relative to this window.
        Parameters:
        mapWindow - the window to inspect.
        Returns:
        the y offset relative to this window's top left corner.
      • setTileSize

        public boolean setTileSize(int tileSize)
      • getTileWidth

        public int getTileWidth()
      • getTileHeight

        public int getTileHeight()
      • minimumCacheSize

        public int minimumCacheSize()
      • getWorldsizePixels

        public double getWorldsizePixels()
        Specified by:
        getWorldsizePixels in interface  MapWindow
        Returns:
        the size of the whole worlds image in pixels
      • setWorldScale

        public boolean setWorldScale(int worldScale)
        Description copied from interface: MapWindow
        Set the scale factor of the map that determines how big the image of the world is.
        Specified by:
        setWorldScale in interface  MapWindow
        Parameters:
        worldScale - the factor by which to multiply the worldsize.
        Returns:
        whether the scale actually changed
      • getWorldScale

        public int getWorldScale()
        Specified by:
        getWorldScale in interface  MapWindow
        Returns:
        the scale factor the world image is scaled up with.