com.jrefinery.chart
Class StandardLegend

java.lang.Object
  extended by com.jrefinery.chart.Legend
      extended by 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.


Field Summary
protected  java.awt.Paint backgroundPaint
          The color used to draw the background of the legend.
static java.awt.Font DEFAULT_FONT
          Default font.
protected  Spacer innerGap
          The blank space inside the legend box.
protected  java.awt.Font itemFont
          The font used to display the legend item names.
protected  java.awt.Paint itemPaint
          The color used to display the legend item names.
protected  java.awt.Paint outlinePaint
          The color used to draw the outline of the legend.
protected  java.awt.Stroke outlineStroke
          The pen/brush used to draw the outline of the legend.
 
Fields inherited from class com.jrefinery.chart.Legend
_anchor, chart, EAST, HORIZONTAL, INVERTED, listeners, NORTH, outerGap, 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 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 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, notifyListeners, removeChangeListener, setAnchor
 
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.


outlineStroke

protected java.awt.Stroke outlineStroke
The pen/brush used to draw the outline of the legend.


outlinePaint

protected java.awt.Paint outlinePaint
The color used to draw the outline of the legend.


backgroundPaint

protected java.awt.Paint backgroundPaint
The color used to draw the background of the legend.


innerGap

protected Spacer innerGap
The blank space inside the legend box.


itemFont

protected java.awt.Font itemFont
The font used to display the legend item names.


itemPaint

protected java.awt.Paint itemPaint
The color used to display the legend item names.

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.
seriesFont - The font used to draw the legend items.
seriesPaint - 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 for the legend.

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:
stroke - 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.

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:
graphics - 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:
???


Copyright © 2003 MBARI.

The Monterey Bay Aquarium Research Institute (MBARI) provides this documentation and code "as is", with no warranty, express or implied, of its quality or consistency. It is provided without support and without obligation on the part of MBARI to assist in its use, correction, modification, or enhancement.