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
  • 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

      private GeometryEditPanel panel
    • originInModel

      private Point2D originInModel
      Origin of view in model space
    • scale

      private double scale
      The scale is the factor which model distance is multiplied by to get view distance
    • scalePM

      private PrecisionModel scalePM
    • scaleFormat

      private NumberFormat scaleFormat
    • viewEnvInModel

      private Envelope viewEnvInModel
    • modelToViewTransform

      private AffineTransform modelToViewTransform
    • srcPt

      private Point2D.Double srcPt
    • destPt

      private Point2D.Double destPt
    • viewSize

      private Dimension 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

  • Method Details

    • viewUpdated

      private void viewUpdated()
    • getModelEnv

      public Envelope getModelEnv()
    • getViewEnv

      public Envelope 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

      public NumberFormat 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

      public boolean intersectsInModel(Envelope env)
    • toModel

      public Point2D toModel(Point2D viewPt)
    • toModelCoordinate

      public Coordinate toModelCoordinate(Point2D viewPt)
    • transform

      public void transform(Coordinate modelCoordinate, Point2D point)
      Description copied from interface: PointTransformation
      Transforms a Coordinate into a Java2D Point.
      Specified by:
      transform in interface PointTransformation
      Parameters:
      modelCoordinate - the source Coordinate
      point - the destination Point
    • toView

      public Point2D toView(Coordinate modelCoordinate)
    • toView

      public Point2D toView(Point2D modelPt)
    • toView

      public Point2D toView(Point2D modelPt, Point2D viewPt)
    • 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)
    • update

      private void update()
    • updateModelToViewTransform

      private void updateModelToViewTransform()
    • 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 -
    • getWidthInModel

      private double getWidthInModel()
    • getHeightInModel

      private double getHeightInModel()
    • getLowerLeftCornerInModel

      public Point2D getLowerLeftCornerInModel()
    • getHeightInView

      public double getHeightInView()
    • getWidthInView

      public double getWidthInView()
    • computeEnvelopeInModel

      private Envelope computeEnvelopeInModel()
    • containsInModel

      public boolean containsInModel(Coordinate 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()