public class PanZoom extends Object implements android.view.View.OnTouchListener
XYPlot
.
By default boundaries there are no boundaries imposed on scrolling and zooming. You can provide these boundaries
on your XYPlot
using XYPlot.getOuterLimits()
.
TODO: zoom using dynamic center point
TODO: stretch both modeModifier and Type | Class and Description |
---|---|
protected static class |
PanZoom.DragState |
static class |
PanZoom.Pan |
static class |
PanZoom.Zoom |
Modifier and Type | Field and Description |
---|---|
protected android.graphics.RectF |
fingersRect |
protected static int |
FIRST_FINGER |
protected static float |
MIN_DIST_2_FING |
protected static int |
SECOND_FINGER |
Modifier | Constructor and Description |
---|---|
protected |
PanZoom(XYPlot plot,
PanZoom.Pan pan,
PanZoom.Zoom zoom) |
Modifier and Type | Method and Description |
---|---|
static PanZoom |
attach(XYPlot plot)
Convenience method for enabling pan/zoom behavior on an instance of
XYPlot , using
a default behavior of PanZoom.Pan.BOTH and PanZoom.Zoom.SCALE . |
static PanZoom |
attach(XYPlot plot,
PanZoom.Pan pan,
PanZoom.Zoom zoom) |
protected void |
calculatePan(android.graphics.PointF oldFirstFinger,
Region bounds,
boolean horizontal) |
protected void |
calculateZoom(android.graphics.RectF newRect,
float scale,
boolean isHorizontal) |
protected android.graphics.RectF |
fingerDistance(float firstFingerX,
float firstFingerY,
float secondFingerX,
float secondFingerY)
Calculates the distance between two finger motion events.
|
protected android.graphics.RectF |
fingerDistance(android.view.MotionEvent evt)
Calculates the distance between two finger motion events.
|
android.view.View.OnTouchListener |
getDelegate() |
protected android.graphics.RectF |
getFingersRect() |
PanZoom.Pan |
getPan() |
PanZoom.Zoom |
getZoom() |
boolean |
isEnabled() |
protected boolean |
isValidScale(float scale) |
boolean |
onTouch(android.view.View view,
android.view.MotionEvent event) |
protected void |
pan(android.view.MotionEvent motionEvent) |
void |
reset() |
void |
setDelegate(android.view.View.OnTouchListener delegate)
Set a delegate to receive onTouch calls before this class does.
|
void |
setEnabled(boolean enabled) |
protected void |
setFingersRect(android.graphics.RectF fingersRect) |
void |
setPan(PanZoom.Pan pan) |
void |
setZoom(PanZoom.Zoom zoom) |
protected void |
zoom(android.view.MotionEvent motionEvent) |
protected static final float MIN_DIST_2_FING
protected static final int FIRST_FINGER
protected static final int SECOND_FINGER
protected android.graphics.RectF fingersRect
protected PanZoom(XYPlot plot, PanZoom.Pan pan, PanZoom.Zoom zoom)
public static PanZoom attach(XYPlot plot)
XYPlot
, using
a default behavior of PanZoom.Pan.BOTH
and PanZoom.Zoom.SCALE
.
Use attach(XYPlot, Pan, Zoom)
for finer grain control of this behavior.plot
- public static PanZoom attach(XYPlot plot, PanZoom.Pan pan, PanZoom.Zoom zoom)
public boolean isEnabled()
public void setEnabled(boolean enabled)
public boolean onTouch(android.view.View view, android.view.MotionEvent event)
onTouch
in interface android.view.View.OnTouchListener
protected android.graphics.RectF fingerDistance(float firstFingerX, float firstFingerY, float secondFingerX, float secondFingerY)
firstFingerX
- firstFingerY
- secondFingerX
- secondFingerY
- protected android.graphics.RectF fingerDistance(android.view.MotionEvent evt)
evt
- protected void pan(android.view.MotionEvent motionEvent)
protected void calculatePan(android.graphics.PointF oldFirstFinger, Region bounds, boolean horizontal)
protected boolean isValidScale(float scale)
protected void zoom(android.view.MotionEvent motionEvent)
protected void calculateZoom(android.graphics.RectF newRect, float scale, boolean isHorizontal)
newRect
- RectF into which zoom calculation results should be placed.scale
- isHorizontal
- public PanZoom.Pan getPan()
public void setPan(PanZoom.Pan pan)
public PanZoom.Zoom getZoom()
public void setZoom(PanZoom.Zoom zoom)
public android.view.View.OnTouchListener getDelegate()
public void setDelegate(android.view.View.OnTouchListener delegate)
View
.delegate
- public void reset()
protected android.graphics.RectF getFingersRect()
protected void setFingersRect(android.graphics.RectF fingersRect)