Package org.openstreetmap.josm.gui
Class MapViewState
java.lang.Object
org.openstreetmap.josm.gui.MapViewState
- All Implemented Interfaces:
Serializable
This class represents a state of the
MapView.- Since:
- 10343
- See Also:
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionprivate classclassA class representing a point in the map view.classA rectangle on the MapView.private class -
Field Summary
FieldsModifier and TypeFieldDescriptionprivate static final intAdditional pixels outside the view for where to start clipping.static final intA flag indicating that the point is outside to the bottom of the map view.static final intA flag indicating that the point is outside to the left of the map view.static final intA flag indicating that the point is outside to the right of the map view.static final intA flag indicating that the point is outside to the top of the map view.private final Projectingprivate final doubleprivate static final longprivate final EastNorthTop leftEastNorthcoordinate of the view.private final Pointprivate final Pointprivate final intprivate final int -
Constructor Summary
ConstructorsModifierConstructorDescriptionprivateMapViewState(double scale, MapViewState mvs) privateMapViewState(JComponent position, MapViewState mvs) privateMapViewState(EastNorth topLeft, MapViewState mvs) privateMapViewState(Projecting projection, int viewWidth, int viewHeight, double scale, EastNorth topLeft) privateMapViewState(Projecting projection, int viewWidth, int viewHeight, double scale, EastNorth topLeft, Point topLeftInWindow, Point topLeftOnScreen) Create a newMapViewStateprivateMapViewState(Projecting projecting, MapViewState mvs) -
Method Summary
Modifier and TypeMethodDescriptionprivate static EastNorthstatic MapViewStatecreateDefaultState(int width, int height) Create the defaultMapViewStateobject for the given map view.booleanequalsInWindow(MapViewState other) Check if this MapViewState equals another one, disregarding the position of the JOSM window on screen.(package private) static PointfindTopLeftInWindow(JComponent position) This is visible for JMockit.(package private) static PointfindTopLeftOnScreen(JComponent position) This is visible for JMockit.Creates an affine transform that is used to convert the east/north coordinates to view coordinates.Returns the area for the given bounds.Gets the center of the view.getForView(double x, double y) Gets the MapViewPoint representation for a position in view coordinates.getPointFor(EastNorth eastNorth) Gets theMapViewState.MapViewPointfor the givenEastNorthcoordinate.getPointFor(ILatLon latlon) Gets theMapViewState.MapViewPointfor the givenLatLoncoordinate.getPointFor(LatLon latlon) Gets theMapViewState.MapViewPointfor the givenLatLoncoordinate.getPointFor(Node node) Gets theMapViewState.MapViewPointfor the given node.Gets the current projecting instance that is used to convert between east/north and lat/lon space.Gets the current projection used for the MapView.doublegetScale()The scale in east/north units per pixel.Gets a rectangle representing the whole view area.getViewArea(Rectangle2D rectangle) Gets a rectangle of the view as map view area.Gets a rectangle that is several pixel bigger than the view.doubleGets the height of the view on the Screen;doubleGets the width of the view on the Screen;movedTo(MapViewState.MapViewPoint mapViewPoint, EastNorth newEastNorthThere) Creates a new state that is moved to an east/north coordinate.toString()usingCenter(EastNorth newCenter) Creates a new state that is the same as the current state except for that it is using a new center.usingLocation(JComponent position) Creates a new state that is the same as the current state except for that it is using the location of the given component.usingProjection(Projection projection) Creates a state that uses the projection.usingScale(double newScale) Creates a new state that is the same as the current state except for that it is using a new scale.
-
Field Details
-
serialVersionUID
- See Also:
-
OUTSIDE_TOP
A flag indicating that the point is outside to the top of the map view.- Since:
- 10827
- See Also:
-
OUTSIDE_BOTTOM
A flag indicating that the point is outside to the bottom of the map view.- Since:
- 10827
- See Also:
-
OUTSIDE_LEFT
A flag indicating that the point is outside to the left of the map view.- Since:
- 10827
- See Also:
-
OUTSIDE_RIGHT
A flag indicating that the point is outside to the right of the map view.- Since:
- 10827
- See Also:
-
CLIP_BOUNDS
Additional pixels outside the view for where to start clipping.- See Also:
-
projecting
-
viewWidth
-
viewHeight
-
scale
-
topLeft
Top leftEastNorthcoordinate of the view. -
topLeftOnScreen
-
topLeftInWindow
-
-
Constructor Details
-
MapViewState
private MapViewState(Projecting projection, int viewWidth, int viewHeight, double scale, EastNorth topLeft, Point topLeftInWindow, Point topLeftOnScreen) Create a newMapViewState- Parameters:
projection- The projection to use.viewWidth- The view widthviewHeight- The view heightscale- The scale to usetopLeft- The top left corner in east/north space.topLeftInWindow- The top left point in windowtopLeftOnScreen- The top left point on screen
-
MapViewState
private MapViewState(Projecting projection, int viewWidth, int viewHeight, double scale, EastNorth topLeft) -
MapViewState
-
MapViewState
-
MapViewState
-
MapViewState
-
-
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
-
getScale
The scale in east/north units per pixel.- Returns:
- The scale.
-
getForView
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 theMapViewState.MapViewPointfor the givenEastNorthcoordinate.- Parameters:
eastNorth- the position.- Returns:
- The point for that position.
-
getPointFor
Gets theMapViewState.MapViewPointfor the givenLatLoncoordinate.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 theMapViewState.MapViewPointfor the givenLatLoncoordinate.- Parameters:
latlon- the position- Returns:
- The point for that position.
- Since:
- 12161
-
getPointFor
Gets theMapViewState.MapViewPointfor the given node. This is faster thangetPointFor(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
Gets the width of the view on the Screen;- Returns:
- The width of the view component in screen pixel.
-
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
Returns the area for the given bounds.- Parameters:
bounds- bounds- Returns:
- the area for the given bounds
-
usingCenter
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
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
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
Create the defaultMapViewStateobject 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 widthheight- The view height- Returns:
- The state
- Since:
- 10375
-
calculateDefaultCenter
-
equalsInWindow
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
-