Package uk.ac.starlink.topcat.plot
Class ErrorModeSelectionModel
java.lang.Object
uk.ac.starlink.topcat.plot.ErrorModeSelectionModel
- All Implemented Interfaces:
ActionListener
,EventListener
,ComboBoxModel
,ListModel
,uk.ac.starlink.ttools.plot.ErrorModeSelection
public class ErrorModeSelectionModel
extends Object
implements uk.ac.starlink.ttools.plot.ErrorModeSelection, ComboBoxModel, ActionListener
Model for selecting
ErrorMode
values.
Methods are provided for acquiring GUI controls which reflect this model.- Since:
- 26 Feb 2007
- Author:
- Mark Taylor
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoid
Updates model state and informs listeners as required.void
addActionListener
(ActionListener listener) Adds a listener which will be informed when the selection changes.void
addListDataListener
(ListDataListener listener) No-op - the list never changes.Returns a set of menu items which allow selection of the state for this model.Returns a normal button which toggles the mode between no error bars and symmetrical error bars.Returns a toolbar button which toggles the mode between no error bars and symmetrical error bars.getElementAt
(int index) uk.ac.starlink.ttools.plot.ErrorMode
Returns the currently selected mode.getIcon
(uk.ac.starlink.ttools.plot.ErrorMode mode, int width, int height, int xpad, int ypad) Returns an icon which can be used to represent a given error mode.int
getSize()
boolean
Indicates enabledness of this model.void
removeActionListener
(ActionListener listener) Removes a listener previously added byaddActionListener(java.awt.event.ActionListener)
.void
removeListDataListener
(ListDataListener listener) No-op - the list never changes.void
setEnabled
(boolean enabled) Toggles enabled state of any controls based on this model.void
setMode
(uk.ac.starlink.ttools.plot.ErrorMode mode) Sets the selected mode.void
setSelectedItem
(Object mode)
-
Constructor Details
-
ErrorModeSelectionModel
Constructor.- Parameters:
iaxis
- index of the axis for which this model selects ErrorModesaxisName
- name of the axis
-
-
Method Details
-
getErrorMode
public uk.ac.starlink.ttools.plot.ErrorMode getErrorMode()Returns the currently selected mode.- Specified by:
getErrorMode
in interfaceuk.ac.starlink.ttools.plot.ErrorModeSelection
- Returns:
- error mode
-
setMode
public void setMode(uk.ac.starlink.ttools.plot.ErrorMode mode) Sets the selected mode.- Parameters:
mode
- new error mode
-
setEnabled
public void setEnabled(boolean enabled) Toggles enabled state of any controls based on this model.- Parameters:
enabled
- true iff user should be able to change state
-
isEnabled
public boolean isEnabled()Indicates enabledness of this model.- Returns:
- true iff user should be able to change state
-
actionPerformed
Updates model state and informs listeners as required. The command string of the provided ActionEvent must match the name of one of the available ErrorModes.- Specified by:
actionPerformed
in interfaceActionListener
- Parameters:
evt
- action whose command string names the new mode
-
createMenuItems
Returns a set of menu items which allow selection of the state for this model. Currently they are radio buttons, one for each known mode.- Returns:
- list of menu items for control
-
createOnOffToolbarButton
Returns a toolbar button which toggles the mode between no error bars and symmetrical error bars. This does not allow full control (not all modes are available).- Returns:
- toolbar button for toggling error bar status
-
createOnOffButton
Returns a normal button which toggles the mode between no error bars and symmetrical error bars. This does not allow full control (not all modes are available).- Returns:
- button for toggling error bar status
-
getElementAt
- Specified by:
getElementAt
in interfaceListModel
-
getSize
public int getSize() -
getSelectedItem
- Specified by:
getSelectedItem
in interfaceComboBoxModel
-
setSelectedItem
- Specified by:
setSelectedItem
in interfaceComboBoxModel
-
addListDataListener
No-op - the list never changes.- Specified by:
addListDataListener
in interfaceListModel
-
removeListDataListener
No-op - the list never changes.- Specified by:
removeListDataListener
in interfaceListModel
-
addActionListener
Adds a listener which will be informed when the selection changes.- Specified by:
addActionListener
in interfaceuk.ac.starlink.ttools.plot.ErrorModeSelection
- Parameters:
listener
- listener
-
removeActionListener
Removes a listener previously added byaddActionListener(java.awt.event.ActionListener)
.- Specified by:
removeActionListener
in interfaceuk.ac.starlink.ttools.plot.ErrorModeSelection
- Parameters:
listener
- listener
-
getIcon
public Icon getIcon(uk.ac.starlink.ttools.plot.ErrorMode mode, int width, int height, int xpad, int ypad) Returns an icon which can be used to represent a given error mode.- Parameters:
mode
- error modewidth
- total width of iconheight
- total height of iconxpad
- internal horizontal padding of iconypad
- internal vertical padding of icon- Returns:
- icon
-