uk.ac.starlink.topcat.plot
Class ErrorModeSelectionModel

java.lang.Object
  extended by 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
ErrorModeSelectionModel(int iaxis, String axisName)
          Constructor.
 
Method Summary
 void actionPerformed(ActionEvent evt)
          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.
 JMenuItem[] createMenuItems()
          Returns a set of menu items which allow selection of the state for this model.
 AbstractButton createOnOffButton()
          Returns a normal button which toggles the mode between no error bars and symmetrical error bars.
 AbstractButton createOnOffToolbarButton()
          Returns a toolbar button which toggles the mode between no error bars and symmetrical error bars.
 Object getElementAt(int index)
           
 uk.ac.starlink.ttools.plot.ErrorMode getErrorMode()
          Returns the currently selected mode.
 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.
 Object getSelectedItem()
           
 int getSize()
           
 boolean isEnabled()
          Indicates enabledness of this model.
 void removeActionListener(ActionListener listener)
          Removes a listener previously added by addActionListener(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)
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

ErrorModeSelectionModel

public ErrorModeSelectionModel(int iaxis,
                               String axisName)
Constructor.

Parameters:
iaxis - index of the axis for which this model selects ErrorModes
axisName - name of the axis
Method Detail

getErrorMode

public uk.ac.starlink.ttools.plot.ErrorMode getErrorMode()
Returns the currently selected mode.

Specified by:
getErrorMode in interface uk.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(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 interface ActionListener
Parameters:
evt - action whose command string names the new mode

createMenuItems

public 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 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 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 Object getElementAt(int index)
Specified by:
getElementAt in interface ListModel

getSize

public int getSize()
Specified by:
getSize in interface ListModel

getSelectedItem

public Object getSelectedItem()
Specified by:
getSelectedItem in interface ComboBoxModel

setSelectedItem

public void setSelectedItem(Object mode)
Specified by:
setSelectedItem in interface ComboBoxModel

addListDataListener

public void addListDataListener(ListDataListener listener)
No-op - the list never changes.

Specified by:
addListDataListener in interface ListModel

removeListDataListener

public void removeListDataListener(ListDataListener listener)
No-op - the list never changes.

Specified by:
removeListDataListener in interface ListModel

addActionListener

public void addActionListener(ActionListener listener)
Adds a listener which will be informed when the selection changes.

Specified by:
addActionListener in interface uk.ac.starlink.ttools.plot.ErrorModeSelection
Parameters:
listener - listener

removeActionListener

public void removeActionListener(ActionListener listener)
Removes a listener previously added by addActionListener(java.awt.event.ActionListener).

Specified by:
removeActionListener in interface uk.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 mode
width - total width of icon
height - total height of icon
xpad - internal horizontal padding of icon
ypad - internal vertical padding of icon
Returns:
icon


Copyright © 2003-2018 CCLRC: Council for the Central Laboratory of the Research Councils. All Rights Reserved.