Class DefaultViewport

    • Constructor Detail

      • DefaultViewport

        public DefaultViewport()
      • DefaultViewport

        public DefaultViewport​(Rectangle viewBounds)
      • DefaultViewport

        public DefaultViewport​(boolean modelYAxisDown)
      • DefaultViewport

        public DefaultViewport​(Rectangle viewBounds,
                               boolean modelYAxisDown)
    • Method Detail

      • isModelYAxisDown

        public boolean isModelYAxisDown()
        Specified by:
        isModelYAxisDown in interface Viewport
        Returns:
        If true, the model coordinate's Y-axis points downwards. Returns false by default.
      • setModelYAxisDown

        public void setModelYAxisDown​(boolean modelYAxisDown)
        Specified by:
        setModelYAxisDown in interface Viewport
        Parameters:
        modelYAxisDown - If true, the model coordinate's Y-axis points downwards.
      • setViewBounds

        public void setViewBounds​(Rectangle viewBounds)
        Specified by:
        setViewBounds in interface Viewport
        Parameters:
        viewBounds - The bounds in view coordinates.
      • getOrientation

        public double getOrientation()
        Specified by:
        getOrientation in interface Viewport
        Returns:
        The rotation angle in radians.
      • setOrientation

        public void setOrientation​(double orientation)
        Description copied from interface: Viewport
        Sets the orientation angle relative to the viewport bound's center point.
        Specified by:
        setOrientation in interface Viewport
        Parameters:
        orientation - the new orientation angle in radians
      • getOffsetX

        public double getOffsetX()
        Specified by:
        getOffsetX in interface Viewport
        Returns:
        The viewport's absolute X-offset in model coordinates.
      • getOffsetY

        public double getOffsetY()
        Specified by:
        getOffsetY in interface Viewport
        Returns:
        The viewport's absolute Y-offset in model coordinates.
      • setOffset

        public void setOffset​(double offsetX,
                              double offsetY)
        Description copied from interface: Viewport
        Sets the viewport's absolute offset in model coordinates.
        Specified by:
        setOffset in interface Viewport
        Parameters:
        offsetX - The X-offset in model coordinates.
        offsetY - The Y-offset in model coordinates.
      • moveViewDelta

        public void moveViewDelta​(double deltaX,
                                  double deltaY)
        Description copied from interface: Viewport
        Moves the model CS by translating it into the opposite direction of the given vector in view coordinates.
        Specified by:
        moveViewDelta in interface Viewport
        Parameters:
        deltaX - the X delta in view coordinates
        deltaY - the Y delta in view coordinates
      • getZoomFactor

        public double getZoomFactor()
        Description copied from interface: Viewport
        Gets the zoom factor. The zoom factor is equal to the number of model units per view unit.
        Specified by:
        getZoomFactor in interface Viewport
        Returns:
        The zoom factor.
      • setZoomFactor

        public void setZoomFactor​(double zoomFactor)
        Description copied from interface: Viewport
        Sets the zoom factor relative to the viewport bound's center point.
        Specified by:
        setZoomFactor in interface Viewport
        Parameters:
        zoomFactor - The new zoom factor, must be greater than zero.
        See Also:
        Viewport.getZoomFactor()
      • zoom

        public void zoom​(Rectangle2D modelBounds)
        Description copied from interface: Viewport
        Zooms to the given area given in model coordinates.
        Specified by:
        zoom in interface Viewport
        Parameters:
        modelBounds - the area in model coordinates
      • setZoomFactor

        public void setZoomFactor​(double zoomFactor,
                                  double modelCenterX,
                                  double modelCenterY)
        Description copied from interface: Viewport
        Zooms to the given point given in model coordinates.
        Specified by:
        setZoomFactor in interface Viewport
        Parameters:
        zoomFactor - The new zoom factor, must be greater than zero.
        modelCenterX - New X of the view's center point in model coordinates.
        modelCenterY - New Y of the view's center point in model coordinates.
      • addListener

        public void addListener​(ViewportListener listener)
        Description copied from interface: Viewport
        Adds a change listener to this viewport.
        Specified by:
        addListener in interface Viewport
        Parameters:
        listener - The listener.
      • removeListener

        public void removeListener​(ViewportListener listener)
        Description copied from interface: Viewport
        Removes a change listener from this viewport.
        Specified by:
        removeListener in interface Viewport
        Parameters:
        listener - The listener.
      • getListeners

        public ViewportListener[] getListeners()
        Description copied from interface: Viewport
        Gets all listeners added to this viewport.
        Specified by:
        getListeners in interface Viewport
        Returns:
        The listeners.
      • setTransform

        public void setTransform​(Viewport other)
        Description copied from interface: Viewport
        Modifies this viewport so that it matches the given one.
        Specified by:
        setTransform in interface Viewport
        Parameters:
        other - The view port to synchronize with.
      • fireViewportChanged

        protected void fireViewportChanged​(boolean orientationChanged)
      • clone

        public Viewport clone()
        Description copied from interface: Viewport
        Creates a clone of this viewport. The clone is a deep copy of this viewport but doesn't copy its listeners.
        Specified by:
        clone in interface Viewport
        Overrides:
        clone in class Object
        Returns:
        The clone.