Class DatasetUtilities
public final class DatasetUtilities extends Object
- 
Method Summary
Modifier and Type Method Description static doublecalculatePieDatasetTotal(PieDataset dataset)Calculates the total of all the values in aPieDataset.static CategoryDatasetcreateCategoryDataset(String[] rowKeys, String[] columnKeys, double[][] data)Creates aCategoryDatasetthat contains a copy of the data in an array (instances ofDoubleare created to represent the data items).static CategoryDatasetcreateCategoryDataset(String rowKeyPrefix, String columnKeyPrefix, double[][] data)Creates aCategoryDatasetthat contains a copy of the data in an array (instances ofDoubleare created to represent the data items).static CategoryDatasetcreateCategoryDataset(String rowKeyPrefix, String columnKeyPrefix, Number[][] data)Creates aCategoryDatasetthat contains a copy of the data in an array.static CategoryDatasetcreateCategoryDataset(String rowKey, KeyedValues rowData)Creates aCategoryDatasetby copying the data from the suppliedKeyedValuesinstance.static Number[]createNumberArray(double[] data)Constructs an array ofNumberobjects from an array ofdoubleprimitives.static Number[][]createNumberArray2D(double[][] data)Constructs an array of arrays ofNumberobjects from a corresponding structure containingdoubleprimitives.static PieDatasetcreatePieDatasetForColumn(CategoryDataset data, int column)Creates a pie dataset from a table dataset by taking all the values for a single column.static PieDatasetcreatePieDatasetForColumn(CategoryDataset data, Comparable columnKey)Creates a pie dataset from a table dataset by taking all the values for a single column.static PieDatasetcreatePieDatasetForRow(CategoryDataset data, int row)Creates a pie dataset from a table dataset by taking all the values for a single row.static PieDatasetcreatePieDatasetForRow(CategoryDataset data, Comparable rowKey)Creates a pie dataset from a table dataset by taking all the values for a single row.static RangegetCumulativeRangeExtent(CategoryDataset dataset)Calculates the range of values for a dataset where each item is the running total of the items for the current series.static RangegetDomainExtent(Dataset dataset)Returns the range of values in the domain for the dataset.static NumbergetMaximumDomainValue(Dataset data)Returns the maximum domain value for the specified dataset.static NumbergetMaximumRangeValue(Dataset data)Returns the maximum range value for the specified dataset.static NumbergetMaximumStackedRangeValue(CategoryDataset data)Returns the maximum value in the dataset range, assuming that values in each category are "stacked".static NumbergetMinimumDomainValue(Dataset data)Returns the minimum domain value for the specified dataset.static NumbergetMinimumRangeValue(Dataset data)Returns the minimum range value for the specified dataset.static NumbergetMinimumStackedRangeValue(CategoryDataset data)Returns the minimum value in the dataset range, assuming that values in each category are "stacked".static RangegetRangeExtent(Dataset data)Returns the range of values in the range for the dataset.static RangegetStackedRangeExtent(CategoryDataset data)Returns the minimum and maximum values for the dataset's range (as in domain/range), assuming that the series in one category are stacked.static RangegetStackedRangeExtent(CategoryDataset dataset, KeyToGroupMap map)Returns the minimum and maximum values for the dataset's range (as in domain/range), assuming that the series in one category are stacked.static RangegetStackedRangeExtent(TableXYDataset data)Returns the minimum and maximum values for the dataset's range, assuming that the series are stacked.static booleanisEmptyOrNull(CategoryDataset data)Returnstrueif the dataset is empty (ornull), andfalseotherwise.static booleanisEmptyOrNull(PieDataset dataset)Returnstrueif the dataset is empty (ornull), andfalseotherwise.static booleanisEmptyOrNull(XYDataset data)Returnstrueif the dataset is empty (ornull), andfalseotherwise.static RangeiterateCategoryRangeExtent(CategoryDataset data)Iterates over the data item of the category dataset to find the range extent.static RangeiterateDomainExtent(XYDataset data)Iterates over the data item of the xy dataset to find the domain extent.static RangeiterateXYRangeExtent(XYDataset data)Iterates over the data item of the xy dataset to find the range extent.static PieDatasetlimitPieDataset(PieDataset dataset, double percentThreshold)Creates an "Other" slice for percentages below the percent threshold.static PieDatasetlimitPieDataset(PieDataset dataset, double percentThreshold, int minItems)Create an "Other" slice for percentages below the percent threshold providing there are more slices below the percent threshold than specified in the slice threshold.static PieDatasetlimitPieDataset(PieDataset dataset, double percentThreshold, int minItems, Comparable key)Creates a new pie dataset based on the supplied dataset, but modified by aggregating all the low value items (those whose value is lower than the percentThreshold) into a single item.static XYDatasetsampleFunction2D(Function2D f, double start, double end, int samples, String seriesName)Creates anXYDatasetby sampling the specified function over a fixed range. 
- 
Method Details
- 
createNumberArray
Constructs an array ofNumberobjects from an array ofdoubleprimitives.- Parameters:
 data- the data.- Returns:
 - an array of 
