|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectorg.gicentre.utils.move.ZoomPan
public class ZoomPan
Class to allow interactive zooming and panning of the Processing display. To use, simply create a ZoomPan object in setup(), then call its transform() method at the start of draw(). Panning is controlled with the right mouse button dragging. Zooming is, by default, controlled with a left mouse drag up to zoom in, left-drag down to zoom out. Can also zoom in and out with the mouse wheel if present. Mouse actions can be filtered so that they only work if a modifier key is pressed (ALT, SHIFT or CONTROL) by calling the setMouseMask() method.
Constructor Summary | |
---|---|
ZoomPan(processing.core.PApplet aContext)
Initialises the zooming and panning transformations for the given applet context. |
|
ZoomPan(processing.core.PApplet aContext,
processing.core.PGraphics graphics)
Initialises the zooming and panning transformations for the given applet and graphics contexts. |
Method Summary | |
---|---|
void |
addZoomPanListener(ZoomPanListener zoomPanListener)
Adds a listener to be informed when some zooming or panning has finished. |
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 |
getMouseCoord()
Reports the current mouse position in coordinate space. |
double |
getZoomScale()
Reports the current zoom scale. |
boolean |
isMouseCaptured()
Reports whether a mouse event has been captured by the zoomer. |
boolean |
isPanning()
Reports whether display is currently being panned (ie mouse is being dragged with pan key/button pressed). |
boolean |
isZooming()
Reports whether display is currently being zoomed (ie mouse is being dragged with zoom key/button pressed). |
void |
mouseEvent(java.awt.event.MouseEvent e)
Updates zoom and pan transformation according to mouse activity. |
boolean |
removeZoomPanListener(ZoomPanListener zoomPanListener)
Removes the given listener from those to be informed when zooming/panning has finished. |
void |
reset()
Resets the display to unzoomed and unpanned position. |
void |
setMouseMask(int mouseMask)
Sets the key that must be pressed before mouse actions are active. |
void |
setZoomMouseButton(int zoomMouseButton)
Sets mouse buttons for zooming and implies that the other mouse button will be for panning. |
void |
transform()
Performs the zooming/panning transformation. |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Constructor Detail |
---|
public ZoomPan(processing.core.PApplet aContext)
aContext
- Applet context in which zooming and panning are to take place.public ZoomPan(processing.core.PApplet aContext, processing.core.PGraphics graphics)
aContext
- Applet context in which zooming and panning are to take place.graphics
- Graphics context in which to draw.Method Detail |
---|
public void transform()
public void reset()
public void addZoomPanListener(ZoomPanListener zoomPanListener)
zoomPanListener
- Listener to be informed when some zooming or panning has finished.public boolean removeZoomPanListener(ZoomPanListener zoomPanListener)
zoomPanListener
- Listener to remove.
public void setMouseMask(int mouseMask)
mouseMask
- Keyboard modifier required to activate mouse actions. Valid values are
CONTROL
, SHIFT
, ALT
, 0
and -1
.public processing.core.PVector getMouseCoord()
mouseX
and mouseY
if the current display
has been zoomed or panned.
public double getZoomScale()
public boolean isZooming()
public boolean isPanning()
public boolean isMouseCaptured()
public void mouseEvent(java.awt.event.MouseEvent e)
e
- Mouse event.public processing.core.PVector getDispToCoord(processing.core.PVector p)
p
- 2D point in zoomed display space.
public processing.core.PVector getCoordToDisp(processing.core.PVector p)
p
- 2D point in original coordinate space.
public void setZoomMouseButton(int zoomMouseButton)
zoomMouseButton
- Zoom mouse button (must be either PConstants.LEFT or PConstants.RIGHT)
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |