- java.lang.Object
-
- org.jfree.chart.block.AbstractBlock
-
- org.jfree.chart.title.Title
-
- All Implemented Interfaces:
Serializable,Cloneable,org.jfree.chart.block.Block,ChartElement,Drawable
- Direct Known Subclasses:
CompositeTitle,ImageTitle,TextTitle
public abstract class Title extends org.jfree.chart.block.AbstractBlock implements ChartElement, org.jfree.chart.block.Block, Cloneable, Serializable
The base class for all chart titles. A chart can have multiple titles, appearing at the top, bottom, left or right of the chart.Concrete implementations of this class will render text and images, and hence do the actual work of drawing titles.
- See Also:
- Serialized Form
-
-
Field Summary
Fields Modifier and Type Field Description static HorizontalAlignmentDEFAULT_HORIZONTAL_ALIGNMENTThe default horizontal alignment.static RectangleInsetsDEFAULT_PADDINGDefault title padding.static RectangleEdgeDEFAULT_POSITIONThe default title position.static VerticalAlignmentDEFAULT_VERTICAL_ALIGNMENTThe default vertical alignment.booleanvisibleA flag that controls whether or not the title is visible.
-
Constructor Summary
Constructors Modifier Constructor Description protectedTitle()Creates a new title, using default attributes where necessary.protectedTitle(RectangleEdge position, HorizontalAlignment horizontalAlignment, VerticalAlignment verticalAlignment)Creates a new title, using default attributes where necessary.protectedTitle(RectangleEdge position, HorizontalAlignment horizontalAlignment, VerticalAlignment verticalAlignment, RectangleInsets padding)Creates a new title.
-
Method Summary
All Methods Instance Methods Abstract Methods Concrete Methods Modifier and Type Method Description voidaddChangeListener(TitleChangeListener listener)Registers an object for notification of changes to the title.Objectclone()Returns a clone of the title.abstract voiddraw(Graphics2D g2, Rectangle2D area)Draws the title on a Java 2D graphics device (such as the screen or a printer).booleanequals(Object obj)Tests an object for equality with this title.HorizontalAlignmentgetHorizontalAlignment()Returns the horizontal alignment of the title.booleangetNotify()Returns the flag that indicates whether or not the notification mechanism is enabled.RectangleEdgegetPosition()Returns the position of the title.VerticalAlignmentgetVerticalAlignment()Returns the vertical alignment of the title.inthashCode()Returns a hashcode for the title.booleanisVisible()Returns a flag that controls whether or not the title should be drawn.protected voidnotifyListeners(TitleChangeEvent event)Notifies all registered listeners that the chart title has changed in some way.voidreceive(ChartElementVisitor visitor)Receives a chart element visitor.voidremoveChangeListener(TitleChangeListener listener)Unregisters an object for notification of changes to the chart title.voidsetHorizontalAlignment(HorizontalAlignment alignment)Sets the horizontal alignment for the title and sends aTitleChangeEventto all registered listeners.voidsetNotify(boolean flag)Sets the flag that indicates whether or not the notification mechanism is enabled.voidsetPosition(RectangleEdge position)Sets the position for the title and sends aTitleChangeEventto all registered listeners.voidsetVerticalAlignment(VerticalAlignment alignment)Sets the vertical alignment for the title, and notifies any registered listeners of the change.voidsetVisible(boolean visible)Sets a flag that controls whether or not the title should be drawn, and sends aTitleChangeEventto all registered listeners.-
Methods inherited from class org.jfree.chart.block.AbstractBlock
arrange, arrange, calculateTotalHeight, calculateTotalWidth, drawBorder, getBounds, getContentXOffset, getContentYOffset, getFrame, getHeight, getID, getMargin, getPadding, getWidth, setBorder, setBounds, setFrame, setHeight, setID, setMargin, setMargin, setPadding, setPadding, setWidth, toContentConstraint, trimBorder, trimMargin, trimPadding, trimToContentHeight, trimToContentWidth
-
-
-
-
Field Detail
-
DEFAULT_POSITION
public static final RectangleEdge DEFAULT_POSITION
The default title position.
-
DEFAULT_HORIZONTAL_ALIGNMENT
public static final HorizontalAlignment DEFAULT_HORIZONTAL_ALIGNMENT
The default horizontal alignment.
-
DEFAULT_VERTICAL_ALIGNMENT
public static final VerticalAlignment DEFAULT_VERTICAL_ALIGNMENT
The default vertical alignment.
-
DEFAULT_PADDING
public static final RectangleInsets DEFAULT_PADDING
Default title padding.
-
visible
public boolean visible
A flag that controls whether or not the title is visible.
-
-
Constructor Detail
-
Title
protected Title()
Creates a new title, using default attributes where necessary.
-
Title
protected Title(RectangleEdge position, HorizontalAlignment horizontalAlignment, VerticalAlignment verticalAlignment)
Creates a new title, using default attributes where necessary.- Parameters:
position- the position of the title (nullnot permitted).horizontalAlignment- the horizontal alignment of the title (nullnot permitted).verticalAlignment- the vertical alignment of the title (nullnot permitted).
-
Title
protected Title(RectangleEdge position, HorizontalAlignment horizontalAlignment, VerticalAlignment verticalAlignment, RectangleInsets padding)
Creates a new title.- Parameters:
position- the position of the title (nullnot permitted).horizontalAlignment- the horizontal alignment of the title (LEFT, CENTER or RIGHT,nullnot permitted).verticalAlignment- the vertical alignment of the title (TOP, MIDDLE or BOTTOM,nullnot permitted).padding- the amount of space to leave around the outside of the title (nullnot permitted).
-
-
Method Detail
-
isVisible
public boolean isVisible()
Returns a flag that controls whether or not the title should be drawn. The default value istrue.- Returns:
- A boolean.
- See Also:
setVisible(boolean)
-
setVisible
public void setVisible(boolean visible)
Sets a flag that controls whether or not the title should be drawn, and sends aTitleChangeEventto all registered listeners.- Parameters:
visible- the new flag value.- See Also:
isVisible()
-
getPosition
public RectangleEdge getPosition()
Returns the position of the title.- Returns:
- The title position (never
null).
-
setPosition
public void setPosition(RectangleEdge position)
Sets the position for the title and sends aTitleChangeEventto all registered listeners.- Parameters:
position- the position (nullnot permitted).
-
getHorizontalAlignment
public HorizontalAlignment getHorizontalAlignment()
Returns the horizontal alignment of the title.- Returns:
- The horizontal alignment (never
null).
-
setHorizontalAlignment
public void setHorizontalAlignment(HorizontalAlignment alignment)
Sets the horizontal alignment for the title and sends aTitleChangeEventto all registered listeners.- Parameters:
alignment- the horizontal alignment (nullnot permitted).
-
getVerticalAlignment
public VerticalAlignment getVerticalAlignment()
Returns the vertical alignment of the title.- Returns:
- The vertical alignment (never
null).
-
setVerticalAlignment
public void setVerticalAlignment(VerticalAlignment alignment)
Sets the vertical alignment for the title, and notifies any registered listeners of the change.- Parameters:
alignment- the new vertical alignment (TOP, MIDDLE or BOTTOM,nullnot permitted).
-
getNotify
public boolean getNotify()
Returns the flag that indicates whether or not the notification mechanism is enabled.- Returns:
- The flag.
-
setNotify
public void setNotify(boolean flag)
Sets the flag that indicates whether or not the notification mechanism is enabled. There are certain situations (such as cloning) where you want to turn notification off temporarily.- Parameters:
flag- the new value of the flag.
-
receive
public void receive(ChartElementVisitor visitor)
Receives a chart element visitor.- Specified by:
receivein interfaceChartElement- Parameters:
visitor- the visitor (nullnot permitted).
-
draw
public abstract void draw(Graphics2D g2, Rectangle2D area)
Draws the title on a Java 2D graphics device (such as the screen or a printer).
-
clone
public Object clone() throws CloneNotSupportedException
Returns a clone of the title.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.
- Overrides:
clonein classorg.jfree.chart.block.AbstractBlock- Returns:
- A clone of the title.
- Throws:
CloneNotSupportedException- not thrown by this class, but it may be thrown by subclasses.
-
addChangeListener
public void addChangeListener(TitleChangeListener listener)
Registers an object for notification of changes to the title.- Parameters:
listener- the object that is being registered.
-
removeChangeListener
public void removeChangeListener(TitleChangeListener listener)
Unregisters an object for notification of changes to the chart title.- Parameters:
listener- the object that is being unregistered.
-
notifyListeners
protected void notifyListeners(TitleChangeEvent event)
Notifies all registered listeners that the chart title has changed in some way.- Parameters:
event- an object that contains information about the change to the title.
-
equals
public boolean equals(Object obj)
Tests an object for equality with this title.- Overrides:
equalsin classorg.jfree.chart.block.AbstractBlock- Parameters:
obj- the object (nullnot permitted).- Returns:
trueorfalse.
-
hashCode
public int hashCode()
Returns a hashcode for the title.- Overrides:
hashCodein classorg.jfree.chart.block.AbstractBlock- Returns:
- The hashcode.
-
-