Package org.jfree.chart
Class Legend
java.lang.Object
org.jfree.chart.Legend
- All Implemented Interfaces:
Serializable,Cloneable
- Direct Known Subclasses:
StandardLegend
public abstract class Legend extends Object implements Serializable, Cloneable
A chart legend shows the names and visual representations of the series that
are plotted in a chart.
- See Also:
StandardLegend, Serialized Form
-
Field Summary
Fields Modifier and Type Field Description static intEASTConstant anchor value for legend position EAST.static intEAST_NORTHEASTConstant anchor value for legend position EAST_NORTHEAST.static intEAST_SOUTHEASTConstant anchor value for legend position EAST_SOUTHEAST.static intNORTHConstant anchor value for legend position NORTH.static intNORTH_NORTHEASTConstant anchor value for legend position NORTH_NORTHEAST.static intNORTH_NORTHWESTConstant anchor value for legend position NORTH_NORTHWEST.static intSOUTHConstant anchor value for legend position SOUTH.static intSOUTH_SOUTHEASTConstant anchor value for legend position SOUTH_SOUTHEAST.static intSOUTH_SOUTHWESTConstant anchor value for legend position SOUTH_SOUTHWEST.static intWESTConstant anchor value for legend position WEST.static intWEST_NORTHWESTConstant anchor value for legend position WEST_NORTHWEST.static intWEST_SOUTHWESTConstant anchor value for legend position WEST_SOUTHWEST. -
Constructor Summary
Constructors Constructor Description Legend()Default constructor. -
Method Summary
Modifier and Type Method Description voidaddChangeListener(LegendChangeListener listener)Registers an object for notification of changes to the legend.static LegendcreateInstance(JFreeChart chart)Static factory method that returns a concrete subclass of Legend.abstract Rectangle2Ddraw(Graphics2D g2, Rectangle2D available, ChartRenderingInfo info)Draws the legend on a Java 2D graphics device (such as the screen or a printer).booleanequals(Object obj)Tests this legend for equality with another object.intgetAnchor()Returns the current anchor of this legend.JFreeChartgetChart()Returns the chart that this legend belongs to.voidremoveChangeListener(LegendChangeListener listener)Deregisters an object for notification of changes to the legend.voidsetAnchor(int anchor)Sets the current anchor of this legend.
-
Field Details
-
WEST
public static final int WESTConstant anchor value for legend position WEST.- See Also:
- Constant Field Values
-
WEST_NORTHWEST
public static final int WEST_NORTHWESTConstant anchor value for legend position WEST_NORTHWEST.- See Also:
- Constant Field Values
-
WEST_SOUTHWEST
public static final int WEST_SOUTHWESTConstant anchor value for legend position WEST_SOUTHWEST.- See Also:
- Constant Field Values
-
NORTH
public static final int NORTHConstant anchor value for legend position NORTH.- See Also:
- Constant Field Values
-
NORTH_NORTHWEST
public static final int NORTH_NORTHWESTConstant anchor value for legend position NORTH_NORTHWEST.- See Also:
- Constant Field Values
-
NORTH_NORTHEAST
public static final int NORTH_NORTHEASTConstant anchor value for legend position NORTH_NORTHEAST.- See Also:
- Constant Field Values
-
EAST
public static final int EASTConstant anchor value for legend position EAST.- See Also:
- Constant Field Values
-
EAST_NORTHEAST
public static final int EAST_NORTHEASTConstant anchor value for legend position EAST_NORTHEAST.- See Also:
- Constant Field Values
-
EAST_SOUTHEAST
public static final int EAST_SOUTHEASTConstant anchor value for legend position EAST_SOUTHEAST.- See Also:
- Constant Field Values
-
SOUTH
public static final int SOUTHConstant anchor value for legend position SOUTH.- See Also:
- Constant Field Values
-
SOUTH_SOUTHWEST
public static final int SOUTH_SOUTHWESTConstant anchor value for legend position SOUTH_SOUTHWEST.- See Also:
- Constant Field Values
-
SOUTH_SOUTHEAST
public static final int SOUTH_SOUTHEASTConstant anchor value for legend position SOUTH_SOUTHEAST.- See Also:
- Constant Field Values
-
-
Constructor Details
-
Legend
public Legend()Default constructor.
-
-
Method Details
-
createInstance
Static factory method that returns a concrete subclass of Legend.- Parameters:
chart- the chart that the legend belongs to.- Returns:
- a StandardLegend.
-
getChart
Returns the chart that this legend belongs to.- Returns:
- the chart.
-
draw
Draws the legend on a Java 2D graphics device (such as the screen or a printer).- Parameters:
g2- the graphics device.available- the area within which the legend (and plot) should be drawn.info- a carrier for returning information about the entities in the legend.- Returns:
- the area remaining after the legend has drawn itself.
-
addChangeListener
Registers an object for notification of changes to the legend.- Parameters:
listener- the object that is being registered.
-
removeChangeListener
Deregisters an object for notification of changes to the legend.- Parameters:
listener- the object that is being deregistered.
-
getAnchor
public int getAnchor()Returns the current anchor of this legend.The default anchor for this legend is
SOUTH.- Returns:
- the current anchor.
-
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- the new anchor value.
-
equals
Tests this legend for equality with another object.
-