Class 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 Detail

      • ZONE_SUFFIXERS

        public static final Suffixer[] ZONE_SUFFIXERS
        List of suffixers suitable for per-zone parameters.
      • LAYER_SUFFIXERS

        public static final Suffixer[] LAYER_SUFFIXERS
        List of suffixers suitable for per-layer parameters.
    • 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 command
        zoneSuffixer - defines how per-zone parameter suffixes are generated
        layerSuffixer - defines how per-layer parameter suffixes are generated
        includeDflts - if true, all parameters are included; if false, only those with non-default values
        lineEnder - line end presentation policy
        levelIndent - number of spaces per indentation level
        cwidth - nominal formatting width in characters; this affects line wrapping, but actual wrapping may depend on other factors too
        tableNamer - 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