Class AttributeSelectionPanel
- java.lang.Object
-
- java.awt.Component
-
- java.awt.Container
-
- javax.swing.JComponent
-
- javax.swing.JPanel
-
- adams.gui.core.BasePanel
-
- adams.gui.tools.wekainvestigator.tab.preprocesstab.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
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static class
AttributeSelectionPanel.AttributeTableModel
A table model that looks at the names of attributes and maintains a list of attributes that have been "selected".-
Nested classes/interfaces inherited from class javax.swing.JPanel
JPanel.AccessibleJPanel
-
Nested classes/interfaces inherited from class javax.swing.JComponent
JComponent.AccessibleJComponent
-
Nested classes/interfaces inherited from class java.awt.Container
Container.AccessibleAWTContainer
-
Nested classes/interfaces inherited from class java.awt.Component
Component.AccessibleAWTComponent, Component.BaselineResizeBehavior, Component.BltBufferStrategy, Component.FlipBufferStrategy
-
-
Field Summary
Fields Modifier and Type Field Description protected adams.gui.core.BaseButton
m_ButtonAll
to select all attributesprotected adams.gui.core.BaseButton
m_ButtonInvert
to invert the current selectionprotected adams.gui.core.BaseButton
m_ButtonNone
to deselect all attributesprotected adams.gui.core.BaseButton
m_ButtonPattern
for entering a regular expression for selectionprotected AttributeSelectionPanel.AttributeTableModel
m_Model
The table model containing attribute names and selection statusprotected adams.gui.core.FilterPanel
m_PanelFilter
the filter panel.protected String
m_PatternRegEx
The current regular expression.protected Set<ListSelectionListener>
m_SelectionListeners
the listeners for changes in the selection.protected adams.gui.core.SortableAndSearchableTableWithButtons
m_Table
The table displaying attribute names and selection status-
Fields inherited from class javax.swing.JComponent
listenerList, TOOL_TIP_TEXT_KEY, ui, UNDEFINED_CONDITION, WHEN_ANCESTOR_OF_FOCUSED_COMPONENT, WHEN_FOCUSED, WHEN_IN_FOCUSED_WINDOW
-
Fields inherited from class java.awt.Component
accessibleContext, BOTTOM_ALIGNMENT, CENTER_ALIGNMENT, LEFT_ALIGNMENT, RIGHT_ALIGNMENT, TOP_ALIGNMENT
-
Fields inherited from interface java.awt.image.ImageObserver
ABORT, ALLBITS, ERROR, FRAMEBITS, HEIGHT, PROPERTIES, SOMEBITS, WIDTH
-
-
Constructor Summary
Constructors Constructor Description AttributeSelectionPanel()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description void
addSelectionListener(ListSelectionListener l)
Add a listener to the list that's notified each time a change to the selection occurs.protected void
finishInit()
Finishes the initialization.weka.core.Instances
getInstances()
Returns the currently displayed instances.int[]
getSelectedAttributes()
Gets an array containing the indices of all selected (ie checked) attributes.int[]
getSelectedRows()
Gets an array containing the indices of all selected rows.ListSelectionModel
getSelectionModel()
Gets the selection model used by the table.adams.gui.core.BaseTable
getTable()
Returns the table.TableModel
getTableModel()
Get the table model in use (or null if no instances have been set yet).protected void
initGUI()
Initializes the widgets.protected void
initialize()
Initializes the members.protected void
notifySelectionListeners(ListSelectionEvent e)
Notifies all listeners that the selection has changed.void
removeSelectionListener(ListSelectionListener l)
Remove a listener from the list that's notified each time a change to the selection occurs.protected void
search()
Searches the panel with the filter.void
setInstances(weka.core.Instances data)
Sets the instances to display the attribute names for.protected void
updateWidgets()
Updates the enabled state of the buttons/combobox.void
valueChanged(ListSelectionEvent e)
Called whenever the value of the selection changes.-
Methods inherited from class adams.gui.core.BasePanel
afterHide, afterShow, beforeHide, beforeShow, closeParent, getParentChild, getParentDialog, getParentFrame, getParentInternalFrame, getParentTitle, initFileChooser, main, printErrorMessage, printException, saveComponent, setEnabledCascade, setEnabledCascade, setParentTitle, setVisible
-
Methods inherited from class javax.swing.JPanel
getAccessibleContext, getUI, getUIClassID, paramString, setUI, updateUI
-
Methods inherited from class javax.swing.JComponent
addAncestorListener, addNotify, addVetoableChangeListener, computeVisibleRect, contains, createToolTip, disable, enable, firePropertyChange, firePropertyChange, firePropertyChange, fireVetoableChange, getActionForKeyStroke, getActionMap, getAlignmentX, getAlignmentY, getAncestorListeners, getAutoscrolls, getBaseline, getBaselineResizeBehavior, getBorder, getBounds, getClientProperty, getComponentGraphics, getComponentPopupMenu, getConditionForKeyStroke, getDebugGraphicsOptions, getDefaultLocale, getFontMetrics, getGraphics, getHeight, getInheritsPopupMenu, getInputMap, getInputMap, getInputVerifier, getInsets, getInsets, getListeners, getLocation, getMaximumSize, getMinimumSize, getNextFocusableComponent, getPopupLocation, getPreferredSize, getRegisteredKeyStrokes, getRootPane, getSize, getToolTipLocation, getToolTipText, getToolTipText, getTopLevelAncestor, getTransferHandler, getVerifyInputWhenFocusTarget, getVetoableChangeListeners, getVisibleRect, getWidth, getX, getY, grabFocus, hide, isDoubleBuffered, isLightweightComponent, isManagingFocus, isOpaque, isOptimizedDrawingEnabled, isPaintingForPrint, isPaintingOrigin, isPaintingTile, isRequestFocusEnabled, isValidateRoot, paint, paintBorder, paintChildren, paintComponent, paintImmediately, paintImmediately, print, printAll, printBorder, printChildren, printComponent, processComponentKeyEvent, processKeyBinding, processKeyEvent, processMouseEvent, processMouseMotionEvent, putClientProperty, registerKeyboardAction, registerKeyboardAction, removeAncestorListener, removeNotify, removeVetoableChangeListener, repaint, repaint, requestDefaultFocus, requestFocus, requestFocus, requestFocusInWindow, requestFocusInWindow, resetKeyboardActions, reshape, revalidate, scrollRectToVisible, setActionMap, setAlignmentX, setAlignmentY, setAutoscrolls, setBackground, setBorder, setComponentPopupMenu, setDebugGraphicsOptions, setDefaultLocale, setDoubleBuffered, setEnabled, setFocusTraversalKeys, setFont, setForeground, setInheritsPopupMenu, setInputMap, setInputVerifier, setMaximumSize, setMinimumSize, setNextFocusableComponent, setOpaque, setPreferredSize, setRequestFocusEnabled, setToolTipText, setTransferHandler, setUI, setVerifyInputWhenFocusTarget, unregisterKeyboardAction, update
-
Methods inherited from class java.awt.Container
add, add, add, add, add, addContainerListener, addImpl, addPropertyChangeListener, addPropertyChangeListener, applyComponentOrientation, areFocusTraversalKeysSet, countComponents, deliverEvent, doLayout, findComponentAt, findComponentAt, getComponent, getComponentAt, getComponentAt, getComponentCount, getComponents, getComponentZOrder, getContainerListeners, getFocusTraversalKeys, getFocusTraversalPolicy, getLayout, getMousePosition, insets, invalidate, isAncestorOf, isFocusCycleRoot, isFocusCycleRoot, isFocusTraversalPolicyProvider, isFocusTraversalPolicySet, layout, list, list, locate, minimumSize, paintComponents, preferredSize, printComponents, processContainerEvent, processEvent, remove, remove, removeAll, removeContainerListener, setComponentZOrder, setFocusCycleRoot, setFocusTraversalPolicy, setFocusTraversalPolicyProvider, setLayout, transferFocusDownCycle, validate, validateTree
-
Methods inherited from class java.awt.Component
action, add, addComponentListener, addFocusListener, addHierarchyBoundsListener, addHierarchyListener, addInputMethodListener, addKeyListener, addMouseListener, addMouseMotionListener, addMouseWheelListener, bounds, checkImage, checkImage, coalesceEvents, contains, createImage, createImage, createVolatileImage, createVolatileImage, disableEvents, dispatchEvent, enable, enableEvents, enableInputMethods, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, getBackground, getBounds, getColorModel, getComponentListeners, getComponentOrientation, getCursor, getDropTarget, getFocusCycleRootAncestor, getFocusListeners, getFocusTraversalKeysEnabled, getFont, getForeground, getGraphicsConfiguration, getHierarchyBoundsListeners, getHierarchyListeners, getIgnoreRepaint, getInputContext, getInputMethodListeners, getInputMethodRequests, getKeyListeners, getLocale, getLocation, getLocationOnScreen, getMouseListeners, getMouseMotionListeners, getMousePosition, getMouseWheelListeners, getName, getParent, getPropertyChangeListeners, getPropertyChangeListeners, getSize, getToolkit, getTreeLock, gotFocus, handleEvent, hasFocus, imageUpdate, inside, isBackgroundSet, isCursorSet, isDisplayable, isEnabled, isFocusable, isFocusOwner, isFocusTraversable, isFontSet, isForegroundSet, isLightweight, isMaximumSizeSet, isMinimumSizeSet, isPreferredSizeSet, isShowing, isValid, isVisible, keyDown, keyUp, list, list, list, location, lostFocus, mouseDown, mouseDrag, mouseEnter, mouseExit, mouseMove, mouseUp, move, nextFocus, paintAll, postEvent, prepareImage, prepareImage, processComponentEvent, processFocusEvent, processHierarchyBoundsEvent, processHierarchyEvent, processInputMethodEvent, processMouseWheelEvent, remove, removeComponentListener, removeFocusListener, removeHierarchyBoundsListener, removeHierarchyListener, removeInputMethodListener, removeKeyListener, removeMouseListener, removeMouseMotionListener, removeMouseWheelListener, removePropertyChangeListener, removePropertyChangeListener, repaint, repaint, repaint, requestFocus, requestFocus, requestFocusInWindow, resize, resize, setBounds, setBounds, setComponentOrientation, setCursor, setDropTarget, setFocusable, setFocusTraversalKeysEnabled, setIgnoreRepaint, setLocale, setLocation, setLocation, setMixingCutoutShape, setName, setSize, setSize, show, show, size, toString, transferFocus, transferFocusBackward, transferFocusUpCycle
-
-
-
-
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_Model
protected AttributeSelectionPanel.AttributeTableModel m_Model
The table model containing 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.
-
-
Method Detail
-
initialize
protected void initialize()
Initializes the members.- Overrides:
initialize
in classadams.gui.core.BasePanel
-
initGUI
protected void initGUI()
Initializes the widgets.- Overrides:
initGUI
in classadams.gui.core.BasePanel
-
finishInit
protected void finishInit()
Finishes the initialization.- Overrides:
finishInit
in classadams.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.
-
valueChanged
public void valueChanged(ListSelectionEvent e)
Called whenever the value of the selection changes.- Specified by:
valueChanged
in interfaceListSelectionListener
- Parameters:
e
- the event that characterizes the change.- See Also:
notifySelectionListeners(ListSelectionEvent)
-
-