public class ViewPortHandler
extends java.lang.Object
| Modifier and Type | Field and Description |
|---|---|
protected float[] |
matrixBuffer
buffer for storing the 9 matrix values of a 3x3 matrix
|
protected android.graphics.Matrix |
mCenterViewPortMatrixBuffer |
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
|
protected float[] |
valsBufferForFitScreen |
| 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 |
canZoomInMoreY()
Returns true if the chart is not yet fully zoomed in on the y-axis
|
boolean |
canZoomOutMoreX()
Returns true if the chart is not yet fully zoomed out on the x-axis
|
boolean |
canZoomOutMoreY()
Returns true if the chart is not yet fully zoomed out on the y-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.
|
void |
fitScreen(android.graphics.Matrix outputMatrix)
Resets all zooming and dragging and makes the chart fit exactly it's
bounds.
|
float |
getChartHeight() |
float |
getChartWidth() |
MPPointF |
getContentCenter() |
android.graphics.RectF |
getContentRect() |
android.graphics.Matrix |
getMatrixTouch()
Returns the charts-touch matrix used for translation and scale on touch.
|
float |
getMaxScaleX() |
float |
getMaxScaleY() |
float |
getMinScaleX() |
float |
getMinScaleY() |
float |
getScaleX()
returns the current x-scale factor
|
float |
getScaleY()
returns the current y-scale factor
|
float |
getSmallestContentExtension()
Returns the smallest extension of the content rect (width or height).
|
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 |
resetZoom(android.graphics.Matrix outputMatrix)
Zooms out to original size.
|
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
|
void |
setMinMaxScaleY(float minScaleY,
float maxScaleY) |
android.graphics.Matrix |
setZoom(float scaleX,
float scaleY)
Sets the scale factor to the specified values.
|
android.graphics.Matrix |
setZoom(float scaleX,
float scaleY,
float x,
float y)
Sets the scale factor to the specified values.
|
void |
setZoom(float scaleX,
float scaleY,
android.graphics.Matrix outputMatrix) |
android.graphics.Matrix |
translate(float[] transformedPts)
Post-translates to the specified points.
|
void |
translate(float[] transformedPts,
android.graphics.Matrix outputMatrix)
Post-translates to the specified points.
|
android.graphics.Matrix |
zoom(float scaleX,
float scaleY)
Post-scales by the specified scale factors.
|
android.graphics.Matrix |
zoom(float scaleX,
float scaleY,
float x,
float y)
Post-scales by the specified scale factors.
|
void |
zoom(float scaleX,
float scaleY,
float x,
float y,
android.graphics.Matrix outputMatrix) |
void |
zoom(float scaleX,
float scaleY,
android.graphics.Matrix outputMatrix) |
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.
|
void |
zoomIn(float x,
float y,
android.graphics.Matrix outputMatrix) |
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.
|
void |
zoomOut(float x,
float y,
android.graphics.Matrix outputMatrix) |
protected final android.graphics.Matrix mMatrixTouch
protected android.graphics.RectF mContentRect
protected float mChartWidth
protected float mChartHeight
protected float[] valsBufferForFitScreen
protected android.graphics.Matrix mCenterViewPortMatrixBuffer
protected final float[] matrixBuffer
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 MPPointF getContentCenter()
public float getChartHeight()
public float getChartWidth()
public float getSmallestContentExtension()
public android.graphics.Matrix zoomIn(float x,
float y)
x - y - public void zoomIn(float x,
float y,
android.graphics.Matrix outputMatrix)
public android.graphics.Matrix zoomOut(float x,
float y)
public void zoomOut(float x,
float y,
android.graphics.Matrix outputMatrix)
public void resetZoom(android.graphics.Matrix outputMatrix)
outputMatrix - public android.graphics.Matrix zoom(float scaleX,
float scaleY)
scaleX - scaleY - public void zoom(float scaleX,
float scaleY,
android.graphics.Matrix outputMatrix)
public android.graphics.Matrix zoom(float scaleX,
float scaleY,
float x,
float y)
scaleX - scaleY - x - y - public void zoom(float scaleX,
float scaleY,
float x,
float y,
android.graphics.Matrix outputMatrix)
public android.graphics.Matrix setZoom(float scaleX,
float scaleY)
scaleX - scaleY - public void setZoom(float scaleX,
float scaleY,
android.graphics.Matrix outputMatrix)
public android.graphics.Matrix setZoom(float scaleX,
float scaleY,
float x,
float y)
scaleX - scaleY - x - y - public android.graphics.Matrix fitScreen()
public void fitScreen(android.graphics.Matrix outputMatrix)
public android.graphics.Matrix translate(float[] transformedPts)
transformedPts - public void translate(float[] transformedPts,
android.graphics.Matrix outputMatrix)
transformedPts - 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 void setMinMaxScaleY(float minScaleY,
float maxScaleY)
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 getMinScaleX()
public float getMaxScaleX()
public float getMinScaleY()
public float getMaxScaleY()
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()
public boolean canZoomOutMoreY()
public boolean canZoomInMoreY()