Class Viewport
java.lang.Object
org.locationtech.jtstest.testbuilder.ui.Viewport
- All Implemented Interfaces:
PointTransformation
Maintains the information associated with mapping
the model view to the screen
-
Field Summary
FieldsModifier and TypeFieldDescriptionprivate Point2D.Double
private static int
private static int
private static double
private static final int
private AffineTransform
private Point2D
Origin of view in model spaceprivate GeometryEditPanel
private static final double
private double
The scale is the factor which model distance is multiplied by to get view distanceprivate NumberFormat
private PrecisionModel
private Point2D.Double
private Envelope
private Dimension
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionprivate Envelope
boolean
Gets a PrecisionModel corresponding to the grid size.double
private double
double
double
getScale()
private double
double
int
Gets the magnitude (power of 10) for the basic grid size.boolean
private void
setOrigin
(double viewOriginX, double viewOriginY) private void
setScale
(double scale) private void
setScaleNoUpdate
(double scale) private static double
snapScale
(double scaleRaw) Snaps scale to nearest multiple of 2, 5 or 10.private static double
snapScaleTo_10_2_5
(double scaleRaw) Not used - scaling to multiples of 10,5,2 is too coarse.private static double
snapScaleToSingleDigitPrecision
(double scaleRaw) double
toModel
(double viewDist) Converts a distance in the view to a distance in the model.toModelCoordinate
(Point2D viewPt) double
toView
(double modelDist) Converts a distance in the model to a distance in the view.toView
(Coordinate modelCoordinate) void
transform
(Coordinate modelCoordinate, Point2D point) Transforms aCoordinate
into a Java2DPoint
.private void
update()
void
private void
private void
void
Zoom to a point, ensuring that the zoom point remains in the same screen location.void
void
zoomPan
(double dx, double dy) void
-
Field Details
-
INITIAL_SCALE
private static double INITIAL_SCALE -
INITIAL_ORIGIN_X
private static int INITIAL_ORIGIN_X -
INITIAL_ORIGIN_Y
private static int INITIAL_ORIGIN_Y -
panel
-
originInModel
Origin of view in model space -
scale
private double scaleThe scale is the factor which model distance is multiplied by to get view distance -
scalePM
-
scaleFormat
-
viewEnvInModel
-
modelToViewTransform
-
srcPt
-
destPt
-
viewSize
-
ROUND_ERROR_REMOVAL
private static final double ROUND_ERROR_REMOVAL- See Also:
-
MIN_GRID_RESOLUTION_PIXELS
private static final int MIN_GRID_RESOLUTION_PIXELS- See Also:
-
-
Constructor Details
-
Viewport
-
-
Method Details
-
viewUpdated
private void viewUpdated() -
getModelEnv
-
getViewEnv
-
getScale
public double getScale() -
setScaleNoUpdate
private void setScaleNoUpdate(double scale) -
setScale
private void setScale(double scale) -
setOrigin
private void setOrigin(double viewOriginX, double viewOriginY) -
getScaleFormat
-
snapScale
private static double snapScale(double scaleRaw) Snaps scale to nearest multiple of 2, 5 or 10. This ensures that model coordinates entered via the geometry view don't carry more precision than the zoom level warrants.- Parameters:
scaleRaw
-- Returns:
-
snapScaleToSingleDigitPrecision
private static double snapScaleToSingleDigitPrecision(double scaleRaw) -
snapScaleTo_10_2_5
private static double snapScaleTo_10_2_5(double scaleRaw) Not used - scaling to multiples of 10,5,2 is too coarse.- Parameters:
scaleRaw
-- Returns:
-
intersectsInModel
-
toModel
-
toModelCoordinate
-
transform
Description copied from interface:PointTransformation
Transforms aCoordinate
into a Java2DPoint
.- Specified by:
transform
in interfacePointTransformation
- Parameters:
modelCoordinate
- the source Coordinatepoint
- the destination Point
-
toView
-
toView
-
toView
-
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
-
update
private void update() -
updateModelToViewTransform
private void updateModelToViewTransform() -
getModelToViewTransform
-
zoomToInitialExtent
public void zoomToInitialExtent() -
zoom
-
zoomPan
public void zoomPan(double dx, double dy) -
zoom
Zoom to a point, ensuring that the zoom point remains in the same screen location.- Parameters:
zoomPt
-zoomFactor
-
-
getWidthInModel
private double getWidthInModel() -
getHeightInModel
private double getHeightInModel() -
getLowerLeftCornerInModel
-
getHeightInView
public double getHeightInView() -
getWidthInView
public double getWidthInView() -
computeEnvelopeInModel
-
containsInModel
-
gridMagnitudeModel
public int gridMagnitudeModel()Gets the magnitude (power of 10) for the basic grid size.- Returns:
- the magnitude
-
getGridPrecisionModel
Gets a PrecisionModel corresponding to the grid size.- Returns:
- the precision model
-
getGridSizeModel
public double getGridSizeModel()
-