Class Plot
- All Implemented Interfaces:
Serializable
,Cloneable
,EventListener
,AxisChangeListener
,DatasetChangeListener
- Direct Known Subclasses:
CategoryPlot
,CompassPlot
,ContourPlot
,FastScatterPlot
,MeterPlot
,MultiplePiePlot
,PiePlot
,PolarPlot
,ThermometerPlot
,WaferMapPlot
,XYPlot
public abstract class Plot extends Object implements AxisChangeListener, DatasetChangeListener, Serializable, Cloneable
JFreeChart
class delegates the drawing of axes and
data to the plot. This base class provides facilities common to most plot
types.- See Also:
- Serialized Form
-
Field Summary
Fields Modifier and Type Field Description 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 Insets
DEFAULT_INSETS
The default insets.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. -
Method Summary
Modifier and Type Method Description 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)
Implement later to make use of anchor.abstract void
draw(Graphics2D g2, Rectangle2D plotArea, PlotState parentState, PlotRenderingInfo info)
Draws the plot on a Java 2D graphics device (such as the screen or a printer).void
drawBackground(Graphics2D g2, Rectangle2D area)
Draws the plot background (the background color and/or image).void
drawOutline(Graphics2D g2, Rectangle2D area)
Draws the plot outline.boolean
equals(Object obj)
Tests this plot for equality with another object.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.double
getDataAreaRatio()
Returns the data area ratio.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.Insets
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 ornull
.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).abstract String
getPlotType()
Returns a short string describing the plot type.Plot
getRootPlot()
Returns the root plot.void
handleClick(int x, int y, PlotRenderingInfo info)
Handles a 'click' on the plot.boolean
isPlotShowing()
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 org.jfree.ui.RectangleEdge
resolveDomainAxisLocation(AxisLocation location, PlotOrientation orientation)
Resolves a domain axis location for a given plot orientation.static org.jfree.ui.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 background alignment.void
setBackgroundPaint(Paint paint)
Sets the background color of the plot area and sends aPlotChangeEvent
to all registered listeners.void
setDataAreaRatio(double ratio)
Sets the data area ratio.void
setDrawingSupplier(DrawingSupplier supplier)
Sets the drawing supplier for the plot.void
setForegroundAlpha(float alpha)
Sets the alpha-transparency for the plot.void
setInsets(Insets insets)
Sets the insets for the plot and notifies registered listeners that the plot has been modified.void
setInsets(Insets insets, boolean notify)
Sets the insets for the plot and, if requested, notifies registered listeners that the plot has been modified.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 aPlotChangeEvent
to all registered listeners.void
setOutlineStroke(Stroke stroke)
Sets the stroke used to outline the plot area and sends aPlotChangeEvent
to all registered listeners.void
setParent(Plot parent)
Sets the parent plot.void
setPlotShowing(boolean showPlot)
void
zoom(double percent)
Performs a zoom on the plot.
-
Field Details
-
ZERO
Useful constant representing zero. -
DEFAULT_INSETS
The default insets. -
DEFAULT_OUTLINE_STROKE
The default outline stroke. -
DEFAULT_OUTLINE_PAINT
The default outline color. -
DEFAULT_FOREGROUND_ALPHA
public static final float DEFAULT_FOREGROUND_ALPHAThe default foreground alpha transparency.- See Also:
- Constant Field Values
-
DEFAULT_BACKGROUND_ALPHA
public static final float DEFAULT_BACKGROUND_ALPHAThe default background alpha transparency.- See Also:
- Constant Field Values
-
DEFAULT_BACKGROUND_PAINT
The default background color. -
MINIMUM_WIDTH_TO_DRAW
public static final int MINIMUM_WIDTH_TO_DRAWThe minimum width at which the plot should be drawn.- See Also:
- Constant Field Values
-
MINIMUM_HEIGHT_TO_DRAW
public static final int MINIMUM_HEIGHT_TO_DRAWThe minimum height at which the plot should be drawn.- See Also:
- Constant Field Values
-
-
Method Details
-
getDatasetGroup
Returns the dataset group for the plot (not currently used).- Returns:
- The dataset group.
-
getNoDataMessage
Returns the string that is displayed when the dataset is empty ornull
.- Returns:
- The 'no data' message (
null
possible).
-
setNoDataMessage
Sets the message that is displayed when the dataset is empty or null.- Parameters:
message
- the message (null permitted).
-
getNoDataMessageFont
Returns the font used to display the 'no data' message.- Returns:
- the font.
-
setNoDataMessageFont
Sets the font used to display the 'no data' message.- Parameters:
font
- the font.
-
getNoDataMessagePaint
Returns the paint used to display the 'no data' message.- Returns:
- the paint.
-
setNoDataMessagePaint
Sets the paint used to display the 'no data' message.- Parameters:
paint
- the paint.
-
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.
- Returns:
- a short string describing the plot type.
-
getParent
Returns the parent plot (or null if this plot is not part of a combined plot).- Returns:
- the parent plot.
-
setParent
Sets the parent plot.- Parameters:
parent
- the parent plot.
-
getRootPlot
Returns the root plot.- Returns:
- The root plot.
-
isSubplot
public boolean isSubplot()Returns true if this plot is part of a combined plot structure.- Returns:
true
if this plot is part of a combined plot structure.
-
getInsets
Returns the insets for the plot area.- Returns:
- The insets.
-
setInsets
Sets the insets for the plot and notifies registered listeners that the plot has been modified.- Parameters:
insets
- the new insets.
-
setInsets
Sets the insets for the plot and, if requested, notifies registered listeners that the plot has been modified.- Parameters:
insets
- the new insets (null
not permitted).notify
- a flag that controls whether the registered listeners are notified.
-
getBackgroundPaint
Returns the background color of the plot area.- Returns:
- the paint (possibly
null
).
-
setBackgroundPaint
Sets the background color of the plot area and sends aPlotChangeEvent
to all registered listeners.- Parameters:
paint
- the paint (null
permitted).
-
getBackgroundAlpha
public float getBackgroundAlpha()Returns the alpha transparency of the plot area background.- Returns:
- the alpha transparency.
-
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:
alpha
- the new alpha value.
-
getDrawingSupplier
Returns the drawing supplier for the plot.- Returns:
- the drawing supplier (possibly
null
).
-
setDrawingSupplier
Sets the drawing supplier for the plot. The drawing supplier is responsible for supplying a limitless (possibly repeating) sequence ofPaint
,Stroke
andShape
objects that the plot's renderer(s) can use to populate its(their) tables.- Parameters:
supplier
- the new supplier.
-
getBackgroundImage
Returns the background image that is used to fill the plot's background area.- Returns:
- The image (possibly
null
).
-
setBackgroundImage
Sets the background image for the plot.- Parameters:
image
- the image (null
permitted).
-
getBackgroundImageAlignment
public int getBackgroundImageAlignment()Returns the background image alignment. Alignment constants are defined in theorg.jfree.ui.Align
class in the JCommon class library.- Returns:
- The alignment.
-
setBackgroundImageAlignment
public void setBackgroundImageAlignment(int alignment)Sets the background alignment.Alignment options are defined by the
Align
class.- Parameters:
alignment
- the alignment.
-
getOutlineStroke
Returns the stroke used to outline the plot area.- Returns:
- the stroke (possibly
null
).
-
setOutlineStroke
Sets the stroke used to outline the plot area and sends aPlotChangeEvent
to all registered listeners. If you set this attribute tonull<.code>, no outline will be drawn. @param stroke the stroke (
null
permitted). -
getOutlinePaint
Returns the color used to draw the outline of the plot area.- Returns:
- The color (possibly
null
).
-
setOutlinePaint
Sets the paint used to draw the outline of the plot area and sends aPlotChangeEvent
to all registered listeners. If you set this attribute tonull
, no outline will be drawn.- Parameters:
paint
- the paint (null
permitted).
-
getForegroundAlpha
public float getForegroundAlpha()Returns the alpha-transparency for the plot foreground.- Returns:
- the alpha-transparency.
-
setForegroundAlpha
public void setForegroundAlpha(float alpha)Sets the alpha-transparency for the plot.- Parameters:
alpha
- the new alpha transparency.
-
getLegendItems
Returns the legend items for the plot. By default, this method returnsnull
. Subclasses should override to return aLegendItemCollection
.- Returns:
- The legend items for the plot (possibly
null
).
-
addChangeListener
Registers an object for notification of changes to the plot.- Parameters:
listener
- the object to be registered.
-
removeChangeListener
Unregisters an object for notification of changes to the plot.- Parameters:
listener
- the object to be unregistered.
-
notifyListeners
Notifies all registered listeners that the plot has been modified.- Parameters:
event
- information about the change event.
-
draw
public abstract void draw(Graphics2D g2, Rectangle2D plotArea, PlotState parentState, PlotRenderingInfo info)Draws the plot on a Java 2D graphics device (such as the screen or a printer).This class does not store any information about where the individual items that make up the plot are actually drawn. If you want to collect this information, pass in a ChartRenderingInfo object. After the drawing is complete, the info object will contain lots of information about the chart. If you don't want the information, pass in null. *
- Parameters:
g2
- the graphics device.plotArea
- the area within which the plot should be drawn.parentState
- the state from the parent plot, if there is one.info
- an object for collecting information about the drawing of the chart.
-
draw
public void draw(Graphics2D g2, Rectangle2D area, Point2D anchor, PlotState parentState, PlotRenderingInfo info)Implement later to make use of anchor.- Parameters:
g2
- the graphics device.area
- the plot area.anchor
- the anchor point.parentState
- the parent state (if any).info
- carries back plot rendering info.
-
drawBackground
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:
g2
- the graphics device.area
- the area within which the plot should be drawn.
-
drawOutline
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:
g2
- the graphics device.area
- the area within which the plot should be drawn.
-
handleClick
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:
x
- the x coordinate (in Java2D space).y
- the y coordinate (in Java2D space).info
- an object containing information about the dimensions of the plot.
-
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:
percent
- the zoom percentage.
-
axisChanged
Receives notification of a change to one of the plot's axes.- Specified by:
axisChanged
in interfaceAxisChangeListener
- Parameters:
event
- information about the event (not used here).
-
datasetChanged
Receives notification of a change to the plot's dataset.The plot reacts by passing on a plot change event to all registered listeners.
- Specified by:
datasetChanged
in interfaceDatasetChangeListener
- Parameters:
event
- information about the event (not used here).
-
getDataAreaRatio
public double getDataAreaRatio()Returns the data area ratio.- Returns:
- The ratio.
-
setDataAreaRatio
public void setDataAreaRatio(double ratio)Sets the data area ratio.- Parameters:
ratio
- the ratio.
-
equals
Tests this plot for equality with another object. -
clone
Creates a clone of the plot.- Returns:
- A clone.
- Throws:
CloneNotSupportedException
- if some component of the plot does not support cloning.
-
resolveDomainAxisLocation
public static org.jfree.ui.RectangleEdge resolveDomainAxisLocation(AxisLocation location, PlotOrientation orientation)Resolves a domain axis location for a given plot orientation.- Parameters:
location
- the location (null
not permitted).orientation
- the orientation (null
not permitted).- Returns:
- The edge (never
null
).
-
resolveRangeAxisLocation
public static org.jfree.ui.RectangleEdge resolveRangeAxisLocation(AxisLocation location, PlotOrientation orientation)Resolves a range axis location for a given plot orientation.- Parameters:
location
- the location (null
not permitted).orientation
- the orientation (null
not permitted).- Returns:
- the edge (never
null
).
-
setPlotShowing
public void setPlotShowing(boolean showPlot) -
isPlotShowing
public boolean isPlotShowing()
-