schmitzm.jfree.chart.style
Class AbstractChartStyle

java.lang.Object
  extended by schmitzm.jfree.chart.style.AbstractChartStyle
All Implemented Interfaces:
ChartStyle, Copyable<ChartStyle>
Direct Known Subclasses:
BasicChartStyle, FeatureChartStyle.Dummy, ScatterChartStyle

public abstract class AbstractChartStyle
extends Object
implements ChartStyle

This class provides an abstract implementation for chart styles. It implements the variables and methods for maintaining the type, the title(s) and flags of the ChartStyle interface.

Version:
1.0
Author:
Martin Schmitz

Field Summary
protected  Map<Integer,ChartAxisStyle> axisStyle
          Holds the styles of the chart axis.
protected  Color bgPaint
          Holds the background color for the chart.
protected  boolean borderVisible
          Stores whether a border is shown around the whole chart.
protected  ChartLabelStyle descStyle
          Holds a long description for the chart.
protected  String id
          Holds a (unique) ID for the style.
protected  boolean legend
          Stores whether a legend is generated for the chart (Default: true).
protected  Category LOGGER
          Logger for this class
protected  int maxRendererDatasetIdx
          Holds the maximum dataset index for which a renderer is specified.
protected  PlotOrientation orientation
          Holds the plot orientation (horizontal/vertical).
protected  ChartPlotStyle plotStyle
          Holds the style for the chart's plot.
protected  Map<Integer,ChartRendererStyle> rendererStyle
          Holds the styles for the chart renderers.
protected  CategoryToolTipGenerator TIPGEN_CAT
          Tooltip generator used for Category-Charts.
protected  XYToolTipGenerator TIPGEN_XY
          Tooltip generator used for XY-Charts.
protected  ChartLabelStyle titleStyle
          Holds the chart title.
protected  boolean tooltips
          Stores whether tooltips are generated for the chart data (Default: true).
protected  ChartType type
          Holds the chart type.
protected  CategoryURLGenerator URLGEN_CAT
          URL generator used for Category-Charts.
protected  XYURLGenerator URLGEN_XY
          URL generator used for XY-Charts.
protected  boolean urls
          Stores whether URLs are generated for the chart (Default: true).
 
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
AbstractChartStyle(String id)
          Creates a line style with default values.
AbstractChartStyle(String id, ChartType type)
          Creates a style with default values.
AbstractChartStyle(String id, ChartType type, String title, String xTitle, String yTitle, boolean legend, boolean tooltips, boolean urls)
          Creates a style.
 
Method Summary
 void applyToChart(JFreeChart chart)
          Applies the properties of this style to an existing chart.
abstract  AbstractChartStyle copy()
          Creates a (deep) clone of this chart style.
 ChartStyle copyTo(ChartStyle dest)
          Copies all properties of this chart style to another chart style.
 int getAxisCount()
          Returns the axis count.
 ChartAxisStyle getAxisStyle(int axis)
          Returns the style of a chart axis.
 Color getBackground()
          Returns the background color of the chart.
 ChartLabelStyle getDescStyle()
          Returns the style of the long chart description.
 String getID()
          Returns the (unique) ID for the style.
 PlotOrientation getOrientation()
          Returns the orientation of the chart.
 ChartPlotStyle getPlotStyle()
          Returns the style of the chart's plot.
 int getRendererCount()
          Returns count of renderer for the chart.
 ChartRendererStyle getRendererStyle(int dataset)
          Returns the style of a dataset renderer.
 ChartLabelStyle getTitleStyle()
          Returns the style of the charts title.
 ChartType getType()
          Returns the type of the chart style.
 boolean hasLegend()
          Returns whether the chart is configured to generate a legend.
 boolean hasTooltips()
          Returns whether the chart is configured to generate tooltips for the data.
 boolean hasURLs()
          Returns whether the chart is configured to generate URLs.
 boolean isBorderVisible()
          Returns whether a border is shown around the whole chart.
 void setAxisStyle(int axis, ChartAxisStyle style)
          Sets the style of a chart axis.
 void setBackground(Color paint)
          Sets the background color of the chart.
 void setBorderVisible(boolean visible)
          Sets whether a border is shown around the whole chart.
 void setDescStyle(ChartLabelStyle descStyle)
          Sets the long description for the chart.
 void setLegend(boolean legend)
          Sets whether the chart is configured to generate a legend.
 void setOrientation(PlotOrientation orientation)
          Sets the orientation of the chart.
 void setPlotStyle(ChartPlotStyle style)
          Sets the style of the chart's plot.
 void setRendererStyle(int dataset, ChartRendererStyle style)
          Sets the style of a dataset renderer.
 void setTitleStyle(ChartLabelStyle style)
          Sets the style of the charts title.
 void setTooltips(boolean tooltips)
          Sets whether the chart is configured to generate tooltips for the data.
 void setType(ChartType type)
          Sets the type of the chart style.
 void setURLs(boolean urls)
          Sets whether the chart is configured to generate URLs.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 
