org.jfree.chart
Class StandardLegend

java.lang.Object
  extended byorg.jfree.chart.Legend
      extended byorg.jfree.chart.StandardLegend
All Implemented Interfaces:
java.lang.Cloneable, 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.

See Also:
Serialized Form

Field Summary
static java.awt.Paint DEFAULT_BACKGROUND_PAINT
          The default background paint.
static java.awt.Font DEFAULT_ITEM_FONT
          The default item font.
static RectangleInsets DEFAULT_MARGIN
          The default margin (space around the outside of the legend).
static java.awt.Paint DEFAULT_OUTLINE_PAINT
          The default outline paint.
static java.awt.Stroke DEFAULT_OUTLINE_STROKE
          The default outline stroke.
static RectangleInsets DEFAULT_PADDING
          The default inner gap.
static java.awt.Font DEFAULT_TITLE_FONT
          The default title font.
static double NO_PREFERRED_WIDTH
          Used with setPreferredWidth(double) to indicate that no preferred width is desired and defaults are to be used.
 
Fields inherited from class org.jfree.chart.Legend
EAST, EAST_NORTHEAST, EAST_SOUTHEAST, HORIZONTAL, INVERTED, NORTH, NORTH_NORTHEAST, NORTH_NORTHWEST, SOUTH, SOUTH_SOUTHEAST, SOUTH_SOUTHWEST, WEST, WEST_NORTHWEST, WEST_SOUTHWEST
 
Constructor Summary
StandardLegend()
          Constructs a new legend with default settings.
 
Method Summary
protected  java.awt.geom.Rectangle2D draw(java.awt.Graphics2D g2, java.awt.geom.Rectangle2D available, boolean horizontal, boolean inverted, ChartRenderingInfo info)
          Draws the legend.
 java.awt.geom.Rectangle2D draw(java.awt.Graphics2D g2, java.awt.geom.Rectangle2D available, ChartRenderingInfo info)
          Draws the legend on a Java 2D graphics device (such as the screen or a printer).
 boolean equals(java.lang.Object obj)
          Tests an object for equality with this legend.
 java.awt.Paint getBackgroundPaint()
          Returns the background paint for the legend.
 int getBoundingBoxArcHeight()
          Returns the height of the arc used to round off the corners of the bounding box.
 int getBoundingBoxArcWidth()
          Returns the width of the arc used to round off the corners of the bounding box.
 java.awt.Font getItemFont()
          Returns the series label font.
 java.awt.Paint getItemPaint()
          Returns the series label paint.
 RectangleInsets getMargin()
          Returns the margin for the legend.
 java.awt.Paint getOutlinePaint()
          Returns the outline paint.
 java.awt.Stroke getOutlineStroke()
          Returns the outline stroke.
 RectangleInsets getPadding()
          Returns the padding for the legend.
 double getPreferredWidth()
          Returns the preferred width of the legend bounding box if such width has been defined; otherwise returns NO_PREFERRED_WIDTH.
 LegendRenderingOrder getRenderingOrder()
          Returns the legend rendering order.
 double getShapeScaleX()
          Returns the x scale factor for shapes displayed in the legend.
 double getShapeScaleY()
          Returns the y scale factor for shapes displayed in the legend.
 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 paint for the legend and sends a LegendChangeEvent to all registered listeners.
 void setBoundingBoxArcHeight(int arcHeight)
          Sets the height of the arc used to round off the corners of the bounding box.
 void setBoundingBoxArcWidth(int arcWidth)
          Sets the width of the arc used to round off the corners of the bounding box.
 void setItemFont(java.awt.Font font)
          Sets the series label font and sends a LegendChangeEvent to all registered listeners.
 void setItemPaint(java.awt.Paint paint)
          Sets the series label paint and sends a LegendChangeEvent to all registered listeners.
 void setMargin(RectangleInsets margin)
          Sets the margin for the legend and sends a LegendChangeEvent to all registered listeners.
 void setOutlinePaint(java.awt.Paint paint)
          Sets the outline paint and sends a LegendChangeEvent to all registered listeners.
 void setOutlineStroke(java.awt.Stroke stroke)
          Sets the outline stroke and sends a LegendChangeEvent to all registered listeners.
 void setPadding(RectangleInsets padding)
          Sets the padding for the legend and sends a LegendChangeEvent to all registered listeners.
 void setPreferredWidth(double width)
          Sets the preferred width of the legend bounding box.
 void setRenderingOrder(LegendRenderingOrder order)
          Sets the legend rendering order and sends a LegendChangeEvent to all registered listeners.
 void setShapeScaleX(double factor)
          Sets the x scale factor for shapes displayed in the legend and sends a LegendChangeEvent to all registered listeners.
 void setShapeScaleY(double factor)
          Sets the y scale factor for shapes displayed in the legend and sends a LegendChangeEvent to all registered listeners.
 void setTitle(java.lang.String title)
          Sets the title of the legend and sends a LegendChangeEvent to all registered listeners.
 void setTitleFont(java.awt.Font font)
          Sets the title font and sends a LegendChangeEvent to all registered listeners.
 
