Class SteplessMapWindow

    • Method Summary

      Modifier and Type Method and Description
      void addChangeListener(MapWindowChangeListener listener)
      Add the given listener to the set of general change listeners.
      void addWorldScaleListener(MapWindowWorldScaleListener listener)
      Add the given listener to the set of tile size change listeners.
      void addZoomListener(ZoomChangedListener listener)
      Add the given listener to the set of zoom change listeners.
      boolean containsPoint(OverlayPoint point)
      Test whether this point is within this window.
      BBox getBoundingBox()
      Get the covered area as a bounding box.
      double getCenterLat()
       
      double getCenterLon()
       
      double getCenterX()
      Get the window's center's tile coordinate.
      double getCenterY()
      Get the window's center's tile coordinate.
      int getHeight()
       
      int getMaxZoom()
       
      int getMinZoom()
       
      double getPositionLat(int y)
      Get the latitude of the given y in view space.
      double getPositionLon(int x)
      Get the longitude of the given x in view space.
      double getPositionX(int px)
      Get the tile coordinate at the given x in view space.
      double getPositionY(int py)
      Get the tile coordinate at the given y in view space.
      int getWidth()
       
      int getWorldScale()
       
      double getWorldsizePixels()
       
      double getX(double x)
       
      double getY(double y)
       
      double getZoom()
       
      void gotoLonLat(double longitude, double latitude)
      Center the map on this position.
      void gotoLonLat(double lon1, double lon2, double lat1, double lat2)
       
      void gotoPoints(Collection<OverlayPoint> points)
      Move the viewport to show all points.
      double latitudeToY(double ilat)
      Calculate the current y position of the given latitude.
      double longitudeToX(double ilon)
      Calculate the current x position of the given longitude.
      double mercatorToX(double mx)
      Calculate the current x position of the given mercator x.
      double mercatorToY(double my)
      Calculate the current y position of the given mercator y.
      void move(int dx, int dy)
      Reposition the map window with the given values.
      void resize(int newWidth, int newHeight)
      Adjust the size of the window.
      void setMaxZoom(int zoomMax)
      Set the maximum allowed zoomlevel.
      void setMinZoom(int zoomMin)
      Set the minimum allowed zoomlevel.
      void setViewBounds(ViewBounds bounds)
       
      boolean setWorldScale(int worldScale)
      Set the scale factor of the map that determines how big the image of the world is.
      boolean zoom(double zoomlevel)
      zoom in to the denoted zoomlevel if possible.
      boolean zoom(int zoomlevel)
      zoom in to the denoted zoomlevel if possible.
      boolean zoomIn()
      zoom in to center if possible.
      boolean zoomIn(double d)
      zoom in to center if possible.
      void zoomInToPosition(int x, int y)
       
      void zoomInToPosition(int x, int y, double d)
       
      boolean zoomOut()
      zoom out from center if possible.
      boolean zoomOut(double d)
      zoom out from center if possible.
      void zoomOutToPosition(int x, int y)
       
      void zoomOutToPosition(int x, int y, double d)
       
    • Constructor Detail

      • SteplessMapWindow

        public SteplessMapWindow(int width,
                                 int height,
                                 double zoom,
                                 int px,
                                 int py)
        Parameters:
        width - the window's width.
        height - the window's height.
        zoom - the zoom level.
        px - the x coordinate.
        py - the y coordinate.
      • SteplessMapWindow

        public SteplessMapWindow(int width,
                                 int height,
                                 double 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.
      • SteplessMapWindow

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

      • setViewBounds

        public void setViewBounds(ViewBounds bounds)
      • getCenterX

        public double getCenterX()
        Get the window's center's tile coordinate.
        Returns:
        the center's tile coordinate.
      • getCenterY

        public double getCenterY()
        Get the window's center's tile coordinate.
        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.
        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.
        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.
      • getZoom

        public double getZoom()
        Specified by:
        getZoom in interface  MapWindow
        Returns:
        the current zoom level.
      • 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(double d)
        zoom in to center if possible.
        Returns:
        whether this operation changed the zoom level.
      • zoomOut

        public boolean zoomOut(double d)
        zoom out from center if possible.
        Returns:
        whether this operation changed the zoom level.
      • zoom

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

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

        public void zoomOutToPosition(int x,
                                      int y,
                                      double d)
      • 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.
      • addWorldScaleListener

        public void addWorldScaleListener(MapWindowWorldScaleListener 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:
        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)
      • 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.
      • zoomIn

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

        public boolean zoomOut()
        Description copied from interface: MapWindow
        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)
        Description copied from interface: MapWindow
        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)
      • getWorldsizePixels

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