org.jfree.chart
Class ChartUtilities

java.lang.Object
  |
  +--org.jfree.chart.ChartUtilities

public class ChartUtilities
extends java.lang.Object

Utility methods for JFreeChart. Includes methods for converting charts to image formats (PNG and JPEG) plus creating simple HTML image maps.

Author:
David Gilbert

Constructor Summary
ChartUtilities()
           
 
Method Summary
static void saveChartAsJPEG(java.io.File file, float quality, JFreeChart chart, int width, int height)
          Saves the chart as a JPEG format image file.
static void saveChartAsJPEG(java.io.File file, float quality, JFreeChart chart, int width, int height, ChartRenderingInfo info)
          Saves the chart as a JPEG format image file.
static void saveChartAsJPEG(java.io.File file, JFreeChart chart, int width, int height)
          Saves the chart as a JPEG format image file.
static void saveChartAsJPEG(java.io.File file, JFreeChart chart, int width, int height, ChartRenderingInfo info)
          Saves the chart as a JPEG format image file.
static void saveChartAsPNG(java.io.File file, JFreeChart chart, int width, int height)
          Saves the chart as a PNG format image file.
static void saveChartAsPNG(java.io.File file, JFreeChart chart, int width, int height, ChartRenderingInfo info)
          Saves the chart as a PNG format image file.
static void saveChartAsPNG(java.io.File file, JFreeChart chart, int width, int height, ChartRenderingInfo info, boolean encodeAlpha, int compression)
          Saves the chart as a PNG format image file.
static void writeBufferedImageAsJPEG(java.io.OutputStream out, java.awt.image.BufferedImage image)
          Writes the BufferedImage to the output stream in JPEG format.
static void writeBufferedImageAsJPEG(java.io.OutputStream out, float quality, java.awt.image.BufferedImage image)
          Writes the BufferedImage to the output stream in JPEG format.
static void writeBufferedImageAsPNG(java.io.OutputStream out, java.awt.image.BufferedImage image)
          Writes the BufferedImage to the output stream in PNG format.
static void writeBufferedImageAsPNG(java.io.OutputStream out, java.awt.image.BufferedImage image, boolean encodeAlpha, int compression)
          Writes the BufferedImage to the output stream in PNG format.
static void writeChartAsJPEG(java.io.OutputStream out, float quality, JFreeChart chart, int width, int height)
          Writes the chart to the output stream in JPEG format.
static void writeChartAsJPEG(java.io.OutputStream out, float quality, JFreeChart chart, int width, int height, ChartRenderingInfo info)
          Writes the chart to the output stream in JPEG format.
static void writeChartAsJPEG(java.io.OutputStream out, JFreeChart chart, int width, int height)
          Writes the chart to the output stream in JPEG format.
static void writeChartAsJPEG(java.io.OutputStream out, JFreeChart chart, int width, int height, ChartRenderingInfo info)
          Writes the chart to the output stream in JPEG format.
static void writeChartAsPNG(java.io.OutputStream out, JFreeChart chart, int width, int height)
          Writes the chart to the output stream in PNG format.
static void writeChartAsPNG(java.io.OutputStream out, JFreeChart chart, int width, int height, boolean encodeAlpha, int compression)
          Writes the chart to the output stream in PNG format.
static void writeChartAsPNG(java.io.OutputStream out, JFreeChart chart, int width, int height, ChartRenderingInfo info)
          Writes the chart to the output stream in PNG format.
static void writeChartAsPNG(java.io.OutputStream out, JFreeChart chart, int width, int height, ChartRenderingInfo info, boolean encodeAlpha, int compression)
          Writes the chart to the output stream in PNG format.
static void writeImageMap(java.io.PrintWriter writer, java.lang.String name, ChartRenderingInfo info)
          Writes an image map to the output stream.
static void writeImageMap(java.io.PrintWriter writer, java.lang.String name, ChartRenderingInfo info, boolean useOverLibForToolTips)
          Writes an image map to the output stream.
static void writeScaledChartAsPNG(java.io.OutputStream out, JFreeChart chart, int width, int height, int widthScaleFactor, int heightScaleFactor)
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

ChartUtilities

public ChartUtilities()
Method Detail

writeChartAsPNG

public static void writeChartAsPNG(java.io.OutputStream out,
                                   JFreeChart chart,
                                   int width,
                                   int height)
                            throws java.io.IOException
Writes the chart to the output stream in PNG format.

Parameters:
out - the output stream.
chart - the chart.
width - the image width.
height - the image height.
Throws:
java.io.IOException - if there are any I/O errors.

writeChartAsPNG

