# Class StiltsMonitor<S extends StiltsMonitor.State>

java.lang.Object
uk.ac.starlink.topcat.StiltsMonitor<S>

Direct Known Subclasses:
  `BasicStiltsMonitor, PlotStiltsMonitor`

public abstract class StiltsMonitor<S extends StiltsMonitor.State> extends Object
Manages a text display component for showing a STILTS comand.

Since:
  27 Sep 2024
Author:
  Mark Taylor

## Nested Class Summary

Nested Classes
Modifier and Type
Class
Description
`static interface`
`StiltsMonitor.State`
Represents a STILTS command.

## Constructor Summary

Constructors
Modifier
Constructor
Description
`protected`
`StiltsMonitor()`
Constructor.

## Method Summary

Modifier and Type
Method
Description
`static JComponent`
`createErrorDisplay(Throwable error)`
Returns a component that can display an error.
`protected abstract S`
`createState()`
Returns a state object describing the content that should be displayed in this monitor.
`Action`
`getClipboardAction()`
Returns an action that copies all the current stilts command text into the system clipboard.
`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.
`S`
`getState()`
Returns the current state of this monitor.
`JTextComponent`
`getTextPanel()`
Returns the text panel which displays the stilts command.
`int`
`getWidthCharacters()`
Returns the width of the text display panel in characters.
`protected void`
`resetState()`
Called if the state that defines what appears in the text pane is changed in some way.
`static JComponent`
`wrapTextPanel(JTextComponent textPanel)`
Utility method for packaging the text panel returned by this object's `getTextPanel()` method.

### Methods inherited from class Object

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

## Constructor Details

### StiltsMonitor

protected StiltsMonitor()
Constructor.

## Method Details

### createState

protected abstract S createState()
Returns a state object describing the content that should be displayed in this monitor.

Returns:
  new state

### getState

public S getState()
Returns the current state of this monitor. A new state is lazily created if no current state is present.

Returns:
  current state

### getTextPanel

public JTextComponent getTextPanel()
Returns the text panel which displays the stilts command.

Returns:
  text panel

### getClipboardAction

public Action getClipboardAction()
Returns an action that copies all the current stilts command text into the system clipboard.

Returns:
  clipboard action

### getErrorAction

public 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

### 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

### resetState

protected void resetState()
Called if the state that defines what appears in the text pane is changed in some way.

### wrapTextPanel

public static JComponent wrapTextPanel(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

### createErrorDisplay

public static JComponent createErrorDisplay(Throwable error)
Returns a component that can display an error.

Parameters:
  `error` - exception
Returns:
  display component