public final class MapViewState extends java.lang.Object
MapView
.Modifier and Type | Class and Description |
---|---|
private class |
MapViewState.MapViewEastNorthPoint |
class |
MapViewState.MapViewPoint
A class representing a point in the map view.
|
class |
MapViewState.MapViewRectangle
A rectangle on the MapView.
|
private class |
MapViewState.MapViewViewPoint |
Modifier and Type | Field and Description |
---|---|
private Projection |
projection |
private double |
scale |
private EastNorth |
topLeft
Top left
EastNorth coordinate of the view. |
private java.awt.Point |
topLeftInWindow |
private java.awt.Point |
topLeftOnScreen |
private int |
viewHeight |
private int |
viewWidth |
Modifier | Constructor and Description |
---|---|
private |
MapViewState(double scale,
MapViewState mapViewState) |
private |
MapViewState(EastNorth topLeft,
MapViewState mapViewState) |
private |
MapViewState(javax.swing.JComponent position,
MapViewState mapViewState) |
private |
MapViewState(Projection projection,
int viewWidth,
int viewHeight,
double scale,
EastNorth topLeft)
Create a new
MapViewState |
private |
MapViewState(Projection projection,
MapViewState mapViewState) |
Modifier and Type | Method and Description |
---|---|
private static EastNorth |
calculateDefaultCenter() |
static MapViewState |
createDefaultState(int width,
int height)
Create the default
MapViewState object for the given map view. |
java.awt.geom.AffineTransform |
getAffineTransform()
Creates an affine transform that is used to convert the east/north coordinates to view coordinates.
|
MapViewState.MapViewPoint |
getCenter()
Gets the center of the view.
|
MapViewState.MapViewPoint |
getForView(double x,
double y)
Gets the MapViewPoint representation for a position in view coordinates.
|
MapViewState.MapViewPoint |
getPointFor(EastNorth eastNorth)
Gets the
MapViewState.MapViewPoint for the given EastNorth coordinate. |
Projection |
getProjection()
Gets the current projection used for the MapView.
|
double |
getScale()
The scale in east/north units per pixel.
|
MapViewState.MapViewRectangle |
getViewArea()
Gets a rectangle representing the whole view area.
|
MapViewState.MapViewRectangle |
getViewArea(java.awt.Rectangle rectangle)
Gets a rectangle of the view as map view area.
|
double |
getViewHeight()
Gets the height of the view on the Screen;
|
double |
getViewWidth()
Gets the width of the view on the Screen;
|
MapViewState |
movedTo(MapViewState.MapViewPoint mapViewPoint,
EastNorth newEastNorthThere) |
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.
|
MapViewState |
usingLocation(javax.swing.JComponent positon)
Creates a new state that is the same as the current state except for that it is using the location of the given component.
|
MapViewState |
usingProjection(Projection projection)
Creates a state that uses the projection.
|
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.
|
private final Projection projection
private final int viewWidth
private final int viewHeight
private final double scale
private final java.awt.Point topLeftOnScreen
private final java.awt.Point topLeftInWindow
private MapViewState(Projection projection, int viewWidth, int viewHeight, double scale, EastNorth topLeft)
MapViewState
projection
- The projection to use.viewWidth
- The view widthviewHeight
- The view heightscale
- The scale to usetopLeft
- The top left corner in east/north space.private MapViewState(EastNorth topLeft, MapViewState mapViewState)
private MapViewState(double scale, MapViewState mapViewState)
private MapViewState(javax.swing.JComponent position, MapViewState mapViewState)
private MapViewState(Projection projection, MapViewState mapViewState)
public double getScale()
public MapViewState.MapViewPoint getForView(double x, double y)
x
- The x coordinate inside the view.y
- The y coordinate inside the view.public MapViewState.MapViewPoint getPointFor(EastNorth eastNorth)
MapViewState.MapViewPoint
for the given EastNorth
coordinate.eastNorth
- the position.public MapViewState.MapViewRectangle getViewArea()
public MapViewState.MapViewRectangle getViewArea(java.awt.Rectangle rectangle)
rectangle
- The rectangle to get.public MapViewState.MapViewPoint getCenter()
public double getViewWidth()
public double getViewHeight()
public Projection getProjection()
public java.awt.geom.AffineTransform getAffineTransform()
public MapViewState usingCenter(EastNorth newCenter)
newCenter
- The new center coordinate.public MapViewState movedTo(MapViewState.MapViewPoint mapViewPoint, EastNorth newEastNorthThere)
mapViewPoint
- The reference point.newEastNorthThere
- The east/north coordinate that should be there.public MapViewState usingScale(double newScale)
newScale
- The new scale to use.public MapViewState usingLocation(javax.swing.JComponent positon)
The view is moved so that the center is the same as the old center.
positon
- The new location to use.public MapViewState usingProjection(Projection projection)
projection
- The projection to use.public static MapViewState createDefaultState(int width, int height)
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 hirarchy.width
- The view widthheight
- The view heightprivate static EastNorth calculateDefaultCenter()