public static void writeChartAsPNG(java.io.OutputStream out,
                                   JFreeChart chart,
                                   int width,
                                   int height,
                                   boolean encodeAlpha,
                                   int compression)
                            throws java.io.IOException
Writes the chart to the output stream in PNG format.

Parameters:
out - the output stream.
chart - the chart.
width - the image width.
height - the image height.
encodeAlpha - encode alpha?
compression - the compression level.
Throws:
java.io.IOException - if there are any I/O errors.

writeChartAsPNG

public static void writeChartAsPNG(java.io.OutputStream out,
                                   JFreeChart chart,
                                   int width,
                                   int height,
                                   ChartRenderingInfo info)
                            throws java.io.IOException
Writes the chart to the 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.

Parameters:
out - the output stream.
chart - the chart.
width - the image width.
height - the image height.
info - the chart rendering info.
Throws:
java.io.IOException - if there are any I/O errors.

writeChartAsPNG

public static void writeChartAsPNG(java.io.OutputStream out,
                                   JFreeChart chart,
                                   int width,
                                   int height,
                                   ChartRenderingInfo info,
                                   boolean encodeAlpha,
                                   int compression)
                            throws java.io.IOException
Writes the chart to the 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.

Parameters:
out - the output stream.
chart - the chart.
width - the image width.
height - the image height.
info - the chart rendering info.
encodeAlpha - encode alpha?
compression - the PNG compression level.
Throws:
java.io.IOException - if there are any I/O errors.

writeScaledChartAsPNG

public static void writeScaledChartAsPNG(java.io.OutputStream out,
                                         JFreeChart chart,
                                         int width,
                                         int height,
                                         int widthScaleFactor,
                                         int heightScaleFactor)
                                  throws java.io.IOException
java.io.IOException

saveChartAsPNG

public static void saveChartAsPNG(java.io.File file,
                                  JFreeChart chart,
                                  int width,
                                  int height)
                           throws java.io.IOException
Saves the chart as a PNG format image file.

Parameters:
file - the file name.
chart - the chart.
width - the image width.
height - the image height.
Throws:
java.io.IOException - if there are any I/O errors.

saveChartAsPNG

public static void saveChartAsPNG(java.io.File file,
                                  JFreeChart chart,
                                  int width,
                                  int height,
                                  ChartRenderingInfo info)
                           throws java.io.IOException
Saves the chart as a PNG format image file.

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.

Parameters:
file - the file.
chart - the chart.
width - the image width.
height - the image height.
info - the chart rendering info.
Throws:
java.io.IOException - if there are any I/O errors.

saveChartAsPNG

public static void saveChartAsPNG(java.io.File file,
                                  JFreeChart chart,
                                  int width,
                                  int height,
                                  ChartRenderingInfo info,
                                  boolean encodeAlpha,
                                  int compression)
                           throws java.io.IOException
Saves the chart as a PNG format image file.

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.

Parameters:
file - the file.
chart - the chart.
width - the image width.
height - the image height.
info - the chart rendering info.
encodeAlpha - encode alpha?
compression - the PNG compression level.
Throws:
java.io.IOException - if there are any I/O errors.

writeChartAsJPEG

public static void writeChartAsJPEG(java.io.OutputStream out,
                                    JFreeChart chart,
                                    int width,
                                    int height)
                             throws java.io.IOException
Writes the chart to the output stream in JPEG format.

Parameters:
out - the output stream.
chart - the chart.
width - the image width.
height - the image height.
Throws:
java.io.IOException - if there are any I/O errors.

writeChartAsJPEG

public static void writeChartAsJPEG(java.io.OutputStream out,
                                    float quality,
                                    JFreeChart chart,
                                    int width,
                                    int height)
                             throws java.io.IOException
Writes the chart to the output stream in JPEG format.

Parameters:
out - the output stream.
quality - the quality setting.
chart - the chart.
width - the image width.
height - the image height.
Throws:
java.io.IOException - if there are any I/O errors.

writeChartAsJPEG

public static void writeChartAsJPEG(java.io.OutputStream out,
                                    JFreeChart chart,
                                    int width,
                                    int height,
                                    ChartRenderingInfo info)
                             throws java.io.IOException
Writes the chart to the 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.

Parameters:
out - the output stream.
chart - the chart.
width - the image width.
height - the image height.
info - the chart rendering info.
Throws:
java.io.IOException - if there are any I/O errors.

writeChartAsJPEG

public static void writeChartAsJPEG(java.io.OutputStream out,
                                    float quality,
                                    JFreeChart chart,
                                    int width,
                                    int height,
                                    ChartRenderingInfo info)
                             throws java.io.IOException
