SSJ
V. 2.6.

umontreal.iro.lecuyer.charts
Class MultipleDatasetChart

java.lang.Object
  extended by umontreal.iro.lecuyer.charts.MultipleDatasetChart

public class MultipleDatasetChart
extends Object

Provides tools to plot many datasets on the same chart. This class is mainly used to draw plots with different styles. Class XYChart and its subclasses are to be preferred to draw simple charts with one style. Datasets are stored in an ArrayList. The first dataset is called as the primary dataset.


Constructor Summary
MultipleDatasetChart()
          Initializes a new MultipleDatasetChart.
MultipleDatasetChart(String title, String XLabel, String YLabel)
          Initializes a new MultipleDatasetChart instance.
 
Method Summary
 int add(SSJXYSeriesCollection dataset)
          Adds a new dataset to the chart at the end of the list and returns its position.
 void disableGrid()
          Disables the background grid.
 void enableGrid(double xstep, double ystep)
          Puts grid on the background.
 SSJXYSeriesCollection get()
          Gets the primary dataset.
 SSJXYSeriesCollection get(int datasetNum)
          Gets the element at the specified position in the dataset list.
 JFreeChart getJFreeChart()
          Returns the JFreeChart variable associated with this chart.
 ArrayList<SSJXYSeriesCollection> getList()
          Returns the dataset list.
 String getTitle()
          Gets the current chart title.
 Axis getXAxis()
          Returns the chart's domain axis (x-axis) object.
 Axis getYAxis()
          Returns the chart's range axis (y-axis) object.
 void set(int datasetNum, SSJXYSeriesCollection dataset)
          Replaces the element at the specified position in the dataset list with the specified element.
 void set(SSJXYSeriesCollection dataset)
          Sets the primary dataset for the plot, replacing the existing dataset if there is one.
 void setAutoRange()
          Sets chart range to automatic values.
 void setLatexDocFlag(boolean flag)
          Same as in XYChart.
 void setManualRange(double[] axisRange)
          Sets new x-axis and y-axis bounds, with format: axisRange = [xmin, xmax, ymin, ymax].
 void setTitle(String title)
          Sets a title to the chart.
 String toLatex(double width, double height)
          Same as in XYChart.
 JFrame view(int width, int height)
          Displays chart on the screen using Swing.
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

MultipleDatasetChart

public MultipleDatasetChart()
Initializes a new MultipleDatasetChart.


MultipleDatasetChart

public MultipleDatasetChart(String title,
                            String XLabel,
                            String YLabel)
Initializes a new MultipleDatasetChart instance. title sets a title, XLabel is a short description of the x-axis, and YLabel is a short description of the y-axis.

Parameters:
title - chart title.
XLabel - Label on x-axis.
YLabel - Label on y-axis.
Method Detail

getJFreeChart

public JFreeChart getJFreeChart()
Returns the JFreeChart variable associated with this chart.

Returns:
the associated JFreeChart variable.

getXAxis

public Axis getXAxis()
Returns the chart's domain axis (x-axis) object.

Returns:
chart's domain axis (x-axis) object.

getYAxis

public Axis getYAxis()
Returns the chart's range axis (y-axis) object.

Returns:
chart's range axis (y-axis) object.

getTitle

public String getTitle()
Gets the current chart title.

Returns:
Chart title.

setTitle

public void setTitle(String title)
Sets a title to the chart. This title will appear on the chart displayed by method view.

Parameters:
title - chart title.

setAutoRange

public void setAutoRange()
Sets chart range to automatic values.


setManualRange

public void setManualRange(double[] axisRange)
Sets new x-axis and y-axis bounds, with format: axisRange = [xmin, xmax, ymin, ymax].

Parameters:
axisRange - new axis ranges.

add

public int add(SSJXYSeriesCollection dataset)
Adds a new dataset to the chart at the end of the list and returns its position.

Parameters:
dataset - dataset to add.
Returns:
the dataset position in the list.

get

public SSJXYSeriesCollection get()
Gets the primary dataset.

Returns:
dataset.

set

public void set(SSJXYSeriesCollection dataset)
Sets the primary dataset for the plot, replacing the existing dataset if there is one.

Parameters:
dataset - the new primary dataset.

get

public SSJXYSeriesCollection get(int datasetNum)
Gets the element at the specified position in the dataset list.

Parameters:
datasetNum - position in the dataset list.
Returns:
dataset.

set

public void set(int datasetNum,
                SSJXYSeriesCollection dataset)
Replaces the element at the specified position in the dataset list with the specified element.

Parameters:
datasetNum - position in the dataset list.
dataset - dataset list.

getList

public ArrayList<SSJXYSeriesCollection> getList()
Returns the dataset list.

Returns:
dataset list.

view

public JFrame view(int width,
                   int height)
Displays chart on the screen using Swing. This method creates an application containing a chart panel displaying the chart. The created frame is positioned on-screen, and displayed before it is returned. The width and the height of the chart are measured in pixels.

Parameters:
width - frame width in pixels.
height - frame height in pixels.

enableGrid

public void enableGrid(double xstep,
                       double ystep)
Puts grid on the background. It is important to note that the grid is always placed in such a way that it contains the axes. Thus, the grid does not always have an intersection at the corner points; this occurs only if the corner points are multiples of the stepping. xstep and ystep sets the stepping in each direction.

Parameters:
xstep - sets the stepping in the x-direction.
ystep - sets the stepping in the y-direction.

disableGrid

public void disableGrid()
Disables the background grid.


toLatex

public String toLatex(double width,
                      double height)
Same as in XYChart.

Parameters:
width - Chart's width in centimeters.
height - Chart's height in centimeters.

setLatexDocFlag

public void setLatexDocFlag(boolean flag)
Same as in XYChart.


SSJ
V. 2.6.

To submit a bug or ask questions, send an e-mail to Pierre L'Ecuyer.