Package uk.ac.starlink.topcat.plot2

## Class StiltsMonitor

- java.lang.Object
- - uk.ac.starlink.topcat.plot2.StiltsMonitor

-     public class StiltsMonitor
      extends java.lang.Object

  Manages text display components for displaying a STILTS command that is supposed to replicate the plot visible in a PlotPanel. The replication may not be identical; a best effort is made.
  Since:
    12 Sep 2017
  Author:
    Mark Taylor

- - ### Constructor Summary

    Constructors
    Constructor | Description
    --- | ---
    `StiltsMonitor​(PlotPanel<?,​?> plotPanel)` | Constructor.

  - ### Method Summary

    All Methods Static Methods Instance Methods Concrete Methods
    Modifier and Type | Method | Description
    --- | --- | ---
    `javax.swing.Action[]` | `getActions()` | Returns a list of actions that the GUI can present to the user relating to the displayed command.
    `javax.swing.Action` | `getClipboardAction()` | Returns an action that copies all the current stilts command text into the system clipboard.
    `javax.swing.Action` | `getErrorAction()` | Returns an action that will pop up the error resulting from attempting to execute the current stilts command in a dialog window, if an error exists.
    `javax.swing.Action` | `getExecuteAction()` | Returns an action that will attempt to execute the current stilts command and display the result in a dialog window.
    `javax.swing.text.JTextComponent` | `getTextPanel()` | Returns the text panel which displays the stilts command.
    `int` | `getWidthCharacters()` | Returns the width of the text display panel in characters.
    `void` | `setFormatter​(uk.ac.starlink.ttools.plot2.task.StiltsPlotFormatter formatter)` | Sets the object that controls the details of formatting stilts commands.
    `static javax.swing.JComponent` | `wrapTextPanel​(javax.swing.text.JTextComponent textPanel)` | Utility method for packaging the text panel returned by this object's `getTextPanel()` method.

    - ### Methods inherited from class java.lang.Object

      `clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

- - ### Constructor Detail

    - #### StiltsMonitor

          public StiltsMonitor​(PlotPanel<?,​?> plotPanel)

      Constructor.
      Parameters:
        `plotPanel` - panel to mirror

  - ### Method Detail

    - #### setFormatter

          public void setFormatter​(uk.ac.starlink.ttools.plot2.task.StiltsPlotFormatter formatter)

      Sets the object that controls the details of formatting stilts commands. This can be assigned by the user to adjust formatting details.
      Parameters:
        `formatter` - new formatter

    - #### getTextPanel

          public javax.swing.text.JTextComponent getTextPanel()

      Returns the text panel which displays the stilts command.
      Returns:
        text panel

    - #### getClipboardAction

          public javax.swing.Action getClipboardAction()

      Returns an action that copies all the current stilts command text into the system clipboard.
      Returns:
        clipboard action

    - #### getExecuteAction

          public javax.swing.Action getExecuteAction()

      Returns an action that will attempt to execute the current stilts command and display the result in a dialog window.
      Returns:
        execution action

    - #### getErrorAction

          public javax.swing.Action getErrorAction()

      Returns an action that will pop up the error resulting from attempting to execute the current stilts command in a dialog window, if an error exists.
      Returns:
        error display action

    - #### getActions

          public javax.swing.Action[] getActions()

      Returns a list of actions that the GUI can present to the user relating to the displayed command.
      Returns:
        action array

    - #### getWidthCharacters

          public int getWidthCharacters()

      Returns the width of the text display panel in characters. This assumes the font has a fixed width per character, which it does. The returned value gives the width of the scrollpane viewport, if applicable, rather than the width of the JTextComponent itself. That is the best width to use when deciding where to wrap lines.
      Returns:
        current visible text region width in units of character width

    - #### wrapTextPanel

          public static javax.swing.JComponent wrapTextPanel​(javax.swing.text.JTextComponent textPanel)

      Utility method for packaging the text panel returned by this object's `getTextPanel()` method. This puts it in a scroll pane, and makes sure the lines don't wrap.
      Parameters:
        `textPanel` - text panel, supposed to be from this monitor
      Returns:
        scrolled component containing panel