de.laures.cewolf.taglib
Class CewolfChartFactory

java.lang.Object
  extended by de.laures.cewolf.taglib.CewolfChartFactory
All Implemented Interfaces:
AxisConstants, ChartConstants, LayoutConstants

public abstract class CewolfChartFactory
extends java.lang.Object
implements ChartConstants, AxisConstants, LayoutConstants

Chart factory creates Jfreechart instances. To add a new factory use the CewolfChartFactory.registerFactory(new CewolfChartFactory() {...}); method.

Author:
Guido Laures

Field Summary
protected  java.lang.String chartType
           
 
Fields inherited from interface de.laures.cewolf.taglib.ChartConstants
AREA, AREA_XY, BUBBLE, CANDLE_STICK, COMBINED_XY, COMPASS, DIAL, GANTT, HIGH_LOW, HISTOGRAM, HORIZONTAL_BAR, HORIZONTAL_BAR_3D, LINE, METER, OVERLAY_CATEGORY, OVERLAY_XY, PIE, PIE_3D, SCATTER, SPIDERWEB, SPLINE, STACKED_AREA, STACKED_HORIZONTAL_BAR, STACKED_HORIZONTAL_BAR_3D, STACKED_VERTICAL_BAR, STACKED_VERTICAL_BAR_3D, THERMOMETER, TIME_SERIES, VERTICAL_BAR, VERTICAL_BAR_3D, VERTICAL_XY_BAR, WAFER, WIND, XY
 
Fields inherited from interface de.laures.cewolf.taglib.AxisConstants
AXIS_TYPE_CATEGORY, AXIS_TYPE_DATE, AXIS_TYPE_NUMBER, ORIENTATION_HORIZONTAL, ORIENTATION_VERTICAL
 
Fields inherited from interface de.laures.cewolf.taglib.LayoutConstants
DOMAIN, RANGE
 
Constructor Summary
protected CewolfChartFactory(java.lang.String chartType)
          Creates a new instance of ChartFactory
 
Method Summary
static void check(org.jfree.data.general.Dataset data, java.lang.Class clazz, java.lang.String chartType)
          Helper to check if the given dataset is the expected type.
static org.jfree.chart.JFreeChart createScatterPlot(java.lang.String title, java.lang.String xAxisLabel, java.lang.String yAxisLabel, org.jfree.data.xy.XYDataset dataset, org.jfree.chart.plot.PlotOrientation orientation, boolean legend, boolean tooltips, boolean urls)
          Creates a scatter plot with default settings.
static org.jfree.chart.JFreeChart createSplineChart(java.lang.String title, java.lang.String xAxisLabel, java.lang.String yAxisLabel, org.jfree.data.xy.XYDataset dataset, org.jfree.chart.plot.PlotOrientation orientation, boolean showLegend, boolean tooltips, boolean urls)
          Creates a spline chart (based on an XYDataset) with default settings.
static org.jfree.chart.JFreeChart createXYLineChart(java.lang.String title, java.lang.String xAxisLabel, java.lang.String yAxisLabel, org.jfree.data.xy.XYDataset dataset, org.jfree.chart.plot.PlotOrientation orientation, boolean legend, boolean tooltips, boolean urls)
          Creates a line chart (based on an XYDataset) with default settings.
abstract  org.jfree.chart.JFreeChart getChartInstance(java.lang.String title, java.lang.String xAxisLabel, java.lang.String yAxisLabel, org.jfree.data.general.Dataset data)
          Callback when the chart instance to be created.
static org.jfree.chart.JFreeChart getChartInstance(java.lang.String chartType, java.lang.String title, java.lang.String xAxisLabel, java.lang.String yAxisLabel, org.jfree.data.general.Dataset data, boolean showLegend)
           
static org.jfree.chart.JFreeChart getCombinedChartInstance(java.lang.String chartType, java.lang.String title, java.lang.String xAxisLabel, java.lang.String yAxisLabel, java.util.List plotDefinitions, java.lang.String layout, boolean showLegend)
           
static org.jfree.chart.JFreeChart getOverlaidChartInstance(java.lang.String chartType, java.lang.String title, java.lang.String xAxisLabel, java.lang.String yAxisLabel, int xAxisType, int yAxisType, java.util.List plotDefinitions, boolean showLegend)
           
static void registerFactory(CewolfChartFactory factory)
          Register a new chart factory instance.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

chartType

protected java.lang.String chartType
Constructor Detail

CewolfChartFactory

protected CewolfChartFactory(java.lang.String chartType)
Creates a new instance of ChartFactory

Method Detail

getChartInstance

public abstract org.jfree.chart.JFreeChart getChartInstance(java.lang.String title,
                                                            java.lang.String xAxisLabel,
                                                            java.lang.String yAxisLabel,
                                                            org.jfree.data.general.Dataset data)
                                                     throws IncompatibleDatasetException
Callback when the chart instance to be created.

Parameters:
title - The title of chart
xAxisLabel - label on x axis
yAxisLabel - label on y axis
data - The dataset to create chart for
Returns:
The newly created JFreeChart instance
Throws:
IncompatibleDatasetException - If the incoming data is not compatible with this factory

