public class ViewPortHandler
extends java.lang.Object
| Modifier and Type | Field and Description |
|---|---|
protected float |
mChartHeight |
protected float |
mChartWidth |
protected android.graphics.RectF |
mContentRect
this rectangle defines the area in which graph values can be drawn
|
protected android.graphics.Matrix |
mMatrixTouch
matrix used for touch events
|
| Constructor and Description |
|---|
ViewPortHandler()
Constructor - don't forget calling setChartDimens(...)
|
| Modifier and Type | Method and Description |
|---|---|
boolean |
canZoomInMoreX()
Returns true if the chart is not yet fully zoomed in on the x-axis
|
boolean |
canZoomOutMoreX()
Returns true if the chart is not yet fully zoomed out on the x-axis
|
void |
centerViewPort(float[] transformedPts,
android.view.View view)
Centers the viewport around the specified position (x-index and y-value)
in the chart.
|
float |
contentBottom() |
float |
contentHeight() |
float |
contentLeft() |
float |
contentRight() |
float |
contentTop() |
float |
contentWidth() |
android.graphics.Matrix |
fitScreen()
Resets all zooming and dragging and makes the chart fit exactly it's
bounds.
|
float |
getChartHeight() |
float |
getChartWidth() |
android.graphics.PointF |
getContentCenter() |
android.graphics.RectF |
getContentRect() |
android.graphics.Matrix |
getMatrixTouch()
Returns the charts-touch matrix used for translation and scale on touch.
|
float |
getScaleX()
returns the current x-scale factor
|
float |
getScaleY()
returns the current y-scale factor
|
float |
getTransX()
Returns the translation (drag / pan) distance on the x-axis
|
float |
getTransY()
Returns the translation (drag / pan) distance on the y-axis
|
boolean |
hasChartDimens() |
boolean |
hasNoDragOffset()
Returns true if both drag offsets (x and y) are zero or smaller.
|
boolean |
isFullyZoomedOut()
if the chart is fully zoomed out, return true
|
boolean |
isFullyZoomedOutX()
Returns true if the chart is fully zoomed out on it's x-axis
(horizontal).
|
boolean |
isFullyZoomedOutY()
Returns true if the chart is fully zoomed out on it's y-axis (vertical).
|
boolean |
isInBounds(float x,
float y) |
boolean |
isInBoundsBottom(float y) |
boolean |
isInBoundsLeft(float x) |
boolean |
isInBoundsRight(float x) |
boolean |
isInBoundsTop(float y) |
boolean |
isInBoundsX(float x)
BELOW METHODS FOR BOUNDS CHECK
|
boolean |
isInBoundsY(float y) |
void |
limitTransAndScale(android.graphics.Matrix matrix,
android.graphics.RectF content)
limits the maximum scale and X translation of the given matrix
|
float |
offsetBottom() |
float |
offsetLeft() |
float |
offsetRight() |
float |
offsetTop() |
android.graphics.Matrix |
refresh(android.graphics.Matrix newMatrix,
android.view.View chart,
boolean invalidate)
call this method to refresh the graph with a given matrix
|
void |
restrainViewPort(float offsetLeft,
float offsetTop,
float offsetRight,
float offsetBottom) |
void |
setChartDimens(float width,
float height)
Sets the width and height of the chart.
|
void |
setDragOffsetX(float offset)
Set an offset in dp that allows the user to drag the chart over it's
bounds on the x-axis.
|
void |
setDragOffsetY(float offset)
Set an offset in dp that allows the user to drag the chart over it's
bounds on the y-axis.
|
void |
setMaximumScaleX(float xScale)
Sets the maximum scale factor for the x-axis
|
void |
setMaximumScaleY(float yScale)
Sets the maximum scale factor for the y-axis
|
void |
setMinimumScaleX(float xScale)
Sets the minimum scale factor for the x-axis
|
void |
setMinimumScaleY(float yScale)
Sets the minimum scale factor for the y-axis
|
void |
setMinMaxScaleX(float minScaleX,
float maxScaleX)
Sets the minimum and maximum scale factors for the x-axis
|
android.graphics.Matrix |
zoom(float scaleX,
float scaleY,
float x,
float y)
Zooms in or out by the given scale factor.
|
android.graphics.Matrix |
zoomIn(float x,
float y)
Zooms in by 1.4f, x and y are the coordinates (in pixels) of the zoom
center.
|
android.graphics.Matrix |
zoomOut(float x,
float y)
Zooms out by 0.7f, x and y are the coordinates (in pixels) of the zoom
center.
|
protected final android.graphics.Matrix mMatrixTouch
protected android.graphics.RectF mContentRect
protected float mChartWidth
protected float mChartHeight
public ViewPortHandler()
public void setChartDimens(float width,
float height)
width - height - public boolean hasChartDimens()
public void restrainViewPort(float offsetLeft,
float offsetTop,
float offsetRight,
float offsetBottom)
public float offsetLeft()
public float offsetRight()
public float offsetTop()
public float offsetBottom()
public float contentTop()
public float contentLeft()
public float contentRight()
public float contentBottom()
public float contentWidth()
public float contentHeight()
public android.graphics.RectF getContentRect()
public android.graphics.PointF getContentCenter()
public float getChartHeight()
public float getChartWidth()
public android.graphics.Matrix zoomIn(float x,
float y)
x - y - public android.graphics.Matrix zoomOut(float x,
float y)
public android.graphics.Matrix zoom(float scaleX,
float scaleY,
float x,
float y)
scaleX - if < 1f --> zoom out, if > 1f --> zoom inscaleY - if < 1f --> zoom out, if > 1f --> zoom inx - y - public android.graphics.Matrix fitScreen()
public void centerViewPort(float[] transformedPts,
android.view.View view)
transformedPts - the position to center view viewport toview - public android.graphics.Matrix refresh(android.graphics.Matrix newMatrix,
android.view.View chart,
boolean invalidate)
newMatrix - public void limitTransAndScale(android.graphics.Matrix matrix,
android.graphics.RectF content)
matrix - public void setMinimumScaleX(float xScale)
xScale - public void setMaximumScaleX(float xScale)
xScale - public void setMinMaxScaleX(float minScaleX,
float maxScaleX)
minScaleX - maxScaleX - public void setMinimumScaleY(float yScale)
yScale - public void setMaximumScaleY(float yScale)
yScale - public android.graphics.Matrix getMatrixTouch()
public boolean isInBoundsX(float x)
public boolean isInBoundsY(float y)
public boolean isInBounds(float x,
float y)
public boolean isInBoundsLeft(float x)
public boolean isInBoundsRight(float x)
public boolean isInBoundsTop(float y)
public boolean isInBoundsBottom(float y)
public float getScaleX()
public float getScaleY()
public float getTransX()
public float getTransY()
public boolean isFullyZoomedOut()
public boolean isFullyZoomedOutY()
public boolean isFullyZoomedOutX()
public void setDragOffsetX(float offset)
offset - public void setDragOffsetY(float offset)
offset - public boolean hasNoDragOffset()
public boolean canZoomOutMoreX()
public boolean canZoomInMoreX()