Methods inherited from class org.jfree.chart.Legend
addChangeListener, clone, createInstance, getAnchor, getChart, isAnchoredToBottom, isAnchoredToCenter, isAnchoredToLeft, isAnchoredToMiddle, isAnchoredToRight, isAnchoredToTop, notifyListeners, registerChart, removeChangeListener, setAnchor
 
Methods inherited from class java.lang.Object
finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

DEFAULT_MARGIN

public static final RectangleInsets DEFAULT_MARGIN
The default margin (space around the outside of the legend).


DEFAULT_PADDING

public static final RectangleInsets DEFAULT_PADDING
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.


NO_PREFERRED_WIDTH

public static final double NO_PREFERRED_WIDTH
Used with setPreferredWidth(double) to indicate that no preferred width is desired and defaults are to be used.

See Also:
Constant Field Values
Constructor Detail

StandardLegend

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

Method Detail

getMargin

public RectangleInsets getMargin()
Returns the margin for the legend. This is the amount of blank space around the outside of the legend.

Returns:
The gap (never null).

setMargin

public void setMargin(RectangleInsets margin)
Sets the margin for the legend and sends a LegendChangeEvent to all registered listeners.

Parameters:
margin - the margin (null not permitted).

getPadding

public RectangleInsets getPadding()
Returns the padding for the legend. This is the amount of blank space around the inside of the legend.

Returns:
The gap (never null).

setPadding

public void setPadding(RectangleInsets padding)
Sets the padding for the legend and sends a LegendChangeEvent to all registered listeners.

Parameters:
padding - the padding (null not permitted).

getBackgroundPaint

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

Returns:
The background paint (never null).

setBackgroundPaint

public void setBackgroundPaint(java.awt.Paint paint)
Sets the background paint for the legend and sends a LegendChangeEvent to all registered listeners.

Parameters:
paint - the paint (null not permitted).

getOutlineStroke

public java.awt.Stroke getOutlineStroke()
Returns the outline stroke.

Returns:
The outline stroke (never null).

setOutlineStroke

public void setOutlineStroke(java.awt.Stroke stroke)
Sets the outline stroke and sends a LegendChangeEvent to all registered listeners.

Parameters:
stroke - the stroke (null not permitted).

getOutlinePaint

public java.awt.Paint getOutlinePaint()
Returns the outline paint.

Returns:
The outline paint (never null).

setOutlinePaint

public void setOutlinePaint(java.awt.Paint paint)
Sets the outline paint and sends a LegendChangeEvent to all registered listeners.

Parameters:
paint - the paint (null not permitted).

getTitle

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

Returns:
The title (possibly null).

setTitle

public void setTitle(java.lang.String title)
Sets the title of the legend and sends a LegendChangeEvent to all registered listeners.

Parameters:
title - the title (null permitted).

getTitleFont

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

Returns:
The font (never null).

setTitleFont

