public class ChartComputator
extends java.lang.Object
| Modifier and Type | Field and Description |
|---|---|
protected int |
chartHeight |
protected int |
chartWidth |
protected android.graphics.Rect |
contentRectMinusAllMargins |
protected android.graphics.Rect |
contentRectMinusAxesMargins |
protected Viewport |
currentViewport
This rectangle represents the currently visible chart values ranges.
|
protected static float |
DEFAULT_MAXIMUM_ZOOM
Maximum chart zoom.
|
protected android.graphics.Rect |
maxContentRect |
protected Viewport |
maxViewport |
protected float |
maxZoom |
protected float |
minViewportHeight |
protected float |
minViewportWidth |
protected ViewportChangeListener |
viewportChangeListener
Warning! Viewport listener is disabled for all charts beside preview charts to avoid additional method calls
during animations.
|
| Constructor and Description |
|---|
ChartComputator() |
| Modifier and Type | Method and Description |
|---|---|
float |
computeRawDistanceX(float distance)
Translates viewport distance int pixel distance for X coordinates.
|
float |
computeRawDistanceY(float distance)
Translates viewport distance int pixel distance for X coordinates.
|
float |
computeRawX(float valueX)
Translates chart value into raw pixel value.
|
float |
computeRawY(float valueY)
Translates chart value into raw pixel value.
|
void |
computeScrollSurfaceSize(android.graphics.Point out)
Computes the current scrollable surface size, in pixels.
|
void |
constrainViewport(float left,
float top,
float right,
float bottom)
Checks if new viewport doesn't exceed max available viewport.
|
int |
getChartHeight() |
int |
getChartWidth() |
android.graphics.Rect |
getContentRectMinusAllMargins()
Returns content rectangle in pixels.
|
android.graphics.Rect |
getContentRectMinusAxesMargins()
Returns content rectangle with chart internal margins, for example for LineChart contentRectMinusAxesMargins is
bigger
than contentRectMinusAllMargins by point radius, thanks to that points are not cut on edges.
|
Viewport |
getCurrentViewport()
Returns current chart viewport, returned object is mutable but should not be modified.
|
Viewport |
getMaximumViewport()
Returns maximum viewport - values ranges extremes.
|
float |
getMaxZoom() |
float |
getMinimumViewportHeight() |
float |
getMinimumViewportWidth() |
Viewport |
getVisibleViewport()
Returns viewport for visible part of chart, for most charts it is equal to current viewport.
|
void |
insetContentRect(int deltaLeft,
int deltaTop,
int deltaRight,
int deltaBottom) |
void |
insetContentRectByInternalMargins(int deltaLeft,
int deltaTop,
int deltaRight,
int deltaBottom) |
boolean |
isWithinContentRect(float x,
float y,
float precision)
Check if given coordinates lies inside contentRectMinusAllMargins.
|
boolean |
rawPixelsToDataPoint(float x,
float y,
android.graphics.PointF dest)
Finds the chart point (i.e.
|
void |
resetContentRect() |
void |
setContentRect(int width,
int height,
int paddingLeft,
int paddingTop,
int paddingRight,
int paddingBottom)
Calculates available width and height.
|
void |
setCurrentViewport(float left,
float top,
float right,
float bottom)
Set new values for curent viewport, that will change what part of chart is visible.
|
void |
setCurrentViewport(Viewport viewport)
Set current viewport to the same values as viewport passed in parameter.
|
void |
setMaxViewport(float left,
float top,
float right,
float bottom)
Set new values for maximum viewport, that will change what part of chart is visible.
|
void |
setMaxViewport(Viewport maxViewport)
Set maximum viewport to the same values as viewport passed in parameter.
|
void |
setMaxZoom(float maxZoom)
Set maximum zoom level, default is 20.
|
void |
setViewportChangeListener(ViewportChangeListener viewportChangeListener) |
void |
setViewportTopLeft(float left,
float top)
Sets the current viewport (defined by
currentViewport) to the given X and Y positions. |
void |
setVisibleViewport(Viewport visibleViewport) |
protected static final float DEFAULT_MAXIMUM_ZOOM
protected float maxZoom
protected int chartWidth
protected int chartHeight
protected android.graphics.Rect contentRectMinusAllMargins
protected android.graphics.Rect contentRectMinusAxesMargins
protected android.graphics.Rect maxContentRect
protected Viewport currentViewport
protected Viewport maxViewport
protected float minViewportWidth
protected float minViewportHeight
protected ViewportChangeListener viewportChangeListener
public void setContentRect(int width,
int height,
int paddingLeft,
int paddingTop,
int paddingRight,
int paddingBottom)
public void resetContentRect()
public void insetContentRect(int deltaLeft,
int deltaTop,
int deltaRight,
int deltaBottom)
public void insetContentRectByInternalMargins(int deltaLeft,
int deltaTop,
int deltaRight,
int deltaBottom)
public void constrainViewport(float left,
float top,
float right,
float bottom)
public void setViewportTopLeft(float left,
float top)
currentViewport) to the given X and Y positions.public float computeRawX(float valueX)
public float computeRawY(float valueY)
public float computeRawDistanceX(float distance)
public float computeRawDistanceY(float distance)
public boolean rawPixelsToDataPoint(float x,
float y,
android.graphics.PointF dest)
contentRectMinusAllMargins. If the point is found,
the "dest"
argument is set to the point and this function returns true. Otherwise, this function returns false and
"dest" is
unchanged.public void computeScrollSurfaceSize(android.graphics.Point out)
contentRectMinusAllMargins. If the chart is zoomed in 200% in both
directions, the
returned size will be twice as large horizontally and vertically.public boolean isWithinContentRect(float x,
float y,
float precision)
public android.graphics.Rect getContentRectMinusAllMargins()
public android.graphics.Rect getContentRectMinusAxesMargins()
public Viewport getCurrentViewport()
public void setCurrentViewport(Viewport viewport)
viewport - public void setCurrentViewport(float left,
float top,
float right,
float bottom)
public Viewport getMaximumViewport()
public void setMaxViewport(Viewport maxViewport)
maxViewport - public void setMaxViewport(float left,
float top,
float right,
float bottom)
public Viewport getVisibleViewport()
public void setVisibleViewport(Viewport visibleViewport)
public float getMinimumViewportWidth()
public float getMinimumViewportHeight()
public void setViewportChangeListener(ViewportChangeListener viewportChangeListener)
public int getChartWidth()
public int getChartHeight()
public float getMaxZoom()
public void setMaxZoom(float maxZoom)
maxZoom -