Methods inherited from interface schmitzm.jfree.chart.style.ChartStyle
applyToDataset
 

Field Detail

TIPGEN_XY

protected XYToolTipGenerator TIPGEN_XY
Tooltip generator used for XY-Charts.


TIPGEN_CAT

protected CategoryToolTipGenerator TIPGEN_CAT
Tooltip generator used for Category-Charts.


URLGEN_XY

protected XYURLGenerator URLGEN_XY
URL generator used for XY-Charts.


URLGEN_CAT

protected CategoryURLGenerator URLGEN_CAT
URL generator used for Category-Charts.


LOGGER

protected final Category LOGGER
Logger for this class


id

protected String id
Holds a (unique) ID for the style.


type

protected ChartType type
Holds the chart type.

See Also:
ChartStyle#ChartType

titleStyle

protected ChartLabelStyle titleStyle
Holds the chart title.


descStyle

protected ChartLabelStyle descStyle
Holds a long description for the chart.


bgPaint

protected Color bgPaint
Holds the background color for the chart.


borderVisible

protected boolean borderVisible
Stores whether a border is shown around the whole chart.


axisStyle

protected Map<Integer,ChartAxisStyle> axisStyle
Holds the styles of the chart axis.


orientation

protected PlotOrientation orientation
Holds the plot orientation (horizontal/vertical).


legend

protected boolean legend
Stores whether a legend is generated for the chart (Default: true).


tooltips

protected boolean tooltips
Stores whether tooltips are generated for the chart data (Default: true).


urls

protected boolean urls
Stores whether URLs are generated for the chart (Default: true).


rendererStyle

protected Map<Integer,ChartRendererStyle> rendererStyle
Holds the styles for the chart renderers.


maxRendererDatasetIdx

protected int maxRendererDatasetIdx
Holds the maximum dataset index for which a renderer is specified.


plotStyle

protected ChartPlotStyle plotStyle
Holds the style for the chart's plot.

Constructor Detail

AbstractChartStyle

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

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

AbstractChartStyle

public AbstractChartStyle(String id,
                          ChartType type)
Creates a style with default values.

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

AbstractChartStyle

public AbstractChartStyle(String id,
                          ChartType type,
                          String title,
                          String xTitle,
                          String yTitle,
                          boolean legend,
                          boolean tooltips,
                          boolean urls)
Creates a style.

Parameters:
id - a (unique) ID for the style
type - style type
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

copy

public abstract AbstractChartStyle copy()
Creates a (deep) clone of this chart style.

Specified by:
copy in interface Copyable<ChartStyle>

copyTo

public ChartStyle copyTo(ChartStyle dest)
Copies all properties of this chart style to another chart style.

Specified by:
copyTo in interface Copyable<ChartStyle>
Parameters:
dest - destination object (if null the copy is created by copy())
Returns:
dest or the new instance
Throws:
IllegalArgumentException - if dest is no AbstractChartStyle

getID

public String getID()
Returns the (unique) ID for the style.

Specified by:
getID in interface ChartStyle

getType

public ChartType getType()
Returns the type of the chart style.

Specified by:
getType in interface ChartStyle

setType

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

Parameters:
type - the chart type
See Also:
ChartStyle#ChartType

getOrientation

public PlotOrientation getOrientation()
Returns the orientation of the chart.

Specified by:
getOrientation in interface ChartStyle
See Also:
PlotOrientation#HORIZONTAL, PlotOrientation#VERTICAL

setOrientation

public void setOrientation(PlotOrientation orientation)
Sets the orientation of the chart.

