Java Code Examples for org.jfree.data.category.DefaultCategoryDataset#addValue()
The following examples show how to use
org.jfree.data.category.DefaultCategoryDataset#addValue() .
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: LevelRendererTest.java From ccu-historian with GNU General Public License v3.0 | 6 votes |
/** * Draws the chart with a <code>null</code> info object to make sure that * no exceptions are thrown (particularly by code in the renderer). */ @Test public void testDrawWithNullInfo() { try { DefaultCategoryDataset dataset = new DefaultCategoryDataset(); dataset.addValue(1.0, "S1", "C1"); CategoryPlot plot = new CategoryPlot(dataset, new CategoryAxis("Category"), new NumberAxis("Value"), new LevelRenderer()); JFreeChart chart = new JFreeChart(plot); /* BufferedImage image = */ chart.createBufferedImage(300, 200, null); } catch (NullPointerException e) { fail("No exception should be thrown."); } }
Example 2
Source File: Chart_2_DatasetUtilities_t.java From coming with MIT License | 6 votes |
/** * Creates a {@link CategoryDataset} by copying the data from the supplied * {@link KeyedValues} instance. * * @param rowKey the row key (<code>null</code> not permitted). * @param rowData the row data (<code>null</code> not permitted). * * @return A dataset. */ public static CategoryDataset createCategoryDataset(Comparable rowKey, KeyedValues rowData) { if (rowKey == null) { throw new IllegalArgumentException("Null 'rowKey' argument."); } if (rowData == null) { throw new IllegalArgumentException("Null 'rowData' argument."); } DefaultCategoryDataset result = new DefaultCategoryDataset(); for (int i = 0; i < rowData.getItemCount(); i++) { result.addValue(rowData.getValue(i), rowKey, rowData.getKey(i)); } return result; }
Example 3
Source File: AbstractCategoryItemRendererTests.java From astor with GNU General Public License v2.0 | 6 votes |
/** * Some checks for the findRangeBounds() method. */ public void testFindRangeBounds() { AbstractCategoryItemRenderer r = new LineAndShapeRenderer(); assertNull(r.findRangeBounds(null)); // an empty dataset should return a null range DefaultCategoryDataset dataset = new DefaultCategoryDataset(); assertNull(r.findRangeBounds(dataset)); dataset.addValue(1.0, "R1", "C1"); assertEquals(new Range(1.0, 1.0), r.findRangeBounds(dataset)); dataset.addValue(-2.0, "R1", "C2"); assertEquals(new Range(-2.0, 1.0), r.findRangeBounds(dataset)); dataset.addValue(null, "R1", "C3"); assertEquals(new Range(-2.0, 1.0), r.findRangeBounds(dataset)); }
Example 4
Source File: DatasetUtilities.java From astor with GNU General Public License v2.0 | 6 votes |
/** * Creates a {@link CategoryDataset} by copying the data from the supplied * {@link KeyedValues} instance. * * @param rowKey the row key (<code>null</code> not permitted). * @param rowData the row data (<code>null</code> not permitted). * * @return A dataset. */ public static CategoryDataset createCategoryDataset(Comparable rowKey, KeyedValues rowData) { if (rowKey == null) { throw new IllegalArgumentException("Null 'rowKey' argument."); } if (rowData == null) { throw new IllegalArgumentException("Null 'rowData' argument."); } DefaultCategoryDataset result = new DefaultCategoryDataset(); for (int i = 0; i < rowData.getItemCount(); i++) { result.addValue(rowData.getValue(i), rowKey, rowData.getKey(i)); } return result; }
Example 5
Source File: Cardumen_00194_s.java From coming with MIT License | 6 votes |
/** * Creates a {@link CategoryDataset} that contains a copy of the data in * an array. * <p> * Row and column keys are created by appending 0, 1, 2, ... to the * supplied prefixes. * * @param rowKeyPrefix the row key prefix. * @param columnKeyPrefix the column key prefix. * @param data the data. * * @return The dataset. */ public static CategoryDataset createCategoryDataset(String rowKeyPrefix, String columnKeyPrefix, Number[][] data) { DefaultCategoryDataset result = new DefaultCategoryDataset(); for (int r = 0; r < data.length; r++) { String rowKey = rowKeyPrefix + (r + 1); for (int c = 0; c < data[r].length; c++) { String columnKey = columnKeyPrefix + (c + 1); result.addValue(data[r][c], rowKey, columnKey); } } return result; }
Example 6
Source File: SpiderWebPlotTest.java From ccu-historian with GNU General Public License v3.0 | 6 votes |
/** * Fetches the legend items and checks the values. */ @Test public void testGetLegendItems() { DefaultCategoryDataset dataset = new DefaultCategoryDataset(); dataset.addValue(35.0, "S1", "C1"); dataset.addValue(45.0, "S1", "C2"); dataset.addValue(55.0, "S2", "C1"); dataset.addValue(15.0, "S2", "C2"); SpiderWebPlot plot = new SpiderWebPlot(dataset); JFreeChart chart = new JFreeChart(plot); LegendItemCollection legendItems = plot.getLegendItems(); assertEquals(2, legendItems.getItemCount()); LegendItem item1 = legendItems.get(0); assertEquals("S1", item1.getLabel()); assertEquals("S1", item1.getSeriesKey()); assertEquals(0, item1.getSeriesIndex()); assertEquals(dataset, item1.getDataset()); assertEquals(0, item1.getDatasetIndex()); LegendItem item2 = legendItems.get(1); assertEquals("S2", item2.getLabel()); assertEquals("S2", item2.getSeriesKey()); assertEquals(1, item2.getSeriesIndex()); assertEquals(dataset, item2.getDataset()); assertEquals(0, item2.getDatasetIndex()); }
Example 7
Source File: StackedBarRendererTest.java From SIMVA-SoS with Apache License 2.0 | 6 votes |
/** * Some checks for the findRangeBounds() method. */ @Test public void testFindRangeBounds() { StackedBarRenderer r = new StackedBarRenderer(); assertNull(r.findRangeBounds(null)); // an empty dataset should return a null range DefaultCategoryDataset dataset = new DefaultCategoryDataset(); assertNull(r.findRangeBounds(dataset)); dataset.addValue(1.0, "R1", "C1"); assertEquals(new Range(0.0, 1.0), r.findRangeBounds(dataset)); dataset.addValue(-2.0, "R1", "C2"); assertEquals(new Range(-2.0, 1.0), r.findRangeBounds(dataset)); dataset.addValue(null, "R1", "C3"); assertEquals(new Range(-2.0, 1.0), r.findRangeBounds(dataset)); dataset.addValue(2.0, "R2", "C1"); assertEquals(new Range(-2.0, 3.0), r.findRangeBounds(dataset)); dataset.addValue(null, "R2", "C2"); assertEquals(new Range(-2.0, 3.0), r.findRangeBounds(dataset)); }
Example 8
Source File: CategoryItemEntityTest.java From SIMVA-SoS with Apache License 2.0 | 5 votes |
/** * Confirm that cloning works. */ @Test public void testCloning() throws CloneNotSupportedException { DefaultCategoryDataset d = new DefaultCategoryDataset(); d.addValue(1.0, "R1", "C1"); d.addValue(2.0, "R1", "C2"); d.addValue(3.0, "R2", "C1"); d.addValue(4.0, "R2", "C2"); CategoryItemEntity e1 = new CategoryItemEntity(new Rectangle2D.Double( 1.0, 2.0, 3.0, 4.0), "ToolTip", "URL", d, 1, "C2", 1); CategoryItemEntity e2 = (CategoryItemEntity) e1.clone(); assertTrue(e1 != e2); assertTrue(e1.getClass() == e2.getClass()); assertTrue(e1.equals(e2)); }
Example 9
Source File: StackedBarRenderer3DTest.java From buffer_bci with GNU General Public License v3.0 | 5 votes |
/** * A test for the createStackedValueList() method. */ @Test public void testCreateStackedValueList1b() { DefaultCategoryDataset d = new DefaultCategoryDataset(); d.addValue(1.0, "s0", "c0"); d.addValue(-1.1, "s1", "c0"); MyRenderer r = new MyRenderer(); List l = r.createStackedValueList(d, "c0", new int[] { 0, 1 }, 0.0, false); assertEquals(3, l.size()); assertEquals(new Double(-1.1), ((Object[]) l.get(0))[1]); assertEquals(new Double(0.0), ((Object[]) l.get(1))[1]); assertEquals(new Double(1.0), ((Object[]) l.get(2))[1]); }
Example 10
Source File: StackedBarRenderer3DTest.java From buffer_bci with GNU General Public License v3.0 | 5 votes |
/** * A test for the createStackedValueList() method. */ @Test public void testCreateStackedValueList2() { DefaultCategoryDataset d = new DefaultCategoryDataset(); d.addValue(-1.0, "s0", "c0"); MyRenderer r = new MyRenderer(); List l = r.createStackedValueList(d, "c0", new int[] { 0 }, 0.0, false); assertEquals(2, l.size()); assertEquals(new Double(-1.0), ((Object[]) l.get(0))[1]); assertEquals(new Double(0.0), ((Object[]) l.get(1))[1]); }
Example 11
Source File: StackedBarRenderer3DTest.java From openstock with GNU General Public License v3.0 | 5 votes |
/** * A test for the createStackedValueList() method. */ @Test public void testCreateStackedValueList1() { DefaultCategoryDataset d = new DefaultCategoryDataset(); d.addValue(1.0, "s0", "c0"); MyRenderer r = new MyRenderer(); List l = r.createStackedValueList(d, "c0", new int[] { 0 }, 0.0, false); assertEquals(2, l.size()); assertEquals(new Double(0.0), ((Object[]) l.get(0))[1]); assertEquals(new Double(1.0), ((Object[]) l.get(1))[1]); }
Example 12
Source File: DatasetUtilitiesTest.java From buffer_bci with GNU General Public License v3.0 | 5 votes |
/** * Creates a dataset for testing. * * @return A dataset. */ private CategoryDataset createCategoryDataset1() { DefaultCategoryDataset result = new DefaultCategoryDataset(); result.addValue(1.0, "R0", "C0"); result.addValue(1.0, "R1", "C0"); result.addValue(1.0, "R2", "C0"); result.addValue(4.0, "R0", "C1"); result.addValue(5.0, "R1", "C1"); result.addValue(6.0, "R2", "C1"); return result; }
Example 13
Source File: StackedBarRenderer3DTests.java From astor with GNU General Public License v2.0 | 5 votes |
/** * A test for the createStackedValueList() method. */ public void testCreateStackedValueList4() { DefaultCategoryDataset d = new DefaultCategoryDataset(); d.addValue(null, "s0", "c0"); MyRenderer r = new MyRenderer(); List l = r.createStackedValueList(d, "c0", new int[] { 0 }, 0.0, false); assertEquals(0, l.size()); }
Example 14
Source File: DatasetUtilitiesTest.java From ccu-historian with GNU General Public License v3.0 | 5 votes |
/** * Check that the findCumulativeRangeBounds() method ignores Double.NaN * values. */ @Test public void testCumulativeRange_NaN() { DefaultCategoryDataset dataset = new DefaultCategoryDataset(); dataset.addValue(10.0, "Series 1", "Start"); dataset.addValue(15.0, "Series 1", "Delta 1"); dataset.addValue(Double.NaN, "Series 1", "Delta 2"); Range range = DatasetUtilities.findCumulativeRangeBounds(dataset); assertEquals(0.0, range.getLowerBound(), EPSILON); assertEquals(25.0, range.getUpperBound(), EPSILON); }
Example 15
Source File: FXCategoryChartGestureDemo.java From mzmine2 with GNU General Public License v2.0 | 5 votes |
/** * Creates a dataset, consisting of two series of monthly data. * * @return the dataset. */ private static CategoryDataset createDataset() { DefaultCategoryDataset data = new DefaultCategoryDataset(); Random r = new Random(System.currentTimeMillis()); for (int i = 0; i < 3; i++) { for (int t = 0; t < 2; t++) { for (int x = 0; x < 100; x++) { double v = r.nextGaussian() * (i + 1); data.addValue(v, "series" + i, "type" + t); } } } return data; }
Example 16
Source File: StackedBarRenderer3DTest.java From ECG-Viewer with GNU General Public License v2.0 | 5 votes |
/** * A test for the createStackedValueList() method. */ @Test public void testCreateStackedValueList5() { DefaultCategoryDataset d = new DefaultCategoryDataset(); d.addValue(1.0, "s0", "c0"); d.addValue(null, "s1", "c0"); d.addValue(2.0, "s2", "c0"); MyRenderer r = new MyRenderer(); List l = r.createStackedValueList(d, "c0", new int[] { 0, 1, 2 }, 0.0, false); assertEquals(3, l.size()); assertEquals(new Double(0.0), ((Object[]) l.get(0))[1]); assertEquals(new Double(1.0), ((Object[]) l.get(1))[1]); assertEquals(new Double(3.0), ((Object[]) l.get(2))[1]); }
Example 17
Source File: DatasetUtilitiesTests.java From astor with GNU General Public License v2.0 | 5 votes |
/** * Some checks for the findStackedRangeBounds(CategoryDataset, * KeyToGroupMap) method. */ public void testFindStackedRangeBounds_CategoryDataset3() { DefaultCategoryDataset dataset = new DefaultCategoryDataset(); KeyToGroupMap map = new KeyToGroupMap("Group A"); Range r = DatasetUtilities.findStackedRangeBounds(dataset, map); assertTrue(r == null); dataset.addValue(1.0, "R1", "C1"); dataset.addValue(2.0, "R2", "C1"); dataset.addValue(3.0, "R3", "C1"); dataset.addValue(4.0, "R4", "C1"); map.mapKeyToGroup("R1", "Group A"); map.mapKeyToGroup("R2", "Group A"); map.mapKeyToGroup("R3", "Group B"); map.mapKeyToGroup("R4", "Group B"); r = DatasetUtilities.findStackedRangeBounds(dataset, map); assertEquals(0.0, r.getLowerBound(), EPSILON); assertEquals(7.0, r.getUpperBound(), EPSILON); dataset.addValue(null, "R5", "C1"); r = DatasetUtilities.findStackedRangeBounds(dataset, map); assertEquals(0.0, r.getLowerBound(), EPSILON); assertEquals(7.0, r.getUpperBound(), EPSILON); dataset.addValue(Double.NaN, "R6", "C1"); r = DatasetUtilities.findStackedRangeBounds(dataset, map); assertEquals(0.0, r.getLowerBound(), EPSILON); assertEquals(7.0, r.getUpperBound(), EPSILON); }
Example 18
Source File: ChartServiceImpl.java From sakai with Educational Community License v2.0 | 5 votes |
private DefaultCategoryDataset getVisitsMonthDataSet(String siteId, int width) { // log.info("Generating visitsMonthDataSet"); SummaryVisitsChartData svc = M_sm.getSummaryVisitsChartData(siteId, StatsManager.VIEW_MONTH); if(svc == null) return null; DefaultCategoryDataset visitsMonthDataSet = new DefaultCategoryDataset(); String visits = msgs.getString("legend_visits"); String uniqueVisits = msgs.getString("legend_unique_visitors"); Day day; Calendar cal = Calendar.getInstance(); cal.setTime(svc.getFirstDay()); Calendar currDay = (Calendar) cal.clone(); long visitsData[] = svc.getVisits(); long uniqueVisitsData[] = svc.getUniqueVisits(); for(int i = 0; i < visitsData.length; i++){ int dayOfMonth = currDay.get(Calendar.DAY_OF_MONTH); if(canUseNormalFontSize(width) || (i == 0 || i == 30 - 1 || i % 2 == 0)){ day = new Day(dayOfMonth, Integer.toString(dayOfMonth)); }else{ day = new Day(dayOfMonth, ""); } visitsMonthDataSet.addValue(visitsData[i], visits, day); visitsMonthDataSet.addValue(uniqueVisitsData[i], uniqueVisits, day); currDay.add(Calendar.DAY_OF_MONTH, 1); } return visitsMonthDataSet; }
Example 19
Source File: ChartViewerUtil.java From cst with GNU Lesser General Public License v3.0 | 5 votes |
public static synchronized void updateValueInChartByMemory(DefaultCategoryDataset dataset, List<? extends Codelet> codelets, String memoryName) { ArrayList<Codelet> tempCodeletsList = new ArrayList<Codelet>(); tempCodeletsList.addAll(codelets); synchronized (tempCodeletsList) { for (Codelet co : tempCodeletsList) { dataset.addValue(co.getOutput(memoryName).getEvaluation(), co.getName(), "activation"); } } }
Example 20
Source File: CategoryItemEntityTest.java From SIMVA-SoS with Apache License 2.0 | 5 votes |
/** * Serialize an instance, restore it, and check for equality. */ @Test public void testSerialization() { DefaultCategoryDataset d = new DefaultCategoryDataset(); d.addValue(1.0, "R1", "C1"); d.addValue(2.0, "R1", "C2"); d.addValue(3.0, "R2", "C1"); d.addValue(4.0, "R2", "C2"); CategoryItemEntity e1 = new CategoryItemEntity(new Rectangle2D.Double( 1.0, 2.0, 3.0, 4.0), "ToolTip", "URL", d, 1, "C2", 1); CategoryItemEntity e2 = (CategoryItemEntity) TestUtilities.serialised(e1); assertEquals(e1, e2); }