Package uk.ac.starlink.topcat
Class StiltsMonitor<S extends StiltsMonitor.State>
java.lang.Object
uk.ac.starlink.topcat.StiltsMonitor<S>
- Direct Known Subclasses:
BasicStiltsMonitor
,PlotStiltsMonitor
Manages a text display component for showing a STILTS comand.
- Since:
- 27 Sep 2024
- Author:
- Mark Taylor
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic interface
Represents a STILTS command. -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionstatic JComponent
createErrorDisplay
(Throwable error) Returns a component that can display an error.protected abstract S
Returns a state object describing the content that should be displayed in this monitor.Returns an action that copies all the current stilts command text into the system clipboard.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.getState()
Returns the current state of this monitor.Returns the text panel which displays the stilts command.int
Returns the width of the text display panel in characters.protected void
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'sgetTextPanel()
method.
-
Constructor Details
-
StiltsMonitor
protected StiltsMonitor()Constructor.
-
-
Method Details
-
createState
Returns a state object describing the content that should be displayed in this monitor.- Returns:
- new state
-
getState
Returns the current state of this monitor. A new state is lazily created if no current state is present.- Returns:
- current state
-
getTextPanel
Returns the text panel which displays the stilts command.- Returns:
- text panel
-
getClipboardAction
Returns an action that copies all the current stilts command text into the system clipboard.- Returns:
- 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.- 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
Utility method for packaging the text panel returned by this object'sgetTextPanel()
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
Returns a component that can display an error.- Parameters:
error
- exception- Returns:
- display component
-