Package uk.ac.starlink.ttools.plot2.task
Class StiltsPlotFormatter
- java.lang.Object
-
- uk.ac.starlink.ttools.plot2.task.StiltsPlotFormatter
-
public class StiltsPlotFormatter extends java.lang.Object
Handles export of StiltsPlot objects to external serialization formats.- Since:
- 15 Sep 2017
- Author:
- Mark Taylor
-
-
Field Summary
Fields Modifier and Type Field Description static Suffixer[]
LAYER_SUFFIXERS
List of suffixers suitable for per-layer parameters.static Suffixer[]
ZONE_SUFFIXERS
List of suffixers suitable for per-zone parameters.
-
Constructor Summary
Constructors Constructor Description StiltsPlotFormatter(CredibleString invocation, Suffixer zoneSuffixer, Suffixer layerSuffixer, boolean includeDflts, LineEnder lineEnder, int levelIndent, int cwidth, TableNamer tableNamer)
Constructor.
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description static javax.swing.text.StyledDocument
createBasicDocument(java.lang.String txt)
Utility method returning a StyledDocument instance with some supplied plain text.uk.ac.starlink.task.Executable
createExecutable(StiltsPlot plot)
Creates a task Executable based on the state of this PlotSpec.PlotDisplay
createPlotComponent(StiltsPlot plot, boolean caching)
Attempts to create a PlotDisplay that re-creates the plot specified by this object.javax.swing.text.StyledDocument
createShellDocument(StiltsPlot plot)
Returns a Document, suitable for use with a JTextPane, formatting the given plot specification.CredibleString
getInvocation()
Returns the invocation used to introduce the STILTS command.Suffixer
getLayerSuffixer()
Returns the policy for selecting per-layer parameter suffixes.TableNamer
getTableNamer()
Returns the file naming policy.Suffixer
getZoneSuffixer()
Returns the policy for selecting per-zone parameter suffixes.void
setForceError(boolean forceError)
Sets whether the generated stilts commands will be made to produce a gratuitous error.
-
-
-
Constructor Detail
-
StiltsPlotFormatter
public StiltsPlotFormatter(CredibleString invocation, Suffixer zoneSuffixer, Suffixer layerSuffixer, boolean includeDflts, LineEnder lineEnder, int levelIndent, int cwidth, TableNamer tableNamer)
Constructor.- Parameters:
invocation
- display text to introduce the STILTS commandzoneSuffixer
- defines how per-zone parameter suffixes are generatedlayerSuffixer
- defines how per-layer parameter suffixes are generatedincludeDflts
- if true, all parameters are included; if false, only those with non-default valueslineEnder
- line end presentation policylevelIndent
- number of spaces per indentation levelcwidth
- nominal formatting width in characters; this affects line wrapping, but actual wrapping may depend on other factors tootableNamer
- determines how tables are named
-
-
Method Detail
-
getInvocation
public CredibleString getInvocation()
Returns the invocation used to introduce the STILTS command.- Returns:
- STILTS invocation string
-
getZoneSuffixer
public Suffixer getZoneSuffixer()
Returns the policy for selecting per-zone parameter suffixes.- Returns:
- zone suffixer
-
getLayerSuffixer
public Suffixer getLayerSuffixer()
Returns the policy for selecting per-layer parameter suffixes.- Returns:
- layer suffixer
-
getTableNamer
public TableNamer getTableNamer()
Returns the file naming policy.- Returns:
- table namer
-
setForceError
public void setForceError(boolean forceError)
Sets whether the generated stilts commands will be made to produce a gratuitous error. This is only useful for debugging purposes.- Parameters:
forceError
- true to force an error from generated commands
-
createExecutable
public uk.ac.starlink.task.Executable createExecutable(StiltsPlot plot) throws uk.ac.starlink.task.TaskException
Creates a task Executable based on the state of this PlotSpec. Various exceptions may be thrown if there is some error. Such errors are quite possible.If this method returns without error there is a fair chance that the serializations prodiced from this object will produce a faithful reproduction of the specified plot.
- Returns:
- executable
- Throws:
uk.ac.starlink.task.TaskException
- if there is some other error in setting up the executable; probably incorrect parameter assignments of some kind
-
createPlotComponent
public PlotDisplay createPlotComponent(StiltsPlot plot, boolean caching) throws uk.ac.starlink.task.TaskException, java.io.IOException, java.lang.InterruptedException
Attempts to create a PlotDisplay that re-creates the plot specified by this object.- Parameters:
caching
- whether the plotted image is to be cached- Returns:
- plot display component
- Throws:
uk.ac.starlink.task.TaskException
java.io.IOException
java.lang.InterruptedException
- See Also:
AbstractPlot2Task.createPlotComponent(uk.ac.starlink.task.Environment, boolean)
-
createShellDocument
public javax.swing.text.StyledDocument createShellDocument(StiltsPlot plot)
Returns a Document, suitable for use with a JTextPane, formatting the given plot specification. This may include coloured highlighting etc. depending on configuration.- Parameters:
plot
- plot speicification
-
createBasicDocument
public static javax.swing.text.StyledDocument createBasicDocument(java.lang.String txt)
Utility method returning a StyledDocument instance with some supplied plain text.- Parameters:
txt
- text content- Returns:
- document
-
-