org.jfree.data.DataUtilities Java Examples
The following examples show how to use
org.jfree.data.DataUtilities.
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: AbstractCategoryItemLabelGenerator.java From ECG-Viewer with GNU General Public License v2.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 #2
Source File: DefaultIntervalCategoryDatasetTest.java From ccu-historian with GNU General Public License v3.0 | 6 votes |
/** * Confirm that cloning works. */ @Test public void testCloning() throws CloneNotSupportedException { double[] starts_S1 = new double[] {0.1, 0.2, 0.3}; double[] starts_S2 = new double[] {0.3, 0.4, 0.5}; double[] ends_S1 = new double[] {0.5, 0.6, 0.7}; double[] ends_S2 = new double[] {0.7, 0.8, 0.9}; double[][] starts = new double[][] {starts_S1, starts_S2}; double[][] ends = new double[][] {ends_S1, ends_S2}; DefaultIntervalCategoryDataset d1 = new DefaultIntervalCategoryDataset( new Comparable[] {"Series 1", "Series 2"}, new Comparable[] {"Category 1", "Category 2", "Category 3"}, DataUtilities.createNumberArray2D(starts), DataUtilities.createNumberArray2D(ends)); DefaultIntervalCategoryDataset d2 = null; d2 = (DefaultIntervalCategoryDataset) d1.clone(); assertTrue(d1 != d2); assertTrue(d1.getClass() == d2.getClass()); assertTrue(d1.equals(d2)); // check that the clone doesn't share the same underlying arrays. d1.setStartValue(0, "Category 1", new Double(0.99)); assertFalse(d1.equals(d2)); d2.setStartValue(0, "Category 1", new Double(0.99)); assertTrue(d1.equals(d2)); }
Example #3
Source File: DefaultIntervalCategoryDatasetTest.java From buffer_bci with GNU General Public License v3.0 | 6 votes |
/** * Confirm that cloning works. */ @Test public void testCloning() throws CloneNotSupportedException { double[] starts_S1 = new double[] {0.1, 0.2, 0.3}; double[] starts_S2 = new double[] {0.3, 0.4, 0.5}; double[] ends_S1 = new double[] {0.5, 0.6, 0.7}; double[] ends_S2 = new double[] {0.7, 0.8, 0.9}; double[][] starts = new double[][] {starts_S1, starts_S2}; double[][] ends = new double[][] {ends_S1, ends_S2}; DefaultIntervalCategoryDataset d1 = new DefaultIntervalCategoryDataset( new Comparable[] {"Series 1", "Series 2"}, new Comparable[] {"Category 1", "Category 2", "Category 3"}, DataUtilities.createNumberArray2D(starts), DataUtilities.createNumberArray2D(ends)); DefaultIntervalCategoryDataset d2 = null; d2 = (DefaultIntervalCategoryDataset) d1.clone(); assertTrue(d1 != d2); assertTrue(d1.getClass() == d2.getClass()); assertTrue(d1.equals(d2)); // check that the clone doesn't share the same underlying arrays. d1.setStartValue(0, "Category 1", new Double(0.99)); assertFalse(d1.equals(d2)); d2.setStartValue(0, "Category 1", new Double(0.99)); assertTrue(d1.equals(d2)); }
Example #4
Source File: StackedAreaRenderer.java From pentaho-reporting with GNU Lesser General Public License v2.1 | 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( final CategoryDataset dataset, final int series, final 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 #5
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 #6
Source File: AbstractCategoryItemLabelGenerator.java From buffer_bci 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: StackedAreaRenderer.java From openstock 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 #8
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 #9
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 #10
Source File: AbstractCategoryItemLabelGenerator.java From buffer_bci 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 #11
Source File: StackedAreaRenderer.java From ccu-historian 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 #12
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 #13
Source File: AbstractCategoryItemLabelGenerator.java From opensim-gui 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 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 #14
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 #15
Source File: StackedAreaRenderer.java From SIMVA-SoS 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>. * * @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 #16
Source File: AbstractCategoryItemLabelGenerator.java From astor with GNU General Public License v2.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 #17
Source File: AbstractCategoryItemLabelGenerator.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 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 #18
Source File: StackedAreaRenderer.java From astor with GNU General Public License v2.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 #19
Source File: AbstractCategoryItemLabelGenerator.java From astor with GNU General Public License v2.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 #20
Source File: StackedAreaRenderer.java From astor with GNU General Public License v2.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 #21
Source File: DefaultIntervalCategoryDatasetTest.java From SIMVA-SoS with Apache License 2.0 | 6 votes |
/** * Confirm that cloning works. */ @Test public void testCloning() throws CloneNotSupportedException { double[] starts_S1 = new double[] {0.1, 0.2, 0.3}; double[] starts_S2 = new double[] {0.3, 0.4, 0.5}; double[] ends_S1 = new double[] {0.5, 0.6, 0.7}; double[] ends_S2 = new double[] {0.7, 0.8, 0.9}; double[][] starts = new double[][] {starts_S1, starts_S2}; double[][] ends = new double[][] {ends_S1, ends_S2}; DefaultIntervalCategoryDataset d1 = new DefaultIntervalCategoryDataset( new Comparable[] {"Series 1", "Series 2"}, new Comparable[] {"Category 1", "Category 2", "Category 3"}, DataUtilities.createNumberArray2D(starts), DataUtilities.createNumberArray2D(ends)); DefaultIntervalCategoryDataset d2 = null; d2 = (DefaultIntervalCategoryDataset) d1.clone(); assertTrue(d1 != d2); assertTrue(d1.getClass() == d2.getClass()); assertTrue(d1.equals(d2)); // check that the clone doesn't share the same underlying arrays. d1.setStartValue(0, "Category 1", new Double(0.99)); assertFalse(d1.equals(d2)); d2.setStartValue(0, "Category 1", new Double(0.99)); assertTrue(d1.equals(d2)); }
Example #22
Source File: DefaultIntervalCategoryDatasetTest.java From ECG-Viewer with GNU General Public License v2.0 | 6 votes |
/** * Confirm that cloning works. */ @Test public void testCloning() throws CloneNotSupportedException { double[] starts_S1 = new double[] {0.1, 0.2, 0.3}; double[] starts_S2 = new double[] {0.3, 0.4, 0.5}; double[] ends_S1 = new double[] {0.5, 0.6, 0.7}; double[] ends_S2 = new double[] {0.7, 0.8, 0.9}; double[][] starts = new double[][] {starts_S1, starts_S2}; double[][] ends = new double[][] {ends_S1, ends_S2}; DefaultIntervalCategoryDataset d1 = new DefaultIntervalCategoryDataset( new Comparable[] {"Series 1", "Series 2"}, new Comparable[] {"Category 1", "Category 2", "Category 3"}, DataUtilities.createNumberArray2D(starts), DataUtilities.createNumberArray2D(ends)); DefaultIntervalCategoryDataset d2 = null; d2 = (DefaultIntervalCategoryDataset) d1.clone(); assertTrue(d1 != d2); assertTrue(d1.getClass() == d2.getClass()); assertTrue(d1.equals(d2)); // check that the clone doesn't share the same underlying arrays. d1.setStartValue(0, "Category 1", new Double(0.99)); assertFalse(d1.equals(d2)); d2.setStartValue(0, "Category 1", new Double(0.99)); assertTrue(d1.equals(d2)); }
Example #23
Source File: DataUtilitiesTests.java From astor with GNU General Public License v2.0 | 6 votes |
/** * Some tests for the clone() method. */ public void testClone() { double[][] a = new double[1][]; double[][] b = DataUtilities.clone(a); assertTrue(DataUtilities.equal(a, b)); a[0] = new double[] { 3.0, 4.0 }; assertFalse(DataUtilities.equal(a, b)); b[0] = new double[] { 3.0, 4.0 }; assertTrue(DataUtilities.equal(a, b)); a = new double[2][3]; a[0][0] = 1.23; a[1][1] = Double.NaN; b = DataUtilities.clone(a); assertTrue(DataUtilities.equal(a, b)); a[0][0] = 99.9; assertFalse(DataUtilities.equal(a, b)); b[0][0] = 99.9; assertTrue(DataUtilities.equal(a, b)); }
Example #24
Source File: StackedAreaRenderer.java From ECG-Viewer with GNU General Public License v2.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 #25
Source File: DefaultIntervalCategoryDatasetTest.java From openstock with GNU General Public License v3.0 | 6 votes |
/** * Confirm that cloning works. */ @Test public void testCloning() throws CloneNotSupportedException { double[] starts_S1 = new double[] {0.1, 0.2, 0.3}; double[] starts_S2 = new double[] {0.3, 0.4, 0.5}; double[] ends_S1 = new double[] {0.5, 0.6, 0.7}; double[] ends_S2 = new double[] {0.7, 0.8, 0.9}; double[][] starts = new double[][] {starts_S1, starts_S2}; double[][] ends = new double[][] {ends_S1, ends_S2}; DefaultIntervalCategoryDataset d1 = new DefaultIntervalCategoryDataset( new Comparable[] {"Series 1", "Series 2"}, new Comparable[] {"Category 1", "Category 2", "Category 3"}, DataUtilities.createNumberArray2D(starts), DataUtilities.createNumberArray2D(ends)); DefaultIntervalCategoryDataset d2 = null; d2 = (DefaultIntervalCategoryDataset) d1.clone(); assertTrue(d1 != d2); assertTrue(d1.getClass() == d2.getClass()); assertTrue(d1.equals(d2)); // check that the clone doesn't share the same underlying arrays. d1.setStartValue(0, "Category 1", new Double(0.99)); assertFalse(d1.equals(d2)); d2.setStartValue(0, "Category 1", new Double(0.99)); assertTrue(d1.equals(d2)); }
Example #26
Source File: DataUtilitiesTests.java From astor with GNU General Public License v2.0 | 5 votes |
/** * Some checks for the calculateRowTotal() method. */ public void testCalculateRowTotal2() { DefaultKeyedValues2D table = new DefaultKeyedValues2D(); table.addValue(new Double(1.0), "R0", "C0"); table.addValue(new Double(2.0), "R0", "C1"); table.addValue(new Double(3.0), "R1", "C0"); table.addValue(new Double(4.0), "R1", "C1"); assertEquals(3.0, DataUtilities.calculateRowTotal(table, 0, new int[] {0, 1}), EPSILON); assertEquals(1.0, DataUtilities.calculateRowTotal(table, 0, new int[] {0}), EPSILON); assertEquals(2.0, DataUtilities.calculateRowTotal(table, 0, new int[] {1}), EPSILON); assertEquals(0.0, DataUtilities.calculateRowTotal(table, 0, new int[] {}), EPSILON); assertEquals(7.0, DataUtilities.calculateRowTotal(table, 1, new int[] {0, 1}), EPSILON); assertEquals(3.0, DataUtilities.calculateRowTotal(table, 1, new int[] {0}), EPSILON); assertEquals(4.0, DataUtilities.calculateRowTotal(table, 1, new int[] {1}), EPSILON); assertEquals(0.0, DataUtilities.calculateRowTotal(table, 1, new int[] {}), EPSILON); table.setValue(null, "R1", "C1"); assertEquals(3.0, DataUtilities.calculateRowTotal(table, 1, new int[] {0, 1}), EPSILON); assertEquals(0.0, DataUtilities.calculateRowTotal(table, 1, new int[] {1}), EPSILON); }
Example #27
Source File: DataUtilitiesTests.java From astor with GNU General Public License v2.0 | 5 votes |
/** * Some checks for the calculateColumnTotal() method. */ public void testCalculateColumnTotal2() { DefaultKeyedValues2D table = new DefaultKeyedValues2D(); table.addValue(new Double(1.0), "R0", "C0"); table.addValue(new Double(2.0), "R0", "C1"); table.addValue(new Double(3.0), "R1", "C0"); table.addValue(new Double(4.0), "R1", "C1"); assertEquals(4.0, DataUtilities.calculateColumnTotal(table, 0, new int[] {0, 1}), EPSILON); assertEquals(1.0, DataUtilities.calculateColumnTotal(table, 0, new int[] {0}), EPSILON); assertEquals(3.0, DataUtilities.calculateColumnTotal(table, 0, new int[] {1}), EPSILON); assertEquals(0.0, DataUtilities.calculateColumnTotal(table, 0, new int[] {}), EPSILON); assertEquals(6.0, DataUtilities.calculateColumnTotal(table, 1, new int[] {0, 1}), EPSILON); assertEquals(2.0, DataUtilities.calculateColumnTotal(table, 1, new int[] {0}), EPSILON); assertEquals(4.0, DataUtilities.calculateColumnTotal(table, 1, new int[] {1}), EPSILON); table.setValue(null, "R1", "C1"); assertEquals(2.0, DataUtilities.calculateColumnTotal(table, 1, new int[] {0, 1}), EPSILON); assertEquals(0.0, DataUtilities.calculateColumnTotal(table, 1, new int[] {1}), EPSILON); }
Example #28
Source File: DataUtilitiesTests.java From astor with GNU General Public License v2.0 | 5 votes |
/** * Some checks for the calculateRowTotal() method. */ public void testCalculateRowTotal() { DefaultKeyedValues2D table = new DefaultKeyedValues2D(); table.addValue(new Double(1.0), "R0", "C0"); table.addValue(new Double(2.0), "R0", "C1"); table.addValue(new Double(3.0), "R1", "C0"); table.addValue(new Double(4.0), "R1", "C1"); assertEquals(3.0, DataUtilities.calculateRowTotal(table, 0), EPSILON); assertEquals(7.0, DataUtilities.calculateRowTotal(table, 1), EPSILON); table.setValue(null, "R1", "C1"); assertEquals(3.0, DataUtilities.calculateRowTotal(table, 1), EPSILON); }
Example #29
Source File: DefaultHeatMapDataset.java From buffer_bci with GNU General Public License v3.0 | 5 votes |
/** * Tests this dataset for equality with an arbitrary object. * * @param obj the object (<code>null</code> permitted). * * @return A boolean. */ @Override public boolean equals(Object obj) { if (obj == this) { return true; } if (!(obj instanceof DefaultHeatMapDataset)) { return false; } DefaultHeatMapDataset that = (DefaultHeatMapDataset) obj; if (this.xSamples != that.xSamples) { return false; } if (this.ySamples != that.ySamples) { return false; } if (this.minX != that.minX) { return false; } if (this.maxX != that.maxX) { return false; } if (this.minY != that.minY) { return false; } if (this.maxY != that.maxY) { return false; } if (!DataUtilities.equal(this.zValues, that.zValues)) { return false; } // can't find any differences return true; }
Example #30
Source File: DataUtilitiesTests.java From astor with GNU General Public License v2.0 | 5 votes |
/** * Some checks for the calculateColumnTotal() method. */ public void testCalculateColumnTotal() { DefaultKeyedValues2D table = new DefaultKeyedValues2D(); table.addValue(new Double(1.0), "R0", "C0"); table.addValue(new Double(2.0), "R0", "C1"); table.addValue(new Double(3.0), "R1", "C0"); table.addValue(new Double(4.0), "R1", "C1"); assertEquals(4.0, DataUtilities.calculateColumnTotal(table, 0), EPSILON); assertEquals(6.0, DataUtilities.calculateColumnTotal(table, 1), EPSILON); table.setValue(null, "R1", "C1"); assertEquals(2.0, DataUtilities.calculateColumnTotal(table, 1), EPSILON); }