org.jfree.chart.plot
Class Plot

The base class for all plots in JFreeChart. The JFreeChart class delegates the drawing of axes and data to the plot. This base class provides facilities common to most plot types.
SinceNot specified.
VersionNot specified.
AuthorNot specified.
Wiki javadoc Use textile entry format.
Add your comments here.
Field Summary
static float DEFAULT_BACKGROUND_ALPHA
The default background alpha transparency.
static Paint DEFAULT_BACKGROUND_PAINT
The default background color.
static float DEFAULT_FOREGROUND_ALPHA
The default foreground alpha transparency.
static RectangleInsets DEFAULT_INSETS
The default insets.
static Shape DEFAULT_LEGEND_ITEM_BOX
A default box shape for legend items.
static Shape DEFAULT_LEGEND_ITEM_CIRCLE
A default circle shape for legend items.
static Paint DEFAULT_OUTLINE_PAINT
The default outline color.
static Stroke DEFAULT_OUTLINE_STROKE
The default outline stroke.
static int MINIMUM_HEIGHT_TO_DRAW
The minimum height at which the plot should be drawn.
static int MINIMUM_WIDTH_TO_DRAW
The minimum width at which the plot should be drawn.
static Number ZERO
Useful constant representing zero.
Constructor Summary
Plot()
Creates a new plot.
Method Summary
void addChangeListener( PlotChangeListener listener )
Registers an object for notification of changes to the plot.
void axisChanged( AxisChangeEvent event )
Receives notification of a change to one of the plot's axes.
Object clone()
Creates a clone of the plot.
void datasetChanged( DatasetChangeEvent event )
Receives notification of a change to the plot's dataset.
void draw( Graphics2D g2, Rectangle2D area, Point2D anchor, PlotState parentState, PlotRenderingInfo info )
Draws the plot within the specified area.
void drawBackground( Graphics2D g2, Rectangle2D area )
Draws the plot background (the background color and/or image).
protected void drawBackgroundImage( Graphics2D g2, Rectangle2D area )
Draws the background image (if there is one) aligned within the specified area.
protected void drawNoDataMessage( Graphics2D g2, Rectangle2D area )
Draws a message to state that there is no data to plot.
void drawOutline( Graphics2D g2, Rectangle2D area )
Draws the plot outline.
boolean equals( Object obj )
Tests this plot for equality with another object.
protected void fillBackground( Graphics2D g2, Rectangle2D area )
Fills the specified area with the background paint.
float getBackgroundAlpha()
Returns the alpha transparency of the plot area background.
Image getBackgroundImage()
Returns the background image that is used to fill the plot's background area.
int getBackgroundImageAlignment()
Returns the background image alignment.
Paint getBackgroundPaint()
Returns the background color of the plot area.
DatasetGroup getDatasetGroup()
Returns the dataset group for the plot (not currently used).
DrawingSupplier getDrawingSupplier()
Returns the drawing supplier for the plot.
float getForegroundAlpha()
Returns the alpha-transparency for the plot foreground.
RectangleInsets getInsets()
Returns the insets for the plot area.
LegendItemCollection getLegendItems()
Returns the legend items for the plot.
String getNoDataMessage()
Returns the string that is displayed when the dataset is empty or null.
Font getNoDataMessageFont()
Returns the font used to display the 'no data' message.
Paint getNoDataMessagePaint()
Returns the paint used to display the 'no data' message.
Paint getOutlinePaint()
Returns the color used to draw the outline of the plot area.
Stroke getOutlineStroke()
Returns the stroke used to outline the plot area.
Plot getParent()
Returns the parent plot (or null if this plot is not part of a combined plot).
String getPlotType()
Returns a short string describing the plot type.
protected double getRectX( double x, double w1, double w2, RectangleEdge edge )
Adjusts the supplied x-value.
protected double getRectY( double y, double h1, double h2, RectangleEdge edge )
Adjusts the supplied y-value.
Plot getRootPlot()
Returns the root plot.
void handleClick( int x, int y, PlotRenderingInfo info )
Handles a 'click' on the plot.
boolean isSubplot()
Returns true if this plot is part of a combined plot structure.
void notifyListeners( PlotChangeEvent event )
Notifies all registered listeners that the plot has been modified.
void removeChangeListener( PlotChangeListener listener )
Unregisters an object for notification of changes to the plot.
static RectangleEdge resolveDomainAxisLocation( AxisLocation location, PlotOrientation orientation )
Resolves a domain axis location for a given plot orientation.
static RectangleEdge resolveRangeAxisLocation( AxisLocation location, PlotOrientation orientation )
Resolves a range axis location for a given plot orientation.
void setBackgroundAlpha( float alpha )
Sets the alpha transparency of the plot area background, and notifies registered listeners that the plot has been modified.
void setBackgroundImage( Image image )
Sets the background image for the plot.
void setBackgroundImageAlignment( int alignment )
Sets the alignment for the background image and sends a PlotChangeEvent to all registered listeners.
void setBackgroundPaint( Paint paint )
Sets the background color of the plot area and sends a PlotChangeEvent to all registered listeners.
protected void setDatasetGroup( DatasetGroup group )
Sets the dataset group (not currently used).
void setDrawingSupplier( DrawingSupplier supplier )
Sets the drawing supplier for the plot.
void setForegroundAlpha( float alpha )
Sets the alpha-transparency for the plot.
void setInsets( RectangleInsets insets )
Sets the insets for the plot and sends a PlotChangeEvent to all registered listeners.
void setInsets( RectangleInsets insets, boolean notify )
Sets the insets for the plot and, if requested, and sends a PlotChangeEvent to all registered listeners.
void setNoDataMessage( String message )
Sets the message that is displayed when the dataset is empty or null.
void setNoDataMessageFont( Font font )
Sets the font used to display the 'no data' message.
void setNoDataMessagePaint( Paint paint )
Sets the paint used to display the 'no data' message.
void setOutlinePaint( Paint paint )
Sets the paint used to draw the outline of the plot area and sends a PlotChangeEvent to all registered listeners.
void setOutlineStroke( Stroke stroke )
Sets the stroke used to outline the plot area and sends a PlotChangeEvent to all registered listeners.
void setParent( Plot parent )
Sets the parent plot.
void zoom( double percent )
Performs a zoom on the plot.
DEFAULT_BACKGROUND_ALPHA
public static float DEFAULT_BACKGROUND_ALPHA
The default background alpha transparency.
Wiki javadoc Use textile entry format.
Add your comments here.
DEFAULT_BACKGROUND_PAINT
public static Paint DEFAULT_BACKGROUND_PAINT
The default background color.
Wiki javadoc Use textile entry format.
Add your comments here.
DEFAULT_FOREGROUND_ALPHA
public static float DEFAULT_FOREGROUND_ALPHA
The default foreground alpha transparency.
Wiki javadoc Use textile entry format.
Add your comments here.
DEFAULT_INSETS
public static RectangleInsets DEFAULT_INSETS
The default insets.
Wiki javadoc Use textile entry format.
Add your comments here.
DEFAULT_LEGEND_ITEM_BOX
public static Shape DEFAULT_LEGEND_ITEM_BOX
A default box shape for legend items.
Wiki javadoc Use textile entry format.
Add your comments here.
DEFAULT_LEGEND_ITEM_CIRCLE
public static Shape DEFAULT_LEGEND_ITEM_CIRCLE
A default circle shape for legend items.
Wiki javadoc Use textile entry format.
Add your comments here.
DEFAULT_OUTLINE_PAINT
public static Paint DEFAULT_OUTLINE_PAINT
The default outline color.
Wiki javadoc Use textile entry format.
Add your comments here.
DEFAULT_OUTLINE_STROKE
public static Stroke DEFAULT_OUTLINE_STROKE
The default outline stroke.
Wiki javadoc Use textile entry format.
Add your comments here.
MINIMUM_HEIGHT_TO_DRAW
public static int MINIMUM_HEIGHT_TO_DRAW
The minimum height at which the plot should be drawn.
Wiki javadoc Use textile entry format.
Add your comments here.
MINIMUM_WIDTH_TO_DRAW
public static int MINIMUM_WIDTH_TO_DRAW
The minimum width at which the plot should be drawn.
Wiki javadoc Use textile entry format.
Add your comments here.
ZERO
public static Number ZERO
Useful constant representing zero.
Wiki javadoc Use textile entry format.
Add your comments here.
Plot
protected Plot ( )
Creates a new plot.
Wiki javadoc Use textile entry format.
Add your comments here.
addChangeListener
public void addChangeListener ( PlotChangeListener listener )
Registers an object for notification of changes to the plot.
Parameters
TypeNameDescription
PlotChangeListener listener the object to be registered.
Returns void No description provided.
Wiki javadoc Use textile entry format.
Add your comments here.
axisChanged
public void axisChanged ( AxisChangeEvent event )
Receives notification of a change to one of the plot's axes.
Implements method in AxisChangeListener
Parameters
TypeNameDescription
AxisChangeEvent event information about the event (not used here).
Returns void No description provided.
Wiki javadoc Use textile entry format.
Add your comments here.
clone
public Object clone ( )
Creates a clone of the plot.
Overrides method in Object
Exceptions
CloneNotSupportedException if some component of the plot does not support cloning.
Wiki javadoc Use textile entry format.
Add your comments here.
datasetChanged
public void datasetChanged ( DatasetChangeEvent event )
Receives notification of a change to the plot's dataset.

