Package org.jfree.chart
Class ChartUtilities
java.lang.Object
org.jfree.chart.ChartUtilities
public abstract class ChartUtilities extends Object
A collection of utility methods for JFreeChart. Includes methods for
converting charts to image formats (PNG and JPEG) plus creating simple HTML
image maps.
-
Constructor Summary
Constructors Constructor Description ChartUtilities() -
Method Summary
Modifier and Type Method Description static byte[]encodeAsPNG(BufferedImage image)Encodes aBufferedImageto PNG format.static byte[]encodeAsPNG(BufferedImage image, boolean encodeAlpha, int compression)Encodes aBufferedImageto PNG format.static StringgetImageMap(String name, ChartRenderingInfo info)Creates an HTML image map.static StringgetImageMap(String name, ChartRenderingInfo info, ToolTipTagFragmentGenerator toolTipTagFragmentGenerator, URLTagFragmentGenerator urlTagFragmentGenerator)Creates an HTML image map.static voidsaveChartAsJPEG(File file, float quality, JFreeChart chart, int width, int height)Saves a chart to a file in JPEG format.static voidsaveChartAsJPEG(File file, float quality, JFreeChart chart, int width, int height, ChartRenderingInfo info)Saves a chart to a file in JPEG format.static voidsaveChartAsJPEG(File file, JFreeChart chart, int width, int height)Saves a chart to a file in JPEG format.static voidsaveChartAsJPEG(File file, JFreeChart chart, int width, int height, ChartRenderingInfo info)Saves a chart to a file in JPEG format.static voidsaveChartAsPNG(File file, JFreeChart chart, int width, int height)Saves a chart to the specified file in PNG format.static voidsaveChartAsPNG(File file, JFreeChart chart, int width, int height, ChartRenderingInfo info)Saves a chart to a file in PNG format.static voidsaveChartAsPNG(File file, JFreeChart chart, int width, int height, ChartRenderingInfo info, boolean encodeAlpha, int compression)Saves a chart to a file in PNG format.static voidwriteBufferedImageAsJPEG(OutputStream out, float quality, BufferedImage image)Writes aBufferedImageto an output stream in JPEG format.static voidwriteBufferedImageAsJPEG(OutputStream out, BufferedImage image)Writes aBufferedImageto an output stream in JPEG format.static voidwriteBufferedImageAsPNG(OutputStream out, BufferedImage image)Writes aBufferedImageto an output stream in PNG format.static voidwriteBufferedImageAsPNG(OutputStream out, BufferedImage image, boolean encodeAlpha, int compression)Writes aBufferedImageto an output stream in PNG format.static voidwriteChartAsJPEG(OutputStream out, float quality, JFreeChart chart, int width, int height)Writes a chart to an output stream in JPEG format.static voidwriteChartAsJPEG(OutputStream out, float quality, JFreeChart chart, int width, int height, ChartRenderingInfo info)Writes a chart to an output stream in JPEG format.static voidwriteChartAsJPEG(OutputStream out, JFreeChart chart, int width, int height)Writes a chart to an output stream in JPEG format.static voidwriteChartAsJPEG(OutputStream out, JFreeChart chart, int width, int height, ChartRenderingInfo info)Writes a chart to an output stream in JPEG format.static voidwriteChartAsPNG(OutputStream out, JFreeChart chart, int width, int height)Writes a chart to an output stream in PNG format.static voidwriteChartAsPNG(OutputStream out, JFreeChart chart, int width, int height, boolean encodeAlpha, int compression)Writes a chart to an output stream in PNG format.static voidwriteChartAsPNG(OutputStream out, JFreeChart chart, int width, int height, ChartRenderingInfo info)Writes a chart to an output stream in PNG format.static voidwriteChartAsPNG(OutputStream out, JFreeChart chart, int width, int height, ChartRenderingInfo info, boolean encodeAlpha, int compression)Writes a chart to an output stream in PNG format.static voidwriteImageMap(PrintWriter writer, String name, ChartRenderingInfo info)Writes an image map to an output stream.static voidwriteImageMap(PrintWriter writer, String name, ChartRenderingInfo info, boolean useOverLibForToolTips)Writes an image map to an output stream.static voidwriteImageMap(PrintWriter writer, String name, ChartRenderingInfo info, ToolTipTagFragmentGenerator toolTipTagFragmentGenerator, URLTagFragmentGenerator urlTagFragmentGenerator)Writes an image map to an output stream.static voidwriteScaledChartAsPNG(OutputStream out, JFreeChart chart, int width, int height, int widthScaleFactor, int heightScaleFactor)Writes a scaled version of a chart to an output stream in PNG format.
-
Constructor Details
-
ChartUtilities
public ChartUtilities()
-
-
Method Details
-
writeChartAsPNG
public static void writeChartAsPNG(OutputStream out, JFreeChart chart, int width, int height) throws IOExceptionWrites a chart to an output stream in PNG format.- Parameters:
out- the output stream (nullnot permitted).chart- the chart (nullnot permitted).width- the image width.height- the image height.- Throws:
IOException- if there are any I/O errors.
-
writeChartAsPNG
public static void writeChartAsPNG(OutputStream out, JFreeChart chart, int width, int height, boolean encodeAlpha, int compression) throws IOExceptionWrites a chart to an output stream in PNG format.- Parameters:
out- the output stream (nullnot permitted).chart- the chart (nullnot permitted).width- the image width.height- the image height.encodeAlpha- encode alpha?compression- the compression level (0-9).- Throws:
IOException- if there are any I/O errors.
-
writeChartAsPNG
public static void writeChartAsPNG(OutputStream out, JFreeChart chart, int width, int height, ChartRenderingInfo info) throws IOExceptionWrites a chart to an output stream in PNG format. This method allows you to pass in aChartRenderingInfoobject, to collect information about the chart dimensions/entities. You will need this info if you want to create an HTML image map.- Parameters:
out- the output stream (nullnot permitted).chart- the chart (nullnot permitted).width- the image width.height- the image height.info- the chart rendering info (nullpermitted).- Throws:
IOException- if there are any I/O errors.
-
writeChartAsPNG
public static void writeChartAsPNG(OutputStream out, JFreeChart chart, int width, int height, ChartRenderingInfo info, boolean encodeAlpha, int compression) throws IOExceptionWrites a chart to an output stream in PNG format. This method allows you to pass in aChartRenderingInfoobject, to collect information about the chart dimensions/entities. You will need this info if you want to create an HTML image map.- Parameters:
out- the output stream (nullnot permitted).chart- the chart (nullnot permitted).width- the image width.height- the image height.info- carries back chart rendering info (nullpermitted).encodeAlpha- encode alpha?compression- the PNG compression level (0-9).- Throws:
IOException- if there are any I/O errors.
-
writeScaledChartAsPNG
public static void writeScaledChartAsPNG(OutputStream out, JFreeChart chart, int width, int height, int widthScaleFactor, int heightScaleFactor) throws IOExceptionWrites a scaled version of a chart to an output stream in PNG format.- Parameters:
out- the output stream (nullnot permitted).chart- the chart (nullnot permitted).width- the unscaled chart width.height- the unscaled chart height.widthScaleFactor- the horizontal scale factor.heightScaleFactor- the vertical scale factor.- Throws:
IOException- if there are any I/O problems.
-
saveChartAsPNG
public static void saveChartAsPNG(File file, JFreeChart chart, int width, int height) throws IOExceptionSaves a chart to the specified file in PNG format.- Parameters:
file- the file name (nullnot permitted).chart- the chart (nullnot permitted).width- the image width.height- the image height.- Throws:
IOException- if there are any I/O errors.
-
saveChartAsPNG
public static void saveChartAsPNG(File file, JFreeChart chart, int width, int height, ChartRenderingInfo info) throws IOExceptionSaves a chart to a file in PNG format. This method allows you to pass in aChartRenderingInfoobject, to collect information about the chart dimensions/entities. You will need this info if you want to create an HTML image map.- Parameters:
file- the file (nullnot permitted).chart- the chart (nullnot permitted).width- the image width.height- the image height.info- the chart rendering info (nullpermitted).- Throws:
IOException- if there are any I/O errors.
-
saveChartAsPNG
public static void saveChartAsPNG(File file, JFreeChart chart, int width, int height, ChartRenderingInfo info, boolean encodeAlpha, int compression) throws IOExceptionSaves a chart to a file in PNG format. This method allows you to pass in aChartRenderingInfoobject, to collect information about the chart dimensions/entities. You will need this info if you want to create an HTML image map.- Parameters:
file- the file (nullnot permitted).chart- the chart (nullnot permitted).width- the image width.height- the image height.info- the chart rendering info (nullpermitted).encodeAlpha- encode alpha?compression- the PNG compression level (0-9).- Throws:
IOException- if there are any I/O errors.
-
writeChartAsJPEG
public static void writeChartAsJPEG(OutputStream out, JFreeChart chart, int width, int height) throws IOExceptionWrites a chart to an output stream in JPEG format.- Parameters:
out- the output stream (nullnot permitted).chart- the chart (nullnot permitted).width- the image width.height- the image height.- Throws:
IOException- if there are any I/O errors.
-
writeChartAsJPEG
public static void writeChartAsJPEG(OutputStream out, float quality, JFreeChart chart, int width, int height) throws IOExceptionWrites a chart to an output stream in JPEG format.- Parameters:
out- the output stream (nullnot permitted).quality- the quality setting.chart- the chart (nullnot permitted).width- the image width.height- the image height.- Throws:
IOException- if there are any I/O errors.
-
writeChartAsJPEG
public static void writeChartAsJPEG(OutputStream out, JFreeChart chart, int width, int height, ChartRenderingInfo info) throws IOExceptionWrites a chart to an output stream in JPEG format. This method allows you to pass in aChartRenderingInfoobject, to collect information about the chart dimensions/entities. You will need this info if you want to create an HTML image map.- Parameters:
out- the output stream (nullnot permitted).chart- the chart (nullnot permitted).width- the image width.height- the image height.info- the chart rendering info (nullpermitted).- Throws:
IOException- if there are any I/O errors.
-
writeChartAsJPEG
public static void writeChartAsJPEG(OutputStream out, float quality, JFreeChart chart, int width, int height, ChartRenderingInfo info) throws IOExceptionWrites a chart to an output stream in JPEG format. This method allows you to pass in aChartRenderingInfoobject, to collect information about the chart dimensions/entities. You will need this info if you want to create an HTML image map.- Parameters:
out- the output stream (nullnot permitted).quality- the output quality (0.0f to 1.0f).chart- the chart (nullnot permitted).width- the image width.height- the image height.info- the chart rendering info (nullpermitted).- Throws:
IOException- if there are any I/O errors.
-
saveChartAsJPEG
public static void saveChartAsJPEG(File file, JFreeChart chart, int width, int height) throws IOExceptionSaves a chart to a file in JPEG format.- Parameters:
file- the file (nullnot permitted).chart- the chart (nullnot permitted).width- the image width.height- the image height.- Throws:
IOException- if there are any I/O errors.
-
saveChartAsJPEG
public static void saveChartAsJPEG(File file, float quality, JFreeChart chart, int width, int height) throws IOExceptionSaves a chart to a file in JPEG format.- Parameters:
file- the file (nullnot permitted).quality- the JPEG quality setting.chart- the chart (nullnot permitted).width- the image width.height- the image height.- Throws:
IOException- if there are any I/O errors.
-
saveChartAsJPEG
public static void saveChartAsJPEG(File file, JFreeChart chart, int width, int height, ChartRenderingInfo info) throws IOExceptionSaves a chart to a file in JPEG format. This method allows you to pass in aChartRenderingInfoobject, to collect information about the chart dimensions/entities. You will need this info if you want to create an HTML image map.- Parameters:
file- the file name (nullnot permitted).chart- the chart (nullnot permitted).width- the image width.height- the image height.info- the chart rendering info (nullpermitted).- Throws:
IOException- if there are any I/O errors.
-
saveChartAsJPEG
public static void saveChartAsJPEG(File file, float quality, JFreeChart chart, int width, int height, ChartRenderingInfo info) throws IOExceptionSaves a chart to a file in JPEG format. This method allows you to pass in aChartRenderingInfoobject, to collect information about the chart dimensions/entities. You will need this info if you want to create an HTML image map.- Parameters:
file- the file name (nullnot permitted).quality- the quality setting.chart- the chart (nullnot permitted).width- the image width.height- the image height.info- the chart rendering info (nullpermitted).- Throws:
IOException- if there are any I/O errors.
-
writeBufferedImageAsJPEG
public static void writeBufferedImageAsJPEG(OutputStream out, BufferedImage image) throws IOExceptionWrites aBufferedImageto an output stream in JPEG format.- Parameters:
out- the output stream (nullnot permitted).image- the image (nullnot permitted).- Throws:
IOException- if there are any I/O errors.
-
writeBufferedImageAsJPEG
public static void writeBufferedImageAsJPEG(OutputStream out, float quality, BufferedImage image) throws IOExceptionWrites aBufferedImageto an output stream in JPEG format.- Parameters:
out- the output stream (nullnot permitted).quality- the image quality (0.0f to 1.0f).image- the image (nullnot permitted).- Throws:
IOException- if there are any I/O errors.
-
writeBufferedImageAsPNG
public static void writeBufferedImageAsPNG(OutputStream out, BufferedImage image) throws IOExceptionWrites aBufferedImageto an output stream in PNG format.- Parameters:
out- the output stream (nullnot permitted).image- the image (nullnot permitted).- Throws:
IOException- if there are any I/O errors.
-
writeBufferedImageAsPNG
public static void writeBufferedImageAsPNG(OutputStream out, BufferedImage image, boolean encodeAlpha, int compression) throws IOExceptionWrites aBufferedImageto an output stream in PNG format.- Parameters:
out- the output stream (nullnot permitted).image- the image (nullnot permitted).encodeAlpha- encode alpha?compression- the compression level (0-9).- Throws:
IOException- if there are any I/O errors.
-
encodeAsPNG
Encodes aBufferedImageto PNG format.- Parameters:
image- the image (nullnot permitted).- Returns:
- a byte array in PNG format.
-
encodeAsPNG
Encodes aBufferedImageto PNG format.- Parameters:
image- the image (nullnot permitted).encodeAlpha- encode alpha?compression- the PNG compression level (0-9).- Returns:
- the byte array in PNG format.
-
writeImageMap
public static void writeImageMap(PrintWriter writer, String name, ChartRenderingInfo info) throws IOExceptionWrites an image map to an output stream.- Parameters:
writer- the writer (nullnot permitted).name- the map name (nullnot permitted).info- the chart rendering info (nullnot permitted).- Throws:
IOException- if there are any I/O errors.
-
writeImageMap
public static void writeImageMap(PrintWriter writer, String name, ChartRenderingInfo info, boolean useOverLibForToolTips) throws IOExceptionWrites an image map to an output stream.- Parameters:
writer- the writer (nullnot permitted).name- the map name (nullnot permitted).info- the chart rendering info (nullnot permitted).useOverLibForToolTips- whether to use OverLIB for tooltips (http://www.bosrup.com/web/overlib/).- Throws:
IOException- if there are any I/O errors.
-
writeImageMap
public static void writeImageMap(PrintWriter writer, String name, ChartRenderingInfo info, ToolTipTagFragmentGenerator toolTipTagFragmentGenerator, URLTagFragmentGenerator urlTagFragmentGenerator) throws IOExceptionWrites an image map to an output stream.- Parameters:
writer- the writer (nullnot permitted).name- the map name (nullnot permitted).info- the chart rendering info (nullnot permitted).toolTipTagFragmentGenerator- the tool tip generator.urlTagFragmentGenerator- the url generator.- Throws:
IOException- if there are any I/O errors.
-
getImageMap
Creates an HTML image map.- Parameters:
name- the map name (nullnot permitted).info- the chart rendering info (nullnot permitted).- Returns:
- the map tag.
-
getImageMap
public static String getImageMap(String name, ChartRenderingInfo info, ToolTipTagFragmentGenerator toolTipTagFragmentGenerator, URLTagFragmentGenerator urlTagFragmentGenerator)Creates an HTML image map.- Parameters:
name- the map name (nullnot permitted).info- the chart rendering info (nullnot permitted).toolTipTagFragmentGenerator- the tool tip generator.urlTagFragmentGenerator- the url generator.- Returns:
- the map tag.
-