Class 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 selecting ErrorMode 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 by addActionListener(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)  
      • 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,
                                       java.lang.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​(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 interface java.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 interface javax.swing.ListModel
      • getSize

        public int getSize()
        Specified by:
        getSize in interface javax.swing.ListModel
      • getSelectedItem

        public java.lang.Object getSelectedItem()
        Specified by:
        getSelectedItem in interface javax.swing.ComboBoxModel
      • setSelectedItem

        public void setSelectedItem​(java.lang.Object mode)
        Specified by:
        setSelectedItem in interface javax.swing.ComboBoxModel
      • addListDataListener

        public void addListDataListener​(javax.swing.event.ListDataListener listener)
        No-op - the list never changes.
        Specified by:
        addListDataListener in interface javax.swing.ListModel
      • removeListDataListener

        public void removeListDataListener​(javax.swing.event.ListDataListener listener)
        No-op - the list never changes.
        Specified by:
        removeListDataListener in interface javax.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 interface uk.ac.starlink.ttools.plot.ErrorModeSelection
        Parameters:
        listener - listener
      • removeActionListener

        public void removeActionListener​(java.awt.event.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 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 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