com.androidplot.xy
Class SimpleXYSeries

java.lang.Object
  extended by com.androidplot.xy.SimpleXYSeries
All Implemented Interfaces:
PlotListener, Series<android.util.Pair<Number,Number>>, XYSeries

public class SimpleXYSeries
extends Object
implements XYSeries, PlotListener

A convenience class used to create instances of XYPlot generated from Lists of Numbers.


Nested Class Summary
static class SimpleXYSeries.ArrayFormat
           
 
Constructor Summary
SimpleXYSeries(List<? extends Number> xVals, List<? extends Number> yVals, String title)
           
SimpleXYSeries(List<? extends Number> model, SimpleXYSeries.ArrayFormat format, String title)
          Generates an XYSeries instance from the List of numbers passed in.
SimpleXYSeries(String title)
           
 
Method Summary
 void addFirst(Number x, Number y)
           
 void addLast(Number x, Number y)
           
 String getTitle()
           
 Number getX(int index)
          Returns the x-value for an index within a series.
 Number getY(int index)
          Returns the y-value for an index within a series.
 void onAfterDraw(Plot source, android.graphics.Canvas canvas)
          Fired immediately after the Plot "source" is drawn onto canvas.
 void onBeforeDraw(Plot source, android.graphics.Canvas canvas)
          Fired immediately before the Plot "source" is drawn onto canvas.
 android.util.Pair<Number,Number> removeFirst()
           
 android.util.Pair<Number,Number> removeLast()
           
 void setModel(List<? extends Number> model, SimpleXYSeries.ArrayFormat format)
          Use the provided list of Numbers as yVals and their corresponding indexes as xVals.
 void setTitle(String title)
           
 void setX(Number value, int index)
          Sets individual x value based on index
 void setXY(Number xVal, Number yVal, int index)
          Sets xy values based on index
 void setY(Number value, int index)
          Sets individual y value based on index
 int size()
           
 void useImplicitXVals()
          Use index value as xVal, instead of explicit, user provided xVals.
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

SimpleXYSeries

public SimpleXYSeries(String title)

SimpleXYSeries

public SimpleXYSeries(List<? extends Number> model,
                      SimpleXYSeries.ArrayFormat format,
                      String title)
Generates an XYSeries instance from the List of numbers passed in. This is a convenience class and should only be used for static data models; it is not suitable for representing dynamically changing data.

Parameters:
model - A List of Number elements comprising the data model.
format - Format of the model. A format of Y_VALS_ONLY means that the array only contains y-values. For this format x values are autogenerated using values of 0 through n-1 where n is the size of the model.
title - Title of the series

SimpleXYSeries

public SimpleXYSeries(List<? extends Number> xVals,
                      List<? extends Number> yVals,
                      String title)
Method Detail

onBeforeDraw

public void onBeforeDraw(Plot source,
                         android.graphics.Canvas canvas)
Description copied from interface: PlotListener
Fired immediately before the Plot "source" is drawn onto canvas. Commonly used by implementing Series instances to activate a read lock on it's self in preparation for the Plot's imminent reading of that series.

Specified by:
onBeforeDraw in interface PlotListener

onAfterDraw

public void onAfterDraw(Plot source,
                        android.graphics.Canvas canvas)
Description copied from interface: PlotListener
Fired immediately after the Plot "source" is drawn onto canvas. Just as onBeforeDraw(...) is commonly used by Series implementations to activate a read lock, this method is commonly used to release that same lock.

Specified by:
onAfterDraw in interface PlotListener

useImplicitXVals

public void useImplicitXVals()
Use index value as xVal, instead of explicit, user provided xVals.


setModel

public void setModel(List<? extends Number> model,
                     SimpleXYSeries.ArrayFormat format)
Use the provided list of Numbers as yVals and their corresponding indexes as xVals.

Parameters:
model - A List of Number elements comprising the data model.
format - Format of the model. A format of Y_VALS_ONLY means that the array only contains y-values. For this format x values are autogenerated using values of 0 through n-1 where n is the size of the model.

setX

public void setX(Number value,
                 int index)
Sets individual x value based on index

Parameters:
value -
index -

setY

public void setY(Number value,
                 int index)
Sets individual y value based on index

Parameters:
value -
index -

setXY

public void setXY(Number xVal,
                  Number yVal,
                  int index)
Sets xy values based on index

Parameters:
xVal -
yVal -
index -

addFirst

public void addFirst(Number x,
                     Number y)

removeFirst

public android.util.Pair<Number,Number> removeFirst()
Returns:
Pair with first equal to x-val and second equal to y-val.

addLast

public void addLast(Number x,
                    Number y)

removeLast

public android.util.Pair<Number,Number> removeLast()
Returns:
Pair with first equal to x-val and second equal to y-val.

getTitle

public String getTitle()
Specified by:
getTitle in interface Series<android.util.Pair<Number,Number>>
Returns:
The title of this Series.

setTitle

public void setTitle(String title)

size

public int size()
Specified by:
size in interface XYSeries
Returns:
Number of elements in this Series.

getX

public Number getX(int index)
Description copied from interface: XYSeries
Returns the x-value for an index within a series.

Specified by:
getX in interface XYSeries
Parameters:
index - the index index (in the range 0 to size()-1).
Returns:
The x-value.

getY

public Number getY(int index)
Description copied from interface: XYSeries
Returns the y-value for an index within a series.

Specified by:
getY in interface XYSeries
Parameters:
index - the index index (in the range 0 to size()-1).
Returns:
The y-value.


Copyright © 2010-2013 androidplot.com. All Rights Reserved.