org.peace_tools.views.overlap
Class ClusterList

java.lang.Object
  extended by java.awt.Component
      extended by java.awt.Container
          extended by javax.swing.JComponent
              extended by javax.swing.JPanel
                  extended by org.peace_tools.views.overlap.ClusterList
All Implemented Interfaces:
java.awt.event.ActionListener, java.awt.image.ImageObserver, java.awt.MenuContainer, java.io.Serializable, java.util.EventListener, javax.accessibility.Accessible

 class ClusterList
extends javax.swing.JPanel
implements java.awt.event.ActionListener

A combo-box like custom component to display list of clusters from a tool bar.

This component provides a custom GUI component that looks similar to a combo-box but uses a JList in its popup to display a set of choices that permit multiple-selections. This permits the user to select multiple clusters and apply colors (and possibly other transformations) to the selected set. This component consists of the following set of independent sub-components:

NoteThis class is meant to be instantiated and used only by the OverlapView class. Consequently it has been made package private.


Nested Class Summary
 
Nested classes/interfaces inherited from class javax.swing.JPanel
javax.swing.JPanel.AccessibleJPanel
 
Nested classes/interfaces inherited from class javax.swing.JComponent
javax.swing.JComponent.AccessibleJComponent
 
Nested classes/interfaces inherited from class java.awt.Container
java.awt.Container.AccessibleAWTContainer
 
Nested classes/interfaces inherited from class java.awt.Component
java.awt.Component.AccessibleAWTComponent, java.awt.Component.BaselineResizeBehavior, java.awt.Component.BltBufferStrategy, java.awt.Component.FlipBufferStrategy
 
Field Summary
private  java.awt.Color borderColor
          The color of the border to be used for this component to provide a simple line border that makes it look like a static control.
private  javax.swing.JButton changeColor
          A tool bar style button that permits the user to change the colors associated with the selected clusters.
private  javax.swing.JList clusterList
          The list that displays the list of clusters currently present in the memory model.
private  javax.swing.JScrollPane clusterListJSP
          The scroll pane that contains the clusterList so that the list can scroll when the there are a large number of clusters.
private  ClusterColorMapper colorMapper
          Helper to look-up color for a given cluster ID.
private  javax.swing.JButton dropDownButton
          The drop down button (with a small triangle) to display cluster pop up list.
private static java.lang.String LOW_COLOR_MSG
          A fixed message that is displayed to the user to indicate that some of the clusters have duplicate colors.
private  OverlapModel overlapModel
          The OverlapModel that provides the necessary information for rendering the core information required by this panel.
private  javax.swing.JComponent owner
          The final top-level component that logically owns this cluster list.
private  javax.swing.JPopupMenu popupList
          The pop up that contains the cluster list to be displayed to the user.
private  javax.swing.JButton randomColors
          A tool bar style button that permits the user to assign random colors to each cluster.
private  javax.swing.JLabel selectionStats
          A simple non-editable text field to display cluster selection statistics.
private static long serialVersionUID
          Generated serialization UID (merely to keep the compiler happy)
 
Fields inherited from class javax.swing.JComponent
accessibleContext, 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
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
ClusterList(OverlapModel overlapModel, ClusterColorMapper colorMapper, javax.swing.JComponent owner)
          The default constructor.
 
Method Summary
 void actionPerformed(java.awt.event.ActionEvent event)
           
private  void createClusterListAndPopup()
          Creates the cluster list used to display clusters.
 void paintComponent(java.awt.Graphics g)
           
protected  void setColors(java.util.List<java.awt.Color> colorList)
          Sets color for selected or all clusters to given color.
 
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, isDoubleBuffered, isLightweightComponent, isManagingFocus, isOpaque, isOptimizedDrawingEnabled, isPaintingForPrint, isPaintingTile, isRequestFocusEnabled, isValidateRoot, paint, paintBorder, paintChildren, 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, setVisible, 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, getPeer, getPropertyChangeListeners, getPropertyChangeListeners, getSize, getToolkit, getTreeLock, gotFocus, handleEvent, hasFocus, hide, 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, resize, resize, setBounds, setBounds, setComponentOrientation, setCursor, setDropTarget, setFocusable, setFocusTraversalKeysEnabled, setIgnoreRepaint, setLocale, setLocation, setLocation, setName, setSize, setSize, show, show, size, toString, transferFocus, transferFocusBackward, transferFocusUpCycle
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

