|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object | +--org.jfree.chart.AbstractTitle
The base class for all chart titles.
A chart can have multiple titles, appearing at the top, bottom, left or right of the chart (defined by the constants TOP, BOTTOM, LEFT and RIGHT --- we also use the constants NORTH, SOUTH, EAST and WEST to remain consistent with java.awt.BorderLayout, as most developers will be familiar with that class).
Concrete implementations of this class will render text, images, and hence do the actual work of drawing titles.
Field Summary | |
static int |
BOTTOM
Useful constant for the title position (also used for vertical alignment). |
static int |
CENTER
Useful constant for the title alignment (horizontal or vertical). |
static int |
DEFAULT_HORIZONTAL_ALIGNMENT
The default horizontal alignment. |
static int |
DEFAULT_POSITION
The default title position. |
static Spacer |
DEFAULT_SPACER
Default title spacer. |
static int |
DEFAULT_VERTICAL_ALIGNMENT
The default vertical alignment. |
static int |
EAST
Useful constant for the title position. |
static int |
LEFT
Useful constant for the title position (also used for horizontal alignment). |
static int |
MIDDLE
Useful constant for the title alignment (horizontal or vertical). |
static int |
NORTH
Useful constant for the title position. |
static int |
RIGHT
Useful constant for the title position (also used for horizontal alignment). |
static int |
SOUTH
Useful constant for the title position. |
static int |
TOP
Useful constant for the title position (also used for vertical alignment). |
static int |
WEST
Useful constant for the title position. |
Constructor Summary | |
protected |
AbstractTitle()
Creates a new title, using default attributes where necessary. |
protected |
AbstractTitle(int position,
int horizontalAlignment,
int verticalAlignment)
Creates a new title, using default attributes where necessary. |
protected |
AbstractTitle(int position,
int horizontalAlignment,
int verticalAlignment,
Spacer spacer)
Constructs a new AbstractTitle. |
Method Summary | |
void |
addChangeListener(TitleChangeListener listener)
Registers an object for notification of changes to the title. |
java.lang.Object |
clone()
Returns a clone of the title. |
abstract void |
draw(java.awt.Graphics2D g2,
java.awt.geom.Rectangle2D titleArea)
Draws the title 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 title. |
int |
getHorizontalAlignment()
Returns the horizontal alignment of the title. |
boolean |
getNotify()
Returns the flag that indicates whether or not the notification mechanism is enabled. |
int |
getPosition()
Returns the relative position of the title---represented by one of four integer constants defined in this class: TOP, BOTTOM, RIGHT or LEFT (or the equivalent NORTH, SOUTH, EAST and WEST). |
abstract double |
getPreferredHeight(java.awt.Graphics2D g2)
Returns the preferred height of the title. |
abstract double |
getPreferredWidth(java.awt.Graphics2D g2)
Returns the preferred width of the title. |
Spacer |
getSpacer()
Returns the spacer (determines the blank space around the edges) for this title. |
int |
getVerticalAlignment()
Returns the vertical alignment of the title. |
protected static boolean |
isValidHorizontalAlignment(int code)
Utility method for checking a horizontal alignment code. |
abstract boolean |
isValidPosition(int position)
Returns true if the title can assume the specified location, and false otherwise. |
protected static boolean |
isValidVerticalAlignment(int code)
Utility method for checking a vertical alignment code. |
protected void |
notifyListeners(TitleChangeEvent event)
Notifies all registered listeners that the chart title has changed in some way. |
void |
removeChangeListener(TitleChangeListener listener)
Unregisters an object for notification of changes to the chart title. |
void |
setHorizontalAlignment(int alignment)
Sets the horizontal alignment for the title, and notifies any registered listeners of the change. |
void |
setNotify(boolean flag)
Sets the flag that indicates whether or not the notification mechanism is enabled. |
void |
setPosition(int position)
Sets the position for the title. |
void |
setSpacer(Spacer spacer)
Sets the spacer for the title, and notifies registered listeners of the change. |
void |
setVerticalAlignment(int alignment)
Sets the vertical alignment for the title, and notifies any registered listeners of the change. |
Methods inherited from class java.lang.Object |
finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
public static final int TOP
public static final int BOTTOM
public static final int RIGHT
public static final int LEFT
public static final int NORTH
public static final int SOUTH
public static final int EAST
public static final int WEST
public static final int CENTER
public static final int MIDDLE
public static final int DEFAULT_POSITION
public static final int DEFAULT_HORIZONTAL_ALIGNMENT
public static final int DEFAULT_VERTICAL_ALIGNMENT
public static final Spacer DEFAULT_SPACER
Constructor Detail |
protected AbstractTitle()
protected AbstractTitle(int position, int horizontalAlignment, int verticalAlignment)
position
- the relative position of the title (TOP, BOTTOM, RIGHT and LEFT).horizontalAlignment
- the horizontal alignment of the title (LEFT, CENTER or RIGHT).verticalAlignment
- the vertical alignment of the title (TOP, MIDDLE or BOTTOM).
java.lang.IllegalArgumentException
- if an invalid location or alignment value is passed.protected AbstractTitle(int position, int horizontalAlignment, int verticalAlignment, Spacer spacer)
This class defines constants for the valid position and alignment values --- an IllegalArgumentException will be thrown if invalid values are passed to this constructor.
position
- the relative position of the title (TOP, BOTTOM, RIGHT and LEFT).horizontalAlignment
- the horizontal alignment of the title (LEFT, CENTER or RIGHT).verticalAlignment
- the vertical alignment of the title (TOP, MIDDLE or BOTTOM).spacer
- the amount of space to leave around the outside of the title.
java.lang.IllegalArgumentException
- if an invalid location or alignment value is passed.Method Detail |
public int getPosition()
public void setPosition(int position)
position
- the relative position of the title (use one of the constants TOP, BOTTOM,
RIGHT and LEFT, or the equivalent NORTH, SOUTH, EAST and WEST).public int getHorizontalAlignment()
public void setHorizontalAlignment(int alignment)
alignment
- the new horizontal alignment (LEFT, CENTER or RIGHT).public int getVerticalAlignment()
public void setVerticalAlignment(int alignment)
alignment
- the new vertical alignment (TOP, MIDDLE or BOTTOM).public Spacer getSpacer()
public void setSpacer(Spacer spacer)
spacer
- the new spacer.public boolean getNotify()
public void setNotify(boolean flag)
flag
- the new value of the flag.public abstract boolean isValidPosition(int position)
position
- the position.
true
if the title can assume the specified position.public abstract double getPreferredWidth(java.awt.Graphics2D g2)
g2
- the graphics device.
public abstract double getPreferredHeight(java.awt.Graphics2D g2)
g2
- the graphics device.
public abstract void draw(java.awt.Graphics2D g2, java.awt.geom.Rectangle2D titleArea)
g2
- the graphics device.titleArea
- the area for drawing the title.public java.lang.Object clone()
One situation when this is useful is when editing the title properties - you can edit a clone, and then it is easier to cancel the changes if necessary.
clone
in class java.lang.Object
public void addChangeListener(TitleChangeListener listener)
listener
- the object that is being registered.public void removeChangeListener(TitleChangeListener listener)
listener
- the object that is being unregistered.protected void notifyListeners(TitleChangeEvent event)
event
- an object that contains information about the change to the title.protected static boolean isValidHorizontalAlignment(int code)
code
- the alignment code.
true
if alignment is LEFT|MIDDLE|RIGHT
.protected static boolean isValidVerticalAlignment(int code)
code
- the alignment code.
true
, if alignment is TOP|MIDDLE|BOTTOM
.public boolean equals(java.lang.Object obj)
equals
in class java.lang.Object
obj
- the object.
true
or false
.
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |