|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object | +--org.jfree.chart.plot.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 java.awt.Insets |
DEFAULT_INSETS
The default insets. |
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(Dataset data)
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. |
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 plotArea,
ChartRenderingInfo info)
Draws the plot on a Java 2D graphics device (such as the screen or a printer). |
void |
drawBackground(java.awt.Graphics2D g2,
java.awt.geom.Rectangle2D area)
Draw the plot background. |
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)
Draw the plot outline |
boolean |
equals(java.lang.Object obj)
Tests this plot for equality with another object. |
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. |
java.awt.Paint |
getBackgroundPaint()
Returns the background color of the plot area. |
double |
getDataAreaRatio()
Returns the data area ratio. |
Dataset |
getDataset()
Returns the primary dataset for the plot. |
DatasetGroup |
getDatasetGroup()
Returns the dataset group for the plot. |
float |
getForegroundAlpha()
Returns the alpha-transparency for the plot foreground. |
java.awt.Insets |
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. |
protected int |
getOppositeAxisLocation(int location)
Returns the location code for the opposite location to the one specified. |
java.awt.Paint |
getOutlinePaint()
Returns the color used to draw the outline of the plot area. |
java.awt.Stroke |
getOutlineStroke()
Returns the pen/brush 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,
int location)
Adjusts the supplied x-value. |
protected double |
getRectY(double y,
double h1,
double h2,
int location)
Adjusts the supplied y-value. |
Plot |
getRootPlot()
Returns the root plot. |
Dataset |
getSecondaryDataset()
Returns the secondary dataset for the plot. |
void |
handleClick(int x,
int y,
ChartRenderingInfo 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. |
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 background alignment. |
void |
setBackgroundPaint(java.awt.Paint paint)
Sets the background color of the plot area. |
void |
setDataAreaRatio(double ratio)
Sets the data area ratio. |
void |
setDataset(Dataset data)
Sets the primary dataset for the chart, replacing any existing dataset. |
protected void |
setDatasetGroup(DatasetGroup group)
Sets the dataset group. |
void |
setForegroundAlpha(float alpha)
Sets the alpha-transparency for the plot. |
void |
setInsets(java.awt.Insets insets)
Sets the insets for the plot and notifies registered listeners that the plot has been modified. |
void |
setInsets(java.awt.Insets insets,
boolean notify)
Sets the insets for the plot and, if requested, notifies registered listeners that the plot has been modified. |
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 color of the outline of the plot area, and notifies registered listeners that the Plot has been modified. |
void |
setOutlineStroke(java.awt.Stroke stroke)
Sets the pen/brush used to outline the plot area, and notifies registered listeners that the plot has been modified. |
void |
setParent(Plot parent)
Sets the parent plot. |
void |
setSecondaryDataset(Dataset dataset)
Sets the secondary dataset. |
void |
zoom(double percent)
Performs a zoom on the plot. |
Methods inherited from class java.lang.Object |
clone, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
public static final java.lang.Number ZERO
public static final java.awt.Insets 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
Constructor Detail |
protected Plot(Dataset data)
data
- the dataset.Method Detail |
public DatasetGroup getDatasetGroup()
protected void setDatasetGroup(DatasetGroup group)
group
- the dataset group.public Dataset getDataset()
public void setDataset(Dataset data)
The plot is automatically registered with the new dataset, to listen for any changes.
data
- the new dataset (null
permitted).public Dataset getSecondaryDataset()
public void setSecondaryDataset(Dataset dataset)
dataset
- the dataset.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()
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 java.awt.Insets getInsets()
public void setInsets(java.awt.Insets insets)
insets
- the new insets.public void setInsets(java.awt.Insets insets, boolean notify)
insets
- the new insets.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
is forwarded to
all registered listeners.
paint
- the paint (null
permitted).public float getBackgroundAlpha()
public void setBackgroundAlpha(float alpha)
alpha
- the new alpha value.public java.awt.Image getBackgroundImage()
null
).public void setBackgroundImage(java.awt.Image image)
image
- the image (null
permitted).public int getBackgroundImageAlignment()
com.jrefinery.ui.Align
class in the JCommon class library.
public void setBackgroundImageAlignment(int alignment)
Alignment options are defined by the Align
class.
alignment
- the alignment.public java.awt.Stroke getOutlineStroke()
public void setOutlineStroke(java.awt.Stroke stroke)
stroke
- the new outline pen/brush (null permitted).public java.awt.Paint getOutlinePaint()
null).
public void setOutlinePaint(java.awt.Paint paint)
paint
- the new outline paint (null permitted).public float getForegroundAlpha()
public void setForegroundAlpha(float alpha)
alpha
- the new alpha transparency.public LegendItemCollection getLegendItems()
By default, this method returns null
. Subclasses should override to return a
LegendItemCollection
.
public void addChangeListener(PlotChangeListener listener)
listener
- the object to be registered.public void removeChangeListener(PlotChangeListener listener)
listener
- the object to be unregistered.public void notifyListeners(PlotChangeEvent event)
event
- information about the change event.public abstract void draw(java.awt.Graphics2D g2, java.awt.geom.Rectangle2D plotArea, ChartRenderingInfo info)
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. *
g2
- the graphics device.plotArea
- the area within which the plot should be drawn.info
- an object for collecting information about the drawing of the chart.public void drawBackground(java.awt.Graphics2D g2, java.awt.geom.Rectangle2D area)
g2
- the graphics device.area
- the area within which the plot should be drawn.public void drawOutline(java.awt.Graphics2D g2, java.awt.geom.Rectangle2D area)
g2
- the graphics device.area
- the area within which the plot should be drawn.protected void drawNoDataMessage(java.awt.Graphics2D g2, java.awt.geom.Rectangle2D area)
g2
- the graphics device.area
- the area within which the plot should be drawn.public void handleClick(int x, int y, ChartRenderingInfo info)
x
- the x coordinate.y
- the y coordinate.info
- an object for collecting information about the drawing of the chart.public void zoom(double percent)
percent
- the zoom percentage.public void axisChanged(AxisChangeEvent event)
axisChanged
in interface AxisChangeListener
event
- information about the event (not used here).public void datasetChanged(DatasetChangeEvent event)
The plot reacts by passing on a plot change event to all registered listeners.
datasetChanged
in interface DatasetChangeListener
event
- information about the event (not used here).protected double getRectX(double x, double w1, double w2, int location)
x
- the x-value.w1
- width 1.w2
- width 2.location
- the location (left or right).
protected double getRectY(double y, double h1, double h2, int location)
y
- the x-value.h1
- height 1.h2
- height 2.location
- the location (top or bottom).
protected int getOppositeAxisLocation(int location)
location
- the location.
public double getDataAreaRatio()
public void setDataAreaRatio(double ratio)
ratio
- the ratio.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 |