|
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||
java.lang.Objectlt.monarch.chart.models.AbstractDataModel
lt.monarch.chart.models.ChartDataModel
public class ChartDataModel extends AbstractDataModel
If you add collections to the data model, be sure that it subclasses List. Otherwise set
operation won't be performed, since there is no set() methods in a Collection class.
In the matrix case the data point is specified by row and column. Note that column in some cases are referred to
the different type of values in the data model, such as x, y, z and etc. If data contains only
one column, it may contain a matrix inside of it, which can be accessed through indexes row and
column. Model can also contain multiple matrixes, for KEY and VALUES, e.i. multiple data cubes.
BE WARE! When passing arrays to the data model, the arrays are not copied but stored,
so if you modify the array outside data model, the array in the data model also will change.
The same is with the inner collections (not the ones specifying data column type).
| Modifier and Type | Field and Description |
|---|
| Fields inherited from class lt.monarch.chart.models.AbstractDataModel |
|---|
columns, data, dataListeners, dimensions, suspended |
| Constructor and Description |
|---|
ChartDataModel()
Default chart data model constructor, which creates empty data model. |
ChartDataModel(java.util.Collection<?> data)
Chart data model constructor. |
ChartDataModel(java.util.Collection<?>[] data)
Chart data model constructor, which allows to add collection array to the model. |
ChartDataModel(DataColumnType[] valType,
java.util.Collection<?> data)
Chart data model constructor. |
ChartDataModel(DataColumnType[] valType,
java.util.Collection<?>[] data)
Chart data model constructor, which allows to add collection array to the model. |
ChartDataModel(DataColumnType[] valType,
java.lang.Object[][] data)
Chart data model constructor, which adds data array to the model. |
ChartDataModel(int size)
Deprecated. |
ChartDataModel(java.lang.Object[][] data)
Chart data model constructor, which adds data array to the model. |
| Modifier and Type | Method and Description |
|---|---|
void |
add(DataColumnType[] valType,
java.lang.Object[] values)
Adds one data element to the data model. |
void |
add(java.lang.Object[] values)
Adds one data element to the data model. |
void |
addKeyValues(java.lang.Object key,
java.lang.Object[] values)
Adds single key object with associated array of values to data model. |
boolean |
containsKey(java.lang.Object key)
Checks if data model contains given key. |
protected void |
finalize()
|
int |
getPointCount()
Counts the data model size. |
int |
getPointCount(MatrixDimensions dimension)
Gets the count of point in the specified dimension. |
java.lang.Object |
getValueAt(DataColumnType valType,
int index)
Gets the data value at the specified point. |
java.lang.Object |
getValueAt(DataColumnType valType,
int row,
int column)
Get value at specified point. |
boolean |
hasColumn(DataColumnType columnType)
Returns flag showing if this data model contains column of the given type. |
void |
remove(int index)
Removes data point. |
void |
removeAll()
Removes all data from the data model |
void |
setValueAt(DataColumnType valType,
int row,
int column,
java.lang.Object value)
Sets value at the specified point. |
void |
setValueAt(DataColumnType valType,
int index,
java.lang.Object value)
Sets value at specified point. |
| Methods inherited from class lt.monarch.chart.models.AbstractDataModel |
|---|
addColumn, addListener, castToArray, castToMatrix, dispose, fireDataChanged, getAddressDimensions, getColumns, getValuesInPoint, removeListener, resumeListeners, setColumns, suspendListeners |
| Methods inherited from class java.lang.Object |
|---|
clone, equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Constructor Detail |
|---|
public ChartDataModel()
@Deprecated public ChartDataModel(int size)
public ChartDataModel(DataColumnType[] valType,
java.lang.Object[][] data)
data[0] = new Object[]{"1999", "2000"};
data[1] = new Object[]{20d, 50d};
array = new ChartDataModel(new DataValueType[] {DataValueType.KEY, DataValueType.VALUE}, data);
When adding matrix to data model you must add it in three dimensional array, like this:
Double m[][][] = new Double[1][L][L];
for (int i = 0; i < L; i++)
{
for (int j = 0; j < L; j++)
{
m[0][i][j] = new Double(Math.random());
}
}
matrix = new ChartDataModel(new DataValueType[] { DataValueType.KEY }, m);
valType - value type array, which shows in what sequence the data from the array should
be added to the modeldata - data array which has to be added to the modelpublic ChartDataModel(java.lang.Object[][] data)
The count of data columns is determined from the length of the data array. Data in the array is like this:
data[0] = new Object[]{"1999", "2000"};
data[1] = new Object[]{20d, 50d};
array = new ChartDataModel(data);
When adding matrix to data model you must add it in three dimensional array, like this:
Double m[][][] = new Double[1][L][L];
for (int i = 0; i < L; i++)
{
for (int j = 0; j < L; j++)
{
m[0][i][j] = new Double(Math.random());
}
}
matrix = new ChartDataModel(m);
data - data array which has to be added to the modelpublic ChartDataModel(java.util.Collection<?>[] data)
ArrayList list1 = new ArrayList();
list1.add("1999");
list1.add("2000");
data[0] = list1;
ArrayList list2 = new ArrayList();
list2.add(59d);
list2.add(89d);
data[1] = list2;
array = new ChartDataModel(data);
or
ArrayListFor matrix data model it should look like this:[] list = new ArrayList[2]; Double[] x = new Double[]{ 5d, 15d, 30d }; Double[] y = new Double[]{ 10d, 20d, 0d }; ArrayList xValues = new ArrayList (); Collections.addAll(xValues, x); ArrayList yValues = new ArrayList (); Collections.addAll(yValues, y); list[0] = xValues; list[1] = yValues; array = new ChartDataModel(list);
int L = 3; ArrayList> m[] = new ArrayList[1]; m[0] = new ArrayList >(); for (int i = 0; i < L; i++) { m[0].add(new ArrayList ()); for (int j = 0; j < L; j++) { m[0].get(i).add(new Double((i + 1) * 10 + j + 1)); } } matrix = new ChartDataModel(m);
data - data collection array which has to be added to the model
public ChartDataModel(DataColumnType[] valType,
java.util.Collection<?>[] data)
Data in the collection array is like this:
ArrayList list1 = new ArrayList();
list1.add("1999");
list1.add("2000");
data[0] = list1;
ArrayList list2 = new ArrayList();
list2.add(59d);
list2.add(89d);
data[1] = list2;
array = new ChartDataModel(new DataValueType[] { DataValueType.KEY, DataValueType.VALUE }, data);
or
ArrayListFor the matrix the sample code looks like this:[] list = new ArrayList[2]; Double[] x = new Double[]{ 5d, 15d, 30d }; Double[] y = new Double[]{ 10d, 20d, 0d }; ArrayList xValues = new ArrayList (); Collections.addAll(xValues, x); ArrayList yValues = new ArrayList (); Collections.addAll(yValues, y); list[0] = xValues; list[1] = yValues; array = new ChartDataModel(new DataValueType[] { DataValueType.KEY, DataValueType.VALUE },list);
int L = 3; ArrayList> m[] = new ArrayList[1]; m[0] = new ArrayList >(); for (int i = 0; i < L; i++) { m[0].add(new ArrayList ()); for (int j = 0; j < L; j++) { m[0].get(i).add(new Double((i + 1) * 10 + j + 1)); } } matrix = new ChartDataModel(new DataValueType[] {DataValueType.KEY },m);
valType - value type array, which shows in what sequence the data from the collection
array should be added to the model.data - data collection array which has to be added to the model.
public ChartDataModel(DataColumnType[] valType,
java.util.Collection<?> data)
ArrayListFor the matrix sample code is this:list = new ArrayList (); Double[] x = new Double[] { 5d, 15d, 30d }; Double[] y = new Double[] { 10d, 20d, 0d }; list.add(x); list.add(y); array = new ChartDataModel(new DataValueType[] { DataValueType.KEY, DataValueType.VALUE }, list);
int L = 3; ArrayList>> m = new ArrayList >>(); m.add(new ArrayList >()); for (int i = 0; i < L; i++) { m.get(0).add(new ArrayList ()); for (int j = 0; j < L; j++) { m.get(0).get(i).add(new Double((i + 1) * 10 + j + 1)); } } matrix = new ChartDataModel(new DataValueType[] { DataValueType.KEY }, m);
valType - value type array, which shows in what sequence the data from the collection
should be added to the model.data - data collection which has to be added to the model.public ChartDataModel(java.util.Collection<?> data)
ArrayListMatrix is created like this:list = new ArrayList (); Double[] x = new Double[] { 5d, 15d, 30d }; Double[] y = new Double[] { 10d, 20d, 0d }; list.add(x); list.add(y); array = new ChartDataModel(list);
int L = 3; ArrayListSince the order of the data columns is not specified in this constructor the data will be placed in columns in ascending order.>> m = new ArrayList >>(); m.add(new ArrayList >()); for (int i = 0; i < L; i++) { m.get(0).add(new ArrayList ()); for (int j = 0; j < L; j++) { m.get(0).get(i).add(new Double((i + 1) * 10 + j + 1)); } } matrix = new ChartDataModel(m);
The length of sub-arrays or size of sub-collections must be the same, since the count of columns is determined from the sub-array or sub-collection size.
Use DataSetConverter to convert table-like arrays and collections to the model representation
data - data collection which has to be added to the model| Method Detail |
|---|
public int getPointCount(MatrixDimensions dimension)
MatrixDataModel
dimension - dimension of the matrix
public java.lang.Object getValueAt(DataColumnType valType,
int row,
int column)
MatrixDataModel
valType - data column typerow - row of the matrixcolumn - column of the matrix
public java.lang.Object getValueAt(DataColumnType valType,
int index)
ArrayDataModel
valType - data column type (KEY, VALUE and etc.)index - data value index in the data modelpublic int getPointCount()
ArrayDataModel
public void setValueAt(DataColumnType valType,
int index,
java.lang.Object value)
ArrayDataModel
valType - data column type (KEY, VALUE and etc.)index - data value index in the data modelvalue - value to set
public void setValueAt(DataColumnType valType,
int row,
int column,
java.lang.Object value)
MatrixDataModel
valType - data column typerow - row number of the matrixcolumn - column number of the matrixvalue - value to set to the specified pointpublic void add(java.lang.Object[] values)
values - data values in
public void addKeyValues(java.lang.Object key,
java.lang.Object[] values)
key - keyvalues - array of valuespublic boolean containsKey(java.lang.Object key)
key - true if data model contains given key
public void add(DataColumnType[] valType,
java.lang.Object[] values)
values - data values invalType - array specifying order of values in the values array.public void remove(int index)
index - index of data point to removepublic void removeAll()
protected void finalize()
throws java.lang.Throwable
finalize in class java.lang.Objectjava.lang.Throwablepublic boolean hasColumn(DataColumnType columnType)
DataModel
columnType - data column typetrue if column with the given type exists.
|
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||