org.odftoolkit.simple.chart
Class DataSet

java.lang.Object
  extended by org.odftoolkit.simple.chart.DataSet

public class DataSet
extends Object

DataSet is wrapper class for chart data. Generally it is a 2 dimensional data container, a set of chart data series. Each data series has a key, i.e. chart label. The data may be a 2 dimensional double array, or a cell range address of a sheet in Spreadsheet document. DataSet provides some convenient methods for users to manipulate specific data series in the chart data.

Since:
0.6

Constructor Summary
DataSet()
          Creates a new DataSet without argument.
DataSet(CellRangeAddressList cellRangeAddress, SpreadsheetDocument spreadsheet, boolean bFirstRowAsLabel, boolean bFirstColumnAsLabel, boolean rowAsDataSeries)
          Creates a new DataSet.
DataSet(String[] labels, String[] legends, double[][] data)
          Creates a new DataSet.
 
Method Summary
 void appendDataSeries(String legend, double[] values)
          Adds a data series at the end of current data set.
 CellRangeAddressList getCellRangeAddress()
          Gets the cell range address list.
 double[] getDataSeriesByIndex(int index)
          Gets the values of a data series by its index in the data set.
 double[] getDataSeriesByLegend(String legend, int beginindex)
          Gets the values of a data series by its legend, if multiple data series have duplicated legends, return the values of the first matched data series.
 int getDataSeriesCount()
          Gets the count of data series in the data set.
 int getIndexOfDataSeries(String legend, int beginindex)
          Gets the index of the data series by its legend.
 String getLabelByIndex(int index)
          Gets the legend of the data series by its index in the data set.
 String[] getLabels()
          Gets the string array of labels.
 String getLegendByIndex(int index)
          Gets the legend of the data series by its index in the data set.
 String[] getLegends()
          Gets the string array of legends.
 int getLengthOfDataSeries(int index)
          Gets the data item count of the data series given by the index.
 int getLengthOfDataSeries(String legend, int beginindex)
          Gets the data item count of the data series given by the label.
 String getLocalTableCellRanges(int seriesCount, int labelLength, Vector<String> seriesCellRange, Vector<String> legendCellAddr)
          Gets the local table cell range.
 Double[][] getLocalTableData()
          Gets the values of a data set as a double dimension array.
 String[] getLocalTableFirstColumn()
          Gets the first column labels of the local table.
 String[] getLocalTableFirstRow()
          Gets the first row labels of the local table.
 int getMaxLengthOfDataSeries()
          Gets the maximal data item count
 void insertDataSeries(int index, String legend, double[] values)
          Adds a data series at the index in current data set.
 boolean isFirstColumnAsLabel()
          Gets whether this data set uses first column as chart label.
 boolean isFirstRowAsLabel()
          Gets whether this data set uses first row as chart label.
 boolean isLocalTable()
          Gets whether this data set uses local table.
 boolean isRowAsDataSeries()
          Gets whether this data set uses row as data series.
 void removeDataSeries(int index)
          Removes a data series by the index of the data series in the data set.
 void removeDataSeries(String legend, int beginindex)
          Remove a data series by the legend of the data series.
 void setLabelByIndex(int index, String label)
          Sets or change the legend of the data series by its index in the data set.
 void setLegendByIndex(int index, String legend)
          Sets or change the legend of the data series by its index in the data set.
 void setLocalTable(boolean isLocalTable)
          Sets this data set uses local table or not.
 void setValues(CellRangeAddressList cellRangeAddress, SpreadsheetDocument spreadsheet, boolean bFirstRowAsLabel, boolean bFirstColumnAsLabel, boolean rowAsDataSeries)
          Sets data for the data set with cell range address of sheet in spreadsheet document or internal chart table in other chart containers.
 void setValues(String[] labels, String[] legends, double[][] data)
          Sets or updates data for the data set with 2 dimensional double array, the first dimension represents the index of data series, the second dimension represents the index of data item in each data series.
 void updateDataSeries(int index, double[] values)
          Updates the data series values according to the index of the data series.
 void updateDataSeries(String legend, int beginindex, double[] values)
          Updates the data series values according to the legend of the data series.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

DataSet

public DataSet()
Creates a new DataSet without argument.


DataSet

public DataSet(String[] labels,
               String[] legends,
               double[][] data)
Creates a new DataSet.

Parameters:
labels - the label strings of this DataSet.
legends - the legend strings of this DataSet.
data - the data of this DataSet, which stores in 2 dimensional double array.

DataSet

public DataSet(CellRangeAddressList cellRangeAddress,
               SpreadsheetDocument spreadsheet,
               boolean bFirstRowAsLabel,
               boolean bFirstColumnAsLabel,
               boolean rowAsDataSeries)
Creates a new DataSet.

Parameters:
cellRangeAddress - the cell range address, which is used as the data source.
spreadsheet - the data source SpreadsheetDocument.
bFirstRowAsLabel - whether this data set uses first row as chart label.
bFirstColumnAsLabel - whether this data set uses first column as chart label.
rowAsDataSeries - whether this data set uses row as data series.
Method Detail

getLocalTableCellRanges

public String getLocalTableCellRanges(int seriesCount,
                                      int labelLength,
                                      Vector<String> seriesCellRange,
                                      Vector<String> legendCellAddr)
Gets the local table cell range.

Returns:
the local table cell range,

getCellRangeAddress

public CellRangeAddressList getCellRangeAddress()
Gets the cell range address list.

Returns:
the cell range address list.

appendDataSeries

public void appendDataSeries(String legend,
                             double[] values)
Adds a data series at the end of current data set.

Parameters:
legend - legend for the data series.
values - data series values corresponding to the legend.

insertDataSeries

public void insertDataSeries(int index,
                             String legend,
                             double[] values)
