schmitzm.jfree
Class JFreeChartUtil

java.lang.Object
  extended by schmitzm.jfree.JFreeChartUtil

public class JFreeChartUtil
extends Object

In dieser Klasse sind Hilfsmethoden fuer JFreeChart hinterlegt.

Version:
1.0
Author:
Martin Schmitz (University of Bonn/Germany)

Field Summary
static ChartStyleXMLFactory<ChartStyle> CHART_STYLE_FACTORY
          Instance of ChartStyleXMLFactory.
static ResourceProvider RESOURCE
          ResourceProvider, der die Lokalisation fuer GUI-Komponenten zur Verfuegung stellt.
 
Constructor Summary
JFreeChartUtil()
           
 
Method Summary
static void addRegressionLineToPlot(XYPlot plot, XYDataset regressionData, Color lineColor)
          Adds a line plot for regression data to a plot.
static void applyDatasetProperties(Dataset dataset, Dataset sample)
          Applies general dataset properties to a Dataset.
static CategoryItemRenderer createCategoryRenderer(BasicChartStyle style)
          Creates a CategoryItemRenderer for the given stepped and stacked properties.
static CategoryItemRenderer createCategoryRenderer(ChartType type, boolean stepped, boolean stacked)
          Creates a CategoryItemRenderer for the given stepped and stacked properties.
static JFreeChart createRegressionChart(XYDataset dataset, String title, String xAxisTitle, String yAxisTitle, boolean regressionLine)
          Creates a JFreeChart which shows a point for each data iten and a the appropriate regression line.
static XYDataset createRegressionLineDataset(XYDataset dataset, int series, Comparable<?> seriesKey, double startX, double endX, int sampleCount)
          Creates sample data for a regression line of an XYDataset.
static XYDataset createRegressionLineDataset(XYSeriesCollection dataset, int series, Comparable<?> seriesKey, int sampleCount)
          Creates sample data for a regression line of an XYDataset.
static XYItemRenderer createXYRenderer(BasicChartStyle style)
          Creates a XYItemRenderer for the given stepped and stacked properties.
static XYItemRenderer createXYRenderer(ChartType type, boolean stepped, boolean stacked)
          Creates a XYItemRenderer for the given stepped and stacked properties.
static void fireChangeEvent(AbstractRenderer renderer)
          Fires a change event to all RendererChangeListener connected to the renderer.
static void fireChangeEvent(Plot plot)
          Fires a change event to all PlotChangeListener connected to the plot.
static Dataset getDatasetForRenderer(Plot plot, Object renderer)
          Returns the (first) dataset of a Plot which is rendererd by a renderer.
static Object getRendererForDataset(Plot plot, int i)
          Returns the renderer for the i-th dataset of a plot.
static DatasetSelectionModel<?,?,?> getSelectionModelForDataset(Plot plot, Dataset dataset)
          Searchs the renderers of a plot for SelectionRenderer for a Dataset and returns its DatasetSelectionModel.
static Map<Integer,DatasetSelectionModel<?,?,?>> getSelectionModels(Plot plot)
          Searchs the renderers of a plot for all SelectionRenderer and returns their DatasetSelectionModels.
static Map<Integer,SelectionRenderer<?>> getSelectionRenderer(Plot plot)
          Returns all SelectionRenderer for a Plot.
static SelectionRenderer<?> getSelectionRendererForDataset(Plot plot, Dataset dataset)
          Searchs the renderers of a plot for SelectionRenderer for a Dataset.
static String R(String key, Object... values)
          Convenience method to access the ResourceProvider.
static void setLegendVisible(JFreeChart chart, boolean visible)
          Sets all chart legends (in)visible.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

RESOURCE

public static ResourceProvider RESOURCE
ResourceProvider, der die Lokalisation fuer GUI-Komponenten zur Verfuegung stellt. Diese sind in properties-Datein unter schmitzm.jfree.resource.locales.JFreeResourceBundle_XXX.properties hinterlegt.


CHART_STYLE_FACTORY

public static final ChartStyleXMLFactory<ChartStyle> CHART_STYLE_FACTORY
Instance of ChartStyleXMLFactory.

Constructor Detail

JFreeChartUtil

public JFreeChartUtil()
Method Detail

R

public static String R(String key,
                       Object... values)
Convenience method to access the ResourceProvider.


setLegendVisible

public static void setLegendVisible(JFreeChart chart,
                                    boolean visible)
Sets all chart legends (in)visible.

Parameters:
chart - a chart to apply
visible - indicates the visible property

fireChangeEvent

public static void fireChangeEvent(Plot plot)
Fires a change event to all PlotChangeListener connected to the plot.

Parameters:
plot - a plot

fireChangeEvent

public static void fireChangeEvent(AbstractRenderer renderer)
Fires a change event to all RendererChangeListener connected to the renderer.

Parameters:
renderer - a renderer

createXYRenderer

