Class ChartExportService
java.lang.Object
com.arbergashi.charts.ui.ChartExportService
Exports charts rendered by
ArberChartPanel into images.
This class intentionally avoids any Swing dialogs or framework I18N. UI concerns (file chooser, notifications) belong to the demo application.
Supported formats
- PNG (always available via JDK)
- PDF (requires Apache PDFBox on the classpath)
- SVG (requires JFree SVG on the classpath)
Core policy: PDF/SVG integrations are optional and loaded via reflection. The host application decides which export formats are available by adding dependencies.
- Since:
- 0.9.0
- Version:
- 0.9.0
- Author:
- Arber Gashi
-
Method Summary
Modifier and TypeMethodDescriptionstatic voidexportPdf(ArberChartPanel panel, File outputFile) Renders the given chart panel into a PDF file.static voidexportPng(ArberChartPanel panel, File outputFile) Renders the given chart panel into a PNG file.static voidexportSvg(ArberChartPanel panel, File outputFile) Renders the given chart panel into an SVG file.
-
Method Details
-
exportPng
Renders the given chart panel into a PNG file.This method is safe to use in headless environments.
Notes:
- If the panel is not yet displayed (width/height = 0), its preferred size is used.
- Parent directories are created automatically.
- Parameters:
panel- the chart panel to exportoutputFile- the output file (PNG)- Throws:
IllegalArgumentException- if panel or outputFile is nullRuntimeException- if writing the image fails
-
exportSvg
Renders the given chart panel into an SVG file.Requires dependency:
org.jfree:jfreesvg
- Parameters:
panel- the chart panel to exportoutputFile- the output file (SVG)- Throws:
IllegalArgumentException- if panel or outputFile is nullRuntimeException- if required SVG backend is missing or writing fails
-
exportPdf
Renders the given chart panel into a PDF file.Requires dependency:
org.apache.pdfbox:pdfbox
- Parameters:
panel- the chart panel to exportoutputFile- the output file (PDF)- Throws:
IllegalArgumentException- if panel or outputFile is nullRuntimeException- if required PDF backend is missing or writing fails
-