com.approximatrix.charting
Class AbstractChart

java.lang.Object
  extended by com.approximatrix.charting.render.AbstractRenderer
      extended by com.approximatrix.charting.AbstractChart
All Implemented Interfaces:
Chart, Renderer
Direct Known Subclasses:
BufferedChart, DefaultChart, ExtendedChart

public abstract class AbstractChart
extends AbstractRenderer
implements Chart

Implements the standard getter and setter methods for a chart.

Version:
1.0
Author:
mueller

Field Summary
protected  java.awt.Rectangle bounds
           
protected  CoordSystem coord
           
protected  Legend legend
           
protected static int MISSING_LEGEND_WIDTH
           
protected static int MISSING_TITLE_HEIGHT
           
protected  ChartDataModel model
           
protected  RowColorModel rcModel
           
protected  java.util.HashMap<java.lang.Integer,AbstractChartRenderer> renderer
           
protected  Title title
           
 
Fields inherited from class com.approximatrix.charting.render.AbstractRenderer
listener
 
Constructor Summary
AbstractChart()
          Creates new AbstractChart
 
Method Summary
 void addChartRenderer(AbstractChartRenderer render, int z)
          Adds a ChartRenderer with a specific z-coordinate.
 java.awt.Rectangle getBounds()
          Returns the Bounds for the Chart.
 ChartDataModel getChartDataModel()
          Returns the ChartDataModel.
 java.util.Map<java.lang.Integer,AbstractChartRenderer> getChartRenderer()
          Returns the Map of all ChartRenderers.
 AbstractChartRenderer getChartRenderer(int z)
          Returns the ChartRenderer with a specific z-coordinate.
 CoordSystem getCoordSystem()
          Returns the coordinate system.
 Legend getLegend()
          Returns this chart's legend.
 RowColorModel getRowColorModel()
          Returns the RowColorModel for this chart.
 Title getTitle()
          Returns the title for this chart.
 void paintDefault(java.awt.Graphics2D g)
          This method is called by the paint method to do the actual painting.
 void render(java.awt.Graphics2D g)
          Does the layout of the title, legend and coordinate system and calls the render method of all those including the ChartRenderers.
 void setBounds(java.awt.Rectangle r)
          Sets the Bounds for this Chart.
 void setChartDataModel(ChartDataModel model)
          Stores the ChartDataModel for this Chart.
 void setChartRenderer(java.util.Map render)
          Sets the Map with all ChartRenderers.
 void setCoordSystem(CoordSystem c)
          Sets the coordinate system for this chart, which can be null if the ChartRenderer doesn't need a coordinate system, e.g.
 void setLegend(Legend l)
          Sets the legend for this chart.
 void setRowColorModel(RowColorModel rcm)
          Sets the RowColorModel for this chart.
 void setTitle(Title t)
          Sets the title for this chart.
 
Methods inherited from class com.approximatrix.charting.render.AbstractRenderer
addRenderChangeListener, clearRenderChangeListeners, fireRenderChangeEvent, getDirectRender, isDifferentBounds, removeRenderChangeListener, setDirectRender
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 
Methods inherited from interface com.approximatrix.charting.render.Renderer
getPreferredSize
 

Field Detail

MISSING_LEGEND_WIDTH

protected static final int MISSING_LEGEND_WIDTH
See Also:
Constant Field Values

MISSING_TITLE_HEIGHT

protected static final int MISSING_TITLE_HEIGHT
See Also:
Constant Field Values

renderer

protected java.util.HashMap<java.lang.Integer,AbstractChartRenderer> renderer

bounds

protected java.awt.Rectangle bounds

legend

protected Legend legend

coord

protected CoordSystem coord

title

protected Title title

rcModel

protected RowColorModel rcModel

model

protected ChartDataModel model
Constructor Detail

AbstractChart

public AbstractChart()
Creates new AbstractChart

Method Detail

addChartRenderer

public void addChartRenderer(AbstractChartRenderer render,
                             int z)
Adds a ChartRenderer with a specific z-coordinate.

Specified by:
addChartRenderer in interface Chart
Parameters:
render - the ChartRenderer
z - the z-coordinate, the highest coordinate is in front.

