Package uk.ac.starlink.topcat.plot
Class ErrorModeSelectionModel
- java.lang.Object
-
- uk.ac.starlink.topcat.plot.ErrorModeSelectionModel
-
- All Implemented Interfaces:
java.awt.event.ActionListener
,java.util.EventListener
,javax.swing.ComboBoxModel
,javax.swing.ListModel
,uk.ac.starlink.ttools.plot.ErrorModeSelection
public class ErrorModeSelectionModel extends java.lang.Object implements uk.ac.starlink.ttools.plot.ErrorModeSelection, javax.swing.ComboBoxModel, java.awt.event.ActionListener
Model for selectingErrorMode
values. Methods are provided for acquiring GUI controls which reflect this model.- Since:
- 26 Feb 2007
- Author:
- Mark Taylor
-
-
Constructor Summary
Constructors Constructor Description ErrorModeSelectionModel(int iaxis, java.lang.String axisName)
Constructor.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description void
actionPerformed(java.awt.event.ActionEvent evt)
Updates model state and informs listeners as required.void
addActionListener(java.awt.event.ActionListener listener)
Adds a listener which will be informed when the selection changes.void
addListDataListener(javax.swing.event.ListDataListener listener)
No-op - the list never changes.javax.swing.JMenuItem[]
createMenuItems()
Returns a set of menu items which allow selection of the state for this model.javax.swing.AbstractButton
createOnOffButton()
Returns a normal button which toggles the mode between no error bars and symmetrical error bars.javax.swing.AbstractButton
createOnOffToolbarButton()
Returns a toolbar button which toggles the mode between no error bars and symmetrical error bars.java.lang.Object
getElementAt(int index)
uk.ac.starlink.ttools.plot.ErrorMode
getErrorMode()
Returns the currently selected mode.javax.swing.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.java.lang.Object
getSelectedItem()
int
getSize()
boolean
isEnabled()
Indicates enabledness of this model.void
removeActionListener(java.awt.event.ActionListener listener)
Removes a listener previously added byaddActionListener(java.awt.event.ActionListener)
.void
removeListDataListener(javax.swing.event.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(java.lang.Object mode)
-
-
-
Method Detail
-
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
public void actionPerformed(java.awt.event.ActionEvent evt)
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 interfacejava.awt.event.ActionListener
- Parameters:
evt
- action whose command string names the new mode
-
createMenuItems
public javax.swing.JMenuItem[] 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
public javax.swing.AbstractButton 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
public javax.swing.AbstractButton 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
public java.lang.Object getElementAt(int index)
- Specified by:
getElementAt
in interfacejavax.swing.ListModel
-
getSize
public int getSize()
- Specified by:
getSize
in interfacejavax.swing.ListModel
-
getSelectedItem
public java.lang.Object getSelectedItem()
- Specified by:
getSelectedItem
in interfacejavax.swing.ComboBoxModel
-
setSelectedItem
public void setSelectedItem(java.lang.Object mode)
- Specified by:
setSelectedItem
in interfacejavax.swing.ComboBoxModel
-
addListDataListener
public void addListDataListener(javax.swing.event.ListDataListener listener)
No-op - the list never changes.- Specified by:
addListDataListener
in interfacejavax.swing.ListModel
-
removeListDataListener
public void removeListDataListener(javax.swing.event.ListDataListener listener)
No-op - the list never changes.- Specified by:
removeListDataListener
in interfacejavax.swing.ListModel
-
addActionListener
public void addActionListener(java.awt.event.ActionListener listener)
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
public void removeActionListener(java.awt.event.ActionListener listener)
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 javax.swing.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
-
-