Java Code Examples for org.jfree.data.category.CategoryDataset#getValue()
The following examples show how to use
org.jfree.data.category.CategoryDataset#getValue() .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: StackedAreaRenderer.java From buffer_bci with GNU General Public License v3.0 | 6 votes |
/** * Calculates the stacked value of the all series up to, but not including * <code>series</code> for the specified category, <code>category</code>. * It returns 0.0 if <code>series</code> is the first series, i.e. 0. * * @param dataset the dataset (<code>null</code> not permitted). * @param series the series. * @param category the category. * * @return double returns a cumulative value for all series' values up to * but excluding <code>series</code> for Object * <code>category</code>. * * @deprecated As of 1.0.13, as the method is never used internally. */ protected double getPreviousHeight(CategoryDataset dataset, int series, int category) { double result = 0.0; Number n; double total = 0.0; if (this.renderAsPercentages) { total = DataUtilities.calculateColumnTotal(dataset, category); } for (int i = 0; i < series; i++) { n = dataset.getValue(i, category); if (n != null) { double v = n.doubleValue(); if (this.renderAsPercentages) { v = v / total; } result += v; } } return result; }
Example 2
Source File: StackedAreaRenderer.java From opensim-gui with Apache License 2.0 | 6 votes |
/** * Calculates the stacked value of the all series up to, but not including * <code>series</code> for the specified category, <code>category</code>. * It returns 0.0 if <code>series</code> is the first series, i.e. 0. * * @param dataset the dataset (<code>null</code> not permitted). * @param series the series. * @param category the category. * * @return double returns a cumulative value for all series' values up to * but excluding <code>series</code> for Object * <code>category</code>. */ protected double getPreviousHeight(CategoryDataset dataset, int series, int category) { double result = 0.0; Number n; double total = 0.0; if (this.renderAsPercentages) { total = DataUtilities.calculateColumnTotal(dataset, category); } for (int i = 0; i < series; i++) { n = dataset.getValue(i, category); if (n != null) { double v = n.doubleValue(); if (this.renderAsPercentages) { v = v / total; } result += v; } } return result; }
Example 3
Source File: AbstractCategoryItemLabelGenerator.java From ccu-historian with GNU General Public License v3.0 | 6 votes |
/** * Creates the array of items that can be passed to the * {@link MessageFormat} class for creating labels. * * @param dataset the dataset (<code>null</code> not permitted). * @param row the row index (zero-based). * @param column the column index (zero-based). * * @return The items (never <code>null</code>). */ protected Object[] createItemArray(CategoryDataset dataset, int row, int column) { Object[] result = new Object[4]; result[0] = dataset.getRowKey(row).toString(); result[1] = dataset.getColumnKey(column).toString(); Number value = dataset.getValue(row, column); if (value != null) { if (this.numberFormat != null) { result[2] = this.numberFormat.format(value); } else if (this.dateFormat != null) { result[2] = this.dateFormat.format(value); } } else { result[2] = this.nullValueString; } if (value != null) { double total = DataUtilities.calculateColumnTotal(dataset, column); double percent = value.doubleValue() / total; result[3] = this.percentFormat.format(percent); } return result; }
Example 4
Source File: StackedAreaRenderer.java From astor with GNU General Public License v2.0 | 6 votes |
/** * Calculates the stacked values (one positive and one negative) of all * series up to, but not including, <code>series</code> for the specified * item. It returns [0.0, 0.0] if <code>series</code> is the first series. * * @param dataset the dataset (<code>null</code> not permitted). * @param series the series index. * @param index the item index. * * @return An array containing the cumulative negative and positive values * for all series values up to but excluding <code>series</code> * for <code>index</code>. */ protected double[] getStackValues(CategoryDataset dataset, int series, int index) { double[] result = new double[2]; for (int i = 0; i < series; i++) { if (isSeriesVisible(i)) { double v = 0.0; Number n = dataset.getValue(i, index); if (n != null) { v = n.doubleValue(); } if (!Double.isNaN(v)) { if (v >= 0.0) { result[1] += v; } else { result[0] += v; } } } } return result; }
Example 5
Source File: Cardumen_00194_t.java From coming with MIT License | 6 votes |
/** * Returns <code>true</code> if the dataset is empty (or <code>null</code>), * and <code>false</code> otherwise. * * @param dataset the dataset (<code>null</code> permitted). * * @return A boolean. */ public static boolean isEmptyOrNull(CategoryDataset dataset) { if (dataset == null) { return true; } int rowCount = dataset.getRowCount(); int columnCount = dataset.getColumnCount(); if (rowCount == 0 || columnCount == 0) { return true; } for (int r = 0; r < rowCount; r++) { for (int c = 0; c < columnCount; c++) { if (dataset.getValue(r, c) != null) { return true; } } } return true; }
Example 6
Source File: AbstractCategoryItemLabelGenerator.java From openstock with GNU General Public License v3.0 | 6 votes |
/** * Creates the array of items that can be passed to the * {@link MessageFormat} class for creating labels. * * @param dataset the dataset (<code>null</code> not permitted). * @param row the row index (zero-based). * @param column the column index (zero-based). * * @return The items (never <code>null</code>). */ protected Object[] createItemArray(CategoryDataset dataset, int row, int column) { Object[] result = new Object[4]; result[0] = dataset.getRowKey(row).toString(); result[1] = dataset.getColumnKey(column).toString(); Number value = dataset.getValue(row, column); if (value != null) { if (this.numberFormat != null) { result[2] = this.numberFormat.format(value); } else if (this.dateFormat != null) { result[2] = this.dateFormat.format(value); } } else { result[2] = this.nullValueString; } if (value != null) { double total = DataUtilities.calculateColumnTotal(dataset, column); double percent = value.doubleValue() / total; result[3] = this.percentFormat.format(percent); } return result; }
Example 7
Source File: BoxAndWhiskerToolTipGenerator.java From SIMVA-SoS with Apache License 2.0 | 6 votes |
/** * Creates the array of items that can be passed to the * {@link MessageFormat} class for creating labels. * * @param dataset the dataset (<code>null</code> not permitted). * @param series the series (zero-based index). * @param item the item (zero-based index). * * @return The items (never <code>null</code>). */ @Override protected Object[] createItemArray(CategoryDataset dataset, int series, int item) { Object[] result = new Object[8]; result[0] = dataset.getRowKey(series); Number y = dataset.getValue(series, item); NumberFormat formatter = getNumberFormat(); result[1] = formatter.format(y); if (dataset instanceof BoxAndWhiskerCategoryDataset) { BoxAndWhiskerCategoryDataset d = (BoxAndWhiskerCategoryDataset) dataset; result[2] = formatter.format(d.getMeanValue(series, item)); result[3] = formatter.format(d.getMedianValue(series, item)); result[4] = formatter.format(d.getMinRegularValue(series, item)); result[5] = formatter.format(d.getMaxRegularValue(series, item)); result[6] = formatter.format(d.getQ1Value(series, item)); result[7] = formatter.format(d.getQ3Value(series, item)); } return result; }
Example 8
Source File: Cardumen_0079_s.java From coming with MIT License | 5 votes |
/** * Iterates over the data item of the category dataset to find * the range bounds. * * @param dataset the dataset (<code>null</code> not permitted). * @param includeInterval a flag that determines whether or not the * y-interval is taken into account. * * @return The range (possibly <code>null</code>). */ public static Range iterateCategoryRangeBounds(CategoryDataset dataset, boolean includeInterval) { double minimum = Double.POSITIVE_INFINITY; double maximum = Double.NEGATIVE_INFINITY; boolean interval = includeInterval && dataset instanceof IntervalCategoryDataset; int rowCount = dataset.getRowCount(); int columnCount = dataset.getColumnCount(); for (int row = 0; row < rowCount; row++) { for (int column = 0; column < columnCount; column++) { Number lvalue; Number uvalue; if (interval) { IntervalCategoryDataset icd = (IntervalCategoryDataset) dataset; lvalue = icd.getStartValue(row, column); uvalue = icd.getEndValue(row, column); } else { lvalue = dataset.getValue(row, column); uvalue = lvalue; } if (lvalue != null) { minimum = Math.min(minimum, lvalue.doubleValue()); } if (uvalue != null) { maximum = Math.max(maximum, uvalue.doubleValue()); } } } if (minimum == Double.POSITIVE_INFINITY) { return null; } else { return new Range(minimum, maximum); } }
Example 9
Source File: WaterfallBarRenderer.java From buffer_bci with GNU General Public License v3.0 | 5 votes |
/** * Returns the range of values the renderer requires to display all the * items from the specified dataset. * * @param dataset the dataset (<code>null</code> not permitted). * * @return The range (or <code>null</code> if the dataset is empty). */ @Override public Range findRangeBounds(CategoryDataset dataset) { if (dataset == null) { return null; } boolean allItemsNull = true; // we'll set this to false if there is at // least one non-null data item... double minimum = 0.0; double maximum = 0.0; int columnCount = dataset.getColumnCount(); for (int row = 0; row < dataset.getRowCount(); row++) { double runningTotal = 0.0; for (int column = 0; column <= columnCount - 1; column++) { Number n = dataset.getValue(row, column); if (n != null) { allItemsNull = false; double value = n.doubleValue(); if (column == columnCount - 1) { // treat the last column value as an absolute runningTotal = value; } else { runningTotal = runningTotal + value; } minimum = Math.min(minimum, runningTotal); maximum = Math.max(maximum, runningTotal); } } } if (!allItemsNull) { return new Range(minimum, maximum); } else { return null; } }
Example 10
Source File: WaterfallBarRenderer.java From astor with GNU General Public License v2.0 | 5 votes |
/** * Returns the range of values the renderer requires to display all the * items from the specified dataset. * * @param dataset the dataset (<code>null</code> not permitted). * * @return The range (or <code>null</code> if the dataset is empty). */ public Range findRangeBounds(CategoryDataset dataset) { if (dataset == null) { throw new IllegalArgumentException("Null 'dataset' argument."); } boolean allItemsNull = true; // we'll set this to false if there is at // least one non-null data item... double minimum = 0.0; double maximum = 0.0; int columnCount = dataset.getColumnCount(); for (int row = 0; row < dataset.getRowCount(); row++) { double runningTotal = 0.0; for (int column = 0; column <= columnCount - 1; column++) { Number n = dataset.getValue(row, column); if (n != null) { allItemsNull = false; double value = n.doubleValue(); if (column == columnCount - 1) { // treat the last column value as an absolute runningTotal = value; } else { runningTotal = runningTotal + value; } minimum = Math.min(minimum, runningTotal); maximum = Math.max(maximum, runningTotal); } } } if (!allItemsNull) { return new Range(minimum, maximum); } else { return null; } }
Example 11
Source File: JGenProg2017_0047_s.java From coming with MIT License | 5 votes |
/** * Returns the minimum value in the dataset range, assuming that values in * each category are "stacked". * * @param dataset the dataset. * * @return The minimum value. */ public static Number findMinimumStackedRangeValue(CategoryDataset dataset) { Number result = null; if (dataset != null) { double minimum = 0.0; int categoryCount = dataset.getRowCount(); for (int item = 0; item < categoryCount; item++) { double total = 0.0; int seriesCount = dataset.getColumnCount(); for (int series = 0; series < seriesCount; series++) { Number number = dataset.getValue(series, item); if (number != null) { double value = number.doubleValue(); if (value < 0.0) { total = total + value; // '+', remember value is negative } } } minimum = Math.min(minimum, total); } result = new Double(minimum); } return result; }
Example 12
Source File: IntervalCategoryItemLabelGenerator.java From openstock with GNU General Public License v3.0 | 5 votes |
/** * Creates the array of items that can be passed to the * <code>MessageFormat</code> class for creating labels. * * @param dataset the dataset (<code>null</code> not permitted). * @param row the row index (zero-based). * @param column the column index (zero-based). * * @return The items (never <code>null</code>). */ @Override protected Object[] createItemArray(CategoryDataset dataset, int row, int column) { Object[] result = new Object[5]; result[0] = dataset.getRowKey(row).toString(); result[1] = dataset.getColumnKey(column).toString(); Number value = dataset.getValue(row, column); if (getNumberFormat() != null) { result[2] = getNumberFormat().format(value); } else if (getDateFormat() != null) { result[2] = getDateFormat().format(value); } if (dataset instanceof IntervalCategoryDataset) { IntervalCategoryDataset icd = (IntervalCategoryDataset) dataset; Number start = icd.getStartValue(row, column); Number end = icd.getEndValue(row, column); if (getNumberFormat() != null) { result[3] = getNumberFormat().format(start); result[4] = getNumberFormat().format(end); } else if (getDateFormat() != null) { result[3] = getDateFormat().format(start); result[4] = getDateFormat().format(end); } } return result; }
Example 13
Source File: Cardumen_00194_t.java From coming with MIT License | 5 votes |
/** * Calculates the range of values for a dataset where each item is the * running total of the items for the current series. * * @param dataset the dataset (<code>null</code> not permitted). * * @return The range. * * @see #findRangeBounds(CategoryDataset) */ public static Range findCumulativeRangeBounds(CategoryDataset dataset) { if (dataset == null) { throw new IllegalArgumentException("Null 'dataset' argument."); } boolean allItemsNull = true; // we'll set this to false if there is at // least one non-null data item... 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(); runningTotal = runningTotal + value; minimum = Math.min(minimum, runningTotal); maximum = Math.max(maximum, runningTotal); } } } if (!allItemsNull) { return new Range(minimum, maximum); } else { return null; } }
Example 14
Source File: DatasetUtilities.java From astor with GNU General Public License v2.0 | 5 votes |
/** * Calculates the range of values for a dataset where each item is the * running total of the items for the current series. * * @param dataset the dataset (<code>null</code> not permitted). * * @return The range. * * @see #findRangeBounds(CategoryDataset) */ public static Range findCumulativeRangeBounds(CategoryDataset dataset) { if (dataset == null) { throw new IllegalArgumentException("Null 'dataset' argument."); } boolean allItemsNull = true; // we'll set this to false if there is at // least one non-null data item... 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(); runningTotal = runningTotal + value; minimum = Math.min(minimum, runningTotal); maximum = Math.max(maximum, runningTotal); } } } if (!allItemsNull) { return new Range(minimum, maximum); } else { return null; } }
Example 15
Source File: DatasetUtilities.java From ECG-Viewer with GNU General Public License v2.0 | 5 votes |
/** * Returns the maximum value in the dataset range, assuming that values in * each category are "stacked". * * @param dataset the dataset (<code>null</code> not permitted). * * @return The maximum value (possibly <code>null</code>). * * @see #findMinimumStackedRangeValue(CategoryDataset) */ public static Number findMaximumStackedRangeValue(CategoryDataset dataset) { ParamChecks.nullNotPermitted(dataset, "dataset"); Number result = null; boolean hasValidData = false; double maximum = 0.0; int categoryCount = dataset.getColumnCount(); for (int item = 0; item < categoryCount; item++) { double total = 0.0; int seriesCount = dataset.getRowCount(); for (int series = 0; series < seriesCount; series++) { Number number = dataset.getValue(series, item); if (number != null) { hasValidData = true; double value = number.doubleValue(); if (value > 0.0) { total = total + value; } } } maximum = Math.max(maximum, total); } if (hasValidData) { result = new Double(maximum); } return result; }
Example 16
Source File: Cardumen_00194_s.java From coming with MIT License | 4 votes |
/** * Returns the minimum and maximum values for the dataset's range * (y-values), assuming that the series in one category are stacked. * * @param dataset the dataset. * @param map a structure that maps series to groups. * * @return The value range (<code>null</code> if the dataset contains no * values). */ public static Range findStackedRangeBounds(CategoryDataset dataset, KeyToGroupMap map) { Range result = null; if (dataset != null) { // create an array holding the group indices... int[] groupIndex = new int[dataset.getRowCount()]; for (int i = 0; i < dataset.getRowCount(); i++) { groupIndex[i] = map.getGroupIndex( map.getGroup(dataset.getRowKey(i)) ); } // minimum and maximum for each group... int groupCount = map.getGroupCount(); double[] minimum = new double[groupCount]; double[] maximum = new double[groupCount]; int categoryCount = dataset.getColumnCount(); for (int item = 0; item < categoryCount; item++) { double[] positive = new double[groupCount]; double[] negative = new double[groupCount]; int seriesCount = dataset.getRowCount(); for (int series = 0; series < seriesCount; series++) { Number number = dataset.getValue(series, item); if (number != null) { double value = number.doubleValue(); if (value > 0.0) { positive[groupIndex[series]] = positive[groupIndex[series]] + value; } if (value < 0.0) { negative[groupIndex[series]] = negative[groupIndex[series]] + value; // '+', remember value is negative } } } for (int g = 0; g < groupCount; g++) { minimum[g] = Math.min(minimum[g], negative[g]); maximum[g] = Math.max(maximum[g], positive[g]); } } for (int j = 0; j < groupCount; j++) { result = Range.combine( result, new Range(minimum[j], maximum[j]) ); } } return result; }
Example 17
Source File: JGenProg2017_0047_s.java From coming with MIT License | 4 votes |
/** * Returns the minimum range value for the specified dataset. This is * easy if the dataset implements the {@link 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 * <code>null</code> if all the data values in the dataset are * <code>null</code>. * * @param dataset the dataset (<code>null</code> not permitted). * * @return The minimum value (possibly <code>null</code>). */ public static Number findMinimumRangeValue(CategoryDataset dataset) { // check parameters... if (dataset == null) { throw new IllegalArgumentException("Null 'dataset' argument."); } // work out the minimum value... if (dataset instanceof RangeInfo) { RangeInfo info = (RangeInfo) dataset; return new Double(info.getRangeLowerBound(true)); } // hasn't implemented RangeInfo, so we'll have to iterate... else { double minimum = Double.POSITIVE_INFINITY; int seriesCount = dataset.getRowCount(); int itemCount = dataset.getColumnCount(); for (int series = 0; series < seriesCount; series++) { for (int item = 0; item < itemCount; item++) { Number value; if (dataset instanceof IntervalCategoryDataset) { IntervalCategoryDataset icd = (IntervalCategoryDataset) dataset; value = icd.getStartValue(series, item); } else { value = dataset.getValue(series, item); } if (value != null) { minimum = Math.min(minimum, value.doubleValue()); } } } if (minimum == Double.POSITIVE_INFINITY) { return null; } else { return new Double(minimum); } } }
Example 18
Source File: Cardumen_00194_s.java From coming with MIT License | 4 votes |
/** * Returns the maximum range value for the specified dataset. This is easy * if the dataset implements the {@link 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 * <code>null</code> if all the data values are <code>null</code>. * * @param dataset the dataset (<code>null</code> not permitted). * * @return The maximum value (possibly <code>null</code>). */ public static Number findMaximumRangeValue(CategoryDataset dataset) { if (dataset == null) { throw new IllegalArgumentException("Null 'dataset' argument."); } // work out the minimum value... if (dataset instanceof RangeInfo) { RangeInfo info = (RangeInfo) dataset; return new Double(info.getRangeUpperBound(true)); } // hasn't implemented RangeInfo, so we'll have to iterate... else { double maximum = Double.NEGATIVE_INFINITY; int seriesCount = dataset.getRowCount(); int itemCount = dataset.getColumnCount(); for (int series = 0; series < seriesCount; series++) { for (int item = 0; item < itemCount; item++) { Number value; if (dataset instanceof IntervalCategoryDataset) { IntervalCategoryDataset icd = (IntervalCategoryDataset) dataset; value = icd.getEndValue(series, item); } else { value = dataset.getValue(series, item); } if (value != null) { maximum = Math.max(maximum, value.doubleValue()); } } } if (maximum == Double.NEGATIVE_INFINITY) { return null; } else { return new Double(maximum); } } }
Example 19
Source File: DatasetUtilities.java From ccu-historian with GNU General Public License v3.0 | 4 votes |
/** * Returns the minimum and maximum values for the dataset's range * (y-values), assuming that the series in one category are stacked. * * @param dataset the dataset. * @param map a structure that maps series to groups. * * @return The value range (<code>null</code> if the dataset contains no * values). */ public static Range findStackedRangeBounds(CategoryDataset dataset, KeyToGroupMap map) { ParamChecks.nullNotPermitted(dataset, "dataset"); boolean hasValidData = false; Range result = null; // create an array holding the group indices for each series... int[] groupIndex = new int[dataset.getRowCount()]; for (int i = 0; i < dataset.getRowCount(); i++) { groupIndex[i] = map.getGroupIndex(map.getGroup( dataset.getRowKey(i))); } // minimum and maximum for each group... int groupCount = map.getGroupCount(); double[] minimum = new double[groupCount]; double[] maximum = new double[groupCount]; int categoryCount = dataset.getColumnCount(); for (int item = 0; item < categoryCount; item++) { double[] positive = new double[groupCount]; double[] negative = new double[groupCount]; int seriesCount = dataset.getRowCount(); for (int series = 0; series < seriesCount; series++) { Number number = dataset.getValue(series, item); if (number != null) { hasValidData = true; double value = number.doubleValue(); if (value > 0.0) { positive[groupIndex[series]] = positive[groupIndex[series]] + value; } if (value < 0.0) { negative[groupIndex[series]] = negative[groupIndex[series]] + value; // '+', remember value is negative } } } for (int g = 0; g < groupCount; g++) { minimum[g] = Math.min(minimum[g], negative[g]); maximum[g] = Math.max(maximum[g], positive[g]); } } if (hasValidData) { for (int j = 0; j < groupCount; j++) { result = Range.combine(result, new Range(minimum[j], maximum[j])); } } return result; }
Example 20
Source File: Test.java From IntelliJDeodorant with MIT License | 4 votes |
protected List createStackedValueList(CategoryDataset dataset, Comparable category, int[] includedRows, double base, boolean asPercentages) { List result = new ArrayList(); double posBase = base; double negBase = base; double total = 0.0; if (asPercentages) { total = DataUtilities.calculateColumnTotal(dataset, dataset.getColumnIndex(category), includedRows); } int baseIndex = -1; int rowCount = includedRows.length; for (int i = 0; i < rowCount; i++) { int r = includedRows[i]; Number n = dataset.getValue(dataset.getRowKey(r), category); if (n == null) { continue; } double v = n.doubleValue(); if (asPercentages) { v = v / total; } if ((v > 0.0) || (!this.ignoreZeroValues && v >= 0.0)) { if (baseIndex < 0) { result.add(new Object[]{null, new Double(base)}); baseIndex = 0; } posBase = posBase + v; result.add(new Object[]{new Integer(r), new Double(posBase)}); } else if (v < 0.0) { if (baseIndex < 0) { result.add(new Object[]{null, new Double(base)}); baseIndex = 0; } negBase = negBase + v; result.add(0, new Object[]{new Integer(-r - 1), new Double(negBase)}); baseIndex++; } } return result; }