registerFactory

public static void registerFactory(CewolfChartFactory factory)
Register a new chart factory instance.

Parameters:
factory - The factory to register

getChartInstance

public static org.jfree.chart.JFreeChart getChartInstance(java.lang.String chartType,
                                                          java.lang.String title,
                                                          java.lang.String xAxisLabel,
                                                          java.lang.String yAxisLabel,
                                                          org.jfree.data.general.Dataset data,
                                                          boolean showLegend)
                                                   throws ChartValidationException
Throws:
ChartValidationException

createSplineChart

public static org.jfree.chart.JFreeChart createSplineChart(java.lang.String title,
                                                           java.lang.String xAxisLabel,
                                                           java.lang.String yAxisLabel,
                                                           org.jfree.data.xy.XYDataset dataset,
                                                           org.jfree.chart.plot.PlotOrientation orientation,
                                                           boolean showLegend,
                                                           boolean tooltips,
                                                           boolean urls)
Creates a spline chart (based on an XYDataset) with default settings.

Parameters:
title - the chart title (null permitted).
xAxisLabel - a label for the X-axis (null permitted).
yAxisLabel - a label for the Y-axis (null permitted).
dataset - the dataset for the chart (null permitted).
orientation - the plot orientation (horizontal or vertical) (null NOT permitted).
showLegend - a flag specifying whether or not a legend is required.
tooltips - configure chart to generate tool tips?
urls - configure chart to generate URLs?
Returns:
The chart.

createScatterPlot

public static org.jfree.chart.JFreeChart createScatterPlot(java.lang.String title,
                                                           java.lang.String xAxisLabel,
                                                           java.lang.String yAxisLabel,
                                                           org.jfree.data.xy.XYDataset dataset,
                                                           org.jfree.chart.plot.PlotOrientation orientation,
                                                           boolean legend,
                                                           boolean tooltips,
                                                           boolean urls)
Creates a scatter plot with default settings. The chart object returned by this method uses an XYPlot instance as the plot, with a NumberAxis for the domain axis, a NumberAxis as the range axis, and an XYConditionRenderer as the renderer.

Parameters:
title - the chart title (null permitted).
xAxisLabel - a label for the X-axis (null permitted).
yAxisLabel - a label for the Y-axis (null permitted).
dataset - the dataset for the chart (null permitted).
orientation - the plot orientation (horizontal or vertical) (null NOT permitted).
legend - a flag specifying whether or not a legend is required.
tooltips - configure chart to generate tool tips?
urls - configure chart to generate URLs?
Returns:
A scatter plot.

createXYLineChart

public static org.jfree.chart.JFreeChart createXYLineChart(java.lang.String title,
                                                           java.lang.String xAxisLabel,
                                                           java.lang.String yAxisLabel,
                                                           org.jfree.data.xy.XYDataset dataset,
                                                           org.jfree.chart.plot.PlotOrientation orientation,
                                                           boolean legend,
                                                           boolean tooltips,
                                                           boolean urls)
Creates a line chart (based on an XYDataset) with default settings.

Parameters:
title - the chart title (null permitted).
xAxisLabel - a label for the X-axis (null permitted).
yAxisLabel - a label for the Y-axis (null permitted).
dataset - the dataset for the chart (null permitted).
orientation - the plot orientation (horizontal or vertical) (null NOT permitted).
legend - a flag specifying whether or not a legend is required.
tooltips - configure chart to generate tool tips?
urls - configure chart to generate URLs?
Returns:
The chart.

getOverlaidChartInstance

public static org.jfree.chart.JFreeChart getOverlaidChartInstance(java.lang.String chartType,
                                                                  java.lang.String title,
                                                                  java.lang.String xAxisLabel,
                                                                  java.lang.String yAxisLabel,
                                                                  int xAxisType,
                                                                  int yAxisType,
                                                                  java.util.List plotDefinitions,
                                                                  boolean showLegend)
                                                           throws ChartValidationException,
                                                                  DatasetProduceException
Throws:
ChartValidationException
DatasetProduceException

getCombinedChartInstance

public static org.jfree.chart.JFreeChart getCombinedChartInstance(java.lang.String chartType,
                                                                  java.lang.String title,
                                                                  java.lang.String xAxisLabel,
                                                                  java.lang.String yAxisLabel,
                                                                  java.util.List plotDefinitions,
                                                                  java.lang.String layout,
                                                                  boolean showLegend)
                                                           throws ChartValidationException,
                                                                  DatasetProduceException
Throws:
ChartValidationException
DatasetProduceException

check

public static void check(org.jfree.data.general.Dataset data,
                         java.lang.Class clazz,
                         java.lang.String chartType)
                  throws IncompatibleDatasetException
Helper to check if the given dataset is the expected type.

Parameters:
data - The dataset
clazz - Expected type (class)
chartType - The chart type string
Throws:
IncompatibleDatasetException - If not the expected class


cewolf tag library - web charts with JFreeChart