@Test public void testCumulativeRange3() { DefaultCategoryDataset dataset = new DefaultCategoryDataset(); dataset.addValue(15.76, "Product 1", "Labour"); dataset.addValue(8.66, "Product 1", "Administration"); dataset.addValue(4.71, "Product 1", "Marketing"); dataset.addValue(3.51, "Product 1", "Distribution"); dataset.addValue(32.64, "Product 1", "Total Expense"); Range range = DatasetUtilities.findCumulativeRangeBounds(dataset); assertEquals(0.0, range.getLowerBound(), EPSILON); assertEquals(65.28, range.getUpperBound(), EPSILON); }
public static Range findCumulativeRangeBounds(CategoryDataset dataset) { ParamChecks.nullNotPermitted(dataset, "dataset"); boolean allItemsNull = true; double minimum = 0.0; double maximum = 0.0; for (int row = 0; row < dataset.getRowCount(); row++) { double runningTotal = 0.0; for (int column = 0; column <= dataset.getColumnCount() - 1; column++) { Number n = dataset.getValue(row, column); if (n != null) { allItemsNull = false; double value = n.doubleValue(); if (!Double.isNaN(value)) { runningTotal = runningTotal + value; minimum = Math.min(minimum, runningTotal); maximum = Math.max(maximum, runningTotal); } } } } if (!allItemsNull) { return new Range(minimum, maximum); } else { return null; } }
DatasetUtilities { public static Range findCumulativeRangeBounds(CategoryDataset dataset) { ParamChecks.nullNotPermitted(dataset, "dataset"); boolean allItemsNull = true; double minimum = 0.0; double maximum = 0.0; for (int row = 0; row < dataset.getRowCount(); row++) { double runningTotal = 0.0; for (int column = 0; column <= dataset.getColumnCount() - 1; column++) { Number n = dataset.getValue(row, column); if (n != null) { allItemsNull = false; double value = n.doubleValue(); if (!Double.isNaN(value)) { runningTotal = runningTotal + value; minimum = Math.min(minimum, runningTotal); maximum = Math.max(maximum, runningTotal); } } } } if (!allItemsNull) { return new Range(minimum, maximum); } else { return null; } } }
DatasetUtilities { public static Range findCumulativeRangeBounds(CategoryDataset dataset) { ParamChecks.nullNotPermitted(dataset, "dataset"); boolean allItemsNull = true; double minimum = 0.0; double maximum = 0.0; for (int row = 0; row < dataset.getRowCount(); row++) { double runningTotal = 0.0; for (int column = 0; column <= dataset.getColumnCount() - 1; column++) { Number n = dataset.getValue(row, column); if (n != null) { allItemsNull = false; double value = n.doubleValue(); if (!Double.isNaN(value)) { runningTotal = runningTotal + value; minimum = Math.min(minimum, runningTotal); maximum = Math.max(maximum, runningTotal); } } } } if (!allItemsNull) { return new Range(minimum, maximum); } else { return null; } } private  DatasetUtilities(); }
DatasetUtilities { public static Range findCumulativeRangeBounds(CategoryDataset dataset) { ParamChecks.nullNotPermitted(dataset, "dataset"); boolean allItemsNull = true; double minimum = 0.0; double maximum = 0.0; for (int row = 0; row < dataset.getRowCount(); row++) { double runningTotal = 0.0; for (int column = 0; column <= dataset.getColumnCount() - 1; column++) { Number n = dataset.getValue(row, column); if (n != null) { allItemsNull = false; double value = n.doubleValue(); if (!Double.isNaN(value)) { runningTotal = runningTotal + value; minimum = Math.min(minimum, runningTotal); maximum = Math.max(maximum, runningTotal); } } } } if (!allItemsNull) { return new Range(minimum, maximum); } else { return null; } } private  DatasetUtilities(); static double calculatePieDatasetTotal(PieDataset dataset); static PieDataset createPieDatasetForRow(CategoryDataset dataset,
                                                    Comparable rowKey); static PieDataset createPieDatasetForRow(CategoryDataset dataset,
                                                    int row); static PieDataset createPieDatasetForColumn(CategoryDataset dataset,
                                                       Comparable columnKey); static PieDataset createPieDatasetForColumn(CategoryDataset dataset,
                                                       int column); static PieDataset createConsolidatedPieDataset(PieDataset source,
            Comparable key, double minimumPercent); static PieDataset createConsolidatedPieDataset(PieDataset source,
            Comparable key, double minimumPercent, int minItems); static CategoryDataset createCategoryDataset(String rowKeyPrefix,
            String columnKeyPrefix, double[][] data); static CategoryDataset createCategoryDataset(String rowKeyPrefix,
            String columnKeyPrefix, Number[][] data); static CategoryDataset createCategoryDataset(Comparable[] rowKeys,
            Comparable[] columnKeys, double[][] data); static CategoryDataset createCategoryDataset(Comparable rowKey,
                                                        KeyedValues rowData); static XYDataset sampleFunction2D(Function2D f, double start,
            double end, int samples, Comparable seriesKey); static XYSeries sampleFunction2DToSeries(Function2D f,
            double start, double end, int samples, Comparable seriesKey); static boolean isEmptyOrNull(PieDataset dataset); static boolean isEmptyOrNull(CategoryDataset dataset); static boolean isEmptyOrNull(XYDataset dataset); static Range findDomainBounds(XYDataset dataset); static Range findDomainBounds(XYDataset dataset,
                                         boolean includeInterval); static Range findDomainBounds(XYDataset dataset,
            List<Comparable> visibleSeriesKeys, boolean includeInterval); static Range iterateDomainBounds(XYDataset dataset); static Range iterateDomainBounds(XYDataset dataset,
                                            boolean includeInterval); static Range findRangeBounds(CategoryDataset dataset); static Range findRangeBounds(CategoryDataset dataset,
                                        boolean includeInterval); static Range findRangeBounds(CategoryDataset dataset,
            List<Comparable> visibleSeriesKeys, boolean includeInterval); static Range findRangeBounds(XYDataset dataset); static Range findRangeBounds(XYDataset dataset,
                                        boolean includeInterval); static Range findRangeBounds(XYDataset dataset,
            List<Comparable> visibleSeriesKeys, Range xRange, boolean includeInterval); static Range iterateRangeBounds(CategoryDataset dataset); static Range iterateRangeBounds(CategoryDataset dataset,
            boolean includeInterval); static Range iterateToFindRangeBounds(CategoryDataset dataset,
            List<Comparable> visibleSeriesKeys, boolean includeInterval); static Range iterateRangeBounds(XYDataset dataset); static Range iterateRangeBounds(XYDataset dataset,
            boolean includeInterval); static Range findZBounds(XYZDataset dataset); static Range findZBounds(XYZDataset dataset,
                                        boolean includeInterval); static Range findZBounds(XYZDataset dataset,
            List<Comparable> visibleSeriesKeys, Range xRange, boolean includeInterval); static Range iterateZBounds(XYZDataset dataset); static Range iterateZBounds(XYZDataset dataset,
            boolean includeInterval); static Range iterateToFindDomainBounds(XYDataset dataset,
            List<Comparable> visibleSeriesKeys, boolean includeInterval); static Range iterateToFindRangeBounds(XYDataset dataset,
            List<Comparable> visibleSeriesKeys, Range xRange, boolean includeInterval); static Range iterateToFindZBounds(XYZDataset dataset,
            List<Comparable> visibleSeriesKeys, Range xRange, boolean includeInterval); static Number findMinimumDomainValue(XYDataset dataset); static Number findMaximumDomainValue(XYDataset dataset); static Number findMinimumRangeValue(CategoryDataset dataset); static Number findMinimumRangeValue(XYDataset dataset); static Number findMaximumRangeValue(CategoryDataset dataset); static Number findMaximumRangeValue(XYDataset dataset); static Range findStackedRangeBounds(CategoryDataset dataset); static Range findStackedRangeBounds(CategoryDataset dataset,
            double base); static Range findStackedRangeBounds(CategoryDataset dataset,
                                               KeyToGroupMap map); static Number findMinimumStackedRangeValue(CategoryDataset dataset); static Number findMaximumStackedRangeValue(CategoryDataset dataset); static Range findStackedRangeBounds(TableXYDataset dataset); static Range findStackedRangeBounds(TableXYDataset dataset,
                                               double base); static double calculateStackTotal(TableXYDataset dataset, int item); static Range findCumulativeRangeBounds(CategoryDataset dataset); static double findYValue(XYDataset dataset, int series, double x); static int[] findItemIndicesForX(XYDataset dataset, int series,
            double x); }
