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.ActionListenerModel for selectingErrorModevalues. 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 voidactionPerformed(java.awt.event.ActionEvent evt)Updates model state and informs listeners as required.voidaddActionListener(java.awt.event.ActionListener listener)Adds a listener which will be informed when the selection changes.voidaddListDataListener(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.AbstractButtoncreateOnOffButton()Returns a normal button which toggles the mode between no error bars and symmetrical error bars.javax.swing.AbstractButtoncreateOnOffToolbarButton()Returns a toolbar button which toggles the mode between no error bars and symmetrical error bars.java.lang.ObjectgetElementAt(int index)uk.ac.starlink.ttools.plot.ErrorModegetErrorMode()Returns the currently selected mode.javax.swing.IcongetIcon(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.ObjectgetSelectedItem()intgetSize()booleanisEnabled()Indicates enabledness of this model.voidremoveActionListener(java.awt.event.ActionListener listener)Removes a listener previously added byaddActionListener(java.awt.event.ActionListener).voidremoveListDataListener(javax.swing.event.ListDataListener listener)No-op - the list never changes.voidsetEnabled(boolean enabled)Toggles enabled state of any controls based on this model.voidsetMode(uk.ac.starlink.ttools.plot.ErrorMode mode)Sets the selected mode.voidsetSelectedItem(java.lang.Object mode)
-
-
-
Method Detail
-
getErrorMode
public uk.ac.starlink.ttools.plot.ErrorMode getErrorMode()
Returns the currently selected mode.- Specified by:
getErrorModein 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:
actionPerformedin 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:
getElementAtin interfacejavax.swing.ListModel
-
getSize
public int getSize()
- Specified by:
getSizein interfacejavax.swing.ListModel
-
getSelectedItem
public java.lang.Object getSelectedItem()
- Specified by:
getSelectedItemin interfacejavax.swing.ComboBoxModel
-
setSelectedItem
public void setSelectedItem(java.lang.Object mode)
- Specified by:
setSelectedItemin interfacejavax.swing.ComboBoxModel
-
addListDataListener
public void addListDataListener(javax.swing.event.ListDataListener listener)
No-op - the list never changes.- Specified by:
addListDataListenerin interfacejavax.swing.ListModel
-
removeListDataListener
public void removeListDataListener(javax.swing.event.ListDataListener listener)
No-op - the list never changes.- Specified by:
removeListDataListenerin 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:
addActionListenerin 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:
removeActionListenerin 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
-
-