|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectorg.jfree.chart.JFreeChart
A chart class implemented using the Java 2D APIs. The current version supports bar charts, line charts, pie charts and xy plots (including time series data).
JFreeChart coordinates several objects to achieve its aim of being able to
draw a chart on a Java 2D graphics device: a list of Title
objects, a
Legend
, a Plot
and a Dataset
(the plot in
turn manages a horizontal axis and a vertical axis).
You should use a ChartPanel
to display a chart in a GUI.
The ChartFactory
class contains static methods for creating 'ready-made' charts.
ChartPanel
,
ChartFactory
,
Title
,
Legend
,
Plot
,
Serialized FormField Summary | |
static org.jfree.ui.about.ProjectInfo |
INFO
Information about the project. |
java.awt.RenderingHints |
renderingHints
Rendering hints that will be used for chart drawing. |
Fields inherited from interface org.jfree.chart.JFreeChartConstants |
DEFAULT_BACKGROUND_IMAGE, DEFAULT_BACKGROUND_IMAGE_ALIGNMENT, DEFAULT_BACKGROUND_IMAGE_ALPHA, DEFAULT_BACKGROUND_PAINT, DEFAULT_TITLE_FONT |
Constructor Summary | |
JFreeChart(Plot plot)
Constructs a chart. |
|
JFreeChart(java.lang.String title,
java.awt.Font titleFont,
Plot plot,
boolean createLegend)
Constructs a chart. |
|
JFreeChart(java.lang.String title,
Plot plot)
Creates a new chart. |
Method Summary | |
void |
addChangeListener(ChartChangeListener listener)
Registers an object for notification of changes to the chart. |
void |
addProgressListener(ChartProgressListener listener)
Registers an object for notification of progress events relating to the chart. |
void |
addSubtitle(Title subtitle)
Adds a chart subtitle, and notifies registered listeners that the chart has been modified. |
java.lang.Object |
clone()
Clones the object, and takes care of listeners. |
java.awt.image.BufferedImage |
createBufferedImage(int width,
int height)
Creates and returns a buffered image into which the chart has been drawn. |
java.awt.image.BufferedImage |
createBufferedImage(int width,
int height,
ChartRenderingInfo info)
Creates and returns a buffered image into which the chart has been drawn. |
void |
draw(java.awt.Graphics2D g2,
java.awt.geom.Rectangle2D area)
Draws the chart on a Java 2D graphics device (such as the screen or a printer). |
void |
draw(java.awt.Graphics2D g2,
java.awt.geom.Rectangle2D area,
ChartRenderingInfo info)
Draws the chart on a Java 2D graphics device (such as the screen or a printer). |
void |
draw(java.awt.Graphics2D g2,
java.awt.geom.Rectangle2D chartArea,
java.awt.geom.Point2D anchor,
ChartRenderingInfo info)
Draws the chart on a Java 2D graphics device (such as the screen or a printer). |
void |
drawTitle(Title title,
java.awt.Graphics2D g2,
java.awt.geom.Rectangle2D area)
Draws a title. |
boolean |
equals(java.lang.Object obj)
Tests this chart for equality with another object. |
void |
fireChartChanged()
Sends a default ChartChangeEvent to all registered listeners. |
boolean |
getAntiAlias()
Returns a flag that indicates whether or not anti-aliasing is used when the chart is drawn. |
java.awt.Image |
getBackgroundImage()
Returns the chart's background image (possibly null). |
int |
getBackgroundImageAlignment()
Returns the background image alignment. |
float |
getBackgroundImageAlpha()
Returns the alpha-transparency for the chart's background image. |
java.awt.Paint |
getBackgroundPaint()
Returns the color/shade used to fill the chart background. |
java.awt.Paint |
getBorderPaint()
Returns the paint used to draw the chart border (if visible). |
java.awt.Stroke |
getBorderStroke()
Returns the stroke used to draw the chart border (if visible). |
CategoryPlot |
getCategoryPlot()
Returns the plot cast as a CategoryPlot . |
Legend |
getLegend()
Returns the chart legend. |
Plot |
getPlot()
Returns the plot for the chart. |
java.awt.RenderingHints |
getRenderingHints()
Returns the collection of rendering hints for the chart. |
Title |
getSubtitle(int index)
Returns a chart subtitle. |
int |
getSubtitleCount()
Returns the number of titles for the chart. |
java.util.List |
getSubtitles()
Returns the list of subtitles. |
boolean |
getSuppressChartChangeEvents()
Deprecated. Use isNotify() instead. |
TextTitle |
getTitle()
Returns the chart title. |
XYPlot |
getXYPlot()
Returns the plot cast as an XYPlot . |
void |
handleClick(int x,
int y,
ChartRenderingInfo info)
Handles a 'click' on the chart. |
boolean |
isBorderVisible()
Returns a flag that controls whether or not a border is drawn around the outside of the chart. |
boolean |
isNotify()
Returns a flag that controls whether or not change events are sent to registered listeners. |
void |
legendChanged(LegendChangeEvent event)
Receives notification that the chart legend has changed, and passes this on to registered listeners. |
static void |
main(java.lang.String[] args)
Prints information about JFreeChart to standard output. |
protected void |
notifyListeners(ChartChangeEvent event)
Sends a ChartChangeEvent to all registered listeners. |
protected void |
notifyListeners(ChartProgressEvent event)
Sends a ChartProgressEvent to all registered listeners. |
void |
plotChanged(PlotChangeEvent event)
Receives notification that the plot has changed, and passes this on to registered listeners. |
void |
removeChangeListener(ChartChangeListener listener)
Deregisters an object for notification of changes to the chart. |
void |
removeProgressListener(ChartProgressListener listener)
Deregisters an object for notification of changes to the chart. |
void |
setAntiAlias(boolean flag)
Sets a flag that indicates whether or not anti-aliasing is used when the chart is drawn. |
void |
setBackgroundImage(java.awt.Image image)
Sets the chart's background image (null permitted). |
void |
setBackgroundImageAlignment(int alignment)
Sets the background alignment. |
void |
setBackgroundImageAlpha(float alpha)
Sets the alpha-transparency for the chart's background image. |
void |
setBackgroundPaint(java.awt.Paint paint)
Sets the color/shade used to fill the chart background. |
void |
setBorderPaint(java.awt.Paint paint)
Sets the paint used to draw the chart border (if visible). |
void |
setBorderStroke(java.awt.Stroke stroke)
Sets the stroke used to draw the chart border (if visible). |
void |
setBorderVisible(boolean visible)
Sets a flag that controls whether or not a border is drawn around the outside of the chart. |
void |
setLegend(Legend legend)
Sets the chart legend. |
void |
setNotify(boolean notify)
Sets a flag that controls whether or not listeners receive ChartChangeEvent
notifications. |
void |
setRenderingHints(java.awt.RenderingHints renderingHints)
Sets the rendering hints for the chart. |
void |
setSubtitles(java.util.List subtitles)
Sets the title list for the chart (completely replaces any existing titles). |
void |
setSuppressChartChangeEvents(boolean flag)
Deprecated. Use setNotify(boolean) instead. |
void |
setTitle(java.lang.String title)
Sets the chart title. |
void |
setTitle(TextTitle title)
Sets the title for the chart. |
void |
titleChanged(TitleChangeEvent event)
Receives notification that a chart title has changed, and passes this on to registered listeners. |
Methods inherited from class java.lang.Object |
finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
public static final org.jfree.ui.about.ProjectInfo INFO
public transient java.awt.RenderingHints renderingHints
Constructor Detail |
public JFreeChart(Plot plot)
Note that the ChartFactory
class contains static methods that will
return a ready-made chart.
plot
- controller of the visual representation of the data (null
not
permitted).public JFreeChart(java.lang.String title, Plot plot)
title
- the chart title.plot
- the plot (null
not permitted).public JFreeChart(java.lang.String title, java.awt.Font titleFont, Plot plot, boolean createLegend)
Note that the ChartFactory class contains static methods that will return a ready-made chart.
title
- the main chart title.titleFont
- the font for displaying the chart title.plot
- controller of the visual representation of the data (null
not
permitted).createLegend
- a flag indicating whether or not a legend should
be created for the chart.Method Detail |
public java.awt.RenderingHints getRenderingHints()
public void setRenderingHints(java.awt.RenderingHints renderingHints)
renderingHints
- the rendering hints (null
not permitted).public boolean isBorderVisible()
public void setBorderVisible(boolean visible)
visible
- the flag.public java.awt.Stroke getBorderStroke()
public void setBorderStroke(java.awt.Stroke stroke)
stroke
- the stroke.public java.awt.Paint getBorderPaint()
public void setBorderPaint(java.awt.Paint paint)
paint
- the paint.public TextTitle getTitle()
public void setTitle(TextTitle title)
title
- the new title (null
permitted).public void setTitle(java.lang.String title)
title
- the new title (null
permitted).public java.util.List getSubtitles()
public void setSubtitles(java.util.List subtitles)
subtitles
- the new list of subtitles.public int getSubtitleCount()
public Title getSubtitle(int index)
index
- the index of the chart subtitle (zero based).
public void addSubtitle(Title subtitle)
subtitle
- the subtitle.public Legend getLegend()
null
).public void setLegend(Legend legend)
legend
- the new chart legend (null permitted).public Plot getPlot()
public CategoryPlot getCategoryPlot()
CategoryPlot
.
NOTE: if the plot is not an instance of CategoryPlot
, then a
ClassCastException
is thrown.
public XYPlot getXYPlot()
XYPlot
.
NOTE: if the plot is not an instance of XYPlot
, then a
ClassCastException
is thrown.
public boolean getAntiAlias()
public void setAntiAlias(boolean flag)
Anti-aliasing usually improves the appearance of charts, but is slower.
flag
- the new value of the flag.public java.awt.Paint getBackgroundPaint()
public void setBackgroundPaint(java.awt.Paint paint)
paint
- the new background color/shade.public java.awt.Image getBackgroundImage()
public void setBackgroundImage(java.awt.Image image)
image
- the image.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 float getBackgroundImageAlpha()
public void setBackgroundImageAlpha(float alpha)
alpha
- the alpha value.public boolean isNotify()
true
or false
.public void setNotify(boolean notify)
ChartChangeEvent
notifications.
notify
- a boolean.public void draw(java.awt.Graphics2D g2, java.awt.geom.Rectangle2D area)
This method is the focus of the entire JFreeChart library.
draw
in interface org.jfree.ui.Drawable
g2
- the graphics device.area
- the area within which the chart should be drawn.public void draw(java.awt.Graphics2D g2, java.awt.geom.Rectangle2D area, ChartRenderingInfo info)
This method is the focus of the entire JFreeChart library.
g2
- the graphics device.area
- the area within which the chart should be drawn.info
- records info about the drawing (null means collect no info).public void draw(java.awt.Graphics2D g2, java.awt.geom.Rectangle2D chartArea, java.awt.geom.Point2D anchor, ChartRenderingInfo info)
This method is the focus of the entire JFreeChart library.
g2
- the graphics device.chartArea
- the area within which the chart should be drawn.anchor
- the anchor point (in Java2D space) for the chart (null
permitted).info
- records info about the drawing (null means collect no info).public void drawTitle(Title title, java.awt.Graphics2D g2, java.awt.geom.Rectangle2D area)
title
- the title.g2
- the graphics device.area
- the area that should contain the title.public java.awt.image.BufferedImage createBufferedImage(int width, int height)
width
- the width.height
- the height.
public java.awt.image.BufferedImage createBufferedImage(int width, int height, ChartRenderingInfo info)
width
- the width.height
- the height.info
- optional object for collection chart dimension and entity information.
public void handleClick(int x, int y, ChartRenderingInfo info)
JFreeChart is not a UI component, so some other object (e.g. ChartPanel) needs to capture the click event and pass it onto the JFreeChart object. If you are not using JFreeChart in a client application, then this method is not required (and hopefully it doesn't get in the way).
x
- x-coordinate of the click (in Java2D space).y
- y-coordinate of the click (in Java2D space).info
- contains chart dimension and entity information.public void addChangeListener(ChartChangeListener listener)
listener
- the object being registered.public void removeChangeListener(ChartChangeListener listener)
listener
- the object being deregistered.public void fireChartChanged()
ChartChangeEvent
to all registered listeners.
This method is for convenience only.
protected void notifyListeners(ChartChangeEvent event)
ChartChangeEvent
to all registered listeners.
event
- information about the event that triggered the notification.public void addProgressListener(ChartProgressListener listener)
listener
- the object being registered.public void removeProgressListener(ChartProgressListener listener)
listener
- the object being deregistered.protected void notifyListeners(ChartProgressEvent event)
ChartProgressEvent
to all registered listeners.
event
- information about the event that triggered the notification.public void titleChanged(TitleChangeEvent event)
titleChanged
in interface TitleChangeListener
event
- information about the chart title change.public void legendChanged(LegendChangeEvent event)
legendChanged
in interface LegendChangeListener
event
- information about the chart legend change.public void plotChanged(PlotChangeEvent event)
plotChanged
in interface PlotChangeListener
event
- information about the plot change.public boolean equals(java.lang.Object obj)
obj
- the object.
true
or false
.public static void main(java.lang.String[] args)
args
- no arguments are honored.public boolean getSuppressChartChangeEvents()
public void setSuppressChartChangeEvents(boolean flag)
flag
- the flag.public java.lang.Object clone() throws java.lang.CloneNotSupportedException
java.lang.CloneNotSupportedException
- if the chart is not cloneable.
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |