-
public class ViewPortHandlerClass that contains information about the charts current viewport settings, including offsets, scale & translation levels, ... Constructor - don't forget calling setChartDimens(...)
-
-
Field Summary
Fields Modifier and Type Field Description private final MatrixmatrixTouchprivate RectFcontentRectprivate FloatchartWidthprivate FloatchartHeightprivate FloatminScaleYprivate FloatmaxScaleYprivate FloatminScaleXprivate FloatmaxScaleXprivate FloatscaleXprivate FloatscaleYprivate FloattransXprivate FloattransYprivate final MPPointFcontentCenterprivate final FloatsmallestContentExtensionprivate final BooleanisFullyZoomedOutprivate final BooleanisFullyZoomedOutYprivate final BooleanisFullyZoomedOutX
-
Constructor Summary
Constructors Constructor Description ViewPortHandler()
-
Method Summary
Modifier and Type Method Description final MatrixgetMatrixTouch()Returns the charts-touch matrix used for translation and scale on touch. final RectFgetContentRect()this rectangle defines the area in which graph values can be drawn final UnitsetContentRect(RectF contentRect)final FloatgetChartWidth()final UnitsetChartWidth(Float chartWidth)final FloatgetChartHeight()final UnitsetChartHeight(Float chartHeight)final FloatgetMinScaleY()minimum scale value on the y-axis final UnitsetMinScaleY(Float minScaleY)final FloatgetMaxScaleY()maximum scale value on the y-axis final UnitsetMaxScaleY(Float maxScaleY)final FloatgetMinScaleX()minimum scale value on the x-axis final UnitsetMinScaleX(Float minScaleX)final FloatgetMaxScaleX()maximum scale value on the x-axis final UnitsetMaxScaleX(Float maxScaleX)final FloatgetScaleX()contains the current scale factor of the x-axis final UnitsetScaleX(Float scaleX)final FloatgetScaleY()returns the current y-scale factor final UnitsetScaleY(Float scaleY)final FloatgetTransX()Returns the translation (drag / pan) distance on the x-axis final UnitsetTransX(Float transX)final FloatgetTransY()Returns the translation (drag / pan) distance on the y-axis final UnitsetTransY(Float transY)final MPPointFgetContentCenter()final FloatgetSmallestContentExtension()final BooleangetIsFullyZoomedOut()final BooleangetIsFullyZoomedOutY()final BooleangetIsFullyZoomedOutX()final UnitsetChartDimens(Float width, Float height)Sets the width and height of the chart. final BooleanhasChartDimens()final UnitrestrainViewPort(Float offsetLeft, Float offsetTop, Float offsetRight, Float offsetBottom)final FloatoffsetLeft()final FloatoffsetRight()final FloatoffsetTop()final FloatoffsetBottom()final FloatcontentTop()final FloatcontentLeft()final FloatcontentRight()final FloatcontentBottom()final FloatcontentWidth()final FloatcontentHeight()final MatrixzoomIn(Float x, Float y)Zooms in by 1.4f, x and y are the coordinates (in pixels) of the zoom center. final UnitzoomIn(Float x, Float y, Matrix outputMatrix)final MatrixzoomOut(Float x, Float y)Zooms out by 0.7f, x and y are the coordinates (in pixels) of the zoom center. final UnitzoomOut(Float x, Float y, Matrix outputMatrix)final UnitresetZoom(Matrix outputMatrix)Zooms out to original size. final Matrixzoom(Float scaleX, Float scaleY)Post-scales by the specified scale factors. final Unitzoom(Float scaleX, Float scaleY, Matrix outputMatrix)final Matrixzoom(Float scaleX, Float scaleY, Float x, Float y)Post-scales by the specified scale factors. final Unitzoom(Float scaleX, Float scaleY, Float x, Float y, Matrix outputMatrix)final MatrixsetZoom(Float scaleX, Float scaleY)Sets the scale factor to the specified values. final UnitsetZoom(Float scaleX, Float scaleY, Matrix outputMatrix)final MatrixsetZoom(Float scaleX, Float scaleY, Float x, Float y)Sets the scale factor to the specified values. final MatrixfitScreen()Resets all zooming and dragging and makes the chart fit exactly it's bounds. final UnitfitScreen(Matrix outputMatrix)Resets all zooming and dragging and makes the chart fit exactly it's bounds. final Matrixtranslate(FloatArray transformedPts)Post-translates to the specified points. final Unittranslate(FloatArray transformedPts, Matrix outputMatrix)Post-translates to the specified points. final UnitcenterViewPort(FloatArray transformedPts, View view)Centers the viewport around the specified position (x-index and y-value) in the chart. final Matrixrefresh(Matrix newMatrix, View chart, Boolean invalidate)call this method to refresh the graph with a given matrix final UnitlimitTransAndScale(Matrix matrix, RectF content)limits the maximum scale and X translation of the given matrix final UnitsetMinimumScaleX(Float xScale)Sets the minimum scale factor for the x-axis final UnitsetMaximumScaleX(Float xScale)Sets the maximum scale factor for the x-axis final UnitsetMinMaxScaleX(Float minScaleX, Float maxScaleX)Sets the minimum and maximum scale factors for the x-axis final UnitsetMinimumScaleY(Float yScale)Sets the minimum scale factor for the y-axis final UnitsetMaximumScaleY(Float yScale)Sets the maximum scale factor for the y-axis final UnitsetMinMaxScaleY(Float minScaleY, Float maxScaleY)final BooleanisInBoundsX(Float x)BELOW METHODS FOR BOUNDS CHECK final BooleanisInBoundsY(Float y)final BooleanisInBounds(Float x, Float y)final BooleanisInBoundsLeft(Float x)final BooleanisInBoundsRight(Float x)final BooleanisInBoundsTop(Float y)final BooleanisInBoundsBottom(Float y)final UnitsetDragOffsetX(Float offset)Set an offset in dp that allows the user to drag the chart over it's bounds on the x-axis. final UnitsetDragOffsetY(Float offset)Set an offset in dp that allows the user to drag the chart over it's bounds on the y-axis. final BooleanhasNoDragOffset()Returns true if both drag offsets (x and y) are zero or smaller. final BooleancanZoomOutMoreX()Returns true if the chart is not yet fully zoomed out on the x-axis final BooleancanZoomInMoreX()Returns true if the chart is not yet fully zoomed in on the x-axis final BooleancanZoomOutMoreY()Returns true if the chart is not yet fully zoomed out on the y-axis final BooleancanZoomInMoreY()Returns true if the chart is not yet fully zoomed in on the y-axis -
-
Method Detail
-
getMatrixTouch
final Matrix getMatrixTouch()
Returns the charts-touch matrix used for translation and scale on touch.
-
getContentRect
final RectF getContentRect()
this rectangle defines the area in which graph values can be drawn
-
setContentRect
final Unit setContentRect(RectF contentRect)
-
getChartWidth
final Float getChartWidth()
-
setChartWidth
final Unit setChartWidth(Float chartWidth)
-
getChartHeight
final Float getChartHeight()
-
setChartHeight
final Unit setChartHeight(Float chartHeight)
-
getMinScaleY
final Float getMinScaleY()
minimum scale value on the y-axis
-
setMinScaleY
final Unit setMinScaleY(Float minScaleY)
-
getMaxScaleY
final Float getMaxScaleY()
maximum scale value on the y-axis
-
setMaxScaleY
final Unit setMaxScaleY(Float maxScaleY)
-
getMinScaleX
final Float getMinScaleX()
minimum scale value on the x-axis
-
setMinScaleX
final Unit setMinScaleX(Float minScaleX)
-
getMaxScaleX
final Float getMaxScaleX()
maximum scale value on the x-axis
-
setMaxScaleX
final Unit setMaxScaleX(Float maxScaleX)
-
getContentCenter
final MPPointF getContentCenter()
-
getSmallestContentExtension
final Float getSmallestContentExtension()
-
getIsFullyZoomedOut
final Boolean getIsFullyZoomedOut()
-
getIsFullyZoomedOutY
final Boolean getIsFullyZoomedOutY()
-
getIsFullyZoomedOutX
final Boolean getIsFullyZoomedOutX()
-
setChartDimens
final Unit setChartDimens(Float width, Float height)
Sets the width and height of the chart.
-
hasChartDimens
final Boolean hasChartDimens()
-
restrainViewPort
final Unit restrainViewPort(Float offsetLeft, Float offsetTop, Float offsetRight, Float offsetBottom)
-
offsetLeft
final Float offsetLeft()
-
offsetRight
final Float offsetRight()
-
offsetBottom
final Float offsetBottom()
-
contentTop
final Float contentTop()
-
contentLeft
final Float contentLeft()
-
contentRight
final Float contentRight()
-
contentBottom
final Float contentBottom()
-
contentWidth
final Float contentWidth()
-
contentHeight
final Float contentHeight()
-
zoomIn
final Matrix zoomIn(Float x, Float y)
Zooms in by 1.4f, x and y are the coordinates (in pixels) of the zoom center.
-
zoomOut
final Matrix zoomOut(Float x, Float y)
Zooms out by 0.7f, x and y are the coordinates (in pixels) of the zoom center.
-
zoom
final Matrix zoom(Float scaleX, Float scaleY, Float x, Float y)
Post-scales by the specified scale factors. x and y is pivot.
-
setZoom
final Matrix setZoom(Float scaleX, Float scaleY)
Sets the scale factor to the specified values.
-
setZoom
final Matrix setZoom(Float scaleX, Float scaleY, Float x, Float y)
Sets the scale factor to the specified values. x and y is pivot.
-
fitScreen
final Matrix fitScreen()
Resets all zooming and dragging and makes the chart fit exactly it's bounds.
-
fitScreen
final Unit fitScreen(Matrix outputMatrix)
Resets all zooming and dragging and makes the chart fit exactly it's bounds. Output Matrix is available for those who wish to cache the object.
-
translate
final Matrix translate(FloatArray transformedPts)
Post-translates to the specified points. Less Performant.
-
translate
final Unit translate(FloatArray transformedPts, Matrix outputMatrix)
Post-translates to the specified points. Output matrix allows for caching objects.
-
centerViewPort
final Unit centerViewPort(FloatArray transformedPts, View view)
Centers the viewport around the specified position (x-index and y-value) in the chart. Centering the viewport outside the bounds of the chart is not possible. Makes most sense in combination with the setScaleMinima(...) method.
- Parameters:
transformedPts- the position to center view viewport to
-
refresh
final Matrix refresh(Matrix newMatrix, View chart, Boolean invalidate)
call this method to refresh the graph with a given matrix
-
limitTransAndScale
final Unit limitTransAndScale(Matrix matrix, RectF content)
limits the maximum scale and X translation of the given matrix
-
setMinimumScaleX
final Unit setMinimumScaleX(Float xScale)
Sets the minimum scale factor for the x-axis
-
setMaximumScaleX
final Unit setMaximumScaleX(Float xScale)
Sets the maximum scale factor for the x-axis
-
setMinMaxScaleX
final Unit setMinMaxScaleX(Float minScaleX, Float maxScaleX)
Sets the minimum and maximum scale factors for the x-axis
-
setMinimumScaleY
final Unit setMinimumScaleY(Float yScale)
Sets the minimum scale factor for the y-axis
-
setMaximumScaleY
final Unit setMaximumScaleY(Float yScale)
Sets the maximum scale factor for the y-axis
-
setMinMaxScaleY
final Unit setMinMaxScaleY(Float minScaleY, Float maxScaleY)
-
isInBoundsX
final Boolean isInBoundsX(Float x)
BELOW METHODS FOR BOUNDS CHECK
-
isInBoundsY
final Boolean isInBoundsY(Float y)
-
isInBounds
final Boolean isInBounds(Float x, Float y)
-
isInBoundsLeft
final Boolean isInBoundsLeft(Float x)
-
isInBoundsRight
final Boolean isInBoundsRight(Float x)
-
isInBoundsTop
final Boolean isInBoundsTop(Float y)
-
isInBoundsBottom
final Boolean isInBoundsBottom(Float y)
-
setDragOffsetX
final Unit setDragOffsetX(Float offset)
Set an offset in dp that allows the user to drag the chart over it's bounds on the x-axis.
-
setDragOffsetY
final Unit setDragOffsetY(Float offset)
Set an offset in dp that allows the user to drag the chart over it's bounds on the y-axis.
-
hasNoDragOffset
final Boolean hasNoDragOffset()
Returns true if both drag offsets (x and y) are zero or smaller.
-
canZoomOutMoreX
final Boolean canZoomOutMoreX()
Returns true if the chart is not yet fully zoomed out on the x-axis
-
canZoomInMoreX
final Boolean canZoomInMoreX()
Returns true if the chart is not yet fully zoomed in on the x-axis
-
canZoomOutMoreY
final Boolean canZoomOutMoreY()
Returns true if the chart is not yet fully zoomed out on the y-axis
-
canZoomInMoreY
final Boolean canZoomInMoreY()
Returns true if the chart is not yet fully zoomed in on the y-axis
-
-
-
-