public abstract class BaseSeries<E extends DataPointInterface> extends java.lang.Object implements Series<E>
Series
.Modifier and Type | Field and Description |
---|---|
protected OnDataPointTapListener |
mOnDataPointTapListener
listener to handle tap events on a data point
|
Constructor and Description |
---|
BaseSeries()
creates series without data
|
BaseSeries(E[] data)
creates series with data
|
Modifier and Type | Method and Description |
---|---|
void |
appendData(E dataPoint,
boolean scrollToEnd,
int maxDataPoints) |
void |
appendData(E dataPoint,
boolean scrollToEnd,
int maxDataPoints,
boolean silent) |
protected void |
checkValueOrder(DataPointInterface onlyLast)
checks that the data is in the correct order
|
void |
clearCursorModeCache() |
void |
clearReference(GraphView graphView)
clear reference to view and activity
|
abstract void |
drawSelection(GraphView mGraphView,
Canvas canvas,
boolean b,
DataPointInterface value) |
protected E |
findDataPoint(float x,
float y)
find the data point which is next to the
coordinates
|
E |
findDataPointAtX(float x) |
int |
getColor() |
double |
getHighestValueX() |
double |
getHighestValueY() |
double |
getLowestValueX() |
double |
getLowestValueY() |
java.lang.String |
getTitle() |
java.util.Iterator<E> |
getValues(double from,
double until)
get the values for a given x range.
|
boolean |
isEmpty() |
void |
onGraphViewAttached(GraphView graphView)
stores the reference of the used graph
|
void |
onTap(float x,
float y)
called by the tap detector in order to trigger
the on tap on datapoint event.
|
protected void |
registerDataPoint(float x,
float y,
E dp)
register the datapoint to find it at a tap
|
void |
resetData(E[] data)
clears the data of this series and sets new.
|
protected void |
resetDataPoints()
clears the cached data point coordinates
|
void |
setColor(int mColor)
set the color of the series.
|
void |
setOnDataPointTapListener(OnDataPointTapListener l)
set a listener for tap on a data point.
|
void |
setTitle(java.lang.String mTitle)
set the title of the series.
|
protected OnDataPointTapListener mOnDataPointTapListener
public BaseSeries()
public BaseSeries(E[] data)
data
- data points
important: array has to be sorted from lowest x-value to the highestpublic double getLowestValueX()
getLowestValueX
in interface Series<E extends DataPointInterface>
public double getHighestValueX()
getHighestValueX
in interface Series<E extends DataPointInterface>
public double getLowestValueY()
getLowestValueY
in interface Series<E extends DataPointInterface>
public double getHighestValueY()
getHighestValueY
in interface Series<E extends DataPointInterface>
public java.util.Iterator<E> getValues(double from, double until)
getValues
in interface Series<E extends DataPointInterface>
from
- minimal x-valueuntil
- maximal x-valuepublic java.lang.String getTitle()
getTitle
in interface Series<E extends DataPointInterface>
public void setTitle(java.lang.String mTitle)
mTitle
- title of the seriespublic int getColor()
getColor
in interface Series<E extends DataPointInterface>
public void setColor(int mColor)
mColor
- public void setOnDataPointTapListener(OnDataPointTapListener l)
setOnDataPointTapListener
in interface Series<E extends DataPointInterface>
l
- listenerpublic void onTap(float x, float y)
onTap
in interface Series<E extends DataPointInterface>
x
- pixely
- pixelprotected E findDataPoint(float x, float y)
x
- pixely
- pixelpublic E findDataPointAtX(float x)
protected void registerDataPoint(float x, float y, E dp)
x
- pixely
- pixeldp
- the data point to saveprotected void resetDataPoints()
public void resetData(E[] data)
data
- the values must be in the correct order!
x-value has to be ASC. First the lowest x value and at least the highest x value.public void onGraphViewAttached(GraphView graphView)
onGraphViewAttached
in interface Series<E extends DataPointInterface>
graphView
- graphviewpublic void appendData(E dataPoint, boolean scrollToEnd, int maxDataPoints, boolean silent)
dataPoint
- values the values must be in the correct order!
x-value has to be ASC. First the lowest x value and at least the highest x value.scrollToEnd
- true => graphview will scroll to the end (maxX)maxDataPoints
- if max data count is reached, the oldest data
value will be lost to avoid memory leakssilent
- set true to avoid rerender the graphpublic void appendData(E dataPoint, boolean scrollToEnd, int maxDataPoints)
dataPoint
- values the values must be in the correct order!
x-value has to be ASC. First the lowest x value and at least the highest x value.scrollToEnd
- true => graphview will scroll to the end (maxX)maxDataPoints
- if max data count is reached, the oldest data
value will be lost to avoid memory leakspublic boolean isEmpty()
isEmpty
in interface Series<E extends DataPointInterface>
protected void checkValueOrder(DataPointInterface onlyLast)
onlyLast
- if not null, it will only check that this
datapoint is after the last point.public abstract void drawSelection(GraphView mGraphView, Canvas canvas, boolean b, DataPointInterface value)
public void clearCursorModeCache()
public void clearReference(GraphView graphView)
Series
clearReference
in interface Series<E extends DataPointInterface>