Adds a data series at the index in current data set.

Parameters:
index - the index the added data series will be located.
legend - legend for the data series.
values - data series values corresponding to the legend.

updateDataSeries

public void updateDataSeries(int index,
                             double[] values)
Updates the data series values according to the index of the data series.

Parameters:
index - the index of the data series in the data set.
values - data series values.

updateDataSeries

public void updateDataSeries(String legend,
                             int beginindex,
                             double[] values)
Updates the data series values according to the legend of the data series.

Parameters:
legend - the chart legend of the data series.
values - data series values.

removeDataSeries

public void removeDataSeries(int index)
Removes a data series by the index of the data series in the data set.

Parameters:
index - index of the data series in the data set.

removeDataSeries

public void removeDataSeries(String legend,
                             int beginindex)
Remove a data series by the legend of the data series.

Parameters:
legend - the legend of the data series.

getIndexOfDataSeries

public int getIndexOfDataSeries(String legend,
                                int beginindex)
Gets the index of the data series by its legend.

Parameters:
legend - the legend of the data series.
Returns:
index of the data series in the data set.

getLegendByIndex

public String getLegendByIndex(int index)
Gets the legend of the data series by its index in the data set.

Parameters:
index - index of the data series in the data set.
Returns:
the legend of the data series.

setLegendByIndex

public void setLegendByIndex(int index,
                             String legend)
Sets or change the legend of the data series by its index in the data set.

Parameters:
index - index of the data series in the data set.
legend - the legend of the data series.

getLabelByIndex

public String getLabelByIndex(int index)
Gets the legend of the data series by its index in the data set.

Parameters:
index - index of the data series in the data set.
Returns:
the label of the data series.

setLabelByIndex

public void setLabelByIndex(int index,
                            String label)
Sets or change the legend of the data series by its index in the data set.

Parameters:
index - index of the data series in the data set.
label - the label of the data series.

getLabels

public String[] getLabels()
Gets the string array of labels.

Returns:
the string array of labels.

getLegends

public String[] getLegends()
Gets the string array of legends.

Returns:
the string array of legends.

isFirstRowAsLabel

public boolean isFirstRowAsLabel()
Gets whether this data set uses first row as chart label.

Returns:
if return true, this data set uses first row as chart label.

isFirstColumnAsLabel

public boolean isFirstColumnAsLabel()
Gets whether this data set uses first column as chart label.

Returns:
if return true, this data set uses first row as chart label.

isRowAsDataSeries

public boolean isRowAsDataSeries()
Gets whether this data set uses row as data series.

Returns:
if return true, this data set uses row as data series.

isLocalTable

public boolean isLocalTable()
Gets whether this data set uses local table.

Returns:
if return true, this data set uses uses local table.

setLocalTable

public void setLocalTable(boolean isLocalTable)
Sets this data set uses local table or not.

Parameters:
isLocalTable - if the value is true, this data set uses uses local table.

getDataSeriesByIndex

public double[] getDataSeriesByIndex(int index)
Gets the values of a data series by its index in the data set.

Parameters:
index - index of the data series in the data set.
Returns:
the values of the data series.

getDataSeriesByLegend

public double[] getDataSeriesByLegend(String legend,
                                      int beginindex)
Gets the values of a data series by its legend, if multiple data series have duplicated legends, return the values of the first matched data series. we do not recommend the duplicated legends, but practically, some ODF editors allow users to do that.

Parameters:
legend - the legend of the data series
Returns:
the values of the data series

getLocalTableData

public Double[][] getLocalTableData()
Gets the values of a data set as a double dimension array.

Returns:
the values of the whole data set.

getLocalTableFirstRow

public String[] getLocalTableFirstRow()
Gets the first row labels of the local table.

Returns:
the first row labels of the local table.

getLocalTableFirstColumn

public String[] getLocalTableFirstColumn()
Gets the first column labels of the local table.

Returns:
the first column labels of the local table.

getLengthOfDataSeries

public int getLengthOfDataSeries(int index)
Gets the data item count of the data series given by the index.

Parameters:
index - index of the data series in the data set
Returns:
the data item count of the data series

getLengthOfDataSeries

public int getLengthOfDataSeries(String legend,
                                 int beginindex)
Gets the data item count of the data series given by the label.

Parameters:
legend - the legend of the data series
Returns:
the data item count of the data series

getMaxLengthOfDataSeries

public int getMaxLengthOfDataSeries()
Gets the maximal data item count

Returns:
the maximal data item count

getDataSeriesCount

public int getDataSeriesCount()
Gets the count of data series in the data set.

Returns:
the count of data series

setValues

public void setValues(String[] labels,
                      String[] legends,
                      double[][] data)
Sets or updates data for the data set with 2 dimensional double array, the first dimension represents the index of data series, the second dimension represents the index of data item in each data series.

Parameters:
labels - the chart labels, which is corresponding to the first dimension of data array.
data - a 2 dimensional double array.

setValues

public void setValues(CellRangeAddressList cellRangeAddress,
                      SpreadsheetDocument spreadsheet,
                      boolean bFirstRowAsLabel,
                      boolean bFirstColumnAsLabel,
                      boolean rowAsDataSeries)
Sets data for the data set with cell range address of sheet in spreadsheet document or internal chart table in other chart containers.

Parameters:
cellRangeAddress - cell range address of sheet or table.
spreadsheet - the spreadsheet document instance, the cell address is relative to the spreadsheet document.
bFirstRowAsLabel - whether this data set uses first row as chart label.
bFirstColumnAsLabel - whether this data set uses first column as chart label.
rowAsDataSeries - whether this data set uses row as data series.


Copyright © 2010-2017 The Apache Software Foundation. All Rights Reserved.