com.approximatrix.charting.render
Class AbstractChartRenderer

java.lang.Object
  extended by com.approximatrix.charting.render.AbstractChartRenderer
All Implemented Interfaces:
Renderer
Direct Known Subclasses:
BarChartRenderer, InterpolationChartRenderer, LineChartRenderer, MultiScatterChartRenderer, PieChartRenderer, PlotChartRenderer, RadarChartRenderer, ScatterChartRenderer, StackedBarChartRenderer

public abstract class AbstractChartRenderer
extends java.lang.Object
implements Renderer

This class is the superclass for all the different ChartRenderer.

Version:
1.0
Author:
mueller

Field Summary
protected  java.awt.Rectangle bounds
           
protected  CoordSystem coord
           
protected  ChartDataModel model
           
protected  RowColorModel rcm
           
 
Constructor Summary
protected AbstractChartRenderer(ChartDataModel model)
          Creates new AbstractChartRenderer
  AbstractChartRenderer(CoordSystem cs, ChartDataModel model)
          Creates new AbstractChartRenderer
 
Method Summary
 java.awt.Rectangle getBounds()
          Gets the bounds for this renderer.
 ChartDataModel getChartDataModel()
          Returns the ChartDataModel whose DataSets are rendered.
 CoordSystem getCoordSystem()
          Returns the current CoordSystem.
 java.awt.Dimension getPreferredSize()
          Returns the preferred size needed for the renderer.
 RowColorModel getRowColorModel()
          Returns the RowColorModel currently in use.
 java.awt.geom.AffineTransform getTransform(int axis)
          Returns the currently defined AffineTransform for any y-axis.
 void render(java.awt.Graphics2D g)
          Calls renderChart(g) and crops the output to the desired bounds.
abstract  void renderChart(java.awt.Graphics2D g)
          Finally renders the chart in the clipped rectangle.
 void setBounds(java.awt.Rectangle bounds)
          Sets the bounds the layout manager has assigned to this renderer.
 void setChartDataModel(ChartDataModel model)
          Sets the ChartDataModel whose DataSets are rendered.
 void setCoordSystem(CoordSystem cs)
          Sets the CoordSystem which contains the AffineTransforms to translate into pixel space.
 void setRowColorModel(RowColorModel rcm)
          Sets a RowColorModel to define the correlation of row titles and colors used for the Legend.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

bounds

protected java.awt.Rectangle bounds

coord

protected CoordSystem coord

model

protected ChartDataModel model

rcm

protected RowColorModel rcm
Constructor Detail

AbstractChartRenderer

protected AbstractChartRenderer(ChartDataModel model)
Creates new AbstractChartRenderer

Parameters:
model - the DataModel that should be rendered

AbstractChartRenderer

public AbstractChartRenderer(CoordSystem cs,
                             ChartDataModel model)
Creates new AbstractChartRenderer

Parameters:
cs - the CoordSystem which contains the AffineTransforms to translate into pixel space
rcm - the RowColorModel that defines the correspondence between row titles and colors
model - the DataModel that should be rendered
Method Detail

getBounds

public java.awt.Rectangle getBounds()
Gets the bounds for this renderer.

Specified by:
getBounds in interface Renderer
Returns:
the bounds of this renderer. If setBounds has not been called before, the bounds computed from getPreferredSize is returned.

getPreferredSize

public java.awt.Dimension getPreferredSize()
Returns the preferred size needed for the renderer.

Specified by:
getPreferredSize in interface Renderer
Returns:
a non-null Dimension object

render

public void render(java.awt.Graphics2D g)
Calls renderChart(g) and crops the output to the desired bounds. This way you can manually set small maximum and minimum values which automatically gets reflected in the CoordSystem but the ChartRenderer doesn't need to care.

Specified by:
render in interface Renderer
Parameters:
g - the Graphics2D object in which to render

renderChart

public abstract void renderChart(java.awt.Graphics2D g)
Finally renders the chart in the clipped rectangle.


setBounds

public void setBounds(java.awt.Rectangle bounds)
Sets the bounds the layout manager has assigned to this renderer. Those, of course, have to be considered in the rendering process.

Specified by:
setBounds in interface Renderer
Parameters:
bounds - the new bounds for the renderer.

setChartDataModel

public void setChartDataModel(ChartDataModel model)
Sets the ChartDataModel whose DataSets are rendered.

Parameters:
model - the ChartDataModel

getChartDataModel

public ChartDataModel getChartDataModel()
Returns the ChartDataModel whose DataSets are rendered.

Returns:
a ChartDataModel which contains the Chart's data

getCoordSystem

public CoordSystem getCoordSystem()
Returns the current CoordSystem.


setCoordSystem

public void setCoordSystem(CoordSystem cs)
Sets the CoordSystem which contains the AffineTransforms to translate into pixel space.

Parameters:
cs - the new CoordSystem

getTransform

public java.awt.geom.AffineTransform getTransform(int axis)
Returns the currently defined AffineTransform for any y-axis.

Parameters:
axis - the y-axis to be used.

setRowColorModel

public void setRowColorModel(RowColorModel rcm)
Sets a RowColorModel to define the correlation of row titles and colors used for the Legend.

Parameters:
rcm - the RowColorModel

getRowColorModel

public RowColorModel getRowColorModel()
Returns the RowColorModel currently in use.

Returns:
a RowColorModel