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.
hh
| Field Summary | |
|---|---|
| static Image |
The default background image. |
| static int |
The default background image alignment. |
| static float |
The default background image alpha. |
| static Paint |
The default background color. |
| static Font |
The default font for titles. |
| static ProjectInfo |
Information about the project. |
| Constructor Summary |
|---|
|
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. |
| Method Summary | |
|---|---|
| void |
Registers an object for notification of changes to the chart. |
| void |
Adds a legend to the plot and sends a ChartChangeEvent to all registered listeners. |
| void |
Registers an object for notification of progress events relating to the chart. |
| void |
Adds a chart subtitle, and notifies registered listeners that the chart has been modified. |
| void |
Clears all subtitles from the chart and sends a ChartChangeEvent to all registered listeners. |
| Object |
Clones the object, and takes care of listeners. |
| BufferedImage |
Creates and returns a buffered image into which the chart has been drawn. |
| BufferedImage |
Creates and returns a buffered image into which the chart has been drawn. |
| BufferedImage |
Creates and returns a buffered image into which the chart has been drawn. |
| BufferedImage |
Creates and returns a buffered image into which the chart has been drawn. |
| void |
Draws the chart on a Java 2D graphics device (such as the screen or a printer). |
| void |
Draws the chart on a Java 2D graphics device (such as the screen or a printer). |
| void |
Draws the chart on a Java 2D graphics device (such as the screen or a printer). |
| protected EntityCollection |
Draws a title. |
| boolean |
Tests this chart for equality with another object. |
| void |
Sends a default ChartChangeEvent to all registered listeners. |
| boolean |
Returns a flag that indicates whether or not anti-aliasing is used when the chart is drawn. |
| Image |
Returns the background image for the chart, or null if
there is no image.
|
| int |
Returns the background image alignment. |
| float |
Returns the alpha-transparency for the chart's background image. |
| Paint |
Returns the paint used for the chart background. |
| Paint |
Returns the paint used to draw the chart border (if visible). |
| Stroke |
Returns the stroke used to draw the chart border (if visible). |
| CategoryPlot |
Returns the plot cast as a CategoryPlot . |
| LegendTitle |
Returns the legend for the chart, if there is one. |
| LegendTitle |
Returns the nth legend for a chart, or null.
|
| RectangleInsets |
Returns the padding between the chart border and the chart drawing area. |
| Plot |
Returns the plot for the chart. |
| RenderingHints |
Returns the collection of rendering hints for the chart. |
| Title |
Returns a chart subtitle. |
| int |
Returns the number of titles for the chart. |
| List |
Returns the list of subtitles for the chart. |
| TextTitle |
Returns the main chart title. |
| XYPlot |
Returns the plot cast as an XYPlot . |
| void |
Handles a 'click' on the chart. |
| boolean |
Returns a flag that controls whether or not a border is drawn around the outside of the chart. |
| boolean |
Returns a flag that controls whether or not change events are sent to registered listeners. |
| static void |
Prints information about JFreeChart to standard output. |
| protected void |
Sends a ChartChangeEvent to all registered listeners. |
| protected void |
Sends a ChartProgressEvent to all registered listeners. |
| void |
Receives notification that the plot has changed, and passes this on to registered listeners. |
| void |
Deregisters an object for notification of changes to the chart. |
| void |
Removes the first legend in the chart and sends a ChartChangeEvent to all registered listeners. |
| void |
Deregisters an object for notification of changes to the chart. |
| void |
Removes the specified subtitle and sends a ChartChangeEvent to all registered listeners. |
| void |
Sets a flag that indicates whether or not anti-aliasing is used when the chart is drawn. |
| void |
Sets the background image for the chart and sends a ChartChangeEvent to all registered listeners. |
| void |
Sets the background alignment. |
| void |
Sets the alpha-transparency for the chart's background image. |
| void |
Sets the paint used to fill the chart background and sends a ChartChangeEvent to all registered listeners. |
| void |
Sets the paint used to draw the chart border (if visible). |
| void |
Sets the stroke used to draw the chart border (if visible). |
| void |
Sets a flag that controls whether or not a border is drawn around the outside of the chart. |
| void |
Sets a flag that controls whether or not listeners receive ChartChangeEvent notifications. |
| void |
Sets the padding between the chart border and the chart drawing area, and sends a ChartChangeEvent to all registered listeners. |
| void |
Sets the rendering hints for the chart. |
| void |
Sets the title list for the chart (completely replaces any existing titles). |
| void |
Sets the main title for the chart and sends a ChartChangeEvent to all registered listeners. |
| void |
Sets the chart title and sends a ChartChangeEvent to all registered listeners. |
| void |
Receives notification that a chart title has changed, and passes this on to registered listeners. |
| Methods inherited from java.langObject |
|---|
public static
int
DEFAULT_BACKGROUND_IMAGE_ALIGNMENT
createLegend argument specifies whether or not a legend
should be added to the chart.
public
void
clearSubtitles
(
)
public
BufferedImage
createBufferedImage
(
int
width,
int
height,
int
imageType,
ChartRenderingInfo
info
)
public
BufferedImage
createBufferedImage
(
int
imageWidth,
int
imageHeight,
double
drawWidth,
double
drawHeight,
ChartRenderingInfo
info
)
This method is the focus of the entire JFreeChart library.
This method is the focus of the entire JFreeChart library.
public
void
fireChartChanged
(
)
This method is for convenience only.
public
boolean
getAntiAlias
(
)
null if
there is no image.
public
int
getBackgroundImageAlignment
(
)
org.jfree.ui.Align class in the JCommon class
library.
public
float
getBackgroundImageAlpha
(
)
NOTE: if the plot is not an instance of CategoryPlot , then a
ClassCastException is thrown.
null.
public
int
getSubtitleCount
(
)
NOTE: if the plot is not an instance of XYPlot , then a
ClassCastException is thrown.
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).
public
boolean
isBorderVisible
(
)
public
boolean
isNotify
(
)
public
void
removeLegend
(
)
public
void
setAntiAlias
(
boolean
flag
)
Anti-aliasing usually improves the appearance of charts, but is slower.
public
void
setBackgroundImageAlignment
(
int
alignment
)
public
void
setBackgroundImageAlpha
(
float
alpha
)
srhsrty
public
void
setBorderVisible
(
boolean
visible
)
public
void
setNotify
(
boolean
notify
)
null. If you want more than one title on
a chart, use the addSubtitle(Title) method. text is null the chart
title is set to null.