25package umontreal.ssj.charts;
27import org.jfree.chart.axis.NumberAxis;
28import org.jfree.chart.ChartFactory;
29import org.jfree.chart.ChartPanel;
30import org.jfree.chart.plot.CategoryPlot;
31import org.jfree.chart.renderer.category.BoxAndWhiskerRenderer;
32import org.jfree.data.statistics.DefaultBoxAndWhiskerCategoryDataset;
33import javax.swing.JFrame;
58 protected void init(String title, String XLabel, String YLabel) {
60 chart = ChartFactory.createBoxAndWhiskerChart(title,
63 (DefaultBoxAndWhiskerCategoryDataset) dataset.getSeriesCollection(),
67 ((CategoryPlot) chart.getPlot()).setRenderer(dataset.getRenderer());
72 protected void initAxis() {
73 YAxis =
new Axis((NumberAxis) ((CategoryPlot) chart.getPlot()).getRangeAxis(),
Axis.ORIENTATION_VERTICAL);
83 init(
null,
null,
null);
99 public BoxChart(String title, String XLabel, String YLabel,
double[] data,
int numPoints) {
102 init(title, XLabel, YLabel);
116 public BoxChart(String title, String XLabel, String YLabel,
double[]... data) {
119 init(title, XLabel, YLabel);
130 public int add(
double[] data) {
131 return add(data, data.length);
144 public int add(
double[] data,
int numPoints) {
165 this.dataset = dataset;
174 ((BoxAndWhiskerRenderer) dataset.getRenderer()).setFillBox(fill);
193 public JFrame
view(
int width,
int height) {
195 if (chart.getTitle() !=
null)
196 myFrame =
new JFrame(
"BoxChart from SSJ : " + chart.getTitle().getText());
198 myFrame =
new JFrame(
"BoxChart from SSJ");
199 ChartPanel chartPanel =
new ChartPanel(chart);
200 chartPanel.setPreferredSize(
new java.awt.Dimension(width, height));
201 myFrame.setContentPane(chartPanel);
203 myFrame.setDefaultCloseOperation(JFrame.DISPOSE_ON_CLOSE);
204 myFrame.setLocationRelativeTo(
null);
205 myFrame.setVisible(
true);
220 public String
toLatex(
double width,
double height) {
221 throw new UnsupportedOperationException(
" NOT implemented yet");
Represents an axis of a chart encapsulated by an instance of XYChart.
void setFillBox(boolean fill)
Sets fill to true, if the boxes are to be filled.
int add(double[] data, int numPoints)
Adds a data series into the series collection.
String toLatex(double width, double height)
NOT IMPLEMENTED.
void setSeriesCollection(BoxSeriesCollection dataset)
Links a new dataset to the current chart.
BoxChart()
Initializes a new BoxChart instance with an empty data set.
JFrame view(int width, int height)
Displays chart on the screen using Swing.
BoxChart(String title, String XLabel, String YLabel, double[] data, int numPoints)
Initializes a new BoxChart instance with data data.
int add(double[] data)
Adds a data series into the series collection.
BoxChart(String title, String XLabel, String YLabel, double[]... data)
Initializes a new BoxChart instance with data data.
BoxSeriesCollection getSeriesCollection()
Returns the chart’s dataset.
This class stores data used in a umontreal.ssj.charts.CategoryChart.
int add(double[] data)
Adds a data series into the series collection.
This class provides tools to create charts from data in a simple way.
void setAutoRange()
Sets chart range to automatic values.