com.approximatrix.charting
Class Legend

java.lang.Object
  extended by com.approximatrix.charting.render.AbstractRenderer
      extended by com.approximatrix.charting.Legend
All Implemented Interfaces:
Renderer

public class Legend
extends AbstractRenderer

This class implements a Chart's Legend. The Strings and the colors can be set manually or eventually through some kind of data model.


Field Summary
protected  int color_text_spacing
           
protected  java.awt.Rectangle colorbox
           
protected  java.awt.Font font
           
protected  int inner_margin
           
protected  RowColorModel rcm
           
 
Constructor Summary
Legend()
          Creates a default Legend.
Legend(RowColorModel rcm)
          Creates a Legend with the given Strings and Colors.
 
Method Summary
 java.awt.Rectangle getColorBox()
          Returns the size of the color boxes.
 java.awt.Font getFont()
          Returns this Legend's Font.
 java.awt.Dimension getPreferredSize()
          Returns the preferred size needed for the renderer.
 RowColorModel getRowColorModel()
          Returns the RowColorModel of the DataModel.
 void paintDefault(java.awt.Graphics2D g)
          This method is called by the paint method to do the actual painting.
 void setColorBox(java.awt.Rectangle r)
          Sets the size of the color boxes.
 void setFont(java.awt.Font f)
          Sets the Font that is used to render the Legend.
 void setRowColorModel(RowColorModel rcm)
          Defines the RowColorModel of the DataModel.
 
Methods inherited from class com.approximatrix.charting.render.AbstractRenderer
getBounds, getDirectRender, render, setBounds, setDirectRender
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

inner_margin

protected int inner_margin

color_text_spacing

protected int color_text_spacing

font

protected java.awt.Font font

colorbox

protected java.awt.Rectangle colorbox

rcm

protected RowColorModel rcm
Constructor Detail

Legend

public Legend()
Creates a default Legend.


Legend

public Legend(RowColorModel rcm)
Creates a Legend with the given Strings and Colors.

Parameters:
rcm - the RowColorModel containing the row titles and their colors.
Method Detail

setRowColorModel

public void setRowColorModel(RowColorModel rcm)
Defines the RowColorModel of the DataModel.

Parameters:
rcm - the RowColorModel

getRowColorModel

public RowColorModel getRowColorModel()
Returns the RowColorModel of the DataModel.

Returns:
the RowColorModel

setColorBox

public void setColorBox(java.awt.Rectangle r)
Sets the size of the color boxes.

Parameters:
r - the Rectangle defining the colored box rendered left to every Legend entry.

getColorBox

public java.awt.Rectangle getColorBox()
Returns the size of the color boxes.

Returns:
the Rectangle defining the colored box left to every Legend entry

setFont

public void setFont(java.awt.Font f)
Sets the Font that is used to render the Legend.

Parameters:
f - the font object

getFont

public java.awt.Font getFont()
Returns this Legend's Font.

Returns:
the font currently in use

getPreferredSize

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

Returns:
a non-null Dimension object

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