schmitzm.jfree.chart.style
Class BasicChartStyle

java.lang.Object
  extended by schmitzm.jfree.chart.style.AbstractChartStyle
      extended by schmitzm.jfree.chart.style.BasicChartStyle
All Implemented Interfaces:
ChartStyle
Direct Known Subclasses:
FeatureBasicChartStyle

public class BasicChartStyle
extends AbstractChartStyle

This class provides a basis chart style for line, area an bar charts.

Version:
1.0
Author:
Martin Schmitz

Field Summary
protected  boolean stacked
          Stores whether the chart is stacked.
protected  boolean stepped
          Stores whether the chart is stepped.
 
Fields inherited from class schmitzm.jfree.chart.style.AbstractChartStyle
axisStyle, bgPaint, borderVisible, descStyle, id, legend, LOGGER, maxRendererDatasetIdx, orientation, plotStyle, rendererStyle, TIPGEN_CAT, TIPGEN_XY, titleStyle, tooltips, type, URLGEN_CAT, URLGEN_XY, urls
 
Fields inherited from interface schmitzm.jfree.chart.style.ChartStyle
DOMAIN_AXIS, RANGE_AXIS, RANGE_AXIS2, X_AXIS, Y_AXIS, Y_AXIS_LEFT, Y_AXIS_RIGHT, Y_AXIS2
 
Constructor Summary
BasicChartStyle(String id)
          Creates a normal line style with default values.
BasicChartStyle(String id, ChartType type)
          Creates a normal, vertical line, bar or area style.
BasicChartStyle(String id, ChartType type, boolean stacked, boolean stepped, PlotOrientation orientation)
          Creates a line, area or bar chart style.
BasicChartStyle(String id, ChartType type, boolean stacked, boolean stepped, PlotOrientation orientation, String title, String xTitle, String yTitle, boolean legend, boolean tooltips, boolean urls)
          Creates a chart style.
 
Method Summary
 void applyToChart(JFreeChart chart)
          Applies the style to an existing chart.
 JFreeChart applyToDataset(Dataset dataset)
          Creates a chart for the given Dataset and applies the style.
 boolean isStacked()
          Returns whether the chart is stacked.
 boolean isStepped()
          Returns whether the chart is stepped.
 void setStacked(boolean stacked)
          Sets whether the chart is stacked.
 void setStepped(boolean stepped)
          Sets whether the chart is stepped.
 void setType(ChartType type)
          Sets the type of the chart style.
protected  void throwUnsupportedTypeException()
          Throws an UnsupportedOperationException.
 
Methods inherited from class schmitzm.jfree.chart.style.AbstractChartStyle
getAxisCount, getAxisStyle, getBackground, getDescStyle, getID, getOrientation, getPlotStyle, getRendererCount, getRendererStyle, getTitleStyle, getType, hasLegend, hasTooltips, hasURLs, isBorderVisible, setAxisStyle, setBackground, setBorderVisible, setDescStyle, setLegend, setOrientation, setPlotStyle, setRendererStyle, setTitleStyle, setTooltips, setURLs
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

stacked

protected boolean stacked
Stores whether the chart is stacked. Line charts can never be stacked.


stepped

protected boolean stepped
Stores whether the chart is stepped. Bar charts are always stepped.

Constructor Detail

BasicChartStyle

public BasicChartStyle(String id)
Creates a normal line style with default values.

Parameters:
id - a (unique) ID for the style

BasicChartStyle

public BasicChartStyle(String id,
                       ChartType type)
Creates a normal, vertical line, bar or area style.

Parameters:
id - a (unique) ID for the style
type - type of the chart layout

BasicChartStyle

public BasicChartStyle(String id,
                       ChartType type,
                       boolean stacked,
                       boolean stepped,
                       PlotOrientation orientation)
Creates a line, area or bar chart style.

Parameters:
id - a (unique) ID for the style
type - style type
stacked - flag whether the chart is stacked (ignored for line charts)
stepped - flag whether the chart is stepped (ignored for bar charts)
orientation - orientation of the chart (PlotOrientation.VERTICAL or PlotOrientation.HORIZONTAL)

BasicChartStyle

public BasicChartStyle(String id,
                       ChartType type,
                       boolean stacked,
                       boolean stepped,
                       PlotOrientation orientation,
                       String title,
                       String xTitle,
                       String yTitle,
                       boolean legend,
                       boolean tooltips,
                       boolean urls)
Creates a chart style.

Parameters:
id - a (unique) ID for the style
type - style type
stacked - flag whether the chart is stacked (ignored for line charts)
stepped - flag whether the chart is stepped (ignored for bar charts)
orientation - orientation of the chart (PlotOrientation.VERTICAL or PlotOrientation.HORIZONTAL)
title - title for the chart
xTitle - title for the chart's X-axis
yTitle - title for the chart's Y-axis
legend - flag whether a legend is generated
tooltips - flag whether toolstips are generated
urls - flag whether URLs are generated
Method Detail

throwUnsupportedTypeException

protected void throwUnsupportedTypeException()
Throws an UnsupportedOperationException.


setType

public void setType(ChartType type)
Sets the type of the chart style.

Overrides:
setType in class AbstractChartStyle
Parameters:
type - the chart type
Throws:
IllegalArgumentException - if aType is not of ChartType.LINE, ChartType.AREA or ChartType.BAR
See Also:
ChartStyle#ChartType

isStacked

public boolean isStacked()
Returns whether the chart is stacked.

Returns:
false for line charts

setStacked

public void setStacked(boolean stacked)
Sets whether the chart is stacked. Sets the stacked property to false for line charts, even aStacked is true.


isStepped

public boolean isStepped()
Returns whether the chart is stepped.

Returns:
true for bar charts

setStepped

public void setStepped(boolean stepped)
Sets whether the chart is stepped. Sets the stepped property to true for bar charts, even stepped is false.


applyToDataset

public JFreeChart applyToDataset(Dataset dataset)
Creates a chart for the given Dataset and applies the style.

Parameters:
dataset - the data for the chart
Throws:
UnsupportedOperationException - if the style can not be applied to the given dataset

applyToChart

public void applyToChart(JFreeChart chart)
Applies the style to an existing chart.

Specified by:
applyToChart in interface ChartStyle
Overrides:
applyToChart in class AbstractChartStyle
Parameters:
chart - chart the style is applied to