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.Doubleprivate static intprivate static intprivate static doubleprivate static final intprivate AffineTransformprivate Point2DOrigin of view in model spaceprivate GeometryEditPanelprivate static final doubleprivate doubleThe scale is the factor which model distance is multiplied by to get view distanceprivate NumberFormatprivate PrecisionModelprivate Point2D.Doubleprivate Envelopeprivate Dimension -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionprivate EnvelopebooleanGets a PrecisionModel corresponding to the grid size.doubleprivate doubledoubledoublegetScale()private doubledoubleintGets the magnitude (power of 10) for the basic grid size.booleanprivate voidsetOrigin(double viewOriginX, double viewOriginY) private voidsetScale(double scale) private voidsetScaleNoUpdate(double scale) private static doublesnapScale(double scaleRaw) Snaps scale to nearest multiple of 2, 5 or 10.private static doublesnapScaleTo_10_2_5(double scaleRaw) Not used - scaling to multiples of 10,5,2 is too coarse.private static doublesnapScaleToSingleDigitPrecision(double scaleRaw) doubletoModel(double viewDist) Converts a distance in the view to a distance in the model.toModelCoordinate(Point2D viewPt) doubletoView(double modelDist) Converts a distance in the model to a distance in the view.toView(Coordinate modelCoordinate) voidtransform(Coordinate modelCoordinate, Point2D point) Transforms aCoordinateinto a Java2DPoint.private voidupdate()voidprivate voidprivate voidvoidZoom to a point, ensuring that the zoom point remains in the same screen location.voidvoidzoomPan(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:PointTransformationTransforms aCoordinateinto a Java2DPoint.- Specified by:
transformin 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()
-