org.jfree.chart
Class StandardLegend

java.lang.Object
  |
  +--org.jfree.chart.Legend
        |
        +--org.jfree.chart.StandardLegend
All Implemented Interfaces:
java.io.Serializable
Direct Known Subclasses:
MeterLegend

public class StandardLegend
extends Legend
implements java.io.Serializable

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

Author:
David Gilbert
See Also:
Serialized Form

Field Summary
static java.awt.Paint DEFAULT_BACKGROUND_PAINT
          The default background paint.
static Spacer DEFAULT_INNER_GAP
          The default inner gap.
static java.awt.Font DEFAULT_ITEM_FONT
          The default item font.
static Spacer DEFAULT_OUTER_GAP
          The default outer gap.
static java.awt.Paint DEFAULT_OUTLINE_PAINT
          The default outline paint.
static java.awt.Stroke DEFAULT_OUTLINE_STROKE
          The default outline stroke.
static java.awt.Font DEFAULT_TITLE_FONT
          The default title font.
 
Fields inherited from class org.jfree.chart.Legend
EAST, HORIZONTAL, INVERTED, NORTH, SOUTH, WEST
 
Constructor Summary
StandardLegend(JFreeChart chart)
          Constructs a new legend with default settings.
 
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.
 boolean equals(java.lang.Object obj)
          Tests an object for equality with this 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.
 Spacer getOuterGap()
          Returns the outer gap for the legend.
 java.awt.Paint getOutlinePaint()
          Returns the outline color.
 boolean getOutlineShapes()
          Returns the flag that indicates whether or not outlines are drawn around shapes.
 java.awt.Stroke getOutlineStroke()
          Returns the outline pen/brush.
 java.awt.Paint getShapeOutlinePaint()
          Returns the paint used to outline shapes.
 java.awt.Stroke getShapeOutlineStroke()
          Returns the stroke used to outline shapes.
 java.lang.String getTitle()
          Gets the title for the legend.
 java.awt.Font getTitleFont()
          Returns the title font.
 void setBackgroundPaint(java.awt.Paint paint)
          Sets the background color of the legend.
 void setDisplaySeriesShapes(boolean flag)
          Sets a flag that controls whether or not the legend displays the series shapes.
 void setItemFont(java.awt.Font font)
          Sets the series label font.
 void setItemPaint(java.awt.Paint paint)
          Sets the series label color.
 void setOuterGap(Spacer outerGap)
          Sets the outer gap for the legend.
 void setOutlinePaint(java.awt.Paint paint)
          Sets the outline color.
 void setOutlineShapes(boolean flag)
          Sets the flag that controls whether or not outlines are drawn around shapes.
 void setOutlineStroke(java.awt.Stroke stroke)
          Sets the outline pen/brush.
 void setShapeOutlinePaint(java.awt.Paint paint)
          Sets the paint used to outline shapes.
 void setShapeOutlineStroke(java.awt.Stroke stroke)
          Sets the stroke used to outline shapes.
 void setTitle(java.lang.String title)
          Sets the title of the legend.
 void setTitleFont(java.awt.Font font)
          Sets the title font.
 
Methods inherited from class org.jfree.chart.Legend
addChangeListener, createInstance, getAnchor, getChart, notifyListeners, removeChangeListener, setAnchor
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

DEFAULT_OUTER_GAP

public static final Spacer DEFAULT_OUTER_GAP
The default outer gap.


DEFAULT_INNER_GAP

public static final Spacer DEFAULT_INNER_GAP
The default inner gap.


DEFAULT_OUTLINE_STROKE

public static final java.awt.Stroke DEFAULT_OUTLINE_STROKE
The default outline stroke.


DEFAULT_OUTLINE_PAINT

public static final java.awt.Paint DEFAULT_OUTLINE_PAINT
The default outline paint.


DEFAULT_BACKGROUND_PAINT

public static final java.awt.Paint DEFAULT_BACKGROUND_PAINT
The default background paint.


DEFAULT_TITLE_FONT

public static final java.awt.Font DEFAULT_TITLE_FONT
The default title font.


DEFAULT_ITEM_FONT

public static final java.awt.Font DEFAULT_ITEM_FONT
The default item font.

Constructor Detail

StandardLegend

public StandardLegend(JFreeChart chart)
Constructs a new legend with default settings.

Parameters:
chart - the chart that the legend belongs to.
Method Detail

getOuterGap

public Spacer getOuterGap()
Returns the outer gap for the legend.

This is the amount of blank space around the outside of the legend.

Returns:
the gap.

setOuterGap

public void setOuterGap(Spacer outerGap)
Sets the outer gap for the legend. A LegendChangeEvent is sent to all registered listeners.

Parameters:
outerGap - the outer gap.

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.

getTitle

public java.lang.String getTitle()
Gets the title for the legend.

Returns:
The title of the legend; which may be null.

setTitle

public void setTitle(java.lang.String title)
Sets the title of the legend.

Parameters:
title - The title to use. Pass null if you don't want a title.

getTitleFont

public java.awt.Font getTitleFont()
Returns the title font.

Returns:
The font.

setTitleFont

public void setTitleFont(java.awt.Font font)
Sets the title font.

Parameters:
font - the new font.

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.

getOutlineShapes

public boolean getOutlineShapes()
Returns the flag that indicates whether or not outlines are drawn around shapes.

Returns:
the flag.

setOutlineShapes

public void setOutlineShapes(boolean flag)
Sets the flag that controls whether or not outlines are drawn around shapes.

Parameters:
flag - The flag.

getShapeOutlineStroke

public java.awt.Stroke getShapeOutlineStroke()
Returns the stroke used to outline shapes.

Returns:
the stroke.

setShapeOutlineStroke

public void setShapeOutlineStroke(java.awt.Stroke stroke)
Sets the stroke used to outline shapes.

Registered listeners are notified of the change.

Parameters:
stroke - the stroke.

getShapeOutlinePaint

public java.awt.Paint getShapeOutlinePaint()
Returns the paint used to outline shapes.

Returns:
the paint.

setShapeOutlinePaint

public void setShapeOutlinePaint(java.awt.Paint paint)
Sets the paint used to outline shapes.

Registered listeners are notified of the change.

Parameters:
paint - the paint.

setDisplaySeriesShapes

public void setDisplaySeriesShapes(boolean flag)
Sets a flag that controls whether or not the legend displays the series shapes.

Parameters:
flag - the new value of the flag.

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).

Specified by:
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.

equals

public boolean equals(java.lang.Object obj)
Tests an object for equality with this legend.

Overrides:
equals in class Legend
Parameters:
obj - the object.
Returns:
true or false.