Writes the chart to the 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.

Parameters:
out - the output stream.
quality - the output quality (0.0f to 1.0f).
chart - the chart.
width - the image width.
height - the image height.
info - the chart rendering info.
Throws:
java.io.IOException - if there are any I/O errors.

saveChartAsJPEG

public static void saveChartAsJPEG(java.io.File file,
                                   JFreeChart chart,
                                   int width,
                                   int height)
                            throws java.io.IOException
Saves the chart as a JPEG format image file.

Parameters:
file - the file.
chart - the chart.
width - the image width.
height - the image height.
Throws:
java.io.IOException - if there are any I/O errors.

saveChartAsJPEG

public static void saveChartAsJPEG(java.io.File file,
                                   float quality,
                                   JFreeChart chart,
                                   int width,
                                   int height)
                            throws java.io.IOException
Saves the chart as a JPEG format image file.

Parameters:
file - the file.
quality - the JPEG quality setting.
chart - the chart.
width - the image width.
height - the image height.
Throws:
java.io.IOException - if there are any I/O errors.

saveChartAsJPEG

public static void saveChartAsJPEG(java.io.File file,
                                   JFreeChart chart,
                                   int width,
                                   int height,
                                   ChartRenderingInfo info)
                            throws java.io.IOException
Saves the chart as a JPEG format image file.

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.

Parameters:
file - the file name.
chart - the chart.
width - the image width.
height - the image height.
info - the chart rendering info.
Throws:
java.io.IOException - if there are any I/O errors.

saveChartAsJPEG

public static void saveChartAsJPEG(java.io.File file,
                                   float quality,
                                   JFreeChart chart,
                                   int width,
                                   int height,
                                   ChartRenderingInfo info)
                            throws java.io.IOException
Saves the chart as a JPEG format image file.

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.

Parameters:
file - the file name.
quality - the quality setting.
chart - the chart.
width - the image width.
height - the image height.
info - the chart rendering info.
Throws:
java.io.IOException - if there are any I/O errors.

writeBufferedImageAsJPEG

public static void writeBufferedImageAsJPEG(java.io.OutputStream out,
                                            java.awt.image.BufferedImage image)
                                     throws java.io.IOException
Writes the BufferedImage to the output stream in JPEG format.

Parameters:
out - the output stream.
image - the buffered image to be written to the OutputStream
Throws:
java.io.IOException - if there are any I/O errors.

writeBufferedImageAsJPEG

public static void writeBufferedImageAsJPEG(java.io.OutputStream out,
                                            float quality,
                                            java.awt.image.BufferedImage image)
                                     throws java.io.IOException
Writes the BufferedImage to the output stream in JPEG format.

Parameters:
out - the output stream.
quality - the image quality (0.0f to 1.0f).
image - the buffered image to be written to the OutputStream
Throws:
java.io.IOException - if there are any I/O errors.

writeBufferedImageAsPNG

public static void writeBufferedImageAsPNG(java.io.OutputStream out,
                                           java.awt.image.BufferedImage image)
                                    throws java.io.IOException
Writes the BufferedImage to the output stream in PNG format.

Parameters:
out - the output stream.
image - the buffered image to be written to the OutputStream
Throws:
java.io.IOException - if there are any I/O errors.

writeBufferedImageAsPNG

public static void writeBufferedImageAsPNG(java.io.OutputStream out,
                                           java.awt.image.BufferedImage image,
                                           boolean encodeAlpha,
                                           int compression)
                                    throws java.io.IOException
Writes the BufferedImage to the output stream in PNG format.

Parameters:
out - the output stream.
image - the buffered image to be written to the OutputStream.
encodeAlpha - encode alpha?
compression - the compression level.
Throws:
java.io.IOException - if there are any I/O errors.

writeImageMap

public static void writeImageMap(java.io.PrintWriter writer,
                                 java.lang.String name,
                                 ChartRenderingInfo info)
                          throws java.io.IOException
Writes an image map to the output stream.

Parameters:
writer - the writer.
name - the map name.
info - the chart rendering info.
Throws:
java.io.IOException - if there are any I/O errors.

writeImageMap

public static void writeImageMap(java.io.PrintWriter writer,
                                 java.lang.String name,
                                 ChartRenderingInfo info,
                                 boolean useOverLibForToolTips)
                          throws java.io.IOException
Writes an image map to the output stream.

Parameters:
writer - the writer.
name - the map name.
info - the chart rendering info.
useOverLibForToolTips - whether to use OverLIB for tooltips (http://www.bosrup.com/web/overlib/).
Throws:
java.io.IOException - if there are any I/O errors.