com.jrefinery.chart
Class Legend

java.lang.Object
  extended by com.jrefinery.chart.Legend
Direct Known Subclasses:
StandardLegend

public abstract class Legend
extends java.lang.Object

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

See Also:
StandardLegend

Field Summary
protected  int _anchor
          The current location anchor of the legend.
protected  JFreeChart chart
          A reference to the chart that the legend belongs to (used for access to the dataset).
static int EAST
          Constant anchor value for legend position EAST.
protected static int HORIZONTAL
          Internal value indicating the bit holding the value of interest in the anchor value.
protected static int INVERTED
          Internal value indicating the bit holding the value of interest in the anchor value.
protected  java.util.List listeners
          Storage for registered change listeners.
static int NORTH
          Constant anchor value for legend position NORTH.
protected  int outerGap
          The amount of blank space around the legend.
static int SOUTH
          Constant anchor value for legend position SOUTH.
static int WEST
          Constant anchor value for legend position WEST.
 
Constructor Summary
Legend(JFreeChart chart, int outerGap)
          Default constructor: returns a new legend.
 
Method Summary
 void addChangeListener(com.jrefinery.chart.event.LegendChangeListener listener)
          Registers an object for notification of changes to the legend.
static Legend createInstance(JFreeChart chart)
          Static factory method that returns a concrete subclass of Legend.
abstract  java.awt.geom.Rectangle2D draw(java.awt.Graphics2D g2, java.awt.geom.Rectangle2D nonTitleArea)
          Draws the legend on a Java 2D graphics device (such as the screen or a printer).
 int getAnchor()
          Returns the current anchor of this legend.
protected  void notifyListeners(com.jrefinery.chart.event.LegendChangeEvent event)
          Notifies all registered listeners that the chart legend has changed in some way.
 void removeChangeListener(com.jrefinery.chart.event.LegendChangeListener listener)
          Deregisters an object for notification of changes to the legend.
 void setAnchor(int anchor)
          Sets the current anchor of this legend.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

WEST

public static final int WEST
Constant anchor value for legend position WEST.

See Also:
Constant Field Values

NORTH

public static final int NORTH
Constant anchor value for legend position NORTH.

See Also:
Constant Field Values

EAST

public static final int EAST
Constant anchor value for legend position EAST.

See Also:
Constant Field Values

SOUTH

public static final int SOUTH
Constant anchor value for legend position SOUTH.

See Also:
Constant Field Values

INVERTED

protected static final int INVERTED
Internal value indicating the bit holding the value of interest in the anchor value.

See Also:
Constant Field Values

HORIZONTAL

protected static final int HORIZONTAL
Internal value indicating the bit holding the value of interest in the anchor value.

See Also:
Constant Field Values

_anchor

protected int _anchor
The current location anchor of the legend.


chart

protected JFreeChart chart
A reference to the chart that the legend belongs to (used for access to the dataset).


outerGap

protected int outerGap
The amount of blank space around the legend.


listeners

protected java.util.List listeners
Storage for registered change listeners.

Constructor Detail

Legend

public Legend(JFreeChart chart,
              int outerGap)
Default constructor: returns a new legend.

Parameters:
chart - The chart that the legend belongs to.
outerGap - The blank space around the legend.
Method Detail

createInstance

public static Legend createInstance(JFreeChart chart)
Static factory method that returns a concrete subclass of Legend.

Parameters:
chart - The chart that the legend belongs to.

draw

public abstract java.awt.geom.Rectangle2D draw(java.awt.Graphics2D g2,
                                               java.awt.geom.Rectangle2D nonTitleArea)
Draws the legend on a Java 2D graphics device (such as the screen or a printer).

Parameters:
g2 - The graphics device.
drawArea - The area within which the legend should be drawn.
Returns:
The area remaining after the legend has drawn itself.

addChangeListener

public void addChangeListener(com.jrefinery.chart.event.LegendChangeListener listener)
Registers an object for notification of changes to the legend.

Parameters:
listener - The object that is being registered.

removeChangeListener

public void removeChangeListener(com.jrefinery.chart.event.LegendChangeListener listener)
Deregisters an object for notification of changes to the legend.

Parameters:
listener - The object that is being deregistered.

notifyListeners

protected void notifyListeners(com.jrefinery.chart.event.LegendChangeEvent event)
Notifies all registered listeners that the chart legend has changed in some way.

Parameters:
event - An object that contains information about the change to the legend.

getAnchor

public int getAnchor()
Returns the current anchor of this legend.

The default anchor for this legend is SOUTH.

Returns:
current anchor value

setAnchor

public void setAnchor(int anchor)
Sets the current anchor of this legend.

The anchor can be one of: NORTH, SOUTH, EAST, WEST. If a valid anchor value is provided, the current anchor is set and an update event is triggered. Otherwise, no change is made.

Parameters:
anchor - new anchor value


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.