Java Code Examples for org.jfree.data.category.DefaultCategoryDataset#setValue()
The following examples show how to use
org.jfree.data.category.DefaultCategoryDataset#setValue() .
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: CategoryPlotTest.java From openstock with GNU General Public License v3.0 | 6 votes |
@Test public void testGetRendererForDataset2() { CategoryDataset dataset = new DefaultCategoryDataset(); CategoryAxis xAxis = new CategoryAxis("X"); NumberAxis yAxis = new NumberAxis("Y"); CategoryItemRenderer renderer = new BarRenderer(); CategoryPlot plot = new CategoryPlot(dataset, xAxis, yAxis, renderer); // add a second dataset DefaultCategoryDataset dataset2 = new DefaultCategoryDataset(); dataset2.setValue(1, "R1", "C1"); plot.setDataset(99, dataset2); // by default, the renderer with index 0 is used assertEquals(renderer, plot.getRendererForDataset(dataset2)); // add a second renderer with the same index as dataset2, now it will // be used CategoryItemRenderer renderer2 = new LineAndShapeRenderer(); plot.setRenderer(99, renderer2); assertEquals(renderer2, plot.getRendererForDataset(dataset2)); }
Example 2
Source File: NumberAxisTest.java From ccu-historian with GNU General Public License v3.0 | 6 votes |
/** * A simple test for the auto-range calculation looking at a * NumberAxis used as the range axis for a CategoryPlot. In this * case, the 'autoRangeIncludesZero' flag is set to false AND the * original dataset is replaced with a new dataset. */ @Test public void testAutoRange3() { DefaultCategoryDataset dataset = new DefaultCategoryDataset(); dataset.setValue(100.0, "Row 1", "Column 1"); dataset.setValue(200.0, "Row 1", "Column 2"); JFreeChart chart = ChartFactory.createLineChart("Test", "Categories", "Value", dataset, PlotOrientation.VERTICAL, false, false, false); CategoryPlot plot = (CategoryPlot) chart.getPlot(); NumberAxis axis = (NumberAxis) plot.getRangeAxis(); axis.setAutoRangeIncludesZero(false); assertEquals(axis.getLowerBound(), 95.0, EPSILON); assertEquals(axis.getUpperBound(), 205.0, EPSILON); // now replacing the dataset should update the axis range... DefaultCategoryDataset dataset2 = new DefaultCategoryDataset(); dataset2.setValue(900.0, "Row 1", "Column 1"); dataset2.setValue(1000.0, "Row 1", "Column 2"); plot.setDataset(dataset2); assertEquals(axis.getLowerBound(), 895.0, EPSILON); assertEquals(axis.getUpperBound(), 1005.0, EPSILON); }
Example 3
Source File: DefaultCategoryDatasetTests.java From astor with GNU General Public License v2.0 | 6 votes |
/** * Confirm that the equals method can distinguish all the required fields. */ public void testEquals() { DefaultCategoryDataset d1 = new DefaultCategoryDataset(); d1.setValue(23.4, "R1", "C1"); DefaultCategoryDataset d2 = new DefaultCategoryDataset(); d2.setValue(23.4, "R1", "C1"); assertTrue(d1.equals(d2)); assertTrue(d2.equals(d1)); d1.setValue(36.5, "R1", "C2"); assertFalse(d1.equals(d2)); d2.setValue(36.5, "R1", "C2"); assertTrue(d1.equals(d2)); d1.setValue(null, "R1", "C1"); assertFalse(d1.equals(d2)); d2.setValue(null, "R1", "C1"); assertTrue(d1.equals(d2)); }
Example 4
Source File: NumberAxisTest.java From buffer_bci with GNU General Public License v3.0 | 6 votes |
/** * A simple test for the auto-range calculation looking at a * NumberAxis used as the range axis for a CategoryPlot. In this * case, the 'autoRangeIncludesZero' flag is set to false AND the * original dataset is replaced with a new dataset. */ @Test public void testAutoRange3() { DefaultCategoryDataset dataset = new DefaultCategoryDataset(); dataset.setValue(100.0, "Row 1", "Column 1"); dataset.setValue(200.0, "Row 1", "Column 2"); JFreeChart chart = ChartFactory.createLineChart("Test", "Categories", "Value", dataset, PlotOrientation.VERTICAL, false, false, false); CategoryPlot plot = (CategoryPlot) chart.getPlot(); NumberAxis axis = (NumberAxis) plot.getRangeAxis(); axis.setAutoRangeIncludesZero(false); assertEquals(axis.getLowerBound(), 95.0, EPSILON); assertEquals(axis.getUpperBound(), 205.0, EPSILON); // now replacing the dataset should update the axis range... DefaultCategoryDataset dataset2 = new DefaultCategoryDataset(); dataset2.setValue(900.0, "Row 1", "Column 1"); dataset2.setValue(1000.0, "Row 1", "Column 2"); plot.setDataset(dataset2); assertEquals(axis.getLowerBound(), 895.0, EPSILON); assertEquals(axis.getUpperBound(), 1005.0, EPSILON); }
Example 5
Source File: DefaultCategoryDatasetTests.java From astor with GNU General Public License v2.0 | 6 votes |
/** * Some tests for the getColumnCount() method. */ public void testGetColumnCount() { DefaultCategoryDataset d = new DefaultCategoryDataset(); assertTrue(d.getColumnCount() == 0); d.addValue(1.0, "R1", "C1"); assertTrue(d.getColumnCount() == 1); d.addValue(1.0, "R1", "C2"); assertTrue(d.getColumnCount() == 2); d.addValue(2.0, "R1", "C2"); assertTrue(d.getColumnCount() == 2); // a column of all null values is still counted... d.setValue(null, "R1", "C2"); assertTrue(d.getColumnCount() == 2); }
Example 6
Source File: CategoryPlotTest.java From ccu-historian with GNU General Public License v3.0 | 6 votes |
@Test public void testMapDatasetToDomainAxis() { CategoryDataset dataset = new DefaultCategoryDataset(); CategoryAxis xAxis = new CategoryAxis("X"); NumberAxis yAxis = new NumberAxis("Y"); CategoryItemRenderer renderer = new BarRenderer(); CategoryPlot plot = new CategoryPlot(dataset, xAxis, yAxis, renderer); CategoryAxis xAxis2 = new CategoryAxis("X2"); plot.setDomainAxis(11, xAxis2); // add a second dataset DefaultCategoryDataset dataset2 = new DefaultCategoryDataset(); dataset2.setValue(1, "R1", "C1"); plot.setDataset(99, dataset); assertEquals(xAxis, plot.getDomainAxisForDataset(99)); // now map the dataset to the second xAxis plot.mapDatasetToDomainAxis(99, 11); assertEquals(xAxis2, plot.getDomainAxisForDataset(99)); }
Example 7
Source File: CategoryPlotTest.java From ECG-Viewer with GNU General Public License v2.0 | 6 votes |
@Test public void testMapDatasetToDomainAxis() { CategoryDataset dataset = new DefaultCategoryDataset(); CategoryAxis xAxis = new CategoryAxis("X"); NumberAxis yAxis = new NumberAxis("Y"); CategoryItemRenderer renderer = new BarRenderer(); CategoryPlot plot = new CategoryPlot(dataset, xAxis, yAxis, renderer); CategoryAxis xAxis2 = new CategoryAxis("X2"); plot.setDomainAxis(11, xAxis2); // add a second dataset DefaultCategoryDataset dataset2 = new DefaultCategoryDataset(); dataset2.setValue(1, "R1", "C1"); plot.setDataset(99, dataset); assertEquals(xAxis, plot.getDomainAxisForDataset(99)); // now map the dataset to the second xAxis plot.mapDatasetToDomainAxis(99, 11); assertEquals(xAxis2, plot.getDomainAxisForDataset(99)); }
Example 8
Source File: CategoryPlotTest.java From SIMVA-SoS with Apache License 2.0 | 6 votes |
@Test public void testMapDatasetToDomainAxis() { CategoryDataset dataset = new DefaultCategoryDataset(); CategoryAxis xAxis = new CategoryAxis("X"); NumberAxis yAxis = new NumberAxis("Y"); CategoryItemRenderer renderer = new BarRenderer(); CategoryPlot plot = new CategoryPlot(dataset, xAxis, yAxis, renderer); CategoryAxis xAxis2 = new CategoryAxis("X2"); plot.setDomainAxis(11, xAxis2); // add a second dataset DefaultCategoryDataset dataset2 = new DefaultCategoryDataset(); dataset2.setValue(1, "R1", "C1"); plot.setDataset(99, dataset); assertEquals(xAxis, plot.getDomainAxisForDataset(99)); // now map the dataset to the second xAxis plot.mapDatasetToDomainAxis(99, 11); assertEquals(xAxis2, plot.getDomainAxisForDataset(99)); }
Example 9
Source File: CategoryPlotTest.java From openstock with GNU General Public License v3.0 | 6 votes |
@Test public void testRangeMarkerIndices() { CategoryDataset dataset = new DefaultCategoryDataset(); CategoryAxis xAxis = new CategoryAxis("X"); NumberAxis yAxis = new NumberAxis("Y"); CategoryItemRenderer renderer = new BarRenderer(); CategoryPlot plot = new CategoryPlot(dataset, xAxis, yAxis, renderer); // add a second dataset, plotted against a second axis DefaultCategoryDataset dataset2 = new DefaultCategoryDataset(); dataset2.setValue(1, "R1", "C1"); plot.setDataset(99, dataset); NumberAxis yAxis2 = new NumberAxis("Y2"); plot.setRangeAxis(1, yAxis2); LineAndShapeRenderer renderer2 = new LineAndShapeRenderer(); plot.setRenderer(99, renderer2); plot.mapDatasetToRangeAxis(99, 1); ValueMarker yMarker1 = new ValueMarker(123); plot.addRangeMarker(99, yMarker1, Layer.FOREGROUND); assertTrue(plot.getRangeMarkers(99, Layer.FOREGROUND).contains( yMarker1)); }
Example 10
Source File: LogAxisTests.java From astor with GNU General Public License v2.0 | 6 votes |
/** * A simple test for the auto-range calculation looking at a * NumberAxis used as the range axis for a CategoryPlot. In this * case, the original dataset is replaced with a new dataset. */ public void testAutoRange3() { DefaultCategoryDataset dataset = new DefaultCategoryDataset(); dataset.setValue(100.0, "Row 1", "Column 1"); dataset.setValue(200.0, "Row 1", "Column 2"); JFreeChart chart = ChartFactory.createLineChart("Test", "Categories", "Value", dataset, false); CategoryPlot plot = (CategoryPlot) chart.getPlot(); LogAxis axis = new LogAxis("Log(Y)"); plot.setRangeAxis(axis); assertEquals(96.59363289248458, axis.getLowerBound(), EPSILON); assertEquals(207.0529847682752, axis.getUpperBound(), EPSILON); // now replacing the dataset should update the axis range... DefaultCategoryDataset dataset2 = new DefaultCategoryDataset(); dataset2.setValue(900.0, "Row 1", "Column 1"); dataset2.setValue(1000.0, "Row 1", "Column 2"); plot.setDataset(dataset2); assertEquals(895.2712433374774, axis.getLowerBound(), EPSILON); assertEquals(1005.2819262292991, axis.getUpperBound(), EPSILON); }
Example 11
Source File: LogAxisTests.java From astor with GNU General Public License v2.0 | 6 votes |
/** * A simple test for the auto-range calculation looking at a * LogAxis used as the range axis for a CategoryPlot. */ public void testAutoRange1() { DefaultCategoryDataset dataset = new DefaultCategoryDataset(); dataset.setValue(100.0, "Row 1", "Column 1"); dataset.setValue(200.0, "Row 1", "Column 2"); JFreeChart chart = ChartFactory.createBarChart( "Test", "Categories", "Value", dataset, PlotOrientation.VERTICAL, false, false, false ); CategoryPlot plot = (CategoryPlot) chart.getPlot(); LogAxis axis = new LogAxis("Log(Y)"); plot.setRangeAxis(axis); assertEquals(0.0, axis.getLowerBound(), EPSILON); assertEquals(2.6066426411261268E7, axis.getUpperBound(), EPSILON); }
Example 12
Source File: CategoryPlotTest.java From openstock with GNU General Public License v3.0 | 6 votes |
/** * Datasets are now stored in a Map, and it should be possible to assign * them an arbitrary key (index). */ @Test public void testDatasetIndices() { CategoryDataset dataset = new DefaultCategoryDataset(); CategoryAxis xAxis = new CategoryAxis("X"); NumberAxis yAxis = new NumberAxis("Y"); CategoryItemRenderer renderer = new BarRenderer(); CategoryPlot plot = new CategoryPlot(dataset, xAxis, yAxis, renderer); assertEquals(dataset, plot.getDataset(0)); DefaultCategoryDataset dataset2 = new DefaultCategoryDataset(); dataset2.setValue(1, "R1", "C1"); // we should be able to give a dataset an arbitrary index plot.setDataset(99, dataset2); assertEquals(2, plot.getDatasetCount()); assertEquals(dataset2, plot.getDataset(99)); assertEquals(0, plot.indexOf(dataset)); assertEquals(99, plot.indexOf(dataset2)); }
Example 13
Source File: LogAxisTest.java From buffer_bci with GNU General Public License v3.0 | 5 votes |
/** * A simple test for the auto-range calculation looking at a * LogAxis used as the range axis for a CategoryPlot. */ @Test public void testAutoRange1() { DefaultCategoryDataset dataset = new DefaultCategoryDataset(); dataset.setValue(100.0, "Row 1", "Column 1"); dataset.setValue(200.0, "Row 1", "Column 2"); JFreeChart chart = ChartFactory.createBarChart("Test", "Categories", "Value", dataset); CategoryPlot plot = (CategoryPlot) chart.getPlot(); LogAxis axis = new LogAxis("Log(Y)"); plot.setRangeAxis(axis); assertEquals(0.0, axis.getLowerBound(), EPSILON); assertEquals(2.6066426411261268E7, axis.getUpperBound(), EPSILON); }
Example 14
Source File: LogAxisTest.java From ccu-historian with GNU General Public License v3.0 | 5 votes |
/** * A simple test for the auto-range calculation looking at a * LogAxis used as the range axis for a CategoryPlot. */ @Test public void testAutoRange1() { DefaultCategoryDataset dataset = new DefaultCategoryDataset(); dataset.setValue(100.0, "Row 1", "Column 1"); dataset.setValue(200.0, "Row 1", "Column 2"); JFreeChart chart = ChartFactory.createBarChart("Test", "Categories", "Value", dataset); CategoryPlot plot = (CategoryPlot) chart.getPlot(); LogAxis axis = new LogAxis("Log(Y)"); plot.setRangeAxis(axis); assertEquals(0.0, axis.getLowerBound(), EPSILON); assertEquals(2.6066426411261268E7, axis.getUpperBound(), EPSILON); }
Example 15
Source File: LogAxisTest.java From openstock with GNU General Public License v3.0 | 5 votes |
/** * A simple test for the auto-range calculation looking at a * LogAxis used as the range axis for a CategoryPlot. */ @Test public void testAutoRange1() { DefaultCategoryDataset dataset = new DefaultCategoryDataset(); dataset.setValue(100.0, "Row 1", "Column 1"); dataset.setValue(200.0, "Row 1", "Column 2"); JFreeChart chart = ChartFactory.createBarChart("Test", "Categories", "Value", dataset); CategoryPlot plot = (CategoryPlot) chart.getPlot(); LogAxis axis = new LogAxis("Log(Y)"); plot.setRangeAxis(axis); assertEquals(0.0, axis.getLowerBound(), EPSILON); assertEquals(2.6066426411261268E7, axis.getUpperBound(), EPSILON); }
Example 16
Source File: NumberAxisTests.java From astor with GNU General Public License v2.0 | 5 votes |
/** * A simple test for the auto-range calculation looking at a * NumberAxis used as the range axis for a CategoryPlot. In this * case, the 'autoRangeIncludesZero' flag is set to false. */ public void testAutoRange2() { DefaultCategoryDataset dataset = new DefaultCategoryDataset(); dataset.setValue(100.0, "Row 1", "Column 1"); dataset.setValue(200.0, "Row 1", "Column 2"); JFreeChart chart = ChartFactory.createLineChart("Test", "Categories", "Value", dataset, PlotOrientation.VERTICAL, false, false, false); CategoryPlot plot = (CategoryPlot) chart.getPlot(); NumberAxis axis = (NumberAxis) plot.getRangeAxis(); axis.setAutoRangeIncludesZero(false); assertEquals(axis.getLowerBound(), 95.0, EPSILON); assertEquals(axis.getUpperBound(), 205.0, EPSILON); }
Example 17
Source File: PivotCategorySetCollector.java From pentaho-reporting with GNU Lesser General Public License v2.1 | 5 votes |
protected void buildDataset() { final DataRow dataRow = getDataRow(); final Object categoryObject = dataRow.get( getCategoryColumn() ); if ( categoryObject instanceof Comparable == false ) { return; } final Comparable categoryComparable = (Comparable) categoryObject; // I love to be paranoid! final DefaultCategoryDataset categoryDataset = (DefaultCategoryDataset) getDataSet(); final int maxIndex = this.valueColumns.size(); for ( int i = 0; i < maxIndex; i++ ) { final Comparable seriesName = querySeriesValue( i ); final Object valueObject = dataRow.get( getValueColumn( i ) ); final Number value = ( valueObject instanceof Number ) ? (Number) valueObject : null; final Number existingValue = CollectorFunctionUtil.queryExistingValueFromDataSet( categoryDataset, categoryComparable, seriesName ); if ( existingValue != null ) { if ( value != null ) { categoryDataset.setValue( CollectorFunctionUtil.add( existingValue, value ), categoryComparable, seriesName ); } } else { categoryDataset.setValue( value, categoryComparable, seriesName ); } } }
Example 18
Source File: NumberAxisTest.java From SIMVA-SoS with Apache License 2.0 | 5 votes |
/** * A simple test for the auto-range calculation looking at a * NumberAxis used as the range axis for a CategoryPlot. In this * case, the 'autoRangeIncludesZero' flag is set to false. */ @Test public void testAutoRange2() { DefaultCategoryDataset dataset = new DefaultCategoryDataset(); dataset.setValue(100.0, "Row 1", "Column 1"); dataset.setValue(200.0, "Row 1", "Column 2"); JFreeChart chart = ChartFactory.createLineChart("Test", "Categories", "Value", dataset, PlotOrientation.VERTICAL, false, false, false); CategoryPlot plot = (CategoryPlot) chart.getPlot(); NumberAxis axis = (NumberAxis) plot.getRangeAxis(); axis.setAutoRangeIncludesZero(false); assertEquals(axis.getLowerBound(), 95.0, EPSILON); assertEquals(axis.getUpperBound(), 205.0, EPSILON); }
Example 19
Source File: NumberAxisTest.java From SIMVA-SoS with Apache License 2.0 | 4 votes |
/** * A check for the interaction between the 'autoRangeIncludesZero' flag * and the base setting in the BarRenderer. */ @Test public void testAutoRange4() { DefaultCategoryDataset dataset = new DefaultCategoryDataset(); dataset.setValue(100.0, "Row 1", "Column 1"); dataset.setValue(200.0, "Row 1", "Column 2"); JFreeChart chart = ChartFactory.createBarChart("Test", "Categories", "Value", dataset, PlotOrientation.VERTICAL, false, false, false); CategoryPlot plot = (CategoryPlot) chart.getPlot(); NumberAxis axis = (NumberAxis) plot.getRangeAxis(); axis.setAutoRangeIncludesZero(false); BarRenderer br = (BarRenderer) plot.getRenderer(); br.setIncludeBaseInRange(false); assertEquals(95.0, axis.getLowerBound(), EPSILON); assertEquals(205.0, axis.getUpperBound(), EPSILON); br.setIncludeBaseInRange(true); assertEquals(0.0, axis.getLowerBound(), EPSILON); assertEquals(210.0, axis.getUpperBound(), EPSILON); axis.setAutoRangeIncludesZero(true); assertEquals(0.0, axis.getLowerBound(), EPSILON); assertEquals(210.0, axis.getUpperBound(), EPSILON); br.setIncludeBaseInRange(true); assertEquals(0.0, axis.getLowerBound(), EPSILON); assertEquals(210.0, axis.getUpperBound(), EPSILON); // now replacing the dataset should update the axis range... DefaultCategoryDataset dataset2 = new DefaultCategoryDataset(); dataset2.setValue(900.0, "Row 1", "Column 1"); dataset2.setValue(1000.0, "Row 1", "Column 2"); plot.setDataset(dataset2); assertEquals(0.0, axis.getLowerBound(), EPSILON); assertEquals(1050.0, axis.getUpperBound(), EPSILON); br.setIncludeBaseInRange(false); assertEquals(0.0, axis.getLowerBound(), EPSILON); assertEquals(1050.0, axis.getUpperBound(), EPSILON); axis.setAutoRangeIncludesZero(false); assertEquals(895.0, axis.getLowerBound(), EPSILON); assertEquals(1005.0, axis.getUpperBound(), EPSILON); }
Example 20
Source File: NumberAxisTests.java From astor with GNU General Public License v2.0 | 4 votes |
/** * A check for the interaction between the 'autoRangeIncludesZero' flag * and the base setting in the BarRenderer. */ public void testAutoRange4() { DefaultCategoryDataset dataset = new DefaultCategoryDataset(); dataset.setValue(100.0, "Row 1", "Column 1"); dataset.setValue(200.0, "Row 1", "Column 2"); JFreeChart chart = ChartFactory.createBarChart("Test", "Categories", "Value", dataset, PlotOrientation.VERTICAL, false, false, false); CategoryPlot plot = (CategoryPlot) chart.getPlot(); NumberAxis axis = (NumberAxis) plot.getRangeAxis(); axis.setAutoRangeIncludesZero(false); BarRenderer br = (BarRenderer) plot.getRenderer(); br.setIncludeBaseInRange(false); assertEquals(95.0, axis.getLowerBound(), EPSILON); assertEquals(205.0, axis.getUpperBound(), EPSILON); br.setIncludeBaseInRange(true); assertEquals(0.0, axis.getLowerBound(), EPSILON); assertEquals(210.0, axis.getUpperBound(), EPSILON); axis.setAutoRangeIncludesZero(true); assertEquals(0.0, axis.getLowerBound(), EPSILON); assertEquals(210.0, axis.getUpperBound(), EPSILON); br.setIncludeBaseInRange(true); assertEquals(0.0, axis.getLowerBound(), EPSILON); assertEquals(210.0, axis.getUpperBound(), EPSILON); // now replacing the dataset should update the axis range... DefaultCategoryDataset dataset2 = new DefaultCategoryDataset(); dataset2.setValue(900.0, "Row 1", "Column 1"); dataset2.setValue(1000.0, "Row 1", "Column 2"); plot.setDataset(dataset2); assertEquals(0.0, axis.getLowerBound(), EPSILON); assertEquals(1050.0, axis.getUpperBound(), EPSILON); br.setIncludeBaseInRange(false); assertEquals(0.0, axis.getLowerBound(), EPSILON); assertEquals(1050.0, axis.getUpperBound(), EPSILON); axis.setAutoRangeIncludesZero(false); assertEquals(895.0, axis.getLowerBound(), EPSILON); assertEquals(1005.0, axis.getUpperBound(), EPSILON); }