Class MapViewState

java.lang.Object
org.openstreetmap.josm.gui.MapViewState
All Implemented Interfaces:
Serializable

public final class MapViewState extends Object implements Serializable
This class represents a state of the MapView.
Since:
10343
See Also:
  • Field Details

  • Constructor Details

  • Method Details

    • findTopLeftInWindow

      This is visible for JMockit.
      Parameters:
      position - The component to get the top left position of its window
      Returns:
      the top left point in window
    • findTopLeftOnScreen

      This is visible for JMockit.
      Parameters:
      position - The component to get the top left position of its screen
      Returns:
      the top left point on screen
    • toString

      public String toString()
      Overrides:
      toString in class Object
    • getScale

      public double getScale()
      The scale in east/north units per pixel.
      Returns:
      The scale.
    • getForView

      public MapViewState.MapViewPoint getForView(double x, double y)
      Gets the MapViewPoint representation for a position in view coordinates.
      Parameters:
      x - The x coordinate inside the view.
      y - The y coordinate inside the view.
      Returns:
      The MapViewPoint.
    • getPointFor

      Gets the MapViewState.MapViewPoint for the given EastNorth coordinate.
      Parameters:
      eastNorth - the position.
      Returns:
      The point for that position.
    • getPointFor

      Gets the MapViewState.MapViewPoint for the given LatLon coordinate.

      This method exists to not break binary compatibility with old plugins

      Parameters:
      latlon - the position
      Returns:
      The point for that position.
      Since:
      10651
    • getPointFor

      Gets the MapViewState.MapViewPoint for the given LatLon coordinate.
      Parameters:
      latlon - the position
      Returns:
      The point for that position.
      Since:
      12161
    • getPointFor

      Gets the MapViewState.MapViewPoint for the given node. This is faster than getPointFor(LatLon) because it uses the node east/north cache.
      Parameters:
      node - The node
      Returns:
      The position of that node.
      Since:
      10827
    • getViewArea

      Gets a rectangle representing the whole view area.
      Returns:
      The rectangle.
    • getViewArea

      Gets a rectangle of the view as map view area.
      Parameters:
      rectangle - The rectangle to get.
      Returns:
      The view area.
      Since:
      10827
    • getCenter

      Gets the center of the view.
      Returns:
      The center position.
    • getViewWidth

      public double getViewWidth()
      Gets the width of the view on the Screen;
      Returns:
      The width of the view component in screen pixel.
    • getViewHeight

      public double getViewHeight()
      Gets the height of the view on the Screen;
      Returns:
      The height of the view component in screen pixel.
    • getProjection

      Gets the current projection used for the MapView.
      Returns:
      The projection.
      See Also:
    • getProjecting

      Gets the current projecting instance that is used to convert between east/north and lat/lon space.
      Returns:
      The projection.
      Since:
      12161
    • getAffineTransform

      Creates an affine transform that is used to convert the east/north coordinates to view coordinates.
      Returns:
      The affine transform. It should not be changed.
      Since:
      10375
    • getViewClipRectangle

      Gets a rectangle that is several pixel bigger than the view. It is used to define the view clipping.
      Returns:
      The rectangle.
    • getArea

      public Area getArea(Bounds bounds)
      Returns the area for the given bounds.
      Parameters:
      bounds - bounds
      Returns:
      the area for the given bounds
    • usingCenter

      public MapViewState usingCenter(EastNorth newCenter)
      Creates a new state that is the same as the current state except for that it is using a new center.
      Parameters:
      newCenter - The new center coordinate.
      Returns:
      The new state.
      Since:
      10375
    • movedTo

      public MapViewState movedTo(MapViewState.MapViewPoint mapViewPoint, EastNorth newEastNorthThere)
      Creates a new state that is moved to an east/north coordinate.
      Parameters:
      mapViewPoint - The reference point.
      newEastNorthThere - The east/north coordinate that should be there.
      Returns:
      The new state.
      Since:
      10375
    • usingScale

      public MapViewState usingScale(double newScale)
      Creates a new state that is the same as the current state except for that it is using a new scale.
      Parameters:
      newScale - The new scale to use.
      Returns:
      The new state.
      Since:
      10375
    • usingLocation

      Creates a new state that is the same as the current state except for that it is using the location of the given component.

      The view is moved so that the center is the same as the old center.

      Parameters:
      position - The new location to use.
      Returns:
      The new state.
      Since:
      10375
    • usingProjection

      Creates a state that uses the projection.
      Parameters:
      projection - The projection to use.
      Returns:
      The new state.
      Since:
      10486
    • createDefaultState

      public static MapViewState createDefaultState(int width, int height)
      Create the default MapViewState object for the given map view. The screen position won't be set so that this method can be used before the view was added to the hierarchy.
      Parameters:
      width - The view width
      height - The view height
      Returns:
      The state
      Since:
      10375
    • calculateDefaultCenter

    • equalsInWindow

      public boolean equalsInWindow(MapViewState other)
      Check if this MapViewState equals another one, disregarding the position of the JOSM window on screen.
      Parameters:
      other - the other MapViewState
      Returns:
      true if the other MapViewState has the same size, scale, position and projection, false otherwise