Class ChartExportService

java.lang.Object
com.arbergashi.charts.ui.ChartExportService

public final class ChartExportService extends Object
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 Details

    • exportPng

      public static void exportPng(ArberChartPanel panel, File outputFile)
      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 export
      outputFile - the output file (PNG)
      Throws:
      IllegalArgumentException - if panel or outputFile is null
      RuntimeException - if writing the image fails
    • exportSvg

      public static void exportSvg(ArberChartPanel panel, File outputFile)
      Renders the given chart panel into an SVG file.

      Requires dependency:

      org.jfree:jfreesvg
      
      Parameters:
      panel - the chart panel to export
      outputFile - the output file (SVG)
      Throws:
      IllegalArgumentException - if panel or outputFile is null
      RuntimeException - if required SVG backend is missing or writing fails
    • exportPdf

      public static void exportPdf(ArberChartPanel panel, File outputFile)
      Renders the given chart panel into a PDF file.

      Requires dependency:

      org.apache.pdfbox:pdfbox
      
      Parameters:
      panel - the chart panel to export
      outputFile - the output file (PDF)
      Throws:
      IllegalArgumentException - if panel or outputFile is null
      RuntimeException - if required PDF backend is missing or writing fails