edu.northwestern.at.utils.plots
Class Plots

java.lang.Object
  extended by edu.northwestern.at.utils.plots.Plots

public class Plots
extends java.lang.Object

Plot utilities.

This static class provides various utility methods for generating plots and charts.


Field Summary
protected static FileExtensionFilter jpegFilter
          JPEG extensions file filter.
protected static FileExtensionFilter pngFilter
          PNG extension file filter.
protected static FileExtensionFilter svgFilter
          SVG extension file filter.
 
Constructor Summary
protected Plots()
          Don't allow instantiation, do allow overrides.
 
Method Summary
static BarChartPanel barChart(double[] barData, double[] barValues, int width, int height, java.lang.String title, java.lang.String xTitle, java.lang.String yTitle, java.lang.String legendLabel, boolean horizontal, boolean showBarValues)
          Generate a bar chart in a JPanel.
static BarChartPanel barChart(java.lang.String[] barLabels, double[] barValues, int width, int height, java.lang.String title, java.lang.String xTitle, java.lang.String yTitle, java.lang.String legendLabel, boolean horizontal, boolean showBarValues)
          Generate a bar chart.
static org.krysalis.jcharts.properties.ChartTypeProperties getChartTypeProperties(int numberOfDataSets)
          Generate default line plot strokes and shapes.
static void linePlot(javax.swing.JPanel panel, double[] xData, double[] yData, int width, int height, java.lang.String title, java.lang.String xTitle, java.lang.String yTitle)
          Generate a line plot in a JPanel.
static void saveChartToFile(org.krysalis.jcharts.Chart chart, java.lang.String fileName)
          Saves the chart to a file.
static void saveChartToFile(java.awt.Window parentWindow, org.krysalis.jcharts.Chart chart)
          Saves the chart to a file.
static void saveChartToFileAsJPEG(org.krysalis.jcharts.Chart chart, java.lang.String fileName)
          Saves the chart to a file in JPEG format.
static void saveChartToFileAsJPEG(org.krysalis.jcharts.Chart chart, java.lang.String fileName, float quality)
          Saves the chart to a file in JPEG format.
static void saveChartToFileAsPNG(org.krysalis.jcharts.Chart chart, java.lang.String fileName)
          Saves the chart to a file in PNG format.
static void saveChartToFileAsSVG(org.krysalis.jcharts.Chart chart, java.lang.String fileName)
          Saves the chart to a file in SVG format.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

jpegFilter

protected static FileExtensionFilter jpegFilter
JPEG extensions file filter.


pngFilter

protected static FileExtensionFilter pngFilter
PNG extension file filter.


svgFilter

protected static FileExtensionFilter svgFilter
SVG extension file filter.

Constructor Detail

Plots

protected Plots()
Don't allow instantiation, do allow overrides.

Method Detail

linePlot

public static void linePlot(javax.swing.JPanel panel,
                            double[] xData,
                            double[] yData,
                            int width,
                            int height,
                            java.lang.String title,
                            java.lang.String xTitle,
                            java.lang.String yTitle)
Generate a line plot in a JPanel.

Parameters:
panel - JPanel into which to drop plot.
xData - double array of x-axis data.
yData - double array of y-axis data.
width - width of bar chart (pixels).
height - height of bar chart (pixels).
title - plot title.
xTitle - x-axis title.
yTitle - y-axis title.

barChart

public static BarChartPanel barChart(java.lang.String[] barLabels,
                                     double[] barValues,
                                     int width,
                                     int height,
                                     java.lang.String title,
                                     java.lang.String xTitle,
                                     java.lang.String yTitle,
                                     java.lang.String legendLabel,
                                     boolean horizontal,
                                     boolean showBarValues)
Generate a bar chart.

Parameters:
barLabels - labels for x-axis.
barValues - double array of y-axis data.
width - width of bar chart (pixels).
height - height of bar chart (pixels).
title - plot title.
xTitle - x-axis title.
yTitle - y-axis title.
horizontal - true to display horizontal bar chart.
showBarValues - true to display bar values in bar.
Returns:
BarChartPanel in which BarChart will be drawn.

barChart

public static BarChartPanel barChart(double[] barData,
                                     double[] barValues,
                                     int width,
                                     int height,
                                     java.lang.String title,
                                     java.lang.String xTitle,
                                     java.lang.String yTitle,
                                     java.lang.String legendLabel,
                                     boolean horizontal,
                                     boolean showBarValues)
Generate a bar chart in a JPanel.

Parameters:
barData - double array of x-axis data.
barValues - double array of y-axis data.
width - width of bar chart (pixels).
height - height of bar chart (pixels).
title - plot title.
xTitle - x-axis title.
yTitle - y-axis title.
horizontal - true to display horizontal bar chart.
showBarValues - true to display bar values in bar.
Returns:
BarChartPanel in which BarChart will be drawn.

getChartTypeProperties

public static org.krysalis.jcharts.properties.ChartTypeProperties getChartTypeProperties(int numberOfDataSets)
Generate default line plot strokes and shapes.

Parameters:
numberOfDataSets - Number of data sets in plot.

saveChartToFileAsJPEG

public static void saveChartToFileAsJPEG(org.krysalis.jcharts.Chart chart,
                                         java.lang.String fileName,
                                         float quality)
Saves the chart to a file in JPEG format.

Parameters:
chart - The chart to save.
fileName - The file name to which to save the plot.
quality - Number between 0.0 and 1.0 indicating compression quality.

saveChartToFileAsJPEG

public static void saveChartToFileAsJPEG(org.krysalis.jcharts.Chart chart,
                                         java.lang.String fileName)
Saves the chart to a file in JPEG format.

Parameters:
chart - The chart to save.
fileName - The file name to which to save the plot.

The JPEG compression quality is set to 1.0f .


saveChartToFileAsPNG

public static void saveChartToFileAsPNG(org.krysalis.jcharts.Chart chart,
                                        java.lang.String fileName)
Saves the chart to a file in PNG format.

Parameters:
chart - The chart to save.
fileName - The file name to which to save the plot.

saveChartToFileAsSVG

public static void saveChartToFileAsSVG(org.krysalis.jcharts.Chart chart,
                                        java.lang.String fileName)
Saves the chart to a file in SVG format.

Parameters:
chart - The chart to save.
fileName - The file name to which to save the plot.

saveChartToFile

public static void saveChartToFile(org.krysalis.jcharts.Chart chart,
                                   java.lang.String fileName)
Saves the chart to a file.

Parameters:
chart - The chart to save.
fileName - The file name to which to save the plot.

The filename extension determines the type of output. .jpg -> jpeg, .png -> png, .svg -> svg. If the filename does not end in one of these, no file is written.


saveChartToFile

public static void saveChartToFile(java.awt.Window parentWindow,
                                   org.krysalis.jcharts.Chart chart)
Saves the chart to a file. Prompts for a file name.

Parameters:
parentWindow - Parent window for file dialog.
chart - The chart to save.