public class ZoomPan30
extends java.lang.Object
ZoomPan
class if it detects Processing 3.x core libraries. Despite this, the class has to remain
public so that it can be registered by Processing's event handling model.Modifier and Type | Method and Description |
---|---|
void |
addZoomPanListener(ZoomPanListener zoomPanListener)
Adds a listener to be informed when some zooming or panning has finished.
|
void |
allowPanButton(boolean allowPan)
Determines whether or not panning is permitted via a button press.
|
void |
allowZoomButton(boolean allowZoom)
Determines whether or not zooming via a button press is permitted.
|
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.
|
processing.core.PVector |
getPanOffset()
Reports the current pan offset.
|
ZoomPan.ZoomPanDirection |
getZoomPanDirection()
Reports the zoom/zan behaviour type.
|
ZoomPanState |
getZoomPanState()
Provides a copy (cloned snapshot) of the current ZoomPanState.
|
double |
getZoomScale()
Reports the current zoom scale.
|
double |
getZoomScaleX()
Reports the current zoom scale in X.
|
double |
getZoomScaleY()
Reports the current zoom scale in Y.
|
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 (i.e.
|
void |
mouseEvent(processing.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 |
setMaxZoomScale(double maxZoomScale)
Sets the maximum permitted zoom scale (i.e.
|
void |
setMaxZoomScaleX(double maxZoomScaleX)
Sets the maximum permitted zoom scale in X(i.e.
|
void |
setMaxZoomScaleY(double maxZoomScaleY)
Sets the maximum permitted zoom scale in Y(i.e.
|
void |
setMinZoomScale(double minZoomScale)
Sets the minimum permitted zoom scale (i.e.
|
void |
setMinZoomScaleX(double minZoomScaleX)
Sets the minimum permitted zoom scale in X (i.e.
|
void |
setMinZoomScaleY(double minZoomScaleY)
Sets the minimum permitted zoom scale in Y(i.e.
|
void |
setMouseMask(int mouseMask)
Sets the key that must be pressed before mouse actions are active.
|
void |
setPanOffset(float panX,
float panY)
Sets a new pan offset.
|
void |
setZoomMouseButton(int zoomMouseButton)
Sets mouse button for zooming.
|
void |
setZoomPanDirection(ZoomPan.ZoomPanDirection zoomPanDirection)
Sets the zooming/panning direction
|
void |
setZoomScale(double zoomScale)
Sets a new zoom scale.
|
void |
setZoomScale(double zoomScaleX,
double zoomScaleY)
Sets a new zoom scale for X and Y.
|
void |
setZoomScaleX(double zoomScaleX)
Sets a new zoom scale in X.
|
void |
setZoomScaleY(double zoomScaleY)
Sets a new zoom scale.
|
void |
text(java.lang.String textToDisplay,
float xPos,
float yPos)
Deprecated.
Should no longer be required as Processing bug fixed in 3.0.
|
void |
transform()
Performs the zooming/panning transformation.
|
void |
transform(processing.core.PGraphics offScreenBuffer)
Performs the zooming/panning transformation in the given graphics context.
|
public void transform()
public void transform(processing.core.PGraphics offScreenBuffer)
offScreenBuffer
- Graphics context in which to apply the zoom/pan transformation.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 double getZoomScaleX()
public double getZoomScaleY()
public void setZoomScale(double zoomScale)
zoomScale
- New zoom scale. A value of 1 indicates no zooming, values above
0 and below 1 will shrink the display; values above 1 will enlarge the
display. Values less than or equal to 0 will be ignored.public void setZoomScale(double zoomScaleX, double zoomScaleY)
zoomScaleX
- New horizontal zoom scale. A value of 1 indicates no zooming, values above
0 and below 1 will shrink the display; values above 1 will enlarge the
display. Values less than or equal to 0 will be ignored.zoomScaleY
- New vertical zoom scale. A value of 1 indicates no zooming, values above
0 and below 1 will shrink the display; values above 1 will enlarge the
display. Values less than or equal to 0 will be ignored.public void setZoomScaleX(double zoomScaleX)
zoomScaleX
- New horizontal zoom scale. A value of 1 indicates no zooming, values above
0 and below 1 will shrink the display; values above 1 will enlarge the
display. Values less than or equal to 0 will be ignored.public void setZoomScaleY(double zoomScaleY)
zoomScaleY
- New vertical zoom scale. A value of 1 indicates no zooming, values above
0 and below 1 will shrink the display; values above 1 will enlarge the
display. Values less than or equal to 0 will be ignored.public void setZoomPanDirection(ZoomPan.ZoomPanDirection zoomPanDirection)
zoomPanDirection
- Direction of available zoom-pan transformations.public ZoomPan.ZoomPanDirection getZoomPanDirection()
public processing.core.PVector getPanOffset()
public void setPanOffset(float panX, float panY)
panX
- X coordinate of new pan offset. A value of 0 indicates no translation
of the display on the horizontal axis; a negative value indicates a
translation to the left; a positive value indicates translation to the right.panY
- Y coordinate of new pan offset. A value of 0 indicates no translation
of the display on the vertical axis; a negative value indicates a translation
upwards; a positive value indicates translation downwards.public boolean isZooming()
public boolean isPanning()
public boolean isMouseCaptured()
public void allowZoomButton(boolean allowZoom)
allowZoom
- Zooming permitted via mouse button press if true.public void allowPanButton(boolean allowPan)
allowPan
- Panning permitted via mouse button press if true.public void mouseEvent(processing.event.MouseEvent e)
e
- Mouse event.public void setMinZoomScale(double minZoomScale)
minZoomScale
- Minimum permitted zoom scale.public void setMinZoomScaleX(double minZoomScaleX)
minZoomScaleX
- Minimum horizontal zoom scale.public void setMinZoomScaleY(double minZoomScaleY)
minZoomScaleY
- Minimum vertical zoom scale.public void setMaxZoomScale(double maxZoomScale)
maxZoomScale
- Maximum permitted zoom scale.public void setMaxZoomScaleX(double maxZoomScaleX)
maxZoomScaleX
- Maximum horizontal zoom scale.public void setMaxZoomScaleY(double maxZoomScaleY)
maxZoomScaleY
- Maximum vertical zoom scale.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@Deprecated public void text(java.lang.String textToDisplay, float xPos, float yPos)
text()
method for faster and more accurate placement of
characters in Java2D mode when a zoomed font is to be displayed. This method is not necessary when
text is not subject to scaling via zooming, nor is is necessary in P2D
, P3D
or OpenGL
modes.textToDisplay
- Text to be displayed.xPos
- x-position of the the text to display in original unzoomed screen coordinates.yPos
- y-position of the the text to display in original unzoomed screen coordinates.public ZoomPanState getZoomPanState()