Specified by:
setOrientation in interface ChartStyle
Parameters:
orientation - the orientation of the chart

getTitleStyle

public ChartLabelStyle getTitleStyle()
Returns the style of the charts title.

Specified by:
getTitleStyle in interface ChartStyle

setTitleStyle

public void setTitleStyle(ChartLabelStyle style)
Sets the style of the charts title.

Specified by:
setTitleStyle in interface ChartStyle
Parameters:
style - the new style (if null the style is reset to an empty default style, so that the getter method always can be accessed!)

getDescStyle

public ChartLabelStyle getDescStyle()
Returns the style of the long chart description.

Specified by:
getDescStyle in interface ChartStyle

setDescStyle

public void setDescStyle(ChartLabelStyle descStyle)
Sets the long description for the chart.

Specified by:
setDescStyle in interface ChartStyle
Parameters:
descStyle - the new chart description style

getBackground

public Color getBackground()
Returns the background color of the chart.

Specified by:
getBackground in interface ChartStyle

setBackground

public void setBackground(Color paint)
Sets the background color of the chart.

Specified by:
setBackground in interface ChartStyle
Parameters:
paint - the background color for the chart

isBorderVisible

public boolean isBorderVisible()
Returns whether a border is shown around the whole chart.

Specified by:
isBorderVisible in interface ChartStyle

setBorderVisible

public void setBorderVisible(boolean visible)
Sets whether a border is shown around the whole chart.

Specified by:
setBorderVisible in interface ChartStyle

hasLegend

public boolean hasLegend()
Returns whether the chart is configured to generate a legend.

Specified by:
hasLegend in interface ChartStyle

setLegend

public void setLegend(boolean legend)
Sets whether the chart is configured to generate a legend.

Specified by:
setLegend in interface ChartStyle

hasTooltips

public boolean hasTooltips()
Returns whether the chart is configured to generate tooltips for the data.

Specified by:
hasTooltips in interface ChartStyle

setTooltips

public void setTooltips(boolean tooltips)
Sets whether the chart is configured to generate tooltips for the data.

Specified by:
setTooltips in interface ChartStyle

hasURLs

public boolean hasURLs()
Returns whether the chart is configured to generate URLs.

Specified by:
hasURLs in interface ChartStyle

setURLs

public void setURLs(boolean urls)
Sets whether the chart is configured to generate URLs.

Specified by:
setURLs in interface ChartStyle

getAxisCount

public int getAxisCount()
Returns the axis count.

Specified by:
getAxisCount in interface ChartStyle

getAxisStyle

public ChartAxisStyle getAxisStyle(int axis)
Returns the style of a chart axis.

Specified by:
getAxisStyle in interface ChartStyle
Parameters:
axis - axis number (0=domain, 1=range, ...)
Returns:
null if the chart has no such axis

setAxisStyle

public void setAxisStyle(int axis,
                         ChartAxisStyle style)
Sets the style of a chart axis.

Specified by:
setAxisStyle in interface ChartStyle
Parameters:
axis - axis number (0=domain, 1=range, ...)
style - style for the axis

getRendererCount

public int getRendererCount()
Returns count of renderer for the chart.

Specified by:
getRendererCount in interface ChartStyle

getRendererStyle

public ChartRendererStyle getRendererStyle(int dataset)
Returns the style of a dataset renderer.

Specified by:
getRendererStyle in interface ChartStyle
Parameters:
dataset - dataset number (starting with 0)
Returns:
null if the chart has no such renderer

setRendererStyle

public void setRendererStyle(int dataset,
                             ChartRendererStyle style)
Sets the style of a dataset renderer.

Specified by:
setRendererStyle in interface ChartStyle
Parameters:
dataset - dataset number (starting with 0)
style - style for the dataset renderer

getPlotStyle

public ChartPlotStyle getPlotStyle()
Returns the style of the chart's plot.

Specified by:
getPlotStyle in interface ChartStyle
Returns:
null if no such style is defined

setPlotStyle

public void setPlotStyle(ChartPlotStyle style)
Sets the style of the chart's plot.

Specified by:
setPlotStyle in interface ChartStyle
Parameters:
style - style for the plot

applyToChart

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

Specified by:
applyToChart in interface ChartStyle
Parameters:
chart - chart to be styled