Double. 
 - 
createNumberArray2D
Constructs an array of arrays ofNumberobjects from a corresponding structure containingdoubleprimitives.- Parameters:
 data- the data.- Returns:
 - an array of 
Double. 
 - 
getDomainExtent
Returns the range of values in the domain for the dataset.If the supplied dataset is
null, the range returned isnull.- Parameters:
 dataset- the dataset (nullpermitted).- Returns:
 - The range of values (possibly 
null). 
 - 
iterateDomainExtent
Iterates over the data item of the xy dataset to find the domain extent.- Parameters:
 data- the xy dataset to iterate over.- Returns:
 - the domain extent of the data within the dataset.
 
 - 
getRangeExtent
Returns the range of values in the range for the dataset. This method is the partner for the getDomainExtent method.- Parameters:
 data- the dataset.- Returns:
 - the range of values in the range for the dataset.
 
 - 
iterateCategoryRangeExtent
Iterates over the data item of the category dataset to find the range extent.- Parameters:
 data- the category dataset to iterate over.- Returns:
 - the range extent of the data within the dataset.
 
 - 
iterateXYRangeExtent
Iterates over the data item of the xy dataset to find the range extent.- Parameters:
 data- the xy dataset to iterate over.- Returns:
 - the range extent of the data within the dataset.
 
 - 
getMinimumDomainValue
Returns the minimum domain value for the specified dataset.This is easy if the dataset implements the DomainInfo interface (a good idea if there is an efficient way to determine the minimum value). Otherwise, it involves iterating over the entire data-set.
Returns null if all the data values in the dataset are null.
- Parameters:
 data- the dataset.- Returns:
 - the minimum domain value in the dataset (or null).
 
 - 
getMaximumDomainValue
Returns the maximum domain value for the specified dataset.This is easy if the dataset implements the DomainInfo interface (a good idea if there is an efficient way to determine the maximum value). Otherwise, it involves iterating over the entire data-set.
Returns null if all the data values in the dataset are null.
- Parameters:
 data- the dataset.- Returns:
 - the maximum domain value in the dataset (or null).
 
 - 
getMinimumRangeValue
Returns the minimum range value for the specified dataset.This is easy if the dataset implements the RangeInfo interface (a good idea if there is an efficient way to determine the minimum value). Otherwise, it involves iterating over the entire data-set.
Returns null if all the data values in the dataset are null.
- Parameters:
 data- the dataset.- Returns:
 - the minimum range value in the dataset (or null).
 
 - 
getMaximumRangeValue
Returns the maximum range value for the specified dataset.This is easy if the dataset implements the RangeInfo interface (a good idea if there is an efficient way to determine the maximum value). Otherwise, it involves iterating over the entire data-set.
Returns null if all the data values are null.
- Parameters:
 data- the dataset.- Returns:
 - the maximum range value in the dataset (or null).
 
 - 
createPieDatasetForRow
Creates a pie dataset from a table dataset by taking all the values for a single row.- Parameters:
 data- the data.rowKey- the row key.- Returns:
 - a pie dataset.
 
 - 
createPieDatasetForRow
Creates a pie dataset from a table dataset by taking all the values for a single row.- Parameters:
 data- the data.row- the row (zero-based index).- Returns:
 - a pie dataset.
 
 - 
createPieDatasetForColumn
Creates a pie dataset from a table dataset by taking all the values for a single column.- Parameters:
 data- the data.columnKey- the column key.- Returns:
 - a pie dataset.
 
 - 
createPieDatasetForColumn
Creates a pie dataset from a table dataset by taking all the values for a single column.- Parameters:
 data- the data.column- the column (zero-based index).- Returns:
 - a pie dataset.
 
 - 
calculatePieDatasetTotal
Calculates the total of all the values in aPieDataset. If the dataset contains negative ornullvalues, they are ignored.- Parameters:
 dataset- the dataset (nullnot permitted).- Returns:
 - The total.
 
 - 
getStackedRangeExtent
Returns the minimum and maximum values for the dataset's range (as in domain/range), assuming that the series in one category are stacked.- Parameters:
 data- the dataset.- Returns:
 - the value range.
 
 - 
getStackedRangeExtent
Returns the minimum and maximum values for the dataset's range (as in domain/range), assuming that the series in one category are stacked.- Parameters:
 dataset- the dataset.map- a structure that maps series to groups.- Returns:
 - the value range.
 
 - 
