Package org.openstreetmap.josm.gui
Class MapViewState.MapViewPoint
- java.lang.Object
-
- org.openstreetmap.josm.gui.MapViewState.MapViewPoint
-
- Direct Known Subclasses:
MapViewState.MapViewEastNorthPoint
,MapViewState.MapViewViewPoint
- Enclosing class:
- MapViewState
public abstract class MapViewState.MapViewPoint extends java.lang.Object
A class representing a point in the map view. It allows to convert between the different coordinate systems.
-
-
Constructor Summary
Constructors Constructor Description MapViewPoint()
-
Method Summary
All Methods Instance Methods Abstract Methods Concrete Methods Modifier and Type Method Description MapViewState.MapViewPoint
add(EastNorth en)
Add the given offset to this pointdouble
distanceToInView(MapViewState.MapViewPoint p2)
Gets the distance between this point and an other point.double
distanceToInViewSq(MapViewState.MapViewPoint p2)
Gets the squared distance between this point and an other point.EastNorth
getEastNorth()
Gets theEastNorth
coordinate of this point.java.awt.geom.Point2D
getInView()
Get this point in view coordinates.abstract double
getInViewX()
Get the x coordinate in view space without creating an intermediate object.abstract double
getInViewY()
Get the y coordinate in view space without creating an intermediate object.java.awt.geom.Point2D
getInWindow()
Convert this point to window coordinates.LatLon
getLatLon()
Gets the current position in LatLon coordinates according to the current projection.LatLon
getLatLonClamped()
Gets the latlon coordinate clamped to the current world area.MapViewState
getMapViewState()
Gets the map view state this path is used for.java.awt.geom.Point2D
getOnScreen()
Convert this point to screen coordinates.int
getOutsideRectangleFlags(MapViewState.MapViewRectangle rect)
Gets the direction in which this point is outside of the given view rectangle.private java.awt.geom.Point2D.Double
getUsingCorner(java.awt.Point corner)
private boolean
inRange(double val, int min, double max)
MapViewState.MapViewPoint
interpolate(MapViewState.MapViewPoint p1, double i)
Do a linear interpolation to the other pointboolean
isInView()
Check if this point is inside the view bounds.double
oneNormInView(MapViewState.MapViewPoint p2)
Gets the sum of the x/y view distances between the points.MapViewState.MapViewRectangle
rectTo(MapViewState.MapViewPoint other)
Create a rectangle from this to the other point.
-
-
-
Constructor Detail
-
MapViewPoint
public MapViewPoint()
-
-
Method Detail
-
getMapViewState
public MapViewState getMapViewState()
Gets the map view state this path is used for.- Returns:
- The state.
- Since:
- 12505
-
getInView
public java.awt.geom.Point2D getInView()
Get this point in view coordinates.- Returns:
- The point in view coordinates.
-
getInViewX
public abstract double getInViewX()
Get the x coordinate in view space without creating an intermediate object.- Returns:
- The x coordinate
- Since:
- 10827
-
getInViewY
public abstract double getInViewY()
Get the y coordinate in view space without creating an intermediate object.- Returns:
- The y coordinate
- Since:
- 10827
-
getInWindow
public java.awt.geom.Point2D getInWindow()
Convert this point to window coordinates.- Returns:
- The point in window coordinates.
-
getOnScreen
public java.awt.geom.Point2D getOnScreen()
Convert this point to screen coordinates.- Returns:
- The point in screen coordinates.
-
getUsingCorner
private java.awt.geom.Point2D.Double getUsingCorner(java.awt.Point corner)
-
getEastNorth
public EastNorth getEastNorth()
Gets theEastNorth
coordinate of this point.- Returns:
- The east/north coordinate.
-
rectTo
public MapViewState.MapViewRectangle rectTo(MapViewState.MapViewPoint other)
Create a rectangle from this to the other point.- Parameters:
other
- The other point. Needs to be of the sameMapViewState
- Returns:
- A rectangle.
-
getLatLon
public LatLon getLatLon()
Gets the current position in LatLon coordinates according to the current projection.- Returns:
- The position as LatLon.
- See Also:
getLatLonClamped()
-
getLatLonClamped
public LatLon getLatLonClamped()
Gets the latlon coordinate clamped to the current world area.- Returns:
- The lat/lon coordinate
- Since:
- 10805
-
add
public MapViewState.MapViewPoint add(EastNorth en)
Add the given offset to this point- Parameters:
en
- The offset in east/north space.- Returns:
- The new point
- Since:
- 10651
-
isInView
public boolean isInView()
Check if this point is inside the view bounds. This is the case iffgetOutsideRectangleFlags(getViewArea())
returns no flags- Returns:
- true if it is.
- Since:
- 10827
-
inRange
private boolean inRange(double val, int min, double max)
-
getOutsideRectangleFlags
public int getOutsideRectangleFlags(MapViewState.MapViewRectangle rect)
Gets the direction in which this point is outside of the given view rectangle.- Parameters:
rect
- The rectangle to check against.- Returns:
- The direction in which it is outside of the view, as OUTSIDE_... flags.
- Since:
- 10827
-
oneNormInView
public double oneNormInView(MapViewState.MapViewPoint p2)
Gets the sum of the x/y view distances between the points. |x1 - x2| + |y1 - y2|- Parameters:
p2
- The other point- Returns:
- The norm
- Since:
- 10827
-
distanceToInViewSq
public double distanceToInViewSq(MapViewState.MapViewPoint p2)
Gets the squared distance between this point and an other point.- Parameters:
p2
- The other point- Returns:
- The squared distance.
- Since:
- 10827
-
distanceToInView
public double distanceToInView(MapViewState.MapViewPoint p2)
Gets the distance between this point and an other point.- Parameters:
p2
- The other point- Returns:
- The distance.
- Since:
- 10827
-
interpolate
public MapViewState.MapViewPoint interpolate(MapViewState.MapViewPoint p1, double i)
Do a linear interpolation to the other point- Parameters:
p1
- The other pointi
- The interpolation factor. 0 is at the current point, 1 at the other point.- Returns:
- The new point
- Since:
- 10874
-
-