com.approximatrix.charting.render
Class AbstractRenderer

java.lang.Object
  extended by com.approximatrix.charting.render.AbstractRenderer
All Implemented Interfaces:
Renderer
Direct Known Subclasses:
AbstractChart, CoordSystem, Legend, Title

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

The AbstractRenderer provides default implementations for the set and get methods of every Renderer. Especially it provides a default mechanism for scaling Renderer instances whose actual bounds are smaller than their preferred size. As a consequence, every Renderer instance only needs to implement paintDefault() which has to render the object from coordinates 0,0 onwards using the preferred size.

Version:
1.0
Author:
mueller

Field Summary
(package private)  java.awt.Rectangle bounds
           
 
Constructor Summary
AbstractRenderer()
          Creates new AbstractRenderer
 
Method Summary
 java.awt.Rectangle getBounds()
          Gets the bounds for this renderer.
abstract  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)
          Renders the Object in the Graphics object.
 void setBounds(java.awt.Rectangle bounds)
          Sets the bounds the layout manager has assigned to this renderer.
 
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

bounds

java.awt.Rectangle bounds
Constructor Detail

AbstractRenderer

public AbstractRenderer()
Creates new AbstractRenderer

Method Detail

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.

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.

render

public void render(java.awt.Graphics2D g)
Renders the Object in the Graphics object. Creates a BufferedImage and the corresponding Graphics2D object to paint in. The Image is created using the preferred size. Afterwards paintDefault is called to perform a standard painting in the Graphics object. If the bounds and the preferred size don't match the image is scaled afterwards.

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

paintDefault

public abstract 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.

Parameters:
g - the Graphics2D object to paint in.