|
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||
java.lang.Object | +--net.sourceforge.chart2d.Dataset
The container for the data values to chart.
A dataset is like a third order array (ex. float[][][]). The first order is
the "sets" order. A set contains data divided by category. The "sets" refer
to the objects described by the legend labels, if a legend exists. The
second order is the "cats" or categories order. Data within a set can be
divided by category. A category can have multiple data items. If using a
graph chart, the categories are described by the labels-axis labels. For pie
charts, there is only one category. The third order is the "items" order.
The "items" order are the values for a particular category and set. For
example, if we had data for the years 1999 and 2000 of how many units were
sold on each day during that time, then one way to chart this would be using
a graph chart and making the years correspond to the "sets" order, "months",
correspond to the "cats" order, and the number of units sold per day
correspond to the "items" order.
There are two important rules to
mention about this. For each set, the number of cats must be the same. For
each cat, the number of items must be the same. In our example, we would
probably want to choose the number of items per category to be 30,
corresponding the average number of days per month. For months with less
than thirdy days, we would populate the unfilled days with the average of the
filled days or simply carry the last value of the filled days into the
unfilled days. For months with more than thirty days, we would average the
last two days, and use that value as the value of the last day.
To create a new dataset, use one of its constructors.
To populate it with data, use its set method.
Pass the container to any number of GraphProperties or PieChart2DProperties
classes using their setDataset method.
If passing to a PieChart2DProperties, the value used for each pie sector is
the sum of the values in each set of data.
| Field Summary | |
static boolean |
VALIDATE_ON_UPDATE_DEFAULT
The default is true. |
| Constructor Summary | |
Dataset()
Creates a dataset with 0 sets, 0 categories, and 0 items. |
|
Dataset(Dataset dataset)
Creates a dataset that is a copy of another dataset. |
|
Dataset(int sets,
int cats,
int items)
Creates a dataset with the specified number of sets, categories per set, and items per set and per category. |
|
| Method Summary | |
(package private) void |
addChart2D(Chart2D chart2D)
Adds a Chart2D object to the set of objects that are using this properties object. |
void |
convertToStacked()
Converts the dataset for use in "stacked" charts. |
float |
get(int set,
int cat,
int item)
Returns the value for the variable in the set specified by set, the category specified by cat within the set, and the item specified by item within the category. |
(package private) boolean |
getChart2DNeedsUpdate(Chart2D chart2D)
Gets whether this Chart2D object hasn't been updated with changes that have been made since its last udpate. |
java.util.Vector |
getChart2DVector()
Returns the vector of Chart2D objects that are using this object. |
float |
getGreatest()
Returns the greatest value of all the data in the datset. |
float |
getLeast()
Returns the least value of all the data in the datset. |
int |
getNumCats()
Returns the number of categories per set of data in this dataset. |
int |
getNumItems()
Returns the number of items per category of data in this dataset. |
int |
getNumSets()
Returns the number of sets of data in this dataset. |
(package private) float[][] |
getOldGraphStruct()
Returns a float[][] representation of this dataset for use by GraphChartArea. |
(package private) float[] |
getOldPieStruct()
Returns a float[] representation of this dataset for use by PieChartArea. |
boolean |
getValidateOnUpdate()
Returns whether the dataset should be validated whenever a chart is to be updated. |
void |
remove(int set,
int cat,
int item)
Removes values from the dataset. |
(package private) void |
removeChart2D(Chart2D chart2D)
Removes a Chart2D object from the set of objects that are using this properties object. |
void |
set(Dataset dataset)
Specifies all the values of this dataset from another Dataset. |
void |
set(int set,
int cat,
int item,
float value)
Specifies the value for the variable in the set specified by set, the category specified by cat within the set, and the item specified by item within the category. |
void |
setDatasetToDefaults()
Specifies the dataset should be set to its default state. |
void |
setValidateOnUpdate(boolean validate)
Returns whether the dataset should be validated whenever a chart is to be updated. |
void |
shiftLower(float[] values)
Shifts all the data items one place, from the higher order to the lower order, replacing the highest order items with the specified items. |
(package private) void |
updateChart2D(Chart2D chart2D)
Updates this Chart2D object with any changes that have been made since its last udpate. |
boolean |
validate(boolean debug)
Validates the dataset, printing a debug message if indicated. |
| Methods inherited from class java.lang.Object |
|
| Field Detail |
public static boolean VALIDATE_ON_UPDATE_DEFAULT
| Constructor Detail |
public Dataset()
public Dataset(int sets,
int cats,
int items)
sets - The number of sets.cats - The number of categories per set.items - The number of items per category and per set.public Dataset(Dataset dataset)
dataset - The dataset to copy.| Method Detail |
public void setDatasetToDefaults()
public void set(int set,
int cat,
int item,
float value)
set - The specified set of the variable.cat - The specified cat of the variable.item - The specified item of the variable.value - The specified value of the variable.public void set(Dataset dataset)
dataset - The Dataset to copy.public void convertToStacked()
public void setValidateOnUpdate(boolean validate)
validate - If true, then the properties will be validated every time
they are used to update a chart.public java.util.Vector getChart2DVector()
public float get(int set,
int cat,
int item)
set - The specified set of the variable.cat - The specified cat of the variable.item - The specified item of the variable.public int getNumSets()
public int getNumCats()
public int getNumItems()
public float getGreatest()
public float getLeast()
public boolean getValidateOnUpdate()
public void remove(int set,
int cat,
int item)
set - The set of data within which data is to be removed.cat - The cat of data within which data is to be removed.item - The item of data that is to be removed.public void shiftLower(float[] values)
values - An array of values of length getNumSets() to shift in.public boolean validate(boolean debug)
debug - If true, a short message will be printed to standard out.float[][] getOldGraphStruct()
float[] getOldPieStruct()
boolean getChart2DNeedsUpdate(Chart2D chart2D)
chart2D - The Chart2D object that may need to be updated.void updateChart2D(Chart2D chart2D)
chart2D - The Chart2D object that will be updated.void addChart2D(Chart2D chart2D)
chart2D - The Chart2D object that will have these properties.void removeChart2D(Chart2D chart2D)
chart2D - The Chart2D object to disassociate from these properties.
|
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||