The plot reacts by passing on a plot change event to all registered listeners.

Implements method in DatasetChangeListener
Parameters
TypeNameDescription
DatasetChangeEvent event information about the event (not used here).
Returns void No description provided.
Wiki javadoc Use textile entry format.
Add your comments here.
draw
public void draw ( Graphics2D g2, Rectangle2D area, Point2D anchor, PlotState parentState, PlotRenderingInfo info )
Draws the plot within the specified area. The anchor is a point on the chart that is specified externally (for instance, it may be the last point of the last mouse click performed by the user) - plots can use or ignore this value as they see fit.

Subclasses need to provide an implementation of this method, obviously.
Parameters
TypeNameDescription
Graphics2D g2 the graphics device.
Rectangle2D area the plot area.
Point2D anchor the anchor point (null permitted).
PlotState parentState the parent state (if any).
PlotRenderingInfo info carries back plot rendering info.
Returns void No description provided.
Wiki javadoc Use textile entry format.
Add your comments here.
drawBackground
public void drawBackground ( Graphics2D g2, Rectangle2D area )
Draws the plot background (the background color and/or image).

This method will be called during the chart drawing process and is declared public so that it can be accessed by the renderers used by certain subclasses. You shouldn't need to call this method directly.

Parameters
TypeNameDescription
Graphics2D g2 the graphics device.
Rectangle2D area the area within which the plot should be drawn.
Returns void No description provided.
Wiki javadoc Use textile entry format.
Add your comments here.
drawBackgroundImage
protected void drawBackgroundImage ( Graphics2D g2, Rectangle2D area )
Draws the background image (if there is one) aligned within the specified area.
Parameters
TypeNameDescription
Graphics2D g2 the graphics device.
Rectangle2D area the area.
Returns void No description provided.
Wiki javadoc Use textile entry format.
Add your comments here.
drawNoDataMessage
protected void drawNoDataMessage ( Graphics2D g2, Rectangle2D area )
Draws a message to state that there is no data to plot.
Parameters
TypeNameDescription
Graphics2D g2 the graphics device.
Rectangle2D area the area within which the plot should be drawn.
Returns void No description provided.
Wiki javadoc Use textile entry format.
Add your comments here.
drawOutline
public void drawOutline ( Graphics2D g2, Rectangle2D area )
Draws the plot outline. This method will be called during the chart drawing process and is declared public so that it can be accessed by the renderers used by certain subclasses. You shouldn't need to call this method directly.
Parameters
TypeNameDescription
Graphics2D g2 the graphics device.
Rectangle2D area the area within which the plot should be drawn.
Returns void No description provided.
Wiki javadoc Use textile entry format.
Add your comments here.
equals
public boolean equals ( Object obj )
Tests this plot for equality with another object.
Overrides method in Object
Parameters
TypeNameDescription
Object obj the object (null permitted).
Wiki javadoc Use textile entry format.
Add your comments here.
fillBackground
protected void fillBackground ( Graphics2D g2, Rectangle2D area )
Fills the specified area with the background paint.
Parameters
TypeNameDescription
Graphics2D g2 the graphics device.
Rectangle2D area the area.
Returns void No description provided.
Wiki javadoc Use textile entry format.
Add your comments here.
getBackgroundAlpha
public float getBackgroundAlpha ( )
Returns the alpha transparency of the plot area background.
Wiki javadoc Use textile entry format.
Add your comments here.
getBackgroundImage
public Image getBackgroundImage ( )
Returns the background image that is used to fill the plot's background area.
Wiki javadoc Use textile entry format.
Add your comments here.
getBackgroundImageAlignment
public int getBackgroundImageAlignment ( )
Returns the background image alignment. Alignment constants are defined in the org.jfree.ui.Align class in the JCommon class library.
Wiki javadoc Use textile entry format.
Add your comments here.
getBackgroundPaint
public Paint getBackgroundPaint ( )
Returns the background color of the plot area.
Wiki javadoc Use textile entry format.
Add your comments here.
getDatasetGroup
public DatasetGroup getDatasetGroup ( )
Returns the dataset group for the plot (not currently used).
Wiki javadoc Use textile entry format.
Add your comments here.
getDrawingSupplier
public DrawingSupplier getDrawingSupplier ( )
Returns the drawing supplier for the plot.
Wiki javadoc Use textile entry format.
Add your comments here.
getForegroundAlpha
public float getForegroundAlpha ( )
Returns the alpha-transparency for the plot foreground.
Wiki javadoc Use textile entry format.
Add your comments here.
getInsets
public RectangleInsets getInsets ( )
Returns the insets for the plot area.
Wiki javadoc Use textile entry format.
Add your comments here.
getLegendItems
public LegendItemCollection getLegendItems ( )
Returns the legend items for the plot. By default, this method returns null. Subclasses should override to return a LegendItemCollection .
Implements method in LegendItemSource
Wiki javadoc Use textile entry format.
Add your comments here.
getNoDataMessage
public String getNoDataMessage ( )
Returns the string that is displayed when the dataset is empty or null.
Wiki javadoc Use textile entry format.
Add your comments here.
getNoDataMessageFont
public Font getNoDataMessageFont ( )
Returns the font used to display the 'no data' message.
Wiki javadoc Use textile entry format.
Add your comments here.
getNoDataMessagePaint
public Paint getNoDataMessagePaint ( )
Returns the paint used to display the 'no data' message.
Wiki javadoc Use textile entry format.
Add your comments here.
getOutlinePaint
public Paint getOutlinePaint ( )
Returns the color used to draw the outline of the plot area.
Wiki javadoc Use textile entry format.
Add your comments here.
getOutlineStroke
public Stroke getOutlineStroke ( )
Returns the stroke used to outline the plot area.
Wiki javadoc Use textile entry format.
Add your comments here.
getParent
public Plot getParent ( )
Returns the parent plot (or null if this plot is not part of a combined plot).
Wiki javadoc Use textile entry format.
Add your comments here.
getPlotType
public String getPlotType ( )
Returns a short string describing the plot type.

