Package atessera.comp

Class GNUPlot

java.lang.Object
atessera.comp.GNUPlot

public final class GNUPlot extends Object
Facade for compiling GNUPlot scripts to cropped PDF charts.

This class encapsulates a two-step GNUPlot pipeline:

  1. gnuplot — executes the script (src.plot) and produces plot.pdf.
  2. pdfcrop — crops the PDF to its bounding box, producing plot-crop.pdf.

After a successful compilation the cropped PDF is available via getOutput(). On failure the last block of stderr is available via getLog().

See Also:
  • Constructor Details

    • GNUPlot

      public GNUPlot(Compiler compiler, List<String> source)
      Constructs a new GNUPlot compilation facade.
      Parameters:
      compiler - the underlying Compiler to use; must not be null
      source - the GNUPlot script as a list of lines; must not be null
  • Method Details

    • compile

      public boolean compile()
      Runs the GNUPlot-to-PDF pipeline.
      Returns:
      true if all steps completed successfully and the cropped PDF was produced; false otherwise
      Throws:
      IllegalStateException - if the compiler result is inconsistent (e.g. zero exit code but no PDF, or non-zero exit code with empty error output)
    • getOutput

      public byte[] getOutput()
      Returns the compiled cropped PDF chart.
      Returns:
      the PDF as a byte array, or null if compilation has not been run or was unsuccessful
    • getLog

      public List<String> getLog()
      Returns the last block of stderr after a failed compilation.
      Returns:
      the error output as a list of lines, or null if no error was captured
    • getRawOutput

      public List<List<String>> getRawOutput()
      Returns the raw stdout captured from each command in the pipeline.
      Returns:
      an unmodifiable view of the captured stdout, or null before compilation
    • getRawErrorOutput

      public List<List<String>> getRawErrorOutput()
      Returns the raw stderr captured from each command in the pipeline.
      Returns:
      an unmodifiable view of the captured stderr, or null before compilation
    • getStackTrace

      public String getStackTrace()
      Returns the stack trace if an internal exception occurred during compilation.
      Returns:
      the stack trace as a string, or null if no exception was thrown