A collection of utility methods for JFreeChart. Includes methods for
converting charts to image formats (PNG and JPEG) plus creating simple HTML
image maps.
encodeAsPNG
public static byte[] encodeAsPNG(BufferedImage image)
throws IOException
Encodes a BufferedImage
to PNG format.
image
- the image (null
not permitted).
- A byte array in PNG format.
encodeAsPNG
public static byte[] encodeAsPNG(BufferedImage image,
boolean encodeAlpha,
int compression)
throws IOException
Encodes a BufferedImage
to PNG format.
image
- the image (null
not permitted).encodeAlpha
- encode alpha?compression
- the PNG compression level (0-9).
- The byte array in PNG format.
getImageMap
public static String getImageMap(String name,
ChartRenderingInfo info)
Creates an HTML image map.
name
- the map name (null
not permitted).info
- the chart rendering info (null
not permitted).
getImageMap
public static String getImageMap(String name,
ChartRenderingInfo info,
ToolTipTagFragmentGenerator toolTipTagFragmentGenerator,
URLTagFragmentGenerator urlTagFragmentGenerator)
Creates an HTML image map.
name
- the map name (null
not permitted).info
- the chart rendering info (null
not permitted).toolTipTagFragmentGenerator
- the tool tip generator.urlTagFragmentGenerator
- the url generator.
saveChartAsJPEG
public static void saveChartAsJPEG(File file,
float quality,
JFreeChart chart,
int width,
int height)
throws IOException
Saves a chart to a file in JPEG format.
file
- the file (null
not permitted).quality
- the JPEG quality setting.chart
- the chart (null
not permitted).width
- the image width.height
- the image height.
saveChartAsJPEG
public static void saveChartAsJPEG(File file,
float quality,
JFreeChart chart,
int width,
int height,
ChartRenderingInfo info)
throws IOException
Saves a chart to a file in JPEG format. This method allows you to pass
in a
ChartRenderingInfo
object, to collect information about the
chart dimensions/entities. You will need this info if you want to
create an HTML image map.
file
- the file name (null
not permitted).quality
- the quality setting.chart
- the chart (null
not permitted).width
- the image width.height
- the image height.info
- the chart rendering info (null
permitted).
saveChartAsJPEG
public static void saveChartAsJPEG(File file,
JFreeChart chart,
int width,
int height)
throws IOException
Saves a chart to a file in JPEG format.
file
- the file (null
not permitted).chart
- the chart (null
not permitted).width
- the image width.height
- the image height.
saveChartAsJPEG
public static void saveChartAsJPEG(File file,
JFreeChart chart,
int width,
int height,
ChartRenderingInfo info)
throws IOException
Saves a chart to a file in JPEG format. This method allows you to pass
in a
ChartRenderingInfo
object, to collect information about the
chart dimensions/entities. You will need this info if you want to
create an HTML image map.
file
- the file name (null
not permitted).chart
- the chart (null
not permitted).width
- the image width.height
- the image height.info
- the chart rendering info (null
permitted).
saveChartAsPNG
public static void saveChartAsPNG(File file,
JFreeChart chart,
int width,
int height)
throws IOException
Saves a chart to the specified file in PNG format.
file
- the file name (null
not permitted).chart
- the chart (null
not permitted).width
- the image width.height
- the image height.
saveChartAsPNG
public static void saveChartAsPNG(File file,
JFreeChart chart,
int width,
int height,
ChartRenderingInfo info)
throws IOException
Saves a chart to a file in PNG format. This method allows you to pass
in a
ChartRenderingInfo
object, to collect information about the
chart dimensions/entities. You will need this info if you want to
create an HTML image map.
file
- the file (null
not permitted).chart
- the chart (null
not permitted).width
- the image width.height
- the image height.info
- the chart rendering info (null
permitted).
saveChartAsPNG
public static void saveChartAsPNG(File file,
JFreeChart chart,
int width,
int height,
ChartRenderingInfo info,
boolean encodeAlpha,
int compression)
throws IOException
Saves a chart to a file in PNG format. This method allows you to pass
in a
ChartRenderingInfo
object, to collect information about the
chart dimensions/entities. You will need this info if you want to
create an HTML image map.
file
- the file (null
not permitted).chart
- the chart (null
not permitted).width
- the image width.height
- the image height.info
- the chart rendering info (null
permitted).encodeAlpha
- encode alpha?compression
- the PNG compression level (0-9).
writeBufferedImageAsJPEG
public static void writeBufferedImageAsJPEG(OutputStream out,
BufferedImage image)
throws IOException
Writes a BufferedImage
to an output stream in JPEG format.
out
- the output stream (null
not permitted).image
- the image (null
not permitted).
writeBufferedImageAsJPEG
public static void writeBufferedImageAsJPEG(OutputStream out,
float quality,
BufferedImage image)
throws IOException
Writes a BufferedImage
to an output stream in JPEG format.
out
- the output stream (null
not permitted).quality
- the image quality (0.0f to 1.0f).image
- the image (null
not permitted).
writeBufferedImageAsPNG
public static void writeBufferedImageAsPNG(OutputStream out,
BufferedImage image)
throws IOException
Writes a BufferedImage
to an output stream in PNG format.
out
- the output stream (null
not permitted).image
- the image (null
not permitted).
writeBufferedImageAsPNG
public static void writeBufferedImageAsPNG(OutputStream out,
BufferedImage image,
boolean encodeAlpha,
int compression)
throws IOException
Writes a BufferedImage
to an output stream in PNG format.
out
- the output stream (null
not permitted).image
- the image (null
not permitted).encodeAlpha
- encode alpha?compression
- the compression level (0-9).
writeChartAsJPEG
public static void writeChartAsJPEG(OutputStream out,
float quality,
JFreeChart chart,
int width,
int height)
throws IOException
Writes a chart to an output stream in JPEG format. Please note that
JPEG is a poor format for chart images, use PNG if possible.
out
- the output stream (null
not permitted).quality
- the quality setting.chart
- the chart (null
not permitted).width
- the image width.height
- the image height.
writeChartAsJPEG
public static void writeChartAsJPEG(OutputStream out,
float quality,
JFreeChart chart,
int width,
int height,
ChartRenderingInfo info)
throws IOException
Writes a chart to an output stream in JPEG format. This method allows
you to pass in a
ChartRenderingInfo
object, to collect
information about the chart dimensions/entities. You will need this
info if you want to create an HTML image map.
out
- the output stream (null
not permitted).quality
- the output quality (0.0f to 1.0f).chart
- the chart (null
not permitted).width
- the image width.height
- the image height.info
- the chart rendering info (null
permitted).
writeChartAsJPEG
public static void writeChartAsJPEG(OutputStream out,
JFreeChart chart,
int width,
int height)
throws IOException
Writes a chart to an output stream in JPEG format. Please note that
JPEG is a poor format for chart images, use PNG if possible.
out
- the output stream (null
not permitted).chart
- the chart (null
not permitted).width
- the image width.height
- the image height.
writeChartAsJPEG
public static void writeChartAsJPEG(OutputStream out,
JFreeChart chart,
int width,
int height,
ChartRenderingInfo info)
throws IOException
Writes a chart to an output stream in JPEG format. This method allows
you to pass in a
ChartRenderingInfo
object, to collect
information about the chart dimensions/entities. You will need this
info if you want to create an HTML image map.
out
- the output stream (null
not permitted).chart
- the chart (null
not permitted).width
- the image width.height
- the image height.info
- the chart rendering info (null
permitted).
writeChartAsPNG
public static void writeChartAsPNG(OutputStream out,
JFreeChart chart,
int width,
int height)
throws IOException
Writes a chart to an output stream in PNG format.
out
- the output stream (null
not permitted).chart
- the chart (null
not permitted).width
- the image width.height
- the image height.
writeChartAsPNG
public static void writeChartAsPNG(OutputStream out,
JFreeChart chart,
int width,
int height,
boolean encodeAlpha,
int compression)
throws IOException
Writes a chart to an output stream in PNG format.
out
- the output stream (null
not permitted).chart
- the chart (null
not permitted).width
- the image width.height
- the image height.encodeAlpha
- encode alpha?compression
- the compression level (0-9).
writeChartAsPNG
public static void writeChartAsPNG(OutputStream out,
JFreeChart chart,
int width,
int height,
ChartRenderingInfo info)
throws IOException
Writes a chart to an output stream in PNG format. This method allows
you to pass in a
ChartRenderingInfo
object, to collect
information about the chart dimensions/entities. You will need this
info if you want to create an HTML image map.
out
- the output stream (null
not permitted).chart
- the chart (null
not permitted).width
- the image width.height
- the image height.info
- the chart rendering info (null
permitted).
writeChartAsPNG
public static void writeChartAsPNG(OutputStream out,
JFreeChart chart,
int width,
int height,
ChartRenderingInfo info,
boolean encodeAlpha,
int compression)
throws IOException
Writes a chart to an output stream in PNG format. This method allows
you to pass in a
ChartRenderingInfo
object, to collect
information about the chart dimensions/entities. You will need this
info if you want to create an HTML image map.
out
- the output stream (null
not permitted).chart
- the chart (null
not permitted).width
- the image width.height
- the image height.info
- carries back chart rendering info (null
permitted).encodeAlpha
- encode alpha?compression
- the PNG compression level (0-9).
writeImageMap
public static void writeImageMap(PrintWriter writer,
String name,
ChartRenderingInfo info,
boolean useOverLibForToolTips)
throws IOException
Writes an image map to an output stream.
writer
- the writer (null
not permitted).name
- the map name (null
not permitted).info
- the chart rendering info (null
not permitted).useOverLibForToolTips
- whether to use OverLIB for tooltips
(http://www.bosrup.com/web/overlib/).
writeImageMap
public static void writeImageMap(PrintWriter writer,
String name,
ChartRenderingInfo info,
ToolTipTagFragmentGenerator toolTipTagFragmentGenerator,
URLTagFragmentGenerator urlTagFragmentGenerator)
throws IOException
Writes an image map to an output stream.
writer
- the writer (null
not permitted).name
- the map name (null
not permitted).info
- the chart rendering info (null
not permitted).toolTipTagFragmentGenerator
- the tool tip generator.urlTagFragmentGenerator
- the url generator.
writeScaledChartAsPNG
public static void writeScaledChartAsPNG(OutputStream out,
JFreeChart chart,
int width,
int height,
int widthScaleFactor,
int heightScaleFactor)
throws IOException
Writes a scaled version of a chart to an output stream in PNG format.
out
- the output stream (null
not permitted).chart
- the chart (null
not permitted).width
- the unscaled chart width.height
- the unscaled chart height.widthScaleFactor
- the horizontal scale factor.heightScaleFactor
- the vertical scale factor.