List of usage examples for org.jfree.data.statistics DefaultBoxAndWhiskerCategoryDataset add
public void add(BoxAndWhiskerItem item, Comparable rowKey, Comparable columnKey)
From source file:edu.ucla.stat.SOCR.chart.demo.BoxAndWhiskerChartDemo1.java
/** * Returns a sample dataset./*from w ww . j av a2 s . co m*/ * * @return The dataset. */ protected BoxAndWhiskerCategoryDataset createDataset(boolean isDemo) { if (isDemo) { SERIES_COUNT = 3; CATEGORY_COUNT = 2; VALUE_COUNT = 10; values_storage = new String[SERIES_COUNT][CATEGORY_COUNT]; DefaultBoxAndWhiskerCategoryDataset result = new DefaultBoxAndWhiskerCategoryDataset(); for (int s = 0; s < SERIES_COUNT; s++) { for (int c = 0; c < CATEGORY_COUNT; c++) { List values = createValueList(0, 20.0, VALUE_COUNT); values_storage[s][c] = vs; result.add(values, "Series " + s, "Category " + c); } } return result; } else return super.createDataset(false); }
From source file:edu.ucla.stat.SOCR.chart.demo.BoxAndWhiskerChartDemo3.java
/** * Returns a sample dataset./*from www. j ava 2 s . c o m*/ * * @return The dataset. */ protected BoxAndWhiskerCategoryDataset createDataset(boolean isDemo) { if (isDemo) { rangeLabel = "Value"; SERIES_COUNT = 3; // CATEGORY_COUNT = 2; VALUE_COUNT = 10; values_storage = new String[SERIES_COUNT][CATEGORY_COUNT]; DefaultBoxAndWhiskerCategoryDataset result = new DefaultBoxAndWhiskerCategoryDataset(); for (int s = 0; s < SERIES_COUNT; s++) { for (int c = 0; c < CATEGORY_COUNT; c++) { List values = createValueList(0, 20.0, VALUE_COUNT); values_storage[s][c] = vs; result.add(values, "Series " + s, "Category " + c); } } return result; } else return super.createDataset(false); }
From source file:org.jax.bham.test.PhenotypeEffectPlotPanel.java
private BoxAndWhiskerCategoryDataset createDataset() { DefaultBoxAndWhiskerCategoryDataset dataset = new DefaultBoxAndWhiskerCategoryDataset(); if (this.showIndividualStrainEffectsCheckBox.isSelected()) { for (Entry<String, ? extends Collection<String>> strainGroupEntry : this.strainGroups.entrySet()) { for (String strain : strainGroupEntry.getValue()) { dataset.add(this.phenotypeData.get(strain), strain, strainGroupEntry.getKey()); }//from ww w . ja v a 2 s .c om } } else { Map<String, Double> meanPhenoData = new HashMap<String, Double>(this.phenotypeData.size()); for (Entry<String, List<Double>> phenoEntry : this.phenotypeData.entrySet()) { if (!phenoEntry.getValue().isEmpty()) { double sum = 0.0; for (double value : phenoEntry.getValue()) { sum += value; } double mean = sum / phenoEntry.getValue().size(); meanPhenoData.put(phenoEntry.getKey(), mean); } } for (Entry<String, ? extends Collection<String>> strainGroupEntry : this.strainGroups.entrySet()) { List<Double> valueList = new ArrayList<Double>(strainGroupEntry.getValue().size()); for (String strain : strainGroupEntry.getValue()) { valueList.add(meanPhenoData.get(strain)); } dataset.add(valueList, SequenceUtilities.toString(strainGroupEntry.getValue(), ", "), strainGroupEntry.getKey()); } } return dataset; }
From source file:org.jfree.data.statistics.DefaultBoxAndWhiskerCategoryDatasetTest.java
/** * Some checks for the remove method.//from ww w. j av a 2 s.c o m */ @Test public void testRemove() { DefaultBoxAndWhiskerCategoryDataset data = new DefaultBoxAndWhiskerCategoryDataset(); boolean pass = false; try { data.remove("R1", "R2"); } catch (UnknownKeyException e) { pass = true; } assertTrue(pass); data.add(new BoxAndWhiskerItem(1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0, new ArrayList()), "R1", "C1"); assertEquals(new Range(7.0, 8.0), data.getRangeBounds(false)); assertEquals(new Range(7.0, 8.0), data.getRangeBounds(true)); data.add(new BoxAndWhiskerItem(2.5, 3.5, 4.5, 5.5, 6.5, 7.5, 8.5, 9.5, new ArrayList()), "R2", "C1"); assertEquals(new Range(7.0, 9.5), data.getRangeBounds(false)); assertEquals(new Range(7.0, 9.5), data.getRangeBounds(true)); data.remove("R1", "C1"); assertEquals(new Range(8.5, 9.5), data.getRangeBounds(false)); assertEquals(new Range(8.5, 9.5), data.getRangeBounds(true)); }
From source file:umontreal.iro.lecuyer.charts.BoxSeriesCollection.java
/** * Creates a new <TT>BoxSeriesCollection</TT> instance with default parameters * and input series <TT>data</TT>. Only <SPAN CLASS="textit">the first</SPAN> <TT>numPoints</TT> * of <TT>data</TT> will taken into account. * /* ww w .ja v a 2 s.c o m*/ * @param data point sets. * * @param numPoints Number of points * * */ public BoxSeriesCollection(double[] data, int numPoints) { renderer = new BoxAndWhiskerRenderer(); ((BoxAndWhiskerRenderer) renderer).setMaximumBarWidth(BARWIDTH); seriesCollection = new DefaultBoxAndWhiskerCategoryDataset(); DefaultBoxAndWhiskerCategoryDataset tempSeriesCollection = (DefaultBoxAndWhiskerCategoryDataset) seriesCollection; final List<Double> list = new ArrayList<Double>(); for (int i = 0; i < numPoints; i++) list.add(data[i]); tempSeriesCollection.add(list, 0, 0); }
From source file:edu.ucla.stat.SOCR.chart.demo.BoxAndWhiskerChartDemo2.java
protected BoxAndWhiskerCategoryDataset createDataset(boolean isDemo) { if (isDemo) { SERIES_COUNT = 1;// w w w. ja v a 2s . c om CATEGORY_COUNT = 1; VALUE_COUNT = 10; values_storage = new String[SERIES_COUNT][CATEGORY_COUNT]; DefaultBoxAndWhiskerCategoryDataset result = new DefaultBoxAndWhiskerCategoryDataset(); List values = createValueList(0, 20.0, VALUE_COUNT); values_storage[0][0] = vs; result.add(values, "", "Data"); raw_y = new String[VALUE_COUNT]; StringTokenizer st = new StringTokenizer(vs, DELIMITERS); data_count = st.countTokens(); for (int i = 0; i < data_count; i++) { raw_y[i] = st.nextToken(); } return result; } else { setArrayFromTable(); int row_count = xyLength; //System.out.println("row_count="+row_count); raw_y = new String[row_count]; data_count = 0; String v_list = new String(); independentVarLength = 1; for (int index = 0; index < independentVarLength; index++) for (int i = 0; i < xyLength; i++) { raw_y[i] = indepValues[i][index]; try { Double.parseDouble(raw_y[i]); data_count++; v_list += raw_y[i] + ","; } catch (Exception e) { System.out.println("Skipping " + raw_y[i]); } } // create the dataset... DefaultBoxAndWhiskerCategoryDataset dataset = new DefaultBoxAndWhiskerCategoryDataset(); SERIES_COUNT = 1; CATEGORY_COUNT = 1; values_storage = new String[SERIES_COUNT][CATEGORY_COUNT]; dataset.add(createValueList(v_list), "", independentHeaders[0]); values_storage[0][0] = vs; return dataset; } }
From source file:br.upe.ecomp.dosa.controller.chart.FileBoxplotChartManager.java
private BoxAndWhiskerCategoryDataset createSampleDataset(double[][] values, int step) { DefaultBoxAndWhiskerCategoryDataset dataset = new DefaultBoxAndWhiskerCategoryDataset(); ArrayList<Double> list = null; for (int i = 0; i < values.length; i++) { list = new ArrayList<Double>(); for (int j = 0; j < values[i].length; j++) { list.add(values[i][j]);/*from w w w .ja va 2s . co m*/ } Collections.sort(list); // dataset.add(list, "Series", " Iteration " + i); dataset.add(BoxAndWhiskerCalculator.calculateBoxAndWhiskerStatistics(list), "Boxplot Evolution chart", i * step); } return dataset; }
From source file:adapters.BoxSeriesCollectionAdapter.java
/** * Creates a new <TT>BoxSeriesCollection</TT> instance with default parameters * and input series <TT>data</TT>. Only <SPAN CLASS="textit">the first</SPAN> <TT>numPoints</TT> * of <TT>data</TT> will taken into account. * * @param data point sets.// ww w .j a v a2 s.c om * * @param numPoints Number of points * * */ public BoxSeriesCollectionAdapter(double[] data, int numPoints) { renderer = new BoxAndWhiskerRenderer(); ((BoxAndWhiskerRenderer) renderer).setMaximumBarWidth(BARWIDTH); seriesCollection = new DefaultBoxAndWhiskerCategoryDataset(); DefaultBoxAndWhiskerCategoryDataset tempSeriesCollection = (DefaultBoxAndWhiskerCategoryDataset) seriesCollection; final List<Double> list = new ArrayList<Double>(); for (int i = 0; i < numPoints; i++) list.add(data[i]); tempSeriesCollection.add(list, 0, 0); }
From source file:fr.ens.transcriptome.corsen.gui.qt.ResultGraphs.java
/** * Create a box plot qimage.//from w w w. jav a 2 s. c o m * @param data Data to use * @return a QImage */ public QImage createBoxPlot(final double[] data, final String unit) { if (data == null || data.length < 2) return null; this.width = this.width / 2; List<Float> listData = new ArrayList<Float>(data.length); for (int i = 0; i < data.length; i++) listData.add((float) data[i]); DefaultBoxAndWhiskerCategoryDataset defaultboxandwhiskercategorydataset = new DefaultBoxAndWhiskerCategoryDataset(); defaultboxandwhiskercategorydataset.add(listData, "Distances", "Min"); JFreeChart chart = ChartFactory.createBoxAndWhiskerChart("Intensities Boxplot", "", "Distance" + unitLegend(unit), defaultboxandwhiskercategorydataset, false); addTransparency(chart); final BufferedImage image = chart.createBufferedImage(this.width, this.height, BufferedImage.TYPE_INT_ARGB, null); return new QImage(toByte(image.getData().getDataBuffer()), this.width, this.height, QImage.Format.Format_ARGB32); }
From source file:org.locationtech.udig.processingtoolbox.tools.BoxPlotDialog.java
private BoxAndWhiskerCategoryDataset getDataset(SimpleFeatureCollection features, String[] fields) { minMaxVisitor.reset();// w w w .jav a2 s.c o m Expression[] expression = new Expression[fields.length]; Map<String, List<Double>> listMap = new TreeMap<String, List<Double>>(); for (int index = 0; index < expression.length; index++) { expression[index] = ff.property(fields[index]); listMap.put(fields[index], new ArrayList<Double>()); } SimpleFeatureIterator featureIter = features.features(); try { while (featureIter.hasNext()) { SimpleFeature feature = featureIter.next(); for (int index = 0; index < expression.length; index++) { Double val = expression[index].evaluate(feature, Double.class); if (val == null || val.isNaN() || val.isInfinite()) { continue; } minMaxVisitor.visit(val, val); listMap.get(fields[index]).add(val); } } } finally { featureIter.close(); } DefaultBoxAndWhiskerCategoryDataset dataset = new DefaultBoxAndWhiskerCategoryDataset(); for (int index = 0; index < fields.length; index++) { dataset.add(listMap.get(fields[index]), "Series1", fields[index]); //$NON-NLS-1$ } return dataset; }