org.gicentre.utils.move

## Class ZoomPanState

- java.lang.Object
- - org.gicentre.utils.move.ZoomPanState

- All Implemented Interfaces:
    java.lang.Cloneable

      public class ZoomPanState
      extends java.lang.Object
      implements java.lang.Cloneable

  Class that stores the state of a ZoomPan instance and transform coordinates accordingly. Modifiable only from classes within the package. Only intended to be created and modified by ZoomPan. Used by ZoomPan internally to store its state.
  Version:
    3.4, 5th February, 2016.
  Author:
    Jo Wood and Aidan Slingsby, giCentre, City University London.

- - ### Method Summary

    All Methods Instance Methods Concrete Methods
    Modifier and Type | Method and Description
    --- | ---
    `java.lang.Object` | `clone()` Creates a clone of this zoomPan state.
    `processing.core.PVector` | `getCoordToDisp(double x, double y)` Transforms the given point from coordinate to display space.
    `processing.core.PVector` | `getCoordToDisp(processing.core.PVector p)` Transforms the given point from coordinate to display space.
    `processing.core.PVector` | `getDispToCoord(processing.core.PVector p)` Transforms the given point from display to coordinate space.
    `processing.core.PVector` | `getPanOffset()` Reports the current pan offset.
    `double` | `getZoomScale()` Reports the current zoom scale in X.
    `double` | `getZoomScaleX()` Reports the current zoom scale in X.
    `double` | `getZoomScaleY()` Reports the current zoom scale in Y.
    `void` | `transform()` Performs the zooming/panning transformation.
    `void` | `transform(processing.core.PGraphics offScreenBuffer)` Performs the zooming/panning transformation in the given graphics context.

    - ### Methods inherited from class java.lang.Object

      `equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

- - ### Method Detail

    - #### getDispToCoord

          public processing.core.PVector getDispToCoord(processing.core.PVector p)

      Transforms the given point from display to coordinate space. Display space is that which has been subjected to zooming and panning. Coordinate space is the original space into which objects have been placed before zooming and panning. For most drawing operations you should not need to use this method. It is available for those operations that do not draw directly, but need to know the transformation between coordinate and screen space.
      Parameters:
        `p` - 2D point in zoomed display space.
      Returns:
        Location of point in original coordinate space.

    - #### getCoordToDisp

          public processing.core.PVector getCoordToDisp(processing.core.PVector p)

      Transforms the given point from coordinate to display space. Display space is that which has been subjected to zooming and panning. Coordinate space is the original space into which objects have been placed before zooming and panning. For most drawing operations you should not need to use this method. It is available for those operations that do not draw directly, but need to know the transformation between coordinate and screen space.
      Parameters:
        `p` - 2D point in original coordinate space.
      Returns:
        Location of point in zoomed display space.

    - #### getCoordToDisp

          public processing.core.PVector getCoordToDisp(double x,
                                                        double y)

      Transforms the given point from coordinate to display space. Display space is that which has been subjected to zooming and panning. Coordinate space is the original space into which objects have been placed before zooming and panning. For most drawing operations you should not need to use this method. It is available for those operations that do not draw directly, but need to know the transformation between coordinate and screen space.
      Parameters:
        `x` - x location of the original coordinate space.
        `y` - y location of the original coordinate space.
      Returns:
        Location of point in zoomed display space.

    - #### transform

          public void transform()

      Performs the zooming/panning transformation. This method should be called in the draw() method before any drawing that is to be zoomed or panned.

    - #### transform

          public void transform(processing.core.PGraphics offScreenBuffer)

      Performs the zooming/panning transformation in the given graphics context. This version of transform() can be used for transforming off-screen buffers that were not provided to the constructor. Can be useful when a sketch temporarily creates an off-screen buffer that needs to be zoomed and panned in the same way as the main PApplet.
      Parameters:
        `offScreenBuffer` - Graphics context in which to apply the zoom / pan transformation.

    - #### getZoomScale

          public double getZoomScale()

      Reports the current zoom scale in X. Can be used for drawing objects that maintain their size when zooming.
      Returns:
        Current zoom scale.

    - #### getZoomScaleX

          public double getZoomScaleX()

      Reports the current zoom scale in X. Can be used for drawing objects that maintain their size when zooming.
      Returns:
        Current zoom scale.

    - #### getZoomScaleY

          public double getZoomScaleY()

      Reports the current zoom scale in Y. Can be used for drawing objects that maintain their size when zooming.
      Returns:
        Current zoom scale.

    - #### getPanOffset

          public processing.core.PVector getPanOffset()

      Reports the current pan offset. Useful when wishing to use an interpolated panning between this current value and some new pan offset.
      Returns:
        Current pan offset. Negative coordinates indicate an offset to the left or upwards, positive values to the right or downward.

    - #### clone

          public java.lang.Object clone()

      Creates a clone of this zoomPan state.
      Overrides:
        `clone` in class `java.lang.Object`
      Returns:
        Clone of this zoomPan state.