org.gicentre.utils.move
Class ZoomPanState

java.lang.Object
  extended by 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.3, 1st August, 2011.
Author:
Jo Wood and Aidan Slingsby, giCentre, City University London.

Method Summary
 java.lang.Object clone()
          Creates a clone of this zoomPan state.
 processing.core.PVector getCoordToDisp(double x, double y)
           
 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.
 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)

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.


getZoomScale

public double getZoomScale()
Reports the current zoom scale. 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.


giCentre Utilities V.3.3, API documentation generated 6th April, 2013