|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES All Classes | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectorg.jfree.chart.plot.Plot
public abstract 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.
Field Summary | |
---|---|
static float |
DEFAULT_BACKGROUND_ALPHA
The default background alpha transparency. |
static java.awt.Paint |
DEFAULT_BACKGROUND_PAINT
The default background color. |
static float |
DEFAULT_FOREGROUND_ALPHA
The default foreground alpha transparency. |
static org.jfree.ui.RectangleInsets |
DEFAULT_INSETS
The default insets. |
static java.awt.Shape |
DEFAULT_LEGEND_ITEM_BOX
A default box shape for legend items. |
static java.awt.Shape |
DEFAULT_LEGEND_ITEM_CIRCLE
A default circle shape for legend items. |
static java.awt.Paint |
DEFAULT_OUTLINE_PAINT
The default outline color. |
static java.awt.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 java.lang.Number |
ZERO
Useful constant representing zero. |
Constructor Summary | |
---|---|
protected |
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. |
java.lang.Object |
clone()
Creates a clone of the plot. |
void |
datasetChanged(DatasetChangeEvent event)
Receives notification of a change to the plot's dataset. |
abstract void |
draw(java.awt.Graphics2D g2,
java.awt.geom.Rectangle2D area,
java.awt.geom.Point2D anchor,
PlotState parentState,
PlotRenderingInfo info)
Draws the plot within the specified area. |
void |
drawBackground(java.awt.Graphics2D g2,
java.awt.geom.Rectangle2D area)
Draws the plot background (the background color and/or image). |
protected void |
drawBackgroundImage(java.awt.Graphics2D g2,
java.awt.geom.Rectangle2D area)
Draws the background image (if there is one) aligned within the specified area. |
protected void |
drawNoDataMessage(java.awt.Graphics2D g2,
java.awt.geom.Rectangle2D area)
Draws a message to state that there is no data to plot. |
void |
drawOutline(java.awt.Graphics2D g2,
java.awt.geom.Rectangle2D area)
Draws the plot outline. |
boolean |
equals(java.lang.Object obj)
Tests this plot for equality with another object. |
protected void |
fillBackground(java.awt.Graphics2D g2,
java.awt.geom.Rectangle2D area)
Fills the specified area with the background paint. |
float |
getBackgroundAlpha()
Returns the alpha transparency of the plot area background. |
java.awt.Image |
getBackgroundImage()
Returns the background image that is used to fill the plot's background area. |
int |
getBackgroundImageAlignment()
Returns the background image alignment. |
float |
getBackgroundImageAlpha()
Returns the alpha transparency used to draw the background image. |
java.awt.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. |
org.jfree.ui.RectangleInsets |
getInsets()
Returns the insets for the plot area. |
LegendItemCollection |
getLegendItems()
Returns the legend items for the plot. |
java.lang.String |
getNoDataMessage()
Returns the string that is displayed when the dataset is empty or null . |
java.awt.Font |
getNoDataMessageFont()
Returns the font used to display the 'no data' message. |
java.awt.Paint |
getNoDataMessagePaint()
Returns the paint used to display the 'no data' message. |
java.awt.Paint |
getOutlinePaint()
Returns the color used to draw the outline of the plot area. |
java.awt.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 java.lang.String |
getPlotType()
Returns a short string describing the plot type. |
protected double |
getRectX(double x,
double w1,
double w2,
org.jfree.ui.RectangleEdge edge)
Adjusts the supplied x-value. |
protected double |
getRectY(double y,
double h1,
double h2,
org.jfree.ui.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 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(java.awt.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 |
setBackgroundImageAlpha(float alpha)
Sets the alpha transparency used when drawing the background image. |
void |
setBackgroundPaint(java.awt.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(org.jfree.ui.RectangleInsets insets)
Sets the insets for the plot and sends a PlotChangeEvent to
all registered listeners. |
void |
setInsets(org.jfree.ui.RectangleInsets insets,
boolean notify)
Sets the insets for the plot and, if requested, and sends a PlotChangeEvent to all registered listeners. |
void |
setNoDataMessage(java.lang.String message)
Sets the message that is displayed when the dataset is empty or null. |
void |
setNoDataMessageFont(java.awt.Font font)
Sets the font used to display the 'no data' message. |
void |
setNoDataMessagePaint(java.awt.Paint paint)
Sets the paint used to display the 'no data' message. |
void |
setOutlinePaint(java.awt.Paint paint)
Sets the paint used to draw the outline of the plot area and sends a PlotChangeEvent to all registered listeners. |
void |
setOutlineStroke(java.awt.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. |
Methods inherited from class java.lang.Object |
---|
finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
---|
public static final java.lang.Number ZERO
public static final org.jfree.ui.RectangleInsets DEFAULT_INSETS
public static final java.awt.Stroke DEFAULT_OUTLINE_STROKE
public static final java.awt.Paint DEFAULT_OUTLINE_PAINT
public static final float DEFAULT_FOREGROUND_ALPHA
public static final float DEFAULT_BACKGROUND_ALPHA
public static final java.awt.Paint DEFAULT_BACKGROUND_PAINT
public static final int MINIMUM_WIDTH_TO_DRAW
public static final int MINIMUM_HEIGHT_TO_DRAW
public static final java.awt.Shape DEFAULT_LEGEND_ITEM_BOX
public static final java.awt.Shape DEFAULT_LEGEND_ITEM_CIRCLE
Constructor Detail |
---|
protected Plot()
Method Detail |
---|
public DatasetGroup getDatasetGroup()
protected void setDatasetGroup(DatasetGroup group)
group
- the dataset group (null
permitted).public java.lang.String getNoDataMessage()
null
.
null
possible).public void setNoDataMessage(java.lang.String message)
message
- the message (null permitted).public java.awt.Font getNoDataMessageFont()
public void setNoDataMessageFont(java.awt.Font font)
font
- the font.public java.awt.Paint getNoDataMessagePaint()
public void setNoDataMessagePaint(java.awt.Paint paint)
paint
- the paint.public abstract java.lang.String getPlotType()
Note: this gets used in the chart property editing user interface, but there needs to be a better mechanism for identifying the plot type.
public Plot getParent()
null
if this plot is not part
of a combined plot).
public void setParent(Plot parent)
parent
- the parent plot.public Plot getRootPlot()
public boolean isSubplot()
true
if this plot is part of a combined plot
structure.public org.jfree.ui.RectangleInsets getInsets()
null
).public void setInsets(org.jfree.ui.RectangleInsets insets)
PlotChangeEvent
to
all registered listeners.
insets
- the new insets (null
not permitted).public void setInsets(org.jfree.ui.RectangleInsets insets, boolean notify)
PlotChangeEvent
to all registered listeners.
insets
- the new insets (null
not permitted).notify
- a flag that controls whether the registered listeners are
notified.public java.awt.Paint getBackgroundPaint()
null
).public void setBackgroundPaint(java.awt.Paint paint)
PlotChangeEvent
to all registered listeners.
paint
- the paint (null
permitted).public float getBackgroundAlpha()
public void setBackgroundAlpha(float alpha)
alpha
- the new alpha value.public DrawingSupplier getDrawingSupplier()
null
).public void setDrawingSupplier(DrawingSupplier supplier)
Paint
, Stroke
and Shape
objects
that the plot's renderer(s) can use to populate its (their) tables.
supplier
- the new supplier.public java.awt.Image getBackgroundImage()
null
).public void setBackgroundImage(java.awt.Image image)
image
- the image (null
permitted).public int getBackgroundImageAlignment()
org.jfree.ui.Align
class in the JCommon class
library.
public void setBackgroundImageAlignment(int alignment)
PlotChangeEvent
to all registered listeners. Alignment options
are defined by the Align
class in the JCommon
class library.
alignment
- the alignment.public float getBackgroundImageAlpha()
setBackgroundImageAlpha(float)
public void setBackgroundImageAlpha(float alpha)
alpha
- the alpha transparency (in the range 0.0f to 1.0f, where
0.0f is fully transparent, and 1.0f is fully opaque).
java.lang.IllegalArgumentException
- if alpha
is not within
the specified range.getBackgroundImageAlpha()
public java.awt.Stroke getOutlineStroke()
null
).public void setOutlineStroke(java.awt.Stroke stroke)
PlotChangeEvent
to all registered listeners. If you set this
attribute to null<.code>, no outline will be drawn.
- Parameters:
stroke
- the stroke (null
permitted).
getOutlinePaint
public java.awt.Paint getOutlinePaint()
- Returns the color used to draw the outline of the plot area.
- Returns:
- The color (possibly
null).
setOutlinePaint
public void setOutlinePaint(java.awt.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:
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
public LegendItemCollection getLegendItems()
- Returns the legend items for the plot. By default, this method returns
null
. Subclasses should override to return a
LegendItemCollection
.
- Specified by:
getLegendItems
in interface LegendItemSource
- Returns:
- The legend items for the plot (possibly
null
).
addChangeListener
public void addChangeListener(PlotChangeListener listener)
- Registers an object for notification of changes to the plot.
- Parameters:
listener
- the object to be registered.
removeChangeListener
public void removeChangeListener(PlotChangeListener listener)
- Unregisters an object for notification of changes to the plot.
- Parameters:
listener
- the object to be unregistered.
notifyListeners
public void notifyListeners(PlotChangeEvent event)
- Notifies all registered listeners that the plot has been modified.
- Parameters:
event
- information about the change event.
draw
public abstract void draw(java.awt.Graphics2D g2,
java.awt.geom.Rectangle2D area,
java.awt.geom.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:
g2
- the graphics device.area
- the plot area.anchor
- the anchor point (null
permitted).parentState
- the parent state (if any).info
- carries back plot rendering info.
drawBackground
public void drawBackground(java.awt.Graphics2D g2,
java.awt.geom.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:
g2
- the graphics device.area
- the area within which the plot should be drawn.
fillBackground
protected void fillBackground(java.awt.Graphics2D g2,
java.awt.geom.Rectangle2D area)
- Fills the specified area with the background paint.
- Parameters:
g2
- the graphics device.area
- the area.
drawBackgroundImage
protected void drawBackgroundImage(java.awt.Graphics2D g2,
java.awt.geom.Rectangle2D area)
- Draws the background image (if there is one) aligned within the
specified area.
- Parameters:
g2
- the graphics device.area
- the area.- See Also:
getBackgroundImage()
,
getBackgroundImageAlignment()
,
getBackgroundImageAlpha()
drawOutline
public void drawOutline(java.awt.Graphics2D g2,
java.awt.geom.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:
g2
- the graphics device.area
- the area within which the plot should be drawn.
drawNoDataMessage
protected void drawNoDataMessage(java.awt.Graphics2D g2,
java.awt.geom.Rectangle2D area)
- Draws a message to state that there is no data to plot.
- Parameters:
g2
- the graphics device.area
- the area within which the plot should be drawn.
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:
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
public void axisChanged(AxisChangeEvent event)
- Receives notification of a change to one of the plot's axes.
- Specified by:
axisChanged
in interface AxisChangeListener
- Parameters:
event
- information about the event (not used 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.
- Specified by:
datasetChanged
in interface DatasetChangeListener
- Parameters:
event
- information about the event (not used here).
getRectX
protected double getRectX(double x,
double w1,
double w2,
org.jfree.ui.RectangleEdge edge)
- Adjusts the supplied x-value.
- Parameters:
x
- the x-value.w1
- width 1.w2
- width 2.edge
- the edge (left or right).
- Returns:
- The adjusted x-value.
getRectY
protected double getRectY(double y,
double h1,
double h2,
org.jfree.ui.RectangleEdge edge)
- Adjusts the supplied y-value.
- Parameters:
y
- the x-value.h1
- height 1.h2
- height 2.edge
- the edge (top or bottom).
- Returns:
- The adjusted y-value.
equals
public boolean equals(java.lang.Object obj)
- Tests this plot for equality with another object.
- Overrides:
equals
in class java.lang.Object
- Parameters:
obj
- the object (null
permitted).
- Returns:
true
or false
.
clone
public java.lang.Object clone()
throws java.lang.CloneNotSupportedException
- Creates a clone of the plot.
- Specified by:
clone
in interface org.jfree.util.PublicCloneable
- Overrides:
clone
in class java.lang.Object
- Returns:
- A clone.
- Throws:
java.lang.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
).
Overview
Package
Class
Use
Tree
Deprecated
Index
Help
PREV CLASS
NEXT CLASS
FRAMES
NO FRAMES
All Classes
SUMMARY: NESTED | FIELD | CONSTR | METHOD
DETAIL: FIELD | CONSTR | METHOD