public void setTitleFont(java.awt.Font font)
Sets the title font and sends a LegendChangeEvent to all registered listeners.

Parameters:
font - the font (null not permitted).

getItemFont

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

Returns:
The font (never null).

setItemFont

public void setItemFont(java.awt.Font font)
Sets the series label font and sends a LegendChangeEvent to all registered listeners.

Parameters:
font - the font (null not permitted).

getItemPaint

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

Returns:
The paint (never null).

setItemPaint

public void setItemPaint(java.awt.Paint paint)
Sets the series label paint and sends a LegendChangeEvent to all registered listeners.

Parameters:
paint - the paint (null not permitted).

getShapeScaleX

public double getShapeScaleX()
Returns the x scale factor for shapes displayed in the legend.

Returns:
the x scale factor.

setShapeScaleX

public void setShapeScaleX(double factor)
Sets the x scale factor for shapes displayed in the legend and sends a LegendChangeEvent to all registered listeners.

Parameters:
factor - the factor.

getShapeScaleY

public double getShapeScaleY()
Returns the y scale factor for shapes displayed in the legend.

Returns:
the y scale factor.

setShapeScaleY

public void setShapeScaleY(double factor)
Sets the y scale factor for shapes displayed in the legend and sends a LegendChangeEvent to all registered listeners.

Parameters:
factor - the factor.

getRenderingOrder

public LegendRenderingOrder getRenderingOrder()
Returns the legend rendering order.

Returns:
The order (never null).

setRenderingOrder

public void setRenderingOrder(LegendRenderingOrder order)
Sets the legend rendering order and sends a LegendChangeEvent to all registered listeners.

Parameters:
order - the order (null not permitted).

getBoundingBoxArcWidth

public int getBoundingBoxArcWidth()
Returns the width of the arc used to round off the corners of the bounding box.

Returns:
the width of the arc used to round off the corners of the bounding box.

setBoundingBoxArcWidth

public void setBoundingBoxArcWidth(int arcWidth)
Sets the width of the arc used to round off the corners of the bounding box. A LegendChangeEvent is sent to all registered listeners.

Parameters:
arcWidth - the new arc width.

getBoundingBoxArcHeight

public int getBoundingBoxArcHeight()
Returns the height of the arc used to round off the corners of the bounding box.

Returns:
the height of the arc used to round off the corners of the bounding box.

setBoundingBoxArcHeight

public void setBoundingBoxArcHeight(int arcHeight)
Sets the height of the arc used to round off the corners of the bounding box. A LegendChangeEvent is sent to all registered listeners.

Parameters:
arcHeight - the new arc height.

getPreferredWidth

public double getPreferredWidth()
Returns the preferred width of the legend bounding box if such width has been defined; otherwise returns NO_PREFERRED_WIDTH.

Returns:
the preferred width of the legend bounding box if such width has been defined; otherwise returns NO_PREFERRED_WIDTH.

setPreferredWidth

public void setPreferredWidth(double width)
Sets the preferred width of the legend bounding box. If a preferred width is set, the legend text is word-wrapped in an attempt to fulfill the preferred width. If the preferred width cannot be fulfilled, the legend would be wider to the extent necessary.

The preferred width takes effect only when the legend's anchor is set to one of the three EAST anchors or to one of the three WEST anchors.

A LegendChangeEvent is sent to all registered listeners.

Parameters:
width - the new width.

draw

public java.awt.geom.Rectangle2D draw(java.awt.Graphics2D g2,
                                      java.awt.geom.Rectangle2D available,
                                      ChartRenderingInfo info)
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.
info - collects rendering info (optional).
Returns:
The area NOT used by the legend.

draw

protected java.awt.geom.Rectangle2D draw(java.awt.Graphics2D g2,
                                         java.awt.geom.Rectangle2D available,
                                         boolean horizontal,
                                         boolean inverted,
                                         ChartRenderingInfo info)
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 - ???
info - collects rendering info (optional).
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 (null permitted).
Returns:
true or false.