|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object | +--com.jrefinery.chart.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 | |
protected float |
backgroundAlpha
The alpha transparency for the background paint. |
protected java.awt.Image |
backgroundImage
An optional image for the plot background. |
protected java.awt.Paint |
backgroundPaint
An optional color used to fill the plot background. |
protected Dataset |
dataset
The data. |
protected static float |
DEFAULT_BACKGROUND_ALPHA
The default background alpha transparency. |
protected static java.awt.Paint |
DEFAULT_BACKGROUND_PAINT
The default background color. |
protected static float |
DEFAULT_FOREGROUND_ALPHA
The default foreground alpha transparency. |
protected static java.awt.Insets |
DEFAULT_INSETS
The default insets. |
protected static java.awt.Paint |
DEFAULT_OUTLINE_PAINT
The default outline color. |
protected static java.awt.Stroke |
DEFAULT_OUTLINE_STROKE
The default outline stroke. |
protected float |
foregroundAlpha
The alpha-transparency for the plot. |
protected java.awt.Insets |
insets
Amount of blank space around the plot area. |
protected javax.swing.event.EventListenerList |
listenerList
Storage for registered change listeners. |
protected static int |
MINIMUM_HEIGHT_TO_DRAW
The minimum height for the plot, any less space than this and it should not be drawn (not fully implemented. |
protected static int |
MINIMUM_WIDTH_TO_DRAW
The minimum width for the plot, any less space than this and it should not be drawn (not fully implemented). |
protected java.lang.String |
noDataMessage
The message to display if no data is available. |
protected java.awt.Font |
noDataMessageFont
The font used to display the 'no data' message. |
protected java.awt.Paint |
outlinePaint
The Paint used to draw an outline around the plot. |
protected java.awt.Stroke |
outlineStroke
The Stroke used to draw an outline around the plot. |
protected java.awt.Paint[] |
seriesOutlinePaint
Paint objects used to draw the outline of each series in the chart. |
protected java.awt.Stroke[] |
seriesOutlineStroke
Stroke objects used to draw the outline of each series in the chart. |
protected java.awt.Paint[] |
seriesPaint
Paint objects used to color each series in the chart. |
protected java.awt.Stroke[] |
seriesStroke
Stroke objects used to draw each series in the chart. |
protected ShapeFactory |
shapeFactory
Factory for shapes used to represent data points |
static java.lang.Number |
ZERO
Useful constant representing zero. |
Fields inherited from interface com.jrefinery.chart.AxisConstants |
DEFAULT_AXIS_LABEL_FONT, DEFAULT_AXIS_LABEL_INSETS, DEFAULT_AXIS_LABEL_PAINT, DEFAULT_TICK_LABEL_FONT, DEFAULT_TICK_LABEL_INSETS, DEFAULT_TICK_LABEL_PAINT, DEFAULT_TICK_PAINT, DEFAULT_TICK_STROKE |
Constructor Summary | |
protected |
Plot(Dataset data)
Constructs a new plot with the specified axes. |
protected |
Plot(Dataset data,
java.awt.Insets insets,
java.awt.Paint backgroundPaint,
java.awt.Image backgroundImage,
float backgroundAlpha,
java.awt.Stroke outlineStroke,
java.awt.Paint outlinePaint,
float foregroundAlpha)
Constructs 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). |
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 |
drawOutlineAndBackground(java.awt.Graphics2D g2,
java.awt.geom.Rectangle2D area)
Draw the plot outline and background. |
float |
getBackgroundAlpha()
Returns the alpha transparency of the plot area background. |
java.awt.Paint |
getBackgroundPaint()
Returns the background color of the plot area. |
Dataset |
getDataset()
Returns the 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. |
java.util.List |
getLegendItemLabels()
Deprecated. use getLegendItems(). |
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 |
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. |
abstract java.lang.String |
getPlotType()
Returns a short string describing the plot type. |
java.awt.Paint |
getSeriesOutlinePaint(int index)
Returns the Paint used to outline any shapes for the specified series. |
java.awt.Stroke |
getSeriesOutlineStroke(int index)
Returns the Stroke used to outline any shapes for the specified series. |
java.awt.Paint |
getSeriesPaint(int index)
Returns a Paint object used as the main color for a series. |
java.awt.Stroke |
getSeriesStroke(int index)
Returns the Stroke used to draw any shapes for a series. |
java.awt.Shape |
getShape(int series,
int item,
double x,
double y,
double scale)
Returns a Shape that can be used in plotting data. |
java.awt.Shape |
getShape(int series,
java.lang.Object category,
double x,
double y,
double scale)
Returns a Shape that can be used in plotting data. |
ShapeFactory |
getShapeFactory()
Returns the object used to generate shapes for marking data points. |
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 |
setBackgroundPaint(java.awt.Paint paint)
Sets the background color of the plot area, and notifies registered listeners that the plot has been modified. |
void |
setDataset(Dataset data)
Sets the data for the chart, replacing any existing data. |
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 |
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 |
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 |
setSeriesOutlinePaint(java.awt.Paint[] paint)
Sets the paint used to outline any shapes representing series, and notifies registered listeners that the chart has been modified. |
void |
setSeriesOutlineStroke(int index,
java.awt.Stroke stroke)
Sets the stroke used to draw any shapes representing a specific series, and notifies registered listeners that the chart has been modified. |
void |
setSeriesOutlineStroke(java.awt.Stroke[] stroke)
Sets the stroke used to draw any shapes representing series, and notifies registered listeners that the chart has been modified. |
void |
setSeriesPaint(int index,
java.awt.Paint paint)
Sets the paint used to color any shapes representing a specific series, and notifies registered listeners that the plot has been modified. |
void |
setSeriesPaint(java.awt.Paint[] paint)
Sets the paint used to color any shapes representing series, and notifies registered listeners that the plot has been modified. |
void |
setSeriesStroke(int index,
java.awt.Stroke stroke)
Sets the stroke used to draw any shapes representing a specific series, and notifies registered listeners that the chart has been modified. |
void |
setSeriesStroke(java.awt.Stroke[] stroke)
Sets the stroke used to draw any shapes representing series, and notifies registered listeners that the chart has been modified. |
void |
setShapeFactory(ShapeFactory factory)
Sets the object used to generate shapes for marking data points. |
void |
zoom(double percent)
Performs a zoom on the plot. |
Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
public static final java.lang.Number ZERO
protected static final java.awt.Insets DEFAULT_INSETS
protected static final java.awt.Stroke DEFAULT_OUTLINE_STROKE
protected static final java.awt.Paint DEFAULT_OUTLINE_PAINT
protected static final float DEFAULT_FOREGROUND_ALPHA
protected static final float DEFAULT_BACKGROUND_ALPHA
protected static final java.awt.Paint DEFAULT_BACKGROUND_PAINT
protected static final int MINIMUM_WIDTH_TO_DRAW
protected static final int MINIMUM_HEIGHT_TO_DRAW
protected Dataset dataset
protected java.lang.String noDataMessage
protected java.awt.Font noDataMessageFont
protected java.awt.Insets insets
protected java.awt.Stroke outlineStroke
protected java.awt.Paint outlinePaint
protected java.awt.Paint backgroundPaint
protected java.awt.Image backgroundImage
protected float foregroundAlpha
protected float backgroundAlpha
protected java.awt.Paint[] seriesPaint
protected java.awt.Stroke[] seriesStroke
protected java.awt.Paint[] seriesOutlinePaint
protected java.awt.Stroke[] seriesOutlineStroke
protected ShapeFactory shapeFactory
protected javax.swing.event.EventListenerList listenerList
Constructor Detail |
protected Plot(Dataset data)
data
- the dataset.protected Plot(Dataset data, java.awt.Insets insets, java.awt.Paint backgroundPaint, java.awt.Image backgroundImage, float backgroundAlpha, java.awt.Stroke outlineStroke, java.awt.Paint outlinePaint, float foregroundAlpha)
data
- the dataset.insets
- the amount of blank space around the plot area.backgroundPaint
- an optional color for the plot's background.backgroundImage
- an optional image for the plot's background.backgroundAlpha
- alpha-transparency for the plot's background.outlineStroke
- the Stroke used to draw an outline around the plot.outlinePaint
- the color used to draw an outline around the plot.foregroundAlpha
- the alpha-transparency for the plot foreground.Method Detail |
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.public DatasetGroup getDatasetGroup()
protected void setDatasetGroup(DatasetGroup group)
group
- the dataset group.public java.lang.String getNoDataMessage()
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 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 boolean isSubplot()
public java.awt.Insets getInsets()
public void setInsets(java.awt.Insets insets)
insets
- the new insets.public java.awt.Paint getBackgroundPaint()
public void setBackgroundPaint(java.awt.Paint paint)
paint
- the new background color (null permitted).public float getBackgroundAlpha()
public void setBackgroundAlpha(float alpha)
alpha
- the new alpha value.public void setBackgroundImage(java.awt.Image image)
image
- the background image.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()
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 java.util.List getLegendItemLabels()
Most plots will return a list of series names, but there are some plots (e.g. PiePlot) that do not have series so they will return something else.
public LegendItemCollection getLegendItems()
By default, this method returns null. Subclasses should override to return a collection of legend items.
public java.awt.Paint getSeriesPaint(int index)
index
- the series index (zero-based).public void setSeriesPaint(java.awt.Paint[] paint)
paint
- an array of Paint objects used to color series.public void setSeriesPaint(int index, java.awt.Paint paint)
index
- the series (zero-based index).paint
- an array of Paint objects used to color series.public java.awt.Stroke getSeriesStroke(int index)
index
- the series (zero-based index).public void setSeriesStroke(java.awt.Stroke[] stroke)
stroke
- an array of Stroke objects used to draw series.public void setSeriesStroke(int index, java.awt.Stroke stroke)
index
- the series (zero-based index)stroke
- an array of Stroke objects used to draw series.public java.awt.Paint getSeriesOutlinePaint(int index)
index
- the series (zero-based index).public void setSeriesOutlinePaint(java.awt.Paint[] paint)
paint
- an array of Paint objects for drawing the outline of series shapes.public java.awt.Stroke getSeriesOutlineStroke(int index)
index
- the series (zero-based index).public void setSeriesOutlineStroke(java.awt.Stroke[] stroke)
stroke
- an array of Stroke objects.public void setSeriesOutlineStroke(int index, java.awt.Stroke stroke)
index
- the series index (zero-based).stroke
- an array of Stroke objects.public ShapeFactory getShapeFactory()
public void setShapeFactory(ShapeFactory factory)
factory
- the new shape factory.public java.awt.Shape getShape(int series, int item, double x, double y, double scale)
series
- the index of the series.item
- the index of the item.x
- x-coordinate of the item.y
- y-coordinate of the item.scale
- the size.public java.awt.Shape getShape(int series, java.lang.Object category, double x, double y, double scale)
series
- the index of the series.category
- the category.x
- x-coordinate of the category.y
- y-coordinate of the category.scale
- the size.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 drawOutlineAndBackground(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).
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |