public class Viewport
extends java.lang.Object
BarGraphSeries
- LineGraphSeries
- PointsGraphSeries
Modifier and Type | Class and Description |
---|---|
static class |
Viewport.AxisBoundsStatus
the state of the axis bounds
|
static interface |
Viewport.OnXAxisBoundsChangedListener
listener to notify when x bounds changed after
scaling or scrolling.
|
Modifier and Type | Field and Description |
---|---|
protected RectD |
mCompleteRange
this holds the whole range of the data
left = minX, right = maxX
bottom = minY, top = maxY
|
protected RectD |
mCurrentViewport
this holds the current visible viewport
left = minX, right = maxX
bottom = minY, top = maxY
|
protected GestureDetector |
mGestureDetector
gesture detector to detect scrolling
|
protected double |
mMaxXAxisSize
maximum allowed viewport size (horizontal)
0 means use the bounds of the actual data that is
available
|
protected double |
mMaxYAxisSize
maximum allowed viewport size (vertical)
0 means use the bounds of the actual data that is
available
|
protected Viewport.OnXAxisBoundsChangedListener |
mOnXAxisBoundsChangedListener
listener to notify when x bounds changed after
scaling or scrolling.
|
protected ScaleGestureDetector |
mScaleGestureDetector
detect scaling
|
protected boolean |
mScalingActive
flag whether scaling is currently active
|
protected OverScroller |
mScroller
not used - for fling
|
protected Viewport.AxisBoundsStatus |
mXAxisBoundsStatus
state of the x axis
|
protected Viewport.AxisBoundsStatus |
mYAxisBoundsStatus
state of the y axis
|
protected double |
referenceX
this reference value is used to generate the
horizontal labels.
|
protected double |
referenceY
this reference value is used to generate the
vertical labels.
|
protected boolean |
scalableY
flag whether the vertical scaling is activated
|
Modifier and Type | Method and Description |
---|---|
void |
calcCompleteRange()
caches the complete range (minX, maxX, minY, maxY)
by iterating all series and all datapoints and
stores it into #mCompleteRange
for the x-range it will respect the series on the
second scale - not for y-values
|
void |
computeScroll()
not used currently
|
void |
draw(Canvas c)
draws the glowing edge effect
|
void |
drawFirst(Canvas c)
will be first called in order to draw
the canvas
Used to draw the background
|
int |
getBackgroundColor() |
int |
getBorderColor()
the border color used.
|
double |
getMaxX(boolean completeRange) |
double |
getMaxXAxisSize()
maximum allowed viewport size (horizontal)
0 means use the bounds of the actual data that is
available
|
double |
getMaxY(boolean completeRange) |
double |
getMaxYAxisSize()
maximum allowed viewport size (vertical)
0 means use the bounds of the actual data that is
available
|
double |
getMinX(boolean completeRange) |
double |
getMinY(boolean completeRange) |
Viewport.OnXAxisBoundsChangedListener |
getOnXAxisBoundsChangedListener() |
protected double |
getReferenceX()
the reference number to generate the labels
|
protected double |
getReferenceY()
the reference number to generate the labels
|
Viewport.AxisBoundsStatus |
getXAxisBoundsStatus() |
Viewport.AxisBoundsStatus |
getYAxisBoundsStatus() |
boolean |
isScalable() |
boolean |
isScrollable() |
boolean |
isXAxisBoundsManual() |
boolean |
isYAxisBoundsManual() |
boolean |
onTouchEvent(MotionEvent event)
will be called on a touch event.
|
void |
scrollToEnd()
forces the viewport to scroll to the end
of the range by keeping the current viewport size.
|
void |
setBackgroundColor(int mBackgroundColor) |
void |
setBorderColor(java.lang.Integer borderColor)
the border color used.
|
void |
setBorderPaint(Paint borderPaint)
custom paint to use for the border.
|
void |
setDrawBorder(boolean drawBorder)
optional draw a border between the labels
and the viewport
|
void |
setMaxX(double x)
set the maximal x value for the current viewport.
|
void |
setMaxXAxisSize(double mMaxXAxisViewportSize)
Set the max viewport size (horizontal)
This can prevent the user from zooming out too much.
|
void |
setMaxY(double y)
set the maximal y value for the current viewport.
|
void |
setMaxYAxisSize(double mMaxYAxisViewportSize)
Set the max viewport size (vertical)
This can prevent the user from zooming out too much.
|
void |
setMinimalViewport(double minX,
double maxX,
double minY,
double maxY)
minimal viewport used for scaling and scrolling.
|
void |
setMinX(double x)
set the minimal x value for the current viewport.
|
void |
setMinY(double y)
set the minimal y value for the current viewport.
|
void |
setOnXAxisBoundsChangedListener(Viewport.OnXAxisBoundsChangedListener l)
set a listener to notify when x bounds changed after
scaling or scrolling.
|
void |
setScalable(boolean mIsScalable)
active the scaling/zooming feature
notice: sets the x axis bounds to manual
|
void |
setScalableY(boolean scalableY)
activate or deactivate the vertical zooming/scaling functionallity.
|
void |
setScrollable(boolean mIsScrollable) |
void |
setScrollableY(boolean scrollableY)
activate/deactivate the vertical scrolling
|
void |
setXAxisBoundsManual(boolean mXAxisBoundsManual) |
void |
setXAxisBoundsStatus(Viewport.AxisBoundsStatus s)
change the state of the x axis.
|
void |
setYAxisBoundsManual(boolean mYAxisBoundsManual) |
void |
setYAxisBoundsStatus(Viewport.AxisBoundsStatus s)
change the state of the y axis.
|
protected double referenceY
protected double referenceX
protected boolean scalableY
protected RectD mCurrentViewport
protected double mMaxXAxisSize
protected double mMaxYAxisSize
protected RectD mCompleteRange
protected boolean mScalingActive
protected GestureDetector mGestureDetector
protected ScaleGestureDetector mScaleGestureDetector
protected OverScroller mScroller
protected Viewport.AxisBoundsStatus mXAxisBoundsStatus
protected Viewport.AxisBoundsStatus mYAxisBoundsStatus
protected Viewport.OnXAxisBoundsChangedListener mOnXAxisBoundsChangedListener
protected double getReferenceX()
public boolean onTouchEvent(MotionEvent event)
event
- public void setXAxisBoundsStatus(Viewport.AxisBoundsStatus s)
setXAxisBoundsManual(boolean)
and setYAxisBoundsManual(boolean)
s
- statepublic void setYAxisBoundsStatus(Viewport.AxisBoundsStatus s)
setXAxisBoundsManual(boolean)
and setYAxisBoundsManual(boolean)
s
- statepublic boolean isScrollable()
public void setScrollable(boolean mIsScrollable)
mIsScrollable
- whether is viewport is scrollablepublic Viewport.AxisBoundsStatus getXAxisBoundsStatus()
public Viewport.AxisBoundsStatus getYAxisBoundsStatus()
public void calcCompleteRange()
public double getMinX(boolean completeRange)
completeRange
- if true => minX of the complete range of all series
if false => minX of the current visible viewportpublic double getMaxX(boolean completeRange)
completeRange
- if true => maxX of the complete range of all series
if false => maxX of the current visible viewportpublic double getMinY(boolean completeRange)
completeRange
- if true => minY of the complete range of all series
if false => minY of the current visible viewportpublic double getMaxY(boolean completeRange)
completeRange
- if true => maxY of the complete range of all series
if false => maxY of the current visible viewportpublic void setMaxY(double y)
setYAxisBoundsManual(boolean)
y
- max / highest valuepublic void setMinY(double y)
setYAxisBoundsManual(boolean)
y
- min / lowest valuepublic void setMaxX(double x)
setXAxisBoundsManual(boolean)
x
- max / highest valuepublic void setMinX(double x)
setXAxisBoundsManual(boolean)
x
- min / lowest valuepublic void computeScroll()
public void drawFirst(Canvas c)
c
- canvas.public void draw(Canvas c)
c
- canvaspublic int getBackgroundColor()
public void setBackgroundColor(int mBackgroundColor)
mBackgroundColor
- background of the viewport area
use transparent to have no backgroundpublic boolean isScalable()
public void setScalable(boolean mIsScalable)
mIsScalable
- whether the viewport is scalablepublic boolean isXAxisBoundsManual()
setMinX(double)
,
setMaxX(double)
public void setXAxisBoundsManual(boolean mXAxisBoundsManual)
mXAxisBoundsManual
- whether the x axis bounds are manual.setMinX(double)
,
setMaxX(double)
public boolean isYAxisBoundsManual()
public void setYAxisBoundsManual(boolean mYAxisBoundsManual)
mYAxisBoundsManual
- whether the y axis bounds are manualsetMaxY(double)
,
setMinY(double)
public void scrollToEnd()
setXAxisBoundsManual(boolean)
public Viewport.OnXAxisBoundsChangedListener getOnXAxisBoundsChangedListener()
public void setOnXAxisBoundsChangedListener(Viewport.OnXAxisBoundsChangedListener l)
l
- the listener to usepublic void setDrawBorder(boolean drawBorder)
drawBorder
- true to draw the borderpublic int getBorderColor()
setDrawBorder(boolean)
public void setBorderColor(java.lang.Integer borderColor)
borderColor
- null to resetpublic void setBorderPaint(Paint borderPaint)
borderPaint
- setDrawBorder(boolean)
public void setScrollableY(boolean scrollableY)
scrollableY
- true to activateprotected double getReferenceY()
public void setScalableY(boolean scalableY)
scalableY
- true to activatepublic double getMaxXAxisSize()
public double getMaxYAxisSize()
public void setMaxXAxisSize(double mMaxXAxisViewportSize)
mMaxXAxisViewportSize
- maximum size of viewportpublic void setMaxYAxisSize(double mMaxYAxisViewportSize)
mMaxYAxisViewportSize
- maximum size of viewportpublic void setMinimalViewport(double minX, double maxX, double minY, double maxY)
minX
- maxX
- minY
- maxY
-