DatasetUtilities { public static Range findCumulativeRangeBounds(CategoryDataset dataset) { ParamChecks.nullNotPermitted(dataset, "dataset"); boolean allItemsNull = true; double minimum = 0.0; double maximum = 0.0; for (int row = 0; row < dataset.getRowCount(); row++) { double runningTotal = 0.0; for (int column = 0; column <= dataset.getColumnCount() - 1; column++) { Number n = dataset.getValue(row, column); if (n != null) { allItemsNull = false; double value = n.doubleValue(); if (!Double.isNaN(value)) { runningTotal = runningTotal + value; minimum = Math.min(minimum, runningTotal); maximum = Math.max(maximum, runningTotal); } } } } if (!allItemsNull) { return new Range(minimum, maximum); } else { return null; } } private  DatasetUtilities(); static double calculatePieDatasetTotal(PieDataset dataset); static PieDataset createPieDatasetForRow(CategoryDataset dataset,
                                                    Comparable rowKey); static PieDataset createPieDatasetForRow(CategoryDataset dataset,
                                                    int row); static PieDataset createPieDatasetForColumn(CategoryDataset dataset,
                                                       Comparable columnKey); static PieDataset createPieDatasetForColumn(CategoryDataset dataset,
                                                       int column); static PieDataset createConsolidatedPieDataset(PieDataset source,
            Comparable key, double minimumPercent); static PieDataset createConsolidatedPieDataset(PieDataset source,
            Comparable key, double minimumPercent, int minItems); static CategoryDataset createCategoryDataset(String rowKeyPrefix,
            String columnKeyPrefix, double[][] data); static CategoryDataset createCategoryDataset(String rowKeyPrefix,
            String columnKeyPrefix, Number[][] data); static CategoryDataset createCategoryDataset(Comparable[] rowKeys,
            Comparable[] columnKeys, double[][] data); static CategoryDataset createCategoryDataset(Comparable rowKey,
                                                        KeyedValues rowData); static XYDataset sampleFunction2D(Function2D f, double start,
            double end, int samples, Comparable seriesKey); static XYSeries sampleFunction2DToSeries(Function2D f,
            double start, double end, int samples, Comparable seriesKey); static boolean isEmptyOrNull(PieDataset dataset); static boolean isEmptyOrNull(CategoryDataset dataset); static boolean isEmptyOrNull(XYDataset dataset); static Range findDomainBounds(XYDataset dataset); static Range findDomainBounds(XYDataset dataset,
                                         boolean includeInterval); static Range findDomainBounds(XYDataset dataset,
            List<Comparable> visibleSeriesKeys, boolean includeInterval); static Range iterateDomainBounds(XYDataset dataset); static Range iterateDomainBounds(XYDataset dataset,
                                            boolean includeInterval); static Range findRangeBounds(CategoryDataset dataset); static Range findRangeBounds(CategoryDataset dataset,
                                        boolean includeInterval); static Range findRangeBounds(CategoryDataset dataset,
            List<Comparable> visibleSeriesKeys, boolean includeInterval); static Range findRangeBounds(XYDataset dataset); static Range findRangeBounds(XYDataset dataset,
                                        boolean includeInterval); static Range findRangeBounds(XYDataset dataset,
            List<Comparable> visibleSeriesKeys, Range xRange, boolean includeInterval); static Range iterateRangeBounds(CategoryDataset dataset); static Range iterateRangeBounds(CategoryDataset dataset,
            boolean includeInterval); static Range iterateToFindRangeBounds(CategoryDataset dataset,
            List<Comparable> visibleSeriesKeys, boolean includeInterval); static Range iterateRangeBounds(XYDataset dataset); static Range iterateRangeBounds(XYDataset dataset,
            boolean includeInterval); static Range findZBounds(XYZDataset dataset); static Range findZBounds(XYZDataset dataset,
                                        boolean includeInterval); static Range findZBounds(XYZDataset dataset,
            List<Comparable> visibleSeriesKeys, Range xRange, boolean includeInterval); static Range iterateZBounds(XYZDataset dataset); static Range iterateZBounds(XYZDataset dataset,
            boolean includeInterval); static Range iterateToFindDomainBounds(XYDataset dataset,
            List<Comparable> visibleSeriesKeys, boolean includeInterval); static Range iterateToFindRangeBounds(XYDataset dataset,
            List<Comparable> visibleSeriesKeys, Range xRange, boolean includeInterval); static Range iterateToFindZBounds(XYZDataset dataset,
            List<Comparable> visibleSeriesKeys, Range xRange, boolean includeInterval); static Number findMinimumDomainValue(XYDataset dataset); static Number findMaximumDomainValue(XYDataset dataset); static Number findMinimumRangeValue(CategoryDataset dataset); static Number findMinimumRangeValue(XYDataset dataset); static Number findMaximumRangeValue(CategoryDataset dataset); static Number findMaximumRangeValue(XYDataset dataset); static Range findStackedRangeBounds(CategoryDataset dataset); static Range findStackedRangeBounds(CategoryDataset dataset,
            double base); static Range findStackedRangeBounds(CategoryDataset dataset,
                                               KeyToGroupMap map); static Number findMinimumStackedRangeValue(CategoryDataset dataset); static Number findMaximumStackedRangeValue(CategoryDataset dataset); static Range findStackedRangeBounds(TableXYDataset dataset); static Range findStackedRangeBounds(TableXYDataset dataset,
                                               double base); static double calculateStackTotal(TableXYDataset dataset, int item); static Range findCumulativeRangeBounds(CategoryDataset dataset); static double findYValue(XYDataset dataset, int series, double x); static int[] findItemIndicesForX(XYDataset dataset, int series,
            double x);  }