com.jrefinery.chart
Class StandardLegend

java.lang.Object
  |
  +--com.jrefinery.chart.Legend
        |
        +--com.jrefinery.chart.StandardLegend
Direct Known Subclasses:
MeterLegend

public class StandardLegend
extends Legend

A chart legend shows the names and visual representations of the series that are plotted in a chart.

Author:
DG

Field Summary
static java.awt.Font DEFAULT_FONT
          Default font.
 
Fields inherited from class com.jrefinery.chart.Legend
EAST, HORIZONTAL, INVERTED, NORTH, SOUTH, WEST
 
Constructor Summary
StandardLegend(JFreeChart chart)
          Constructs a new legend with default settings.
StandardLegend(JFreeChart chart, int outerGap, Spacer innerGap, java.awt.Paint backgroundPaint, java.awt.Stroke outlineStroke, java.awt.Paint outlinePaint, java.awt.Font itemFont, java.awt.Paint itemPaint)
          Constructs a new legend.
 
Method Summary
 java.awt.geom.Rectangle2D draw(java.awt.Graphics2D g2, java.awt.geom.Rectangle2D available)
          Draws the legend on a Java 2D graphics device (such as the screen or a printer).
protected  java.awt.geom.Rectangle2D draw(java.awt.Graphics2D g2, java.awt.geom.Rectangle2D available, boolean horizontal, boolean inverted)
          Draws the legend.
 java.awt.Paint getBackgroundPaint()
          Returns the background color for the legend.
 java.awt.Font getItemFont()
          Returns the series label font.
 java.awt.Paint getItemPaint()
          Returns the series label color.
 java.awt.Paint getKeyBoxOutlinePaint()
          Returns the paint used to outline key boxes.
 java.awt.Stroke getKeyBoxOutlineStroke()
          Returns the stroke used to outline key boxes.
 java.awt.Paint getOutlinePaint()
          Returns the outline color.
 java.awt.Stroke getOutlineStroke()
          Returns the outline pen/brush.
 void setBackgroundPaint(java.awt.Paint paint)
          Sets the background color of the legend.
 void setItemFont(java.awt.Font font)
          Sets the series label font.
 void setItemPaint(java.awt.Paint paint)
          Sets the series label color.
 void setKeyBoxOutlinePaint(java.awt.Paint paint)
          Sets the paint used to outline key boxes.
 void setKeyBoxOutlineStroke(java.awt.Stroke stroke)
          Sets the stroke used to outline key boxes.
 void setOutlinePaint(java.awt.Paint paint)
          Sets the outline color.
 void setOutlineStroke(java.awt.Stroke stroke)
          Sets the outline pen/brush.
 
Methods inherited from class com.jrefinery.chart.Legend
addChangeListener, createInstance, getAnchor, getChart, getOuterGap, getOutlineKeyBoxes, notifyListeners, removeChangeListener, setAnchor, setOutlineKeyBoxes
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

DEFAULT_FONT

public static final java.awt.Font DEFAULT_FONT
Default font.
Constructor Detail

StandardLegend

public StandardLegend(JFreeChart chart)
Constructs a new legend with default settings.
Parameters:
chart - the chart that the legend belongs to.

StandardLegend

public StandardLegend(JFreeChart chart,
                      int outerGap,
                      Spacer innerGap,
                      java.awt.Paint backgroundPaint,
                      java.awt.Stroke outlineStroke,
                      java.awt.Paint outlinePaint,
                      java.awt.Font itemFont,
                      java.awt.Paint itemPaint)
Constructs a new legend.
Parameters:
chart - the chart that the legend belongs to.
outerGap - the gap around the outside of the legend.
innerGap - the gap inside the legend.
backgroundPaint - the background color.
outlineStroke - the pen/brush used to draw the outline.
outlinePaint - the color used to draw the outline.
itemFont - the font used to draw the legend items.
itemPaint - the color used to draw the legend items.
Method Detail

getBackgroundPaint

public java.awt.Paint getBackgroundPaint()
Returns the background color for the legend.
Returns:
the background color.

setBackgroundPaint

public void setBackgroundPaint(java.awt.Paint paint)
Sets the background color of the legend.

Registered listeners are notified that the legend has changed.

Parameters:
paint - the new background color.

getOutlineStroke

public java.awt.Stroke getOutlineStroke()
Returns the outline pen/brush.
Returns:
the outline pen/brush.

setOutlineStroke

public void setOutlineStroke(java.awt.Stroke stroke)
Sets the outline pen/brush.

Registered listeners are notified that the legend has changed.

Parameters:
stroke - the new outline pen/brush.

getOutlinePaint

public java.awt.Paint getOutlinePaint()
Returns the outline color.
Returns:
the outline color.

setOutlinePaint

public void setOutlinePaint(java.awt.Paint paint)
Sets the outline color.

Registered listeners are notified that the legend has changed.

Parameters:
paint - the new outline color.

getItemFont

public java.awt.Font getItemFont()
Returns the series label font.
Returns:
the series label font.

setItemFont

public void setItemFont(java.awt.Font font)
Sets the series label font.

Registered listeners are notified that the legend has changed.

Parameters:
font - the new series label font.

getItemPaint

public java.awt.Paint getItemPaint()
Returns the series label color.
Returns:
the series label color.

setItemPaint

public void setItemPaint(java.awt.Paint paint)
Sets the series label color.

Registered listeners are notified that the legend has changed.

Parameters:
paint - the new series label color.

getKeyBoxOutlineStroke

public java.awt.Stroke getKeyBoxOutlineStroke()
Returns the stroke used to outline key boxes.
Returns:
the stroke.

setKeyBoxOutlineStroke

public void setKeyBoxOutlineStroke(java.awt.Stroke stroke)
Sets the stroke used to outline key boxes.

Registered listeners are notified of the change.

Parameters:
stroke - the stroke.

getKeyBoxOutlinePaint

public java.awt.Paint getKeyBoxOutlinePaint()
Returns the paint used to outline key boxes.
Returns:
the paint.

setKeyBoxOutlinePaint

public void setKeyBoxOutlinePaint(java.awt.Paint paint)
Sets the paint used to outline key boxes.

Registered listeners are notified of the change.

Parameters:
paint - the paint.

draw

public java.awt.geom.Rectangle2D draw(java.awt.Graphics2D g2,
                                      java.awt.geom.Rectangle2D available)
Draws the legend on a Java 2D graphics device (such as the screen or a printer).
Overrides:
draw in class Legend
Parameters:
g2 - the graphics device.
available - the area within which the legend, and afterwards the plot, should be drawn.
Returns:
the area used by the legend.

draw

protected java.awt.geom.Rectangle2D draw(java.awt.Graphics2D g2,
                                         java.awt.geom.Rectangle2D available,
                                         boolean horizontal,
                                         boolean inverted)
Draws the legend.
Parameters:
g2 - the graphics device.
available - the area available for drawing the chart.
horizontal - a flag indicating whether the legend items are laid out horizontally.
inverted - ???
Returns:
the remaining available drawing area.