selectionStats

private javax.swing.JLabel selectionStats
A simple non-editable text field to display cluster selection statistics. This field is meant to provide the user with some summary information for convenience.


dropDownButton

private javax.swing.JButton dropDownButton
The drop down button (with a small triangle) to display cluster pop up list. This button is created indirectly from the constructor and either hides or displays the pop up that contains the cluster list.


changeColor

private final javax.swing.JButton changeColor
A tool bar style button that permits the user to change the colors associated with the selected clusters. This button is created in the constructor.


randomColors

private final javax.swing.JButton randomColors
A tool bar style button that permits the user to assign random colors to each cluster. The colors are chosen at random from a given palate. This button is created in the constructor.


popupList

private javax.swing.JPopupMenu popupList
The pop up that contains the cluster list to be displayed to the user. The usage of pop up menu in this context is a bit unconventional because typically menus would have only menu items. However, in this case, it has a JList. However, the pop up menu provides the convenience to display a pop up without having to handle the overheads of focus management and displaying the popup.


clusterList

private javax.swing.JList clusterList
The list that displays the list of clusters currently present in the memory model. This list is created in the constructor and is further customized in the createClusterListAndPopup() method.


clusterListJSP

private javax.swing.JScrollPane clusterListJSP
The scroll pane that contains the clusterList so that the list can scroll when the there are a large number of clusters.


overlapModel

private final OverlapModel overlapModel
The OverlapModel that provides the necessary information for rendering the core information required by this panel. This instance variable is initialized by the constructor and is never changed during the life time of this object.


owner

private final javax.swing.JComponent owner
The final top-level component that logically owns this cluster list. This component is notified to refresh the display whenver cluster colors are changed or updated.


colorMapper

private final ClusterColorMapper colorMapper
Helper to look-up color for a given cluster ID. This interface is used when rendering fragments. The color mapper is used to look up the colors set for a given cluster, given its cluster ID. The cluster colors are set and updated indirectly by the OverlapView class.


borderColor

private final java.awt.Color borderColor
The color of the border to be used for this component to provide a simple line border that makes it look like a static control. This value is set in the constructor before setting the background of this control to white.


LOW_COLOR_MSG

private static final java.lang.String LOW_COLOR_MSG
A fixed message that is displayed to the user to indicate that some of the clusters have duplicate colors. This constant is used in the actionPerformed(ActionEvent) method.

See Also:
Constant Field Values

serialVersionUID

private static final long serialVersionUID
Generated serialization UID (merely to keep the compiler happy)

See Also:
Constant Field Values
Constructor Detail

ClusterList

public ClusterList(OverlapModel overlapModel,
                   ClusterColorMapper colorMapper,
                   javax.swing.JComponent owner)
The default constructor.

Parameters:
overlapModel - The overlap model from where the data regarding the set of clusters is retrieved.
colorMapper - The helper object to be used to determine the color for rendering fragments belonging to various clusters.
owner - The owner to be repainted whenever colors for clusters are changed.
Method Detail

actionPerformed

public void actionPerformed(java.awt.event.ActionEvent event)
Specified by:
actionPerformed in interface java.awt.event.ActionListener

paintComponent

public void paintComponent(java.awt.Graphics g)
Overrides:
paintComponent in class javax.swing.JComponent

setColors

protected void setColors(java.util.List<java.awt.Color> colorList)
Sets color for selected or all clusters to given color. This method is a common helper method that is used to change (or set) colors for either all clusters or just the selected clusters (as the case may be) to a given set of colors. The set of colors to be used are passed in as the parameter. This method reuses colors in the list if the number of selected clusters are greater than the number of colors.

Parameters:
colorList - The list of colors to be used for assigning colors to various clusters. If this list is null, then a default color of grey is assigned to each cluster.

createClusterListAndPopup

private void createClusterListAndPopup()
Creates the cluster list used to display clusters. This method is invoked from the constructor to create the cluster list and the popupList that is used to display the cluster list whenever the user clicks on the dropDownButton. This method is invoked only once from the constructor. It was primarily introduced to streamline the constructor.