getChartRenderer

public java.util.Map<java.lang.Integer,AbstractChartRenderer> getChartRenderer()
Returns the Map of all ChartRenderers.

Specified by:
getChartRenderer in interface Chart
Returns:
a java.util.Map with all ChartRenderers

getChartRenderer

public AbstractChartRenderer getChartRenderer(int z)
Returns the ChartRenderer with a specific z-coordinate.

Specified by:
getChartRenderer in interface Chart
Parameters:
z - the z-coordinate
Returns:
the ChartRenderer or null.

getCoordSystem

public CoordSystem getCoordSystem()
Returns the coordinate system.

Specified by:
getCoordSystem in interface Chart
Returns:
a ClassicCoordSystem object or null if there is none.

getLegend

public Legend getLegend()
Returns this chart's legend.

Specified by:
getLegend in interface Chart
Returns:
the Legend object.

getTitle

public Title getTitle()
Returns the title for this chart.

Specified by:
getTitle in interface Chart
Returns:
a Title object.

getRowColorModel

public RowColorModel getRowColorModel()
Returns the RowColorModel for this chart. Note that this is simply the default row color model, and not necessarily the model used by all renderers.

Returns:
a RowColorModel object.

setChartRenderer

public void setChartRenderer(java.util.Map render)
Sets the Map with all ChartRenderers. The keys have to be the z-coordinates of the ChartRenderers.

Specified by:
setChartRenderer in interface Chart
Parameters:
render - a java.util.Map with all ChartRenderers.

setCoordSystem

public void setCoordSystem(CoordSystem c)
Sets the coordinate system for this chart, which can be null if the ChartRenderer doesn't need a coordinate system, e.g. if it's a PieChart.

Specified by:
setCoordSystem in interface Chart
Parameters:
c - the ClassicCoordSystem object

setLegend

public void setLegend(Legend l)
Sets the legend for this chart.

Specified by:
setLegend in interface Chart
Parameters:
l - the Legend

setTitle

public void setTitle(Title t)
Sets the title for this chart.

Specified by:
setTitle in interface Chart
Parameters:
t - the Title object

setRowColorModel

public void setRowColorModel(RowColorModel rcm)
                      throws java.lang.NullPointerException
Sets the RowColorModel for this chart. Also updates any renderers using the previous default model to this one.

Parameters:
rcm - the new RowColorModel
Throws:
java.lang.NullPointerException

setChartDataModel

public void setChartDataModel(ChartDataModel model)
Stores the ChartDataModel for this Chart.

Specified by:
setChartDataModel in interface Chart
Parameters:
model - the ChartDataModel

getChartDataModel

public ChartDataModel getChartDataModel()
Returns the ChartDataModel.

Specified by:
getChartDataModel in interface Chart
Returns:
the ChartDataModel for the Chart

setBounds

public void setBounds(java.awt.Rectangle r)
Sets the Bounds for this Chart. This is important for rendering the chart and always has to be done before rendering.

Specified by:
setBounds in interface Chart
Specified by:
setBounds in interface Renderer
Overrides:
setBounds in class AbstractRenderer
Parameters:
r - the Rectangle object defining this chart's bounds.

getBounds

public java.awt.Rectangle getBounds()
Returns the Bounds for the Chart.

Specified by:
getBounds in interface Chart
Specified by:
getBounds in interface Renderer
Overrides:
getBounds in class AbstractRenderer
Returns:
a Rectangle object defining this chart's bounds.

paintDefault

public void paintDefault(java.awt.Graphics2D g)
This method is called by the paint method to do the actual painting. The painting is supposed to start at point (0,0) and the size is always the same as the preferred size. The paint method performs the possible scaling.

Specified by:
paintDefault in class AbstractRenderer
Parameters:
g - the Graphics2D object to paint in.

render

public void render(java.awt.Graphics2D g)
Does the layout of the title, legend and coordinate system and calls the render method of all those including the ChartRenderers.

Specified by:
render in interface Chart
Specified by:
render in interface Renderer
Overrides:
render in class AbstractRenderer
Parameters:
g - the Graphics2D object to paint in.