Class Viewport

  • All Implemented Interfaces:
    PointTransformation

    public class Viewport
    extends java.lang.Object
    implements PointTransformation
    Maintains the information associated with mapping the model view to the screen
    • Field Detail

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

        private java.awt.geom.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
      • scaleFormat

        private java.text.NumberFormat scaleFormat
      • viewEnvInModel

        private Envelope viewEnvInModel
      • modelToViewTransform

        private java.awt.geom.AffineTransform modelToViewTransform
      • srcPt

        private java.awt.geom.Point2D.Double srcPt
      • destPt

        private java.awt.geom.Point2D.Double destPt
      • viewSize

        private java.awt.Dimension viewSize
      • MIN_GRID_RESOLUTION_PIXELS

        private static final int MIN_GRID_RESOLUTION_PIXELS
        See Also:
        Constant Field Values
    • Method Detail

      • 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 java.text.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 java.awt.geom.Point2D toModel​(java.awt.geom.Point2D viewPt)
      • toModelCoordinate

        public Coordinate toModelCoordinate​(java.awt.geom.Point2D viewPt)
      • toView

        public java.awt.geom.Point2D toView​(Coordinate modelCoordinate)
      • toView

        public java.awt.geom.Point2D toView​(java.awt.geom.Point2D modelPt)
      • toView

        public java.awt.geom.Point2D toView​(java.awt.geom.Point2D modelPt,
                                            java.awt.geom.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​(java.awt.Dimension viewSize)
      • update

        private void update()
      • updateModelToViewTransform

        private void updateModelToViewTransform()
      • getModelToViewTransform

        public java.awt.geom.AffineTransform getModelToViewTransform()
      • zoomToInitialExtent

        public void zoomToInitialExtent()
      • zoom

        public void zoom​(Envelope zoomEnv)
      • zoomPan

        public void zoomPan​(double dx,
                            double dy)
      • zoom

        public void zoom​(java.awt.geom.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 java.awt.geom.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()