umontreal.iro.lecuyer.charts
Class MultipleDatasetChart
- java.lang.Object
-
- umontreal.iro.lecuyer.charts.MultipleDatasetChart
-
public class MultipleDatasetChart extends java.lang.ObjectProvides tools to plot many datasets on the same chart. This class is mainly used to draw plots with different styles. ClassXYChartand 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
Constructors Constructor and Description MultipleDatasetChart()Initializes a new MultipleDatasetChart.MultipleDatasetChart(java.lang.String title, java.lang.String XLabel, java.lang.String YLabel)Initializes a new MultipleDatasetChart instance.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method and Description intadd(SSJXYSeriesCollection dataset)Adds a new dataset to the chart at the end of the list and returns its position.voiddisableGrid()Disables the background grid.voidenableGrid(double xstep, double ystep)Puts grid on the background.SSJXYSeriesCollectionget()Gets the primary dataset.SSJXYSeriesCollectionget(int datasetNum)Gets the element at the specified position in the dataset list.JFreeChartgetJFreeChart()Returns the JFreeChart variable associated with this chart.java.util.ArrayList<SSJXYSeriesCollection>getList()Returns the dataset list.java.lang.StringgetTitle()Gets the current chart title.AxisgetXAxis()Returns the chart's domain axis (x-axis) object.AxisgetYAxis()Returns the chart's range axis (y-axis) object.voidset(int datasetNum, SSJXYSeriesCollection dataset)Replaces the element at the specified position in the dataset list with the specified element.voidset(SSJXYSeriesCollection dataset)Sets the primary dataset for the plot, replacing the existing dataset if there is one.voidsetAutoRange()Sets chart range to automatic values.voidsetLatexDocFlag(boolean flag)Same as inXYChart.voidsetManualRange(double[] axisRange)Sets new x-axis and y-axis bounds, with format: axisRange = [xmin, xmax, ymin, ymax].voidsetTitle(java.lang.String title)Sets a title to the chart.java.lang.StringtoLatex(double width, double height)Same as inXYChart.javax.swing.JFrameview(int width, int height)Displays chart on the screen using Swing.
-
-
-
Constructor Detail
-
MultipleDatasetChart
public MultipleDatasetChart()
Initializes a new MultipleDatasetChart.
-
MultipleDatasetChart
public MultipleDatasetChart(java.lang.String title, java.lang.String XLabel, java.lang.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 java.lang.String getTitle()
Gets the current chart title.- Returns:
- Chart title.
-
setTitle
public void setTitle(java.lang.String title)
Sets a title to the chart. This title will appear on the chart displayed by methodview.- 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 java.util.ArrayList<SSJXYSeriesCollection> getList()
Returns the dataset list.- Returns:
- dataset list.
-
view
public javax.swing.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 java.lang.String toLatex(double width, double height)Same as inXYChart.- Parameters:
width- Chart's width in centimeters.height- Chart's height in centimeters.
-
setLatexDocFlag
public void setLatexDocFlag(boolean flag)
Same as inXYChart.
-
-
DMelt 3.0 © DataMelt by jWork.ORG