Class Viewport
- java.lang.Object
-
- org.locationtech.jtstest.testbuilder.ui.Viewport
-
- All Implemented Interfaces:
PointTransformation
public class Viewport extends Object implements PointTransformation
Maintains the information associated with mapping the model view to the screen- Author:
- Martin Davis
-
-
Constructor Summary
Constructors Constructor Description Viewport(GeometryEditPanel panel)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description boolean
contains(Point2D p)
boolean
containsInModel(Coordinate p)
boolean
containsInModel(Coordinate p0, Coordinate p1)
PrecisionModel
getGridPrecisionModel()
Gets a PrecisionModel corresponding to the grid size.double
getGridSizeModel()
double
getHeightInView()
Point2D
getLowerLeftCornerInModel()
Envelope
getModelEnv()
AffineTransform
getModelToViewTransform()
double
getScale()
NumberFormat
getScaleFormat()
Envelope
getViewEnv()
double
getWidthInView()
int
gridMagnitudeModel()
Gets the magnitude (power of 10) for the basic grid size.boolean
intersectsInModel(Coordinate p0, Coordinate p1)
boolean
intersectsInModel(Envelope env)
double
toModel(double viewDist)
Converts a distance in the view to a distance in the model.Point2D
toModel(Point2D viewPt)
Coordinate
toModelCoordinate(Point2D viewPt)
double
toView(double modelDist)
Converts a distance in the model to a distance in the view.Point2D
toView(Point2D modelPt)
Point2D
toView(Point2D modelPt, Point2D viewPt)
Point2D
toView(Coordinate modelCoordinate)
void
transform(Coordinate modelCoordinate, Point2D point)
Transforms aCoordinate
into a Java2DPoint
.void
update(Dimension viewSize)
void
zoom(Point2D zoomPt, double zoomScale)
Zoom to a point, ensuring that the zoom point remains in the same screen location.void
zoom(Envelope zoomEnv)
void
zoomPan(double dx, double dy)
void
zoomToInitialExtent()
-
-
-
Constructor Detail
-
Viewport
public Viewport(GeometryEditPanel panel)
-
-
Method Detail
-
getModelEnv
public Envelope getModelEnv()
-
getViewEnv
public Envelope getViewEnv()
-
getScale
public double getScale()
-
getScaleFormat
public NumberFormat getScaleFormat()
-
intersectsInModel
public boolean intersectsInModel(Envelope env)
-
intersectsInModel
public boolean intersectsInModel(Coordinate p0, Coordinate p1)
-
toModelCoordinate
public Coordinate toModelCoordinate(Point2D viewPt)
-
transform
public void transform(Coordinate modelCoordinate, Point2D point)
Description copied from interface:PointTransformation
Transforms aCoordinate
into a Java2DPoint
.- Specified by:
transform
in interfacePointTransformation
- Parameters:
modelCoordinate
- the source Coordinatepoint
- the destination Point
-
toView
public Point2D toView(Coordinate modelCoordinate)
-
toModel
public double toModel(double viewDist)
Converts a distance in the view to a distance in the model.- Parameters:
viewDist
-- Returns:
- the model distance
-
toView
public double toView(double modelDist)
Converts a distance in the model to a distance in the view.- Parameters:
modelDist
-- Returns:
- the view distance
-
update
public void update(Dimension viewSize)
-
getModelToViewTransform
public AffineTransform getModelToViewTransform()
-
zoomToInitialExtent
public void zoomToInitialExtent()
-
zoom
public void zoom(Envelope zoomEnv)
-
zoomPan
public void zoomPan(double dx, double dy)
-
zoom
public void zoom(Point2D zoomPt, double zoomScale)
Zoom to a point, ensuring that the zoom point remains in the same screen location.- Parameters:
zoomPt
-zoomFactor
-
-
getLowerLeftCornerInModel
public Point2D getLowerLeftCornerInModel()
-
getHeightInView
public double getHeightInView()
-
getWidthInView
public double getWidthInView()
-
containsInModel
public boolean containsInModel(Coordinate p)
-
containsInModel
public boolean containsInModel(Coordinate p0, Coordinate p1)
-
contains
public boolean contains(Point2D p)
-
gridMagnitudeModel
public int gridMagnitudeModel()
Gets the magnitude (power of 10) for the basic grid size.- Returns:
- the magnitude
-
getGridPrecisionModel
public PrecisionModel getGridPrecisionModel()
Gets a PrecisionModel corresponding to the grid size.- Returns:
- the precision model
-
getGridSizeModel
public double getGridSizeModel()
-
-