1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56
|
package tim.prune.function.charts;
/**
* Class to hold a data series for the charts
*/
public class ChartSeries
{
/** Array of booleans, true for data existing, false otherwise */
private final boolean[] _hasData;
/** Array of data */
private final double[] _data;
/**
* Constructor
* @param inNumPoints number of points
*/
public ChartSeries(int inNumPoints)
{
_hasData = new boolean[inNumPoints];
_data = new double[inNumPoints];
}
/**
* @return the number of values
*/
public int getNumPoints() {
return _hasData.length;
}
/**
* @param inIndex index of point
* @return true if series has data for this point
*/
public boolean hasData(int inIndex) {
return _hasData[inIndex];
}
/**
* @param inIndex index of point
* @return data value for this point
*/
public double getData(int inIndex) {
return _data[inIndex];
}
/**
* Set the data at the given index
* @param inIndex index of point
* @param inData data value
*/
public void setData(int inIndex, double inData)
{
_hasData[inIndex] = true;
_data[inIndex] = inData;
}
}
|