25package umontreal.ssj.charts;
27import org.jfree.chart.renderer.category.BoxAndWhiskerRenderer;
28import org.jfree.data.statistics.DefaultBoxAndWhiskerCategoryDataset;
31import java.util.ArrayList;
32import java.util.Locale;
33import java.util.Formatter;
46 final double BARWIDTH = 0.1;
52 renderer =
new BoxAndWhiskerRenderer();
53 seriesCollection =
new DefaultBoxAndWhiskerCategoryDataset();
54 ((BoxAndWhiskerRenderer) renderer).setMaximumBarWidth(BARWIDTH);
66 renderer =
new BoxAndWhiskerRenderer();
68 ((BoxAndWhiskerRenderer) renderer).setMaximumBarWidth(BARWIDTH);
69 seriesCollection =
new DefaultBoxAndWhiskerCategoryDataset();
71 DefaultBoxAndWhiskerCategoryDataset tempSeriesCollection = (DefaultBoxAndWhiskerCategoryDataset) seriesCollection;
73 final List<Double> list =
new ArrayList<Double>();
74 for (
int i = 0; i < numPoints; i++)
77 tempSeriesCollection.add(list, 0, 0);
87 renderer =
new BoxAndWhiskerRenderer();
88 seriesCollection =
new DefaultBoxAndWhiskerCategoryDataset();
90 DefaultBoxAndWhiskerCategoryDataset tempSeriesCollection = (DefaultBoxAndWhiskerCategoryDataset) seriesCollection;
92 for (
int i = 0; i < data.length; i++) {
93 if (data[i].length == 0)
94 throw new IllegalArgumentException(
"Unable to render the plot. data[" + i +
"] contains no row");
95 final List<Double> list =
new ArrayList<Double>();
96 for (
int j = 0; j < data[i].length - 1; j++)
98 tempSeriesCollection.add(list, 0,
"Serie " + i);
101 ((BoxAndWhiskerRenderer) renderer).setMaximumBarWidth(BARWIDTH);
112 renderer =
new BoxAndWhiskerRenderer();
113 ((BoxAndWhiskerRenderer) renderer).setFillBox(
false);
114 seriesCollection = data;
115 ((BoxAndWhiskerRenderer) renderer).setMaximumBarWidth(BARWIDTH);
130 public int add(
double[] data) {
131 return add(data, data.length);
144 public int add(
double[] data,
int numPoints) {
145 DefaultBoxAndWhiskerCategoryDataset tempSeriesCollection = (DefaultBoxAndWhiskerCategoryDataset) seriesCollection;
147 final List<Double> list =
new ArrayList<Double>();
148 for (
int i = 0; i < numPoints; i++)
151 int count = tempSeriesCollection.getColumnCount();
152 tempSeriesCollection.add(list, 0,
"Serie " + count);
163 return (String) ((DefaultBoxAndWhiskerCategoryDataset) seriesCollection).getColumnKey(series);
172 double max = 0, min = 0;
173 DefaultBoxAndWhiskerCategoryDataset tempSeriesCollection = (DefaultBoxAndWhiskerCategoryDataset) seriesCollection;
175 if (tempSeriesCollection.getColumnCount() != 0 && tempSeriesCollection.getRowCount() != 0) {
176 max = tempSeriesCollection.getItem(0, 0).getMaxOutlier().doubleValue();
177 min = tempSeriesCollection.getItem(0, 0).getMinOutlier().doubleValue();
180 for (
int i = 0; i < tempSeriesCollection.getRowCount(); i++) {
181 for (
int j = 0; j < tempSeriesCollection.getColumnCount(); j++) {
182 max = Math.max(max, tempSeriesCollection.getItem(i, j).getMaxOutlier().doubleValue());
183 min = Math.min(min, tempSeriesCollection.getItem(i, j).getMinOutlier().doubleValue());
187 double[] retour = { min, max };
197 Formatter formatter =
new Formatter(Locale.US);
198 for (
int i = 0; i < seriesCollection.getRowCount(); i++) {
199 formatter.format(
" Series " + i +
" : %n");
200 for (
int j = 0; j < seriesCollection.getColumnCount(); j++)
201 formatter.format(
",%15e%n", seriesCollection.getValue(i, j));
203 return formatter.toString();
213 public String
toLatex(
double YScale,
double YShift,
double ymin,
double ymax) {
214 throw new UnsupportedOperationException(
" NOT implemented yet");
String getName(int series)
Gets the current name of the selected series.
int add(double[] data, int numPoints)
Adds a data series into the series collection.
BoxSeriesCollection(DefaultBoxAndWhiskerCategoryDataset data)
Creates a new BoxSeriesCollection instance with default parameters and given data series.
int add(double[] data)
Adds a data series into the series collection.
BoxSeriesCollection(double[]... data)
Creates a new BoxSeriesCollection instance with default parameters and given data series.
BoxSeriesCollection(double[] data, int numPoints)
Creates a new BoxSeriesCollection instance with default parameters and input series data.
double[] getRangeBounds()
Returns the range ( -coordinates) min and max values.
BoxSeriesCollection()
Creates a new BoxSeriesCollection instance with an empty dataset.
String toLatex(double YScale, double YShift, double ymin, double ymax)
NOT IMPLEMENTED: To do.
String toString()
Returns in a String all data contained in the current object.
Stores data used in a CategoryChart.