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
Constructors -
Method Summary
Modifier and TypeMethodDescriptionstatic booleanReturnstrueif JFreeSVG is on the classpath, andfalseotherwise.static booleanReturnstrueif OrsonPDF (or JFreePDF) is on the classpath, andfalseotherwise.static voidwriteAsJPEG(Drawable drawable, int w, int h, File file) Writes the current content to the specified file in JPEG format.static voidwriteAsPDF(Drawable drawable, int w, int h, File file) Writes aDrawableto the specified file in PDF format.static voidwriteAsPNG(Drawable drawable, int w, int h, File file) Writes the current content to the specified file in PNG format.static voidwriteAsSVG(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
Returnstrueif JFreeSVG is on the classpath, andfalseotherwise. The JFreeSVG library can be found at http://www.jfree.org/jfreesvg/- Returns:
- A boolean.
-
isOrsonPDFAvailable
Returnstrueif OrsonPDF (or JFreePDF) is on the classpath, andfalseotherwise. 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 (nullnot permitted).w- the chart width.h- the chart height.file- the output file (nullnot permitted).
-
writeAsPDF
Writes aDrawableto 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 (nullnot permitted).w- the chart width.h- the chart height.file- the output file (nullnot 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 (nullnot permitted).w- the chart width.h- the chart height.file- the output file (nullnot 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 (nullnot permitted).w- the chart width.h- the chart height.file- the output file (nullnot permitted).- Throws:
FileNotFoundException- if the file is not found.IOException- if there is an I/O problem.
-