java.lang.Object | |
↳ | org.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
(which often includes the chart's legend), a Plot
and a
Dataset
(the plot in turn manages a
domain axis and a range axis).
You should use a ChartPanel
to display a chart in a GUI.
The ChartFactory
class contains static methods for creating
'ready-made' charts.
Constants | |||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|
float | DEFAULT_BACKGROUND_IMAGE_ALPHA | The default background image alpha. |
Fields | |||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|
DEFAULT_BACKGROUND_IMAGE | The default background image. | ||||||||||
DEFAULT_BACKGROUND_IMAGE_ALIGNMENT | The default background image alignment. | ||||||||||
DEFAULT_BACKGROUND_PAINT | The default background color. | ||||||||||
DEFAULT_TITLE_FONT | The default font for titles. | ||||||||||
INFO | Information about the project. |
Public Constructors | |||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|
Creates a new chart based on the supplied plot.
| |||||||||||
Creates a new chart with the given title and plot.
| |||||||||||
Creates a new chart with the given title and plot.
|
Public Methods | |||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|
Registers an object for notification of changes to the chart.
| |||||||||||
Adds a legend to the plot and sends a
ChartChangeEvent to all
registered listeners. | |||||||||||
Registers an object for notification of progress events relating to the
chart.
| |||||||||||
Adds a chart subtitle, and notifies registered listeners that the chart
has been modified.
| |||||||||||
Adds a subtitle at a particular position in the subtitle list, and sends
a
ChartChangeEvent to all registered listeners. | |||||||||||
Clears all subtitles from the chart and sends a
ChartChangeEvent
to all registered listeners. | |||||||||||
Clones the object, and takes care of listeners.
| |||||||||||
Creates and returns a buffered image into which the chart has been drawn.
| |||||||||||
Creates and returns a buffered image into which the chart has been drawn.
| |||||||||||
Creates and returns a buffered image into which the chart has been drawn.
| |||||||||||
Creates and returns a buffered image into which the chart has been drawn.
| |||||||||||
Draws the chart on a Java 2D graphics device (such as the screen or a
printer).
| |||||||||||
Draws the chart on a Java 2D graphics device (such as the screen or a
printer).
| |||||||||||
Draws the chart on a Java 2D graphics device (such as the screen or a
printer).
| |||||||||||
Tests this chart for equality with another object.
| |||||||||||
Sends a default
ChartChangeEvent to all registered listeners. | |||||||||||
Returns a flag that indicates whether or not anti-aliasing is used when
the chart is drawn.
| |||||||||||
Returns the background image for the chart, or
null if
there is no image. | |||||||||||
Returns the background image alignment.
| |||||||||||
Returns the alpha-transparency for the chart's background image.
| |||||||||||
Returns the paint used for the chart background.
| |||||||||||
Returns the paint used to draw the chart border (if visible).
| |||||||||||
Returns the stroke used to draw the chart border (if visible).
| |||||||||||
Returns the plot cast as a
CategoryPlot . | |||||||||||
Returns the legend for the chart, if there is one.
| |||||||||||
Returns the nth legend for a chart, or
null . | |||||||||||
Returns the padding between the chart border and the chart drawing area.
| |||||||||||
Returns the plot for the chart.
| |||||||||||
Returns the collection of rendering hints for the chart.
| |||||||||||
Returns a chart subtitle.
| |||||||||||
Returns the number of titles for the chart.
| |||||||||||
Returns the list of subtitles for the chart.
| |||||||||||
Returns the current value stored in the rendering hints table for
KEY_TEXT_ANTIALIASING . | |||||||||||
Returns the main chart title.
| |||||||||||
Returns the plot cast as an
XYPlot . | |||||||||||
Handles a 'click' on the chart.
| |||||||||||
Returns a flag that controls whether or not a border is drawn around the
outside of the chart.
| |||||||||||
Returns a flag that controls whether or not change events are sent to
registered listeners.
| |||||||||||
Prints information about JFreeChart to standard output.
| |||||||||||
Receives notification that the plot has changed, and passes this on to
registered listeners.
| |||||||||||
Deregisters an object for notification of changes to the chart.
| |||||||||||
Removes the first legend in the chart and sends a
ChartChangeEvent to all registered listeners. | |||||||||||
Deregisters an object for notification of changes to the chart.
| |||||||||||
Removes the specified subtitle and sends a
ChartChangeEvent to
all registered listeners. | |||||||||||
Sets a flag that indicates whether or not anti-aliasing is used when the
chart is drawn.
| |||||||||||
Sets the background image for the chart and sends a
ChartChangeEvent to all registered listeners. | |||||||||||
Sets the background alignment.
| |||||||||||
Sets the alpha-transparency for the chart's background image.
| |||||||||||
Sets the paint used to fill the chart background and sends a
ChartChangeEvent to all registered listeners. | |||||||||||
Sets the paint used to draw the chart border (if visible).
| |||||||||||
Sets the stroke used to draw the chart border (if visible).
| |||||||||||
Sets a flag that controls whether or not a border is drawn around the
outside of the chart.
| |||||||||||
Sets a flag that controls whether or not listeners receive
ChartChangeEvent notifications. | |||||||||||
Sets the padding between the chart border and the chart drawing area,
and sends a
ChartChangeEvent to all registered listeners. | |||||||||||
Sets the rendering hints for the chart.
| |||||||||||
Sets the title list for the chart (completely replaces any existing
titles) and sends a
ChartChangeEvent to all registered
listeners. | |||||||||||
Sets the value in the rendering hints table for
KEY_TEXT_ANTIALIASING to either
VALUE_TEXT_ANTIALIAS_ON or
VALUE_TEXT_ANTIALIAS_OFF , then sends a
ChartChangeEvent to all registered listeners. | |||||||||||
Sets the value in the rendering hints table for
KEY_TEXT_ANTIALIASING and sends a
ChartChangeEvent to all registered listeners. | |||||||||||
Sets the chart title and sends a
ChartChangeEvent to all
registered listeners. | |||||||||||
Sets the main title for the chart and sends a
ChartChangeEvent
to all registered listeners. | |||||||||||
Receives notification that a chart title has changed, and passes this
on to registered listeners.
|
Protected Methods | |||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|
Draws a title.
| |||||||||||
Sends a
ChartProgressEvent to all registered listeners. | |||||||||||
Sends a
ChartChangeEvent to all registered listeners. |
[Expand]
Inherited Methods | |||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|
![]() | |||||||||||
![]() | |||||||||||
![]() |
The default background image alpha.
The default background image alignment.
Information about the project.
Creates a new chart based on the supplied plot. The chart will have
a legend added automatically, but no title (although you can easily add
one later).
Note that the ChartFactory
class contains a range
of static methods that will return ready-made charts, and often this
is a more convenient way to create charts than using this constructor.
plot | the plot (null not permitted).
|
---|
Creates a new chart with the given title and plot. A default font
(DEFAULT_TITLE_FONT
) is used for the title, and the chart will
have a legend added automatically.
Note that the ChartFactory
class contains a range
of static methods that will return ready-made charts, and often this
is a more convenient way to create charts than using this constructor.
title | the chart title (null permitted). |
---|---|
plot | the plot (null not permitted).
|
Creates a new chart with the given title and plot. The
createLegend
argument specifies whether or not a legend
should be added to the chart.
Note that the ChartFactory
class contains a range
of static methods that will return ready-made charts, and often this
is a more convenient way to create charts than using this constructor.
title | the chart title (null permitted). |
---|---|
titleFont | the font for displaying the chart title
(null permitted). |
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. |
Registers an object for notification of changes to the chart.
listener | the listener (null not permitted). |
---|
Adds a legend to the plot and sends a ChartChangeEvent
to all
registered listeners.
legend | the legend (null not permitted). |
---|
Registers an object for notification of progress events relating to the chart.
listener | the object being registered. |
---|
Adds a chart subtitle, and notifies registered listeners that the chart has been modified.
subtitle | the subtitle (null not permitted). |
---|
Adds a subtitle at a particular position in the subtitle list, and sends
a ChartChangeEvent
to all registered listeners.
index | the index (in the range 0 to getSubtitleCount() ). |
---|---|
subtitle | the subtitle to add (null not permitted). |
Clears all subtitles from the chart and sends a ChartChangeEvent
to all registered listeners.
Clones the object, and takes care of listeners. Note: caller shall register its own listeners on cloned graph.
CloneNotSupportedException | if the chart is not cloneable. |
---|
Creates and returns a buffered image into which the chart has been drawn.
width | the width. |
---|---|
height | the height. |
imageType | the image type. |
info | carries back chart state information (null
permitted). |
Creates and returns a buffered image into which the chart has been drawn.
width | the width. |
---|---|
height | the height. |
Creates and returns a buffered image into which the chart has been drawn.
width | the width. |
---|---|
height | the height. |
info | carries back chart state information (null
permitted). |
Creates and returns a buffered image into which the chart has been drawn.
imageWidth | the image width. |
---|---|
imageHeight | the image height. |
drawWidth | the width for drawing the chart (will be scaled to fit image). |
drawHeight | the height for drawing the chart (will be scaled to fit image). |
info | optional object for collection chart dimension and entity information. |
Draws the chart on a Java 2D graphics device (such as the screen or a printer).
This method is the focus of the entire JFreeChart library.
g2 | the graphics device. |
---|---|
area | the area within which the chart should be drawn. |
Draws the chart on a Java 2D graphics device (such as the screen or a printer). 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). |
Draws the chart on a Java 2D graphics device (such as the screen or a printer).
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). |
Tests this chart for equality with another object.
obj | the object (null permitted). |
---|
Sends a default ChartChangeEvent
to all registered listeners.
This method is for convenience only.
Returns a flag that indicates whether or not anti-aliasing is used when the chart is drawn.
Returns the background image for the chart, or null
if
there is no image.
null
).Returns the background image alignment. Alignment constants are defined
in the org.jfree.ui.Align
class in the JCommon class
library.
Returns the alpha-transparency for the chart's background image.
Returns the paint used for the chart background.
null
).Returns the paint used to draw the chart border (if visible).
Returns the stroke used to draw the chart border (if visible).
Returns the plot cast as a CategoryPlot
.
NOTE: if the plot is not an instance of CategoryPlot
, then a
ClassCastException
is thrown.
Returns the legend for the chart, if there is one. Note that a chart can have more than one legend - this method returns the first.
null
).Returns the nth legend for a chart, or null
.
index | the legend index (zero-based). |
---|
null
).Returns the padding between the chart border and the chart drawing area.
null
).Returns the plot for the chart. The plot is a class responsible for coordinating the visual representation of the data, including the axes (if any).
Returns the collection of rendering hints for the chart.
null
).Returns a chart subtitle.
index | the index of the chart subtitle (zero based). |
---|
Returns the number of titles for the chart.
Returns the list of subtitles for the chart.
null
).Returns the current value stored in the rendering hints table for
KEY_TEXT_ANTIALIASING
.
null
).Returns the main chart title. Very often a chart will have just one
title, so we make this case simple by providing accessor methods for
the main title. However, multiple titles are supported - see the
addSubtitle(Title)
method.
null
).Handles a 'click' on the chart. JFreeChart is not a UI component, so
some other object (for example, 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.
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
(null not permitted).
|
Returns a flag that controls whether or not a border is drawn around the outside of the chart.
Returns a flag that controls whether or not change events are sent to registered listeners.
Prints information about JFreeChart to standard output.
args | no arguments are honored. |
---|
Receives notification that the plot has changed, and passes this on to registered listeners.
event | information about the plot change. |
---|
Deregisters an object for notification of changes to the chart.
listener | the listener (null not permitted) |
---|
Removes the first legend in the chart and sends a
ChartChangeEvent
to all registered listeners.
Deregisters an object for notification of changes to the chart.
listener | the object being deregistered. |
---|
Removes the specified subtitle and sends a ChartChangeEvent
to
all registered listeners.
title | the title. |
---|
Sets a flag that indicates whether or not anti-aliasing is used when the chart is drawn.
Anti-aliasing usually improves the appearance of charts, but is slower.
flag | the new value of the flag. |
---|
Sets the background image for the chart and sends a
ChartChangeEvent
to all registered listeners.
image | the image (null permitted). |
---|
Sets the background alignment. Alignment options are defined by the org.jfree.ui.Align class.
alignment | the alignment. |
---|
Sets the alpha-transparency for the chart's background image. Registered listeners are notified that the chart has been changed.
alpha | the alpha value. |
---|
Sets the paint used to fill the chart background and sends a
ChartChangeEvent
to all registered listeners.
paint | the paint (null permitted). |
---|
Sets the paint used to draw the chart border (if visible).
paint | the paint. |
---|
Sets the stroke used to draw the chart border (if visible).
stroke | the stroke. |
---|
Sets a flag that controls whether or not a border is drawn around the outside of the chart.
visible | the flag. |
---|
Sets a flag that controls whether or not listeners receive
ChartChangeEvent
notifications.
notify | a boolean. |
---|
Sets the padding between the chart border and the chart drawing area,
and sends a ChartChangeEvent
to all registered listeners.
padding | the padding (null not permitted). |
---|
Sets the rendering hints for the chart. These will be added (using the Graphics2D.addRenderingHints() method) near the start of the JFreeChart.draw() method.
renderingHints | the rendering hints (null not
permitted). |
---|
Sets the title list for the chart (completely replaces any existing
titles) and sends a ChartChangeEvent
to all registered
listeners.
subtitles | the new list of subtitles (null not
permitted). |
---|
Sets the value in the rendering hints table for
KEY_TEXT_ANTIALIASING
to either
VALUE_TEXT_ANTIALIAS_ON
or
VALUE_TEXT_ANTIALIAS_OFF
, then sends a
ChartChangeEvent
to all registered listeners.
flag | the new value of the flag. |
---|
Sets the value in the rendering hints table for
KEY_TEXT_ANTIALIASING
and sends a
ChartChangeEvent
to all registered listeners.
val | the new value (null permitted). |
---|
Sets the chart title and sends a ChartChangeEvent
to all
registered listeners. This is a convenience method that ends up calling
the setTitle(TextTitle)
method. If there is an existing title,
its text is updated, otherwise a new title using the default font is
added to the chart. If text
is null
the chart
title is set to null
.
text | the title text (null permitted). |
---|
Sets the main title for the chart and sends a ChartChangeEvent
to all registered listeners. If you do not want a title for the
chart, set it to null
. If you want more than one title on
a chart, use the addSubtitle(Title)
method.
title | the title (null permitted). |
---|
Receives notification that a chart title has changed, and passes this on to registered listeners.
event | information about the chart title change. |
---|
Draws a title. The title should be drawn at the top, bottom, left or right of the specified area, and the area should be updated to reflect the amount of space used by the title.
t | the title (null not permitted). |
---|---|
g2 | the graphics device (null not permitted). |
area | the chart area, excluding any existing titles
(null not permitted). |
entities | a flag that controls whether or not an entity collection is returned for the title. |
null
).
Sends a ChartProgressEvent
to all registered listeners.
event | information about the event that triggered the notification. |
---|
Sends a ChartChangeEvent
to all registered listeners.
event | information about the event that triggered the notification. |
---|