List of usage examples for org.jfree.data.statistics DefaultStatisticalCategoryDataset DefaultStatisticalCategoryDataset
public DefaultStatisticalCategoryDataset()
From source file:edu.ucla.stat.SOCR.chart.demo.StatisticalLineChartDemo3.java
/** * Creates a sample dataset.//from ww w . jav a 2 s . c o m * * @return The dataset. */ protected CategoryDataset createDataset(boolean isDemo) { double mean, stdDev; if (isDemo) { SERIES_COUNT = 2; // CATEGORY_COUNT = 4; VALUE_COUNT = 10; values_storage = new String[SERIES_COUNT][CATEGORY_COUNT]; DefaultStatisticalCategoryDataset dataset = new DefaultStatisticalCategoryDataset(); for (int s = 0; s < SERIES_COUNT; s++) { for (int c = 0; c < CATEGORY_COUNT; c++) { Double[] values = createValueList(0, 20.0, VALUE_COUNT); values_storage[s][c] = vs; mean = Statistics.calculateMean(values); stdDev = Statistics.getStdDev(values); dataset.add(mean, stdDev, "Series " + s, "Category " + c); } } return dataset; } else return super.createDataset(false); }
From source file:edu.ucla.stat.SOCR.chart.demo.StatisticalBarChartDemo3.java
/** * Creates a sample dataset./*from w w w . ja v a2 s. c o m*/ * * @return The dataset. */ protected CategoryDataset createDataset(boolean isDemo) { double mean, stdDev; if (isDemo) { SERIES_COUNT = 3; // CATEGORY_COUNT = 1; VALUE_COUNT = 10; values_storage = new String[SERIES_COUNT][CATEGORY_COUNT]; DefaultStatisticalCategoryDataset dataset = new DefaultStatisticalCategoryDataset(); for (int s = 0; s < SERIES_COUNT; s++) { for (int c = 0; c < CATEGORY_COUNT; c++) { Double[] values = createValueList(0, 20.0, VALUE_COUNT); values_storage[s][c] = vs; mean = Statistics.calculateMean(values); stdDev = Statistics.getStdDev(values); dataset.add(mean, stdDev, "Series " + s, "Category " + c); } } return dataset; } else return super.createDataset(false); }
From source file:org.jfree.data.statistics.DefaultStatisticalCategoryDatasetTest.java
/** * Confirm that the equals method can distinguish all the required fields. *///from w ww . j a v a 2s . c o m @Test public void testEquals() { DefaultStatisticalCategoryDataset d1 = new DefaultStatisticalCategoryDataset(); DefaultStatisticalCategoryDataset d2 = new DefaultStatisticalCategoryDataset(); assertTrue(d1.equals(d2)); assertTrue(d2.equals(d1)); }
From source file:org.jfree.data.statistics.DefaultStatisticalCategoryDatasetTest.java
/** * Some checks for cloning.//w w w. ja v a 2 s. c o m */ @Test public void testCloning() { DefaultStatisticalCategoryDataset d1 = new DefaultStatisticalCategoryDataset(); d1.add(1.1, 2.2, "R1", "C1"); d1.add(3.3, 4.4, "R1", "C2"); d1.add(null, new Double(5.5), "R1", "C3"); d1.add(new Double(6.6), null, "R2", "C3"); DefaultStatisticalCategoryDataset d2 = null; try { d2 = (DefaultStatisticalCategoryDataset) d1.clone(); } catch (CloneNotSupportedException e) { fail(e.toString()); } assertTrue(d1 != d2); assertTrue(d1.getClass() == d2.getClass()); assertTrue(d1.equals(d2)); // check independence d1.add(1.1, 2.2, "R3", "C1"); assertFalse(d1.equals(d2)); }
From source file:edu.ucla.stat.SOCR.chart.demo.StatisticalBarChartDemo1a.java
/** * @param isdemo data come from demo(true) or dataTable(false) */// w w w . j a v a2 s . c o m protected CategoryDataset createDataset(boolean isDemo) { if (isDemo) { DefaultStatisticalCategoryDataset dataset = new DefaultStatisticalCategoryDataset(); dataset.add(10.0, 2.4, "Series 1", "C1"); dataset.add(15.0, 4.4, "Series 1", "C2"); dataset.add(13.0, 2.1, "Series 1", "C3"); dataset.add(7.0, 1.3, "Series 1", "C4"); dataset.add(22.0, 2.4, "Series 2", "C1"); dataset.add(18.0, 4.4, "Series 2", "C2"); dataset.add(28.0, 2.1, "Series 2", "C3"); dataset.add(17.0, 1.3, "Series 2", "C4"); return dataset; } else return super.createDataset(false); }
From source file:org.aksw.iguana.reborn.charts.datasets.StatisticalBarChartDemo.java
/** * Creates a sample dataset./*from w w w . ja v a2 s. c om*/ * * @return The dataset. */ private StatisticalCategoryDataset createDataset() { final DefaultStatisticalCategoryDataset result = new DefaultStatisticalCategoryDataset(); result.add(32.5, 17.9, "Series 1", "Type 1"); result.add(27.8, 11.4, "Series 1", "Type 2"); result.add(29.3, 14.4, "Series 1", "Type 3"); result.add(37.9, 10.3, "Series 1", "Type 4"); result.add(22.9, 7.9, "Series 2", "Type 1"); result.add(21.8, 18.4, "Series 2", "Type 2"); result.add(19.3, 12.4, "Series 2", "Type 3"); result.add(30.3, 20.7, "Series 2", "Type 4"); result.add(12.5, 10.9, "Series 3", "Type 1"); result.add(24.8, 7.4, "Series 3", "Type 2"); result.add(19.3, 13.4, "Series 3", "Type 3"); result.add(17.1, 10.6, "Series 3", "Type 4"); return result; }
From source file:org.ow2.clif.jenkins.ClifProjectAction.java
private JFreeChart createActionGraph(ClifGraphParam params) { DefaultStatisticalCategoryDataset timeDS = new DefaultStatisticalCategoryDataset(); DataSetBuilder<String, ChartUtil.NumberOnlyBuildLabel> minmaxDS = new DataSetBuilder<String, ChartUtil.NumberOnlyBuildLabel>(); List<AbstractBuild> builds = new ArrayList<AbstractBuild>(getProject().getBuilds()); Collections.sort(builds);/*from w w w. ja v a 2 s. co m*/ for (Run<?, ?> currentBuild : builds) { Result buildResult = currentBuild.getResult(); if (buildResult != null && buildResult.isBetterOrEqualTo(Result.SUCCESS)) { ChartUtil.NumberOnlyBuildLabel label = new ChartUtil.NumberOnlyBuildLabel(currentBuild); ClifBuildAction clifBuildAction = currentBuild.getAction(ClifBuildAction.class); if (clifBuildAction == null) { continue; } ClifReport clifReport = clifBuildAction.getReport(); if (clifReport == null) { continue; } TestPlan tp = clifReport.getTestplan(params.getTestPlan()); if (tp == null) { continue; } if (tp.getAggregatedMeasures() != null) { Measure m = tp.getAggregatedMeasure(params.getLabel()); if (m == null) { continue; } timeDS.add(m.getAverage(), m.getStdDev(), Messages.ProjectAction_Mean(), label); minmaxDS.add(m.getMax(), Messages.ProjectAction_Max(), label); minmaxDS.add(m.getMin(), Messages.ProjectAction_Min(), label); } } } final CategoryAxis xAxis = new CategoryAxis(Messages.ProjectAction_BuildAxis()); xAxis.setLowerMargin(0.01); xAxis.setUpperMargin(0.01); xAxis.setCategoryLabelPositions(CategoryLabelPositions.UP_90); xAxis.setMaximumCategoryLabelLines(3); final ValueAxis timeAxis = new NumberAxis(Messages.ProjectAction_TimeAxis()); timeAxis.setUpperMargin(0.1); // final ValueAxis minmaxTimeAxis = new NumberAxis("Time (ms)"); final BarRenderer timeRenderer = new StatisticalBarRenderer(); timeRenderer.setSeriesPaint(2, ColorPalette.RED); timeRenderer.setSeriesPaint(1, ColorPalette.YELLOW); timeRenderer.setSeriesPaint(0, ColorPalette.BLUE); timeRenderer.setItemMargin(0.0); final CategoryPlot plot = new CategoryPlot(timeDS, xAxis, timeAxis, timeRenderer); plot.setBackgroundPaint(Color.WHITE); plot.setOutlinePaint(null); plot.setForegroundAlpha(0.8f); plot.setRangeGridlinesVisible(true); plot.setRangeGridlinePaint(Color.black); final CategoryItemRenderer minmaxRenderer = new LineAndShapeRenderer(); // plot.setRangeAxis(1, timeAxis); plot.setDataset(1, minmaxDS.build()); plot.mapDatasetToRangeAxis(1, 0); plot.setRenderer(1, minmaxRenderer); JFreeChart chart = new JFreeChart(params.getLabel(), plot); chart.setBackgroundPaint(Color.WHITE); return chart; }
From source file:edu.ucla.stat.SOCR.chart.SuperCategoryChart_StatA.java
/** * @param isdemo data come from demo(true) or dataTable(false) *//* w w w .j a v a 2 s. co m*/ protected CategoryDataset createDataset(boolean isDemo) { if (isDemo) { return super.createDataset(true); } else { try { setArrayFromTable(); double[][] xmean = new double[xyLength][independentVarLength]; double[][] xstdDev = new double[xyLength][independentVarLength]; String[][] y = new String[xyLength][dependentVarLength]; String[] ss = new String[2]; for (int index = 0; index < independentVarLength; index++) for (int i = 0; i < xyLength; i++) { if (indepValues[i][index] == null || indepValues[i][index].length() == 0) { if (index % 2 == 0) xmean[i][index / 2] = 0.0; else xstdDev[i][index / 2] = 0.0; } else { if (index % 2 == 0) xmean[i][index / 2] = Double.parseDouble(indepValues[i][index]); else xstdDev[i][index / 2] = Double.parseDouble(indepValues[i][index]); } } for (int index = 0; index < dependentVarLength; index++) for (int i = 0; i < xyLength; i++) y[i][index] = depValues[i][index]; // create the dataset... dataset = new DefaultStatisticalCategoryDataset(); //dependent for (int j = 0; j < xyLength; j++) for (int i = 0; i < independentVarLength / 2; i++) { String header = "C" + i; if (independentHeaders[i * 2].length() != 0 && independentHeaders[i * 2].indexOf("Mean") != -1) header = independentHeaders[i * 2].substring(0, independentHeaders[i * 2].indexOf("Mean")); if (y[j][0] != null) dataset.add(xmean[j][i], xstdDev[j][i], y[j][0], header); //System.out.println("adding :("+x[j][i]+","+y[j]+","+independentHeaders[i]+")" ); } return dataset; } catch (NumberFormatException e) { showMessageDialog("Data format error!"); return null; } } }
From source file:edu.ucla.stat.SOCR.chart.SuperCategoryChart_Stat.java
/** * @param isdemo data come from demo(true) or dataTable(false) *///from ww w.j ava 2 s .com protected CategoryDataset createDataset(boolean isDemo) { if (isDemo) { return super.createDataset(true); } else { try { setArrayFromTable(); double[][] xmean = new double[xyLength][independentVarLength]; double[][] xstdDev = new double[xyLength][independentVarLength]; String[][] y = new String[xyLength][dependentVarLength]; String[] ss = new String[2]; for (int index = 0; index < independentVarLength; index++) for (int i = 0; i < xyLength; i++) { if (indepValues[i][index] == null || indepValues[i][index].length() == 0) { xmean[i][index] = 0.0; xstdDev[i][index] = 0.0; } else { StringTokenizer st = new StringTokenizer(indepValues[i][index], DELIMITERS); ss[0] = st.nextToken(); ss[1] = st.nextToken(); // ss = indepValues[i][index].split("( *)+,+( *)"); xmean[i][index] = Double.parseDouble(ss[0]); xstdDev[i][index] = Double.parseDouble(ss[1]); } } for (int index = 0; index < dependentVarLength; index++) for (int i = 0; i < xyLength; i++) y[i][index] = depValues[i][index]; // create the dataset... dataset = new DefaultStatisticalCategoryDataset(); //dependent for (int j = 0; j < xyLength; j++) for (int i = 0; i < independentVarLength; i++) { if (y[j][0] != null) dataset.add(xmean[j][i], xstdDev[j][i], y[j][0], independentHeaders[i]); //System.out.println("adding :("+x[j][i]+","+y[j]+","+independentHeaders[i]+")" ); } return dataset; } catch (NumberFormatException e) { showMessageDialog("Data format error!"); return null; } } }
From source file:org.jfree.data.statistics.DefaultStatisticalCategoryDatasetTest.java
/** * Check serialization of a default instance. */// ww w.j a va2 s . c om @Test public void testSerialization1() { DefaultStatisticalCategoryDataset d1 = new DefaultStatisticalCategoryDataset(); d1.add(1.1, 2.2, "R1", "C1"); d1.add(3.3, 4.4, "R1", "C2"); d1.add(null, new Double(5.5), "R1", "C3"); d1.add(new Double(6.6), null, "R2", "C3"); DefaultStatisticalCategoryDataset d2 = (DefaultStatisticalCategoryDataset) TestUtilities.serialised(d1); assertEquals(d1, d2); }