Package org.jfree.chart.util
Class ExportUtils
java.lang.Object
org.jfree.chart.util.ExportUtils
Utility functions for exporting charts to SVG and PDF format.
-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionstatic boolean
Returnstrue
if JFreeSVG is on the classpath, andfalse
otherwise.static boolean
Returnstrue
if OrsonPDF (or JFreePDF) is on the classpath, andfalse
otherwise.static void
writeAsJPEG
(Drawable drawable, int w, int h, File file) Writes the current content to the specified file in JPEG format.static void
writeAsPDF
(Drawable drawable, int w, int h, File file) Writes aDrawable
to the specified file in PDF format.static void
writeAsPNG
(Drawable drawable, int w, int h, File file) Writes the current content to the specified file in PNG format.static void
writeAsSVG
(Drawable drawable, int w, int h, File file) Writes the current content to the specified file in SVG format.
-
Constructor Details
-
ExportUtils
public ExportUtils()
-
-
Method Details
-
isJFreeSVGAvailable
Returnstrue
if JFreeSVG is on the classpath, andfalse
otherwise. The JFreeSVG library can be found at http://www.jfree.org/jfreesvg/- Returns:
- A boolean.
-
isOrsonPDFAvailable
Returnstrue
if OrsonPDF (or JFreePDF) is on the classpath, andfalse
otherwise. The OrsonPDF library can be found at https://github.com/jfree/orsonpdf. JFreePDF is a modular version of the same library, requiring Java 11 or later. Since JFreeChart might be used in a modular context, this function has been modified (in version 1.5.3) to detect JFreePDF also.- Returns:
- A boolean.
-
writeAsSVG
Writes the current content to the specified file in SVG format. This will only work when the JFreeSVG library is found on the classpath. Reflection is used to ensure there is no compile-time dependency on JFreeSVG.- Parameters:
drawable
- the drawable (null
not permitted).w
- the chart width.h
- the chart height.file
- the output file (null
not permitted).
-
writeAsPDF
Writes aDrawable
to the specified file in PDF format. This will only work when the OrsonPDF library is found on the classpath. Reflection is used to ensure there is no compile-time dependency on OrsonPDF.- Parameters:
drawable
- the drawable (null
not permitted).w
- the chart width.h
- the chart height.file
- the output file (null
not permitted).
-
writeAsPNG
public static void writeAsPNG(Drawable drawable, int w, int h, File file) throws FileNotFoundException, IOException Writes the current content to the specified file in PNG format.- Parameters:
drawable
- the drawable (null
not permitted).w
- the chart width.h
- the chart height.file
- the output file (null
not permitted).- Throws:
FileNotFoundException
- if the file is not found.IOException
- if there is an I/O problem.
-
writeAsJPEG
public static void writeAsJPEG(Drawable drawable, int w, int h, File file) throws FileNotFoundException, IOException Writes the current content to the specified file in JPEG format.- Parameters:
drawable
- the drawable (null
not permitted).w
- the chart width.h
- the chart height.file
- the output file (null
not permitted).- Throws:
FileNotFoundException
- if the file is not found.IOException
- if there is an I/O problem.
-