Package atessera.comp
Class GNUPlot
java.lang.Object
atessera.comp.GNUPlot
Facade for compiling GNUPlot scripts to cropped PDF charts.
This class encapsulates a two-step GNUPlot pipeline:
gnuplot— executes the script (src.plot) and producesplot.pdf.pdfcrop— crops the PDF to its bounding box, producingplot-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 Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionbooleancompile()Runs the GNUPlot-to-PDF pipeline.getLog()Returns the last block of stderr after a failed compilation.byte[]Returns the compiled cropped PDF chart.Returns the raw stderr captured from each command in the pipeline.Returns the raw stdout captured from each command in the pipeline.Returns the stack trace if an internal exception occurred during compilation.
-
Constructor Details
-
GNUPlot
Constructs a newGNUPlotcompilation facade.- Parameters:
compiler- the underlyingCompilerto use; must not benullsource- the GNUPlot script as a list of lines; must not benull
-
-
Method Details
-
compile
public boolean compile()Runs the GNUPlot-to-PDF pipeline.- Returns:
trueif all steps completed successfully and the cropped PDF was produced;falseotherwise- 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
nullif compilation has not been run or was unsuccessful
-
getLog
Returns the last block of stderr after a failed compilation.- Returns:
- the error output as a list of lines, or
nullif no error was captured
-
getRawOutput
Returns the raw stdout captured from each command in the pipeline.- Returns:
- an unmodifiable view of the captured stdout, or
nullbefore compilation
-
getRawErrorOutput
Returns the raw stderr captured from each command in the pipeline.- Returns:
- an unmodifiable view of the captured stderr, or
nullbefore compilation
-
getStackTrace
Returns the stack trace if an internal exception occurred during compilation.- Returns:
- the stack trace as a string, or
nullif no exception was thrown
-