Note: this gets used in the chart property editing user interface, but there needs to be a better mechanism for identifying the plot type.

Wiki javadoc Use textile entry format.
Add your comments here.
getRectX
protected double getRectX ( double x, double w1, double w2, RectangleEdge edge )
Adjusts the supplied x-value.
Parameters
TypeNameDescription
double x the x-value.
double w1 width 1.
double w2 width 2.
RectangleEdge edge the edge (left or right).
Wiki javadoc Use textile entry format.
Add your comments here.
getRectY
protected double getRectY ( double y, double h1, double h2, RectangleEdge edge )
Adjusts the supplied y-value.
Parameters
TypeNameDescription
double y the x-value.
double h1 height 1.
double h2 height 2.
RectangleEdge edge the edge (top or bottom).
Wiki javadoc Use textile entry format.
Add your comments here.
getRootPlot
public Plot getRootPlot ( )
Returns the root plot.
Wiki javadoc Use textile entry format.
Add your comments here.
handleClick
public void handleClick ( int x, int y, PlotRenderingInfo info )
Handles a 'click' on the plot. Since the plot does not maintain any information about where it has been drawn, the plot rendering info is supplied as an argument.
Parameters
TypeNameDescription
int x the x coordinate (in Java2D space).
int y the y coordinate (in Java2D space).
PlotRenderingInfo info an object containing information about the dimensions of the plot.
Returns void No description provided.
Wiki javadoc Use textile entry format.
Add your comments here.
isSubplot
public boolean isSubplot ( )
Returns true if this plot is part of a combined plot structure.
Wiki javadoc Use textile entry format.
Add your comments here.
notifyListeners
public void notifyListeners ( PlotChangeEvent event )
Notifies all registered listeners that the plot has been modified.
Parameters
TypeNameDescription
PlotChangeEvent event information about the change event.
Returns void No description provided.
Wiki javadoc Use textile entry format.
Add your comments here.
removeChangeListener
public void removeChangeListener ( PlotChangeListener listener )
Unregisters an object for notification of changes to the plot.
Parameters
TypeNameDescription
PlotChangeListener listener the object to be unregistered.
Returns void No description provided.
Wiki javadoc Use textile entry format.
Add your comments here.
resolveDomainAxisLocation
public static RectangleEdge resolveDomainAxisLocation ( AxisLocation location, PlotOrientation orientation )
Resolves a domain axis location for a given plot orientation.
Parameters
TypeNameDescription
AxisLocation location the location (null not permitted).
PlotOrientation orientation the orientation (null not permitted).
Wiki javadoc Use textile entry format.
Add your comments here.
resolveRangeAxisLocation
public static RectangleEdge resolveRangeAxisLocation ( AxisLocation location, PlotOrientation orientation )
Resolves a range axis location for a given plot orientation.
Parameters
TypeNameDescription
AxisLocation location the location (null not permitted).
PlotOrientation orientation the orientation (null not permitted).
Wiki javadoc Use textile entry format.
Add your comments here.
setBackgroundAlpha
public void setBackgroundAlpha ( float alpha )
Sets the alpha transparency of the plot area background, and notifies registered listeners that the plot has been modified.
Parameters
TypeNameDescription
float alpha the new alpha value.
Returns void No description provided.
Wiki javadoc Use textile entry format.
Add your comments here.
setBackgroundImage
public void setBackgroundImage ( Image image )
Sets the background image for the plot.
Parameters
TypeNameDescription
Image image the image (null permitted).
Returns void No description provided.
Wiki javadoc Use textile entry format.
Add your comments here.
setBackgroundImageAlignment
public void setBackgroundImageAlignment ( int alignment )
Sets the alignment for the background image and sends a PlotChangeEvent to all registered listeners. Alignment options are defined by the Align class in the JCommon class library.
Parameters
TypeNameDescription
int alignment the alignment.
Returns void No description provided.
Wiki javadoc Use textile entry format.
Add your comments here.
setBackgroundPaint
public void setBackgroundPaint ( Paint paint )
Sets the background color of the plot area and sends a PlotChangeEvent to all registered listeners.
Parameters
TypeNameDescription
Paint paint the paint (null permitted).
Returns void No description provided.
Wiki javadoc Use textile entry format.
Add your comments here.
setDatasetGroup
protected void setDatasetGroup ( DatasetGroup group )
Sets the dataset group (not currently used).
Parameters
TypeNameDescription
DatasetGroup group the dataset group (null permitted).
Returns void No description provided.
Wiki javadoc Use textile entry format.
Add your comments here.
setDrawingSupplier
public void setDrawingSupplier ( DrawingSupplier supplier )
Sets the drawing supplier for the plot. The drawing supplier is responsible for supplying a limitless (possibly repeating) sequence of Paint, Stroke and Shape objects that the plot's renderer(s) can use to populate its (their) tables.
Parameters
TypeNameDescription
DrawingSupplier supplier the new supplier.
Returns void No description provided.
Wiki javadoc Use textile entry format.
Add your comments here.
setForegroundAlpha
public void setForegroundAlpha ( float alpha )
Sets the alpha-transparency for the plot.
Parameters
TypeNameDescription
float alpha the new alpha transparency.
Returns void No description provided.
Wiki javadoc Use textile entry format.
Add your comments here.
setInsets
public void setInsets ( RectangleInsets insets )
Sets the insets for the plot and sends a PlotChangeEvent to all registered listeners.
Parameters
TypeNameDescription
RectangleInsets insets the new insets (null not permitted).
Returns void No description provided.
Wiki javadoc Use textile entry format.
Add your comments here.
setInsets
public void setInsets ( RectangleInsets insets, boolean notify )
Sets the insets for the plot and, if requested, and sends a PlotChangeEvent to all registered listeners.
Parameters
TypeNameDescription
RectangleInsets insets the new insets (null not permitted).
boolean notify a flag that controls whether the registered listeners are notified.
Returns void No description provided.
Wiki javadoc Use textile entry format.
Add your comments here.
setNoDataMessage
public void setNoDataMessage ( String message )
Sets the message that is displayed when the dataset is empty or null.
Parameters
TypeNameDescription
String message the message (null permitted).
Returns void No description provided.
Wiki javadoc Use textile entry format.
Add your comments here.
setNoDataMessageFont
public void setNoDataMessageFont ( Font font )
Sets the font used to display the 'no data' message.
Parameters
TypeNameDescription
Font font the font.
Returns void No description provided.
Wiki javadoc Use textile entry format.
Add your comments here.
setNoDataMessagePaint
public void setNoDataMessagePaint ( Paint paint )
Sets the paint used to display the 'no data' message.
Parameters
TypeNameDescription
Paint paint the paint.
Returns void No description provided.
Wiki javadoc Use textile entry format.
Add your comments here.
setOutlinePaint
public void setOutlinePaint ( Paint paint )
Sets the paint used to draw the outline of the plot area and sends a PlotChangeEvent to all registered listeners. If you set this attribute to null, no outline will be drawn.
Parameters
TypeNameDescription
Paint paint the paint (null permitted).
Returns void No description provided.
Wiki javadoc Use textile entry format.
Add your comments here.
setOutlineStroke
public void setOutlineStroke ( Stroke stroke )
Sets the stroke used to outline the plot area and sends a PlotChangeEvent to all registered listeners. If you set this attribute to null<.code>, no outline will be drawn.
Parameters
TypeNameDescription
Stroke stroke the stroke (null permitted).
Returns void No description provided.
Wiki javadoc Use textile entry format.
Add your comments here.
setParent
public void setParent ( Plot parent )
Sets the parent plot.
Parameters
TypeNameDescription
Plot parent the parent plot.
Returns void No description provided.
Wiki javadoc Use textile entry format.
Add your comments here.
zoom
public void zoom ( double percent )
Performs a zoom on the plot. Subclasses should override if zooming is appropriate for the type of plot.
Parameters
TypeNameDescription
double percent the zoom percentage.
Returns void No description provided.
Wiki javadoc Use textile entry format.
Add your comments here.