public class IlvDefaultDataSet extends IlvAbstractDataSet
Values are stored in an extensible array of double
values.
You can specify that only the Y values are stored, in which case the
X value of a data point is equal to its index in the data set.
Modifier and Type | Field and Description |
---|---|
protected ArrayList<String> |
labels
The data labels.
|
protected IlvDoubleArray |
xValues
The x-values array.
|
protected IlvDoubleArray |
yValues
The y-values array.
|
DEFAULT_UNDEF_VALUE
Constructor and Description |
---|
IlvDefaultDataSet(String name)
Creates a new data set with the default initial capacity for data point
storage.
|
IlvDefaultDataSet(String name,
boolean useXValues)
Creates a new data set with the default initial capacity for data point
storage.
|
IlvDefaultDataSet(String name,
double[] yValues)
Initializes a new data set with a copy the specified y-values.
|
IlvDefaultDataSet(String name,
double[] xValues,
double[] yValues,
boolean copy)
Creates a new data set with the specified X and Y values.
|
IlvDefaultDataSet(String name,
int initialSize,
boolean useXValues)
Initializes a new data set with the specified initial capacity for data point
storage.
|
Modifier and Type | Method and Description |
---|---|
void |
addData(double x,
double y)
Adds a data point at the end of this data set.
|
void |
addData(double x,
double y,
String label)
Adds a data point at the end of this data set.
|
static IlvDefaultDataSet[] |
create(double[][] values,
int xSeriesIdx,
String[] names,
String[] dataLabels)
Creates data sets from the specified data.
|
protected void |
dataAdded(int idx)
Called when a data point has been added.
|
protected void |
dataChanged(int firstIdx,
int lastIdx,
int eventType)
Called when data points have been modified.
|
int |
getDataCount()
Returns the number of data points held by this data set.
|
String |
getDataLabel(int idx)
Returns the label associated with the data point at the specified index.
|
String[] |
getDataLabels()
Returns the data point labels.
|
double |
getXData(int idx)
Returns the x-value of the data point at the specified index.
|
double[] |
getXValues()
Returns the x values of all data points in a freshly allocated array.
|
double |
getYData(int idx)
Returns the y-value of the data point at the specified index.
|
double[] |
getYValues()
Returns the y values of all data points in a freshly allocated array.
|
boolean |
isEditable()
Indicates whether the data set is editable.
|
boolean |
isUsingXValues()
Tells whether X values are stored in the data set.
|
boolean |
isXValuesSorted()
Indicates whether the X values held by this data set are sorted
in ascending order.
|
void |
setData(double[] xValues,
double[] yValues,
int count)
Initializes the contents of this data set with a copy of the specified
values.
|
void |
setData(int idx,
double x,
double y)
Modifies the data point at the specified index.
|
void |
setDataLabel(int idx,
String label)
Sets a data point label.
|
void |
setDataLabels(String[] labels)
Specifies the data point labels.
|
void |
setXData(int idx,
double x)
Modifies the x value of the data point at the specified index.
|
void |
setXValues(double[] xValues)
Changes the x values of all data points.
|
void |
setYData(int idx,
double y)
Modifies the y value of the data point at the specified index.
|
void |
setYValues(double[] yValues)
Changes the y values of all data points.
|
void |
useXValues(boolean b)
Specifies whether x-values should be stored in the data set.
|
addDataSetListener, computeLimits, computeMinimumXDifference, endBatch, fireDataAddedEvent, fireDataChangedEvent, fireDataSetContentsEvent, fireDataSetPropertyEvent, getData, getDataBetween, getDataInside, getDataInside, getMinimumXDifference, getName, getProperty, getUndefValue, getXRange, getXRange, getYRange, getYRange, invalidateLimits, invalidateLimits, invalidateLimits, isBatched, isXRangeIncludingUndefinedPoints, putProperty, removeDataSetListener, setLimitsValid, setName, setUndefValue, setXRangeIncludingUndefinedPoints, startBatch, toString
protected IlvDoubleArray xValues
null
or an array of the same size as
yValues
.protected IlvDoubleArray yValues
public IlvDefaultDataSet(String name)
name
- The name of the data set.public IlvDefaultDataSet(String name, boolean useXValues)
name
- The name of the data set.useXValues
- A boolean value indicating whether x-values should
be stored in the data set, or generated according to the data points
indices.isUsingXValues()
public IlvDefaultDataSet(String name, int initialSize, boolean useXValues)
name
- The name of the data set.initialSize
- The initial size for the array holding the data points
coordinates.useXValues
- A boolean value indicating whether x-values should
be stored in the data set, or generated according to the data points
indices.isUsingXValues()
public IlvDefaultDataSet(String name, double[] yValues)
The x-values of the data set will be computed according to the data points indices.
isUsingXValues()
public IlvDefaultDataSet(String name, double[] xValues, double[] yValues, boolean copy)
xValues
- The x-values.yValues
- The y-values.copy
- If true
, the given arrays are copied. Otherwise,
the arrays are directly referenced by the data set. In the latter case,
no modification should be done on the original arrays.public final boolean isUsingXValues()
true
if x-values are stored in the data set, or
false
if they are computed according to the data points
indices.useXValues(boolean)
public void useXValues(boolean b)
isUsingXValues()
public void setData(double[] xValues, double[] yValues, int count)
DataSetContentsEvent.FULL_UPDATE
event.xValues
- an array of at least count elements, or
null
yValues
- an array of at least count elements, or
(only if count == 0
) null
count
- The number of relevant elements in the xValues and
yValues arrays.public int getDataCount()
getDataCount
in interface IlvDataSet
getDataCount
in class IlvAbstractDataSet
public double getXData(int idx)
getXData
in interface IlvDataSet
getXData
in class IlvAbstractDataSet
idx
- a data point index, >= 0, < getDataCount()
public double getYData(int idx)
getYData
in interface IlvDataSet
getYData
in class IlvAbstractDataSet
idx
- a data point index, >= 0, < getDataCount()
public boolean isEditable()
isEditable
in interface IlvDataSet
isEditable
in class IlvAbstractDataSet
true
.public void setData(int idx, double x, double y)
setData
in interface IlvDataSet
setData
in class IlvAbstractDataSet
idx
- The index of the considered data point.x
- The new x-value of the data point. This value is not taken into
account if the data set does not store x-values.y
- The new y-value of the data point.isUsingXValues()
public void addData(double x, double y)
create(double[][], int, java.lang.String[], java.lang.String[])
method.addData
in interface IlvDataSet
addData
in class IlvAbstractDataSet
x
- The x-value of the new data point. This value is not taken into
account if the data set does not store x-values.y
- The y-value of the new data point.isUsingXValues()
public void addData(double x, double y, String label)
create(double[][], int, java.lang.String[], java.lang.String[])
method.x
- The x-value of the new data point. This value is not taken into
account if the data set does not store x-values.y
- The y-value of the new data point.label
- The label of the new data point.isUsingXValues()
,
setDataLabels(java.lang.String[])
public String getDataLabel(int idx)
getDataLabel
in interface IlvDataSet
getDataLabel
in class IlvAbstractDataSet
idx
- a data point index, >= 0, < getDataCount()
setDataLabels(java.lang.String[])
public boolean isXValuesSorted()
isXValuesSorted
in interface IlvDataSet
isXValuesSorted
in class IlvAbstractDataSet
protected void dataChanged(int firstIdx, int lastIdx, int eventType)
dataChanged
in class IlvAbstractDataSet
firstIdx
- The index of the first point impacted by the
modification.lastIdx
- The index of the last point impacted by the
modification.eventType
- The type of the notification event.protected void dataAdded(int idx)
dataAdded
in class IlvAbstractDataSet
public void setXData(int idx, double x)
This method has no effect if isUsingXValues()
returns
false
.
Note: This method does not work in subclasses like
IlvCyclicDataSet
.
public double[] getXValues()
getDataCount()
elements.public void setXValues(double[] xValues)
isUsingXValues()
returns true
, it also
changes the number of data points held by this data set.
This method has no effect if isUsingXValues()
returns
false
.
Note: This method does not work in subclasses like
IlvCyclicDataSet
.
public void setYData(int idx, double y)
Note: This method does not work in subclasses like
IlvCyclicDataSet
.
public double[] getYValues()
getDataCount()
elements.public void setYValues(double[] yValues)
isUsingXValues()
returns false
, it also
changes the number of data points held by this data set.
Note: This method does not work in subclasses like
IlvCyclicDataSet
.
public void setDataLabel(int idx, String label)
public String[] getDataLabels()
Note: This method does not work in subclasses like
IlvCyclicDataSet
.
getDataCount()
elements are relevant.public void setDataLabels(String[] labels)
public static IlvDefaultDataSet[] create(double[][] values, int xSeriesIdx, String[] names, String[] dataLabels)
values
- The values used to initialize the data source.
This parameter is interpreted as an array of series.xSeriesIdx
- Specifies the index of the X series in the
values
parameter. If xSeriesIdx
is equal to
-1
, values
is assumed to hold only Y series.
Otherwise, the corresponding X series is shared by all the data sets.names
- An optional array holding the names of the data sets.dataLabels
- An optional array of data point labels. These names
will be used by all the data sets.© Copyright Rogue Wave Software, Inc. 1997, 2018. All Rights Reserved.