Class AttributeSelectionPanel

  • All Implemented Interfaces:
    ImageObserver, MenuContainer, Serializable, EventListener, Accessible, ListSelectionListener

    public class AttributeSelectionPanel
    extends adams.gui.core.BasePanel
    implements ListSelectionListener
    Creates a panel that displays the attributes contained in a set of instances, letting the user toggle whether each attribute is selected or not (eg: so that unselected attributes can be removed before classification).
    Besides the All, None and Invert button one can also choose attributes which names match a regular expression (Pattern button). E.g. for removing all attributes that contain an ID and therefore unwanted information, one can match all names that contain "id" in the name:
     (.*_id_.*|.*_id$|^id$)
     
    This does not match e.g. "humidity", which could be an attribute we would like to keep.
    Author:
    Len Trigg ([email protected]), FracPete (fracpete at waikato dot ac dot nz)
    See Also:
    Serialized Form
    • Field Detail

      • m_ButtonAll

        protected adams.gui.core.BaseButton m_ButtonAll
        to select all attributes
      • m_ButtonNone

        protected adams.gui.core.BaseButton m_ButtonNone
        to deselect all attributes
      • m_ButtonInvert

        protected adams.gui.core.BaseButton m_ButtonInvert
        to invert the current selection
      • m_ButtonPattern

        protected adams.gui.core.BaseButton m_ButtonPattern
        for entering a regular expression for selection
      • m_PanelFilter

        protected adams.gui.core.FilterPanel m_PanelFilter
        the filter panel.
      • m_Table

        protected adams.gui.core.SortableAndSearchableTableWithButtons m_Table
        The table displaying attribute names and selection status
      • m_PatternRegEx

        protected String m_PatternRegEx
        The current regular expression.
      • m_SelectionListeners

        protected Set<ListSelectionListener> m_SelectionListeners
        the listeners for changes in the selection.
    • Constructor Detail

      • AttributeSelectionPanel

        public AttributeSelectionPanel()
    • Method Detail

      • initialize

        protected void initialize()
        Initializes the members.
        Overrides:
        initialize in class adams.gui.core.BasePanel
      • initGUI

        protected void initGUI()
        Initializes the widgets.
        Overrides:
        initGUI in class adams.gui.core.BasePanel
      • finishInit

        protected void finishInit()
        Finishes the initialization.
        Overrides:
        finishInit in class adams.gui.core.BasePanel
      • updateWidgets

        protected void updateWidgets()
        Updates the enabled state of the buttons/combobox.
      • setInstances

        public void setInstances​(weka.core.Instances data)
        Sets the instances to display the attribute names for.
        Parameters:
        data - the instances
      • getInstances

        public weka.core.Instances getInstances()
        Returns the currently displayed instances.
        Returns:
        the instances, null if none available
      • search

        protected void search()
        Searches the panel with the filter.
      • getSelectedRows

        public int[] getSelectedRows()
        Gets an array containing the indices of all selected rows.
        Returns:
        the array of selected indices.
      • getSelectedAttributes

        public int[] getSelectedAttributes()
        Gets an array containing the indices of all selected (ie checked) attributes.
        Returns:
        the array of selected indices, null if no model present.
      • getTable

        public adams.gui.core.BaseTable getTable()
        Returns the table.
        Returns:
        the table
      • getTableModel

        public TableModel getTableModel()
        Get the table model in use (or null if no instances have been set yet).
        Returns:
        the table model in use or null if no instances have been seen yet.
      • getSelectionModel

        public ListSelectionModel getSelectionModel()
        Gets the selection model used by the table.
        Returns:
        a value of type 'ListSelectionModel'
      • addSelectionListener

        public void addSelectionListener​(ListSelectionListener l)
        Add a listener to the list that's notified each time a change to the selection occurs.
        Parameters:
        l - the ListSelectionListener
      • removeSelectionListener

        public void removeSelectionListener​(ListSelectionListener l)
        Remove a listener from the list that's notified each time a change to the selection occurs.
        Parameters:
        l - the ListSelectionListener
      • notifySelectionListeners

        protected void notifySelectionListeners​(ListSelectionEvent e)
        Notifies all listeners that the selection has changed.