public static XYItemRenderer createXYRenderer(BasicChartStyle style)
Creates a XYItemRenderer for the given stepped and stacked properties.

Parameters:
type - chart type
stepped - stepped property
stacked - stacked property

createXYRenderer

public static XYItemRenderer createXYRenderer(ChartType type,
                                              boolean stepped,
                                              boolean stacked)
Creates a XYItemRenderer for the given stepped and stacked properties.

Parameters:
type - chart type
stepped - stepped property
stacked - stacked property

createCategoryRenderer

public static CategoryItemRenderer createCategoryRenderer(BasicChartStyle style)
Creates a CategoryItemRenderer for the given stepped and stacked properties.

Parameters:
type - chart type
stepped - stepped property
stacked - stacked property

createCategoryRenderer

public static CategoryItemRenderer createCategoryRenderer(ChartType type,
                                                          boolean stepped,
                                                          boolean stacked)
Creates a CategoryItemRenderer for the given stepped and stacked properties.

Parameters:
type - chart type
stepped - stepped property
stacked - stacked property

getRendererForDataset

public static Object getRendererForDataset(Plot plot,
                                           int i)
Returns the renderer for the i-th dataset of a plot.

Parameters:
plot - a plot
index - the dataset index
Returns:
the primary renderer if no specific renderer is set for dataset i

getSelectionRendererForDataset

public static SelectionRenderer<?> getSelectionRendererForDataset(Plot plot,
                                                                  Dataset dataset)
Searchs the renderers of a plot for SelectionRenderer for a Dataset.

Parameters:
plot - the plot to check for renderer
dataset - the dataset a SelectionRenderer is searched for
Returns:
null if there is no SelectionRenderer defined for the dataset

getSelectionModelForDataset

public static DatasetSelectionModel<?,?,?> getSelectionModelForDataset(Plot plot,
                                                                       Dataset dataset)
Searchs the renderers of a plot for SelectionRenderer for a Dataset and returns its DatasetSelectionModel.

Parameters:
plot - the plot to check for renderer
dataset - the dataset a SelectionRenderer is searched for
Returns:
null if there is no SelectionRenderer defined for the dataset

getSelectionRenderer

public static Map<Integer,SelectionRenderer<?>> getSelectionRenderer(Plot plot)
Returns all SelectionRenderer for a Plot.

Parameters:
plot - the plot to check for renderer
Returns:
never null

getSelectionModels

public static Map<Integer,DatasetSelectionModel<?,?,?>> getSelectionModels(Plot plot)
Searchs the renderers of a plot for all SelectionRenderer and returns their DatasetSelectionModels.

Parameters:
plot - the plot to check for renderer
Returns:
never null

getDatasetForRenderer

public static Dataset getDatasetForRenderer(Plot plot,
                                            Object renderer)
Returns the (first) dataset of a Plot which is rendererd by a renderer.

Parameters:
plot - the plot which holds the datasets and renderer
renderer - the renderer a dataset is seached for
Returns:
null if there is no dataset which is rendered by the given renderer

applyDatasetProperties

public static void applyDatasetProperties(Dataset dataset,
                                          Dataset sample)
Applies general dataset properties to a Dataset.

Parameters:
dataset - dataset the properties are applied to
sample - dataset the properties are taken from

createRegressionChart

public static JFreeChart createRegressionChart(XYDataset dataset,
                                               String title,
                                               String xAxisTitle,
                                               String yAxisTitle,
                                               boolean regressionLine)
Creates a JFreeChart which shows a point for each data iten and a the appropriate regression line.

Parameters:
dataset - the data
title - title for the chart
xAxisTitle - title for the X-Axis
yAxisTitle - title for the Y-Axis
regressionLine - indicates whether the regression line is shown

createRegressionLineDataset

public static XYDataset createRegressionLineDataset(XYSeriesCollection dataset,
                                                    int series,
                                                    Comparable<?> seriesKey,
                                                    int sampleCount)
Creates sample data for a regression line of an XYDataset.

Parameters:
dataset - data the regression line is created for
series - series of dataset the regression line is created for
seriesKey - the key for the created dataset
sampleCnt - count of created samples

createRegressionLineDataset

public static XYDataset createRegressionLineDataset(XYDataset dataset,
                                                    int series,
                                                    Comparable<?> seriesKey,
                                                    double startX,
                                                    double endX,
                                                    int sampleCount)
Creates sample data for a regression line of an XYDataset.

Parameters:
dataset - data the regression line is created for
series - series of dataset the regression line is created for
seriesKey - the key for the created dataset
startX - the first value the sample data is created for
endX - the last value the sample data is created for
sampleCnt - count of created samples

addRegressionLineToPlot

public static void addRegressionLineToPlot(XYPlot plot,
                                           XYDataset regressionData,
                                           Color lineColor)
Adds a line plot for regression data to a plot.

Parameters:
plot - the plot the line is added to (at the end)
regressionData - the regression data
lineColor - the color for the regression line