datasetList.add(new DefaultBoxAndWhiskerCategoryDataset()); datasetList.get(i).add( distributionLevelList.get(i), solverLabel,
JFrame f = new JFrame("Test"); f.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); DefaultBoxAndWhiskerCategoryDataset boxData = new DefaultBoxAndWhiskerCategoryDataset(); boxData.add(Arrays.asList(30, 36, 46, 55, 65, 76, 81, 80, 71, 59, 44, 34), "Planet", "Endor"); boxData.add(Arrays.asList(22, 25, 34, 44, 54, 63, 69, 67, 59, 48, 38, 28), "Planet", "Hoth"); BoxAndWhiskerRenderer boxRenderer = new BoxAndWhiskerRenderer(); DefaultCategoryDataset catData = new DefaultCategoryDataset(); catData.addValue(boxData.getMeanValue(0, 0), "Mean", boxData.getColumnKey(0)); catData.addValue(boxData.getMeanValue(0, 1), "Mean", boxData.getColumnKey(1)); LineAndShapeRenderer lineRenderer = new LineAndShapeRenderer(); CategoryAxis xAxis = new CategoryAxis("Type");
/** * Adds a data series into the series collection. Vector <TT>data</TT> represents * a point set. Only <SPAN CLASS="textit">the first</SPAN> <TT>numPoints</TT> of * <TT>data</TT> will be added to the new series. * * @param data Point set * * @param numPoints Number of points to add * * @return Integer that represent the new point set's position in the JFreeChart <TT>DefaultBoxAndWhiskerXYDataset</TT> object. * */ public int add (double[] data, int numPoints) { DefaultBoxAndWhiskerCategoryDataset tempSeriesCollection = (DefaultBoxAndWhiskerCategoryDataset)seriesCollection; final List<Double> list = new ArrayList<Double>(); for (int i = 0; i < numPoints; i ++) list.add(data[i]); int count = tempSeriesCollection.getColumnCount(); tempSeriesCollection.add(list, 0, "Serie " + count); return count; }
/** * Returns the range (<SPAN CLASS="MATH"><I>y</I></SPAN>-coordinates) min and max values. * * @return range min and max values. * */ public double[] getRangeBounds() { double max=0, min=0; DefaultBoxAndWhiskerCategoryDataset tempSeriesCollection = (DefaultBoxAndWhiskerCategoryDataset)seriesCollection; if(tempSeriesCollection.getColumnCount() != 0 && tempSeriesCollection.getRowCount() != 0) { max = tempSeriesCollection.getItem(0, 0).getMaxOutlier().doubleValue() ; min = tempSeriesCollection.getItem(0, 0).getMinOutlier().doubleValue() ; } for(int i = 0; i < tempSeriesCollection.getRowCount(); i++) { for( int j = 0; j < tempSeriesCollection.getColumnCount(); j++) { max = Math.max(max, tempSeriesCollection.getItem(i, j).getMaxOutlier().doubleValue() ); min = Math.min(min, tempSeriesCollection.getItem(i, j).getMinOutlier().doubleValue() ); } } double[] retour = {min, max}; return retour; }
/** * Clears all data from the dataset and sends a {@link DatasetChangeEvent} * to all registered listeners. * * @since 1.0.7 */ public void clear() { this.data.clear(); updateBounds(); fireDatasetChanged(); }
/** * Removes an item from the dataset and sends a {@link DatasetChangeEvent} * to all registered listeners. * * @param rowKey the row key (<code>null</code> not permitted). * @param columnKey the column key (<code>null</code> not permitted). * * @see #add(BoxAndWhiskerItem, Comparable, Comparable) * * @since 1.0.7 */ public void remove(Comparable rowKey, Comparable columnKey) { // defer null argument checks int r = getRowIndex(rowKey); int c = getColumnIndex(columnKey); this.data.removeObject(rowKey, columnKey); // if this cell held a maximum and/or minimum value, we'll need to // update the cached bounds... if ((this.maximumRangeValueRow == r && this.maximumRangeValueColumn == c) || (this.minimumRangeValueRow == r && this.minimumRangeValueColumn == c)) { updateBounds(); } fireDatasetChanged(); }
/** * Creates a new <TT>BoxSeriesCollection</TT> instance with an empty dataset. * */ public BoxSeriesCollection () { renderer = new BoxAndWhiskerRenderer(); seriesCollection = new DefaultBoxAndWhiskerCategoryDataset (); ((BoxAndWhiskerRenderer)renderer).setMaximumBarWidth(BARWIDTH); }
/** * Adds a list of values relating to one box-and-whisker entity to the * table. The various median values are calculated. * * @param list a collection of values from which the various medians will * be calculated. * @param rowKey the row key ({@code null} not permitted). * @param columnKey the column key ({@code null} not permitted). * * @see #add(BoxAndWhiskerItem, Comparable, Comparable) */ public void add(List list, Comparable rowKey, Comparable columnKey) { BoxAndWhiskerItem item = BoxAndWhiskerCalculator .calculateBoxAndWhiskerStatistics(list); add(item, rowKey, columnKey); }
this.maximumRangeValueRow = -1; this.maximumRangeValueColumn = -1; int rowCount = getRowCount(); int columnCount = getColumnCount(); for (int r = 0; r < rowCount; r++) { for (int c = 0; c < columnCount; c++) { BoxAndWhiskerItem item = getItem(r, c); if (item != null) { Number min = item.getMinOutlier();
/** * Clears all data from the dataset and sends a {@link DatasetChangeEvent} * to all registered listeners. * * @since 1.0.7 */ public void clear() { this.data.clear(); updateBounds(); fireDatasetChanged(); }
/** * Removes an item from the dataset and sends a {@link DatasetChangeEvent} * to all registered listeners. * * @param rowKey the row key ({@code null} not permitted). * @param columnKey the column key ({@code null} not permitted). * * @see #add(BoxAndWhiskerItem, Comparable, Comparable) * * @since 1.0.7 */ public void remove(Comparable rowKey, Comparable columnKey) { // defer null argument checks int r = getRowIndex(rowKey); int c = getColumnIndex(columnKey); this.data.removeObject(rowKey, columnKey); // if this cell held a maximum and/or minimum value, we'll need to // update the cached bounds... if ((this.maximumRangeValueRow == r && this.maximumRangeValueColumn == c) || (this.minimumRangeValueRow == r && this.minimumRangeValueColumn == c)) { updateBounds(); } fireDatasetChanged(); }
/** * 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. * * @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); }
/** * Adds a list of values relating to one box-and-whisker entity to the * table. The various median values are calculated. * * @param list a collection of values from which the various medians will * be calculated. * @param rowKey the row key (<code>null</code> not permitted). * @param columnKey the column key (<code>null</code> not permitted). * * @see #add(BoxAndWhiskerItem, Comparable, Comparable) */ public void add(List list, Comparable rowKey, Comparable columnKey) { BoxAndWhiskerItem item = BoxAndWhiskerCalculator .calculateBoxAndWhiskerStatistics(list); add(item, rowKey, columnKey); }
this.maximumRangeValueRow = -1; this.maximumRangeValueColumn = -1; int rowCount = getRowCount(); int columnCount = getColumnCount(); for (int r = 0; r < rowCount; r++) { for (int c = 0; c < columnCount; c++) { BoxAndWhiskerItem item = getItem(r, c); if (item != null) { Number min = item.getMinOutlier();
/** * Removes a row from the dataset and sends a {@link DatasetChangeEvent} * to all registered listeners. * * @param rowIndex the row index. * * @see #removeColumn(int) * * @since 1.0.7 */ public void removeRow(int rowIndex) { this.data.removeRow(rowIndex); updateBounds(); fireDatasetChanged(); }
/** * Creates a new <TT>BoxSeriesCollection</TT> instance with default * parameters and given data series. The input parameter represents series * of point sets. * * @param data series of point sets. * * */ public BoxSeriesCollection (double[]... data) { renderer = new BoxAndWhiskerRenderer(); seriesCollection = new DefaultBoxAndWhiskerCategoryDataset (); DefaultBoxAndWhiskerCategoryDataset tempSeriesCollection = (DefaultBoxAndWhiskerCategoryDataset)seriesCollection; for (int i = 0; i < data.length; i ++) { if (data[i].length == 0) throw new IllegalArgumentException("Unable to render the plot. data[" + i +"] contains no row"); final List<Double> list = new ArrayList<Double>(); for (int j = 0; j < data[i].length-1; j ++) list.add(data[i][j]); tempSeriesCollection.add(list, 0, "Serie " + i); list.clear(); } ((BoxAndWhiskerRenderer)renderer).setMaximumBarWidth(BARWIDTH); }
@Override public void afterDetailEval(ReportParameters reportParameters) { super.afterDetailEval(reportParameters); String series = reportParameters.getValue("series"); String category = reportParameters.getValue("category"); Double mean = reportParameters.getValue("mean"); Double median = reportParameters.getValue("median"); Double q1 = reportParameters.getValue("q1"); Double q3 = reportParameters.getValue("q3"); Double minRegularValue = reportParameters.getValue("minregularvalue"); Double maxRegularValue = reportParameters.getValue("maxregularvalue"); Double minOutlier = reportParameters.getValue("minoutlier"); Double maxOutlier = reportParameters.getValue("maxoutlier"); BoxAndWhiskerItem item = new BoxAndWhiskerItem(mean, median, q1, q3, minRegularValue, maxRegularValue, minOutlier, maxOutlier, null); dataset.add(item, series, category); } }
/** * Removes a column from the dataset and sends a {@link DatasetChangeEvent} * to all registered listeners. * * @param columnIndex the column index. * * @see #removeRow(int) * * @since 1.0.7 */ public void removeColumn(int columnIndex) { this.data.removeColumn(columnIndex); updateBounds(); fireDatasetChanged(); }
DefaultBoxAndWhiskerCategoryDataset dataset = new DefaultBoxAndWhiskerCategoryDataset (); dataset.add (hourList[ii], "Last 30 days", "" + ii);