getMinimumStackedRangeValue
Returns the minimum value in the dataset range, assuming that values in each category are "stacked".- Parameters:
 data- the dataset.- Returns:
 - the minimum value.
 
 - 
getMaximumStackedRangeValue
Returns the maximum value in the dataset range, assuming that values in each category are "stacked".- Parameters:
 data- the dataset (nullpermitted).- Returns:
 - The maximum value (possibly 
null). 
 - 
sampleFunction2D
public static XYDataset sampleFunction2D(Function2D f, double start, double end, int samples, String seriesName)Creates anXYDatasetby sampling the specified function over a fixed range.- Parameters:
 f- the function (nullnot permitted).start- the start value for the range.end- the end value for the range.samples- the number of sample points (must be > 1).seriesName- the name to give the resulting series (nullnot permitted).- Returns:
 - A dataset.
 
 - 
createCategoryDataset
public static CategoryDataset createCategoryDataset(String rowKeyPrefix, String columnKeyPrefix, double[][] data)Creates aCategoryDatasetthat contains a copy of the data in an array (instances ofDoubleare created to represent the data items).Row and column keys are created by appending 0, 1, 2, ... to the supplied prefixes.
- Parameters:
 rowKeyPrefix- the row key prefix.columnKeyPrefix- the column key prefix.data- the data.- Returns:
 - the dataset.
 
 - 
createCategoryDataset
public static CategoryDataset createCategoryDataset(String rowKeyPrefix, String columnKeyPrefix, Number[][] data)Creates aCategoryDatasetthat contains a copy of the data in an array.Row and column keys are created by appending 0, 1, 2, ... to the supplied prefixes.
- Parameters:
 rowKeyPrefix- the row key prefix.columnKeyPrefix- the column key prefix.data- the data.- Returns:
 - the dataset.
 
 - 
createCategoryDataset
public static CategoryDataset createCategoryDataset(String[] rowKeys, String[] columnKeys, double[][] data)Creates aCategoryDatasetthat contains a copy of the data in an array (instances ofDoubleare created to represent the data items).Row and column keys are taken from the supplied arrays.
- Parameters:
 rowKeys- the row keys.columnKeys- the column keys.data- the data.- Returns:
 - The dataset.
 
 - 
createCategoryDataset
Creates aCategoryDatasetby copying the data from the suppliedKeyedValuesinstance.- Parameters:
 rowKey- the row key.rowData- the row data.- Returns:
 - A dataset.
 
 - 
isEmptyOrNull
Returnstrueif the dataset is empty (ornull), andfalseotherwise.- Parameters:
 data- the dataset (nullpermitted).- Returns:
 - A boolean.
 
 - 
isEmptyOrNull
Returnstrueif the dataset is empty (ornull), andfalseotherwise.- Parameters:
 dataset- the dataset (nullpermitted).- Returns:
 - a boolean.
 
 - 
isEmptyOrNull
Returnstrueif the dataset is empty (ornull), andfalseotherwise.- Parameters:
 data- the dataset (nullpermitted).- Returns:
 - A boolean.
 
 - 
limitPieDataset
Creates an "Other" slice for percentages below the percent threshold.- Parameters:
 dataset- the PieDataset.percentThreshold- the percent threshold.- Returns:
 - A PieDataset.
 
 - 
limitPieDataset
public static PieDataset limitPieDataset(PieDataset dataset, double percentThreshold, int minItems)Create an "Other" slice for percentages below the percent threshold providing there are more slices below the percent threshold than specified in the slice threshold.- Parameters:
 dataset- the source dataset.percentThreshold- the percent threshold (ten percent is 0.10).minItems- only aggregate low values if there are at least this many.- Returns:
 - A PieDataset.
 
 - 
limitPieDataset
public static PieDataset limitPieDataset(PieDataset dataset, double percentThreshold, int minItems, Comparable key)Creates a new pie dataset based on the supplied dataset, but modified by aggregating all the low value items (those whose value is lower than the percentThreshold) into a single item. The aggregated items are assigned the specified key. Aggregation only occurs if there are at least minItems items to aggregate.- Parameters:
 dataset- the source dataset.percentThreshold- the percent threshold (ten percent is 0.10).minItems- only aggregate low values if there are at least this many.key- the key to represent the aggregated items.- Returns:
 - The pie dataset with (possibly) aggregated items.
 
 - 
getStackedRangeExtent
Returns the minimum and maximum values for the dataset's range, assuming that the series are stacked.- Parameters:
 data- the dataset.- Returns:
 - the value range.
 
 - 
getCumulativeRangeExtent
Calculates the range of values for a dataset where each item is the running total of the items for the current series.- Parameters:
 dataset- the dataset.- Returns:
 - The range.
 
 
 -