beowulf.gui
Class JNode

java.lang.Object
  extended byjava.awt.Component
      extended byjava.awt.Container
          extended byjavax.swing.JComponent
              extended byjavax.swing.JLabel
                  extended bybeowulf.gui.JNode
All Implemented Interfaces:
Accessible, ActionListener, DCMouseEventReceiver, EventListener, ImageObserver, MenuContainer, Serializable, SwingConstants

public class JNode
extends JLabel
implements ActionListener, DCMouseEventReceiver

A JNode is a GUI representation of a node in a graph. JNodes are designed to work in strong connection with JGraphs. A JGraph will use a JNodeFactory to produce JNodes for a given graph.

The JNode class is the principle class that needs to be changed in order to customize a JGraph representation. Subclassing the JNode allows for a different GUI representation (through overriding the method .paintComponent(Graphics g)), a more complicated popup menu structure, and more options in the properties window.

The subclass can access the popup menu through the protected variable 'menu', which is of type JPopupMenu. Menu items can be added/removed etc. The subclass of JNode will already be an action listener bound to receive action events generated by the default element of the popup menu - the show properties menu item. If the subclass of JNode is to have a .actionPerformed(ActionEvent) method, this method should call super.actionPerformed() so that such events can be processed correctly.

If the subclass of the JNode is to have more elements in the properties window, see the documentation on the JNode.PropertiesWindow class. Following the architecture of JNode and JNode.PropertiesWindow should allow for easy customization of both aspects of the JNode. The recommended method of doing this is to subclass both JNode and JNode.PropertiesWindow, and have the the subclass of JNode be an enclosing class of the other subclass.


Version:
1.0 - Feb 19, 2004
Author:
Andy Scukanec - (ags at cs dot cornell dot edu)
See Also:
Serialized Form

Nested Class Summary
 class JNode.PropertiesWindow
          This class is a specialized JFrame and will display all relevant properties of a JNode when the "show properties" option in a JNode's popup menu is selected.
 
Nested classes inherited from class javax.swing.JLabel
JLabel.AccessibleJLabel
 
Nested classes inherited from class javax.swing.JComponent
JComponent.AccessibleJComponent
 
Nested classes inherited from class java.awt.Container
Container.AccessibleAWTContainer
 
Nested classes inherited from class java.awt.Component
Component.AccessibleAWTComponent, Component.BltBufferStrategy, Component.FlipBufferStrategy
 
Field Summary
protected static Class[] EMPTY_PARAM_CLASS_LIST
          A convenience object for some of the reflection calls in the properties window.
protected static Object[] EMPTY_PARAM_LIST
          A convenience object for some of the reflection calls in the properties window.
protected  JPopupMenu menu
          The popup menu for options associated with this JNode.
protected  JNode.PropertiesWindow propertiesWindow
          The properties window associated with this JNode.
protected  int radius
          The radius of self loops, -1 indicates default radius.
protected static Dimension SCREEN_SIZE
          A convenience object for sizing and moving the properties window.
protected static String SHOW_PROPERTIES
          The string identified with the "show properties" action.
protected static Class[] SINGLE_PARAM_CLASS_LIST
          A convenience object for some of the reflection calls in the properties window.
protected static Object[] SINGLE_PARAM_LIST
          A convenience object for some of the reflection calls in the properties window.
protected  Object value
          The node in the underlying graph that this JNode represents
 
Fields inherited from class javax.swing.JLabel
labelFor
 
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 javax.swing.SwingConstants
BOTTOM, CENTER, EAST, HORIZONTAL, LEADING, LEFT, NEXT, NORTH, NORTH_EAST, NORTH_WEST, PREVIOUS, RIGHT, SOUTH, SOUTH_EAST, SOUTH_WEST, TOP, TRAILING, VERTICAL, WEST
 
Fields inherited from interface java.awt.image.ImageObserver
ABORT, ALLBITS, ERROR, FRAMEBITS, HEIGHT, PROPERTIES, SOMEBITS, WIDTH
 
Constructor Summary
JNode(Object newValue)
          Construct a new JNode with a given node to represent.
 
Method Summary
 void actionPerformed(ActionEvent ae)
           
 int getRadius()
          Returns the radius of all self-loops.
 Object getValue()
          Returns the node that this JNode represents in the underlying graph.
protected  void makePopupMenu()
          Called from the constructor to make the popup menu and associate it with this JNode object.
 void mouseClicked(MouseEvent me)
          This method will be called whenever a mouse button is clicked on top of the generating component.
 void mouseEntered(MouseEvent me)
          This method will be called whenever the mouse cursor enters the generating component.
 void mouseExited(MouseEvent me)
          This method will be called whenever the mouse cursor exits the generating component.
 void mousePressed(MouseEvent me)
          This method will be called whenever a mouse button is pressed on top of the generating component.
 void mouseReleased(MouseEvent me)
          This method will be called whenever a mouse button is released on top of the generating component.
 void setRadius(int newRadius)
          Sets the radius of self drawn loops.
 void setValue(Object newValue)
          Sets the node that this JNode represents.
 void showProperties()
          Called when the "show properties" action is chosen in the popup menu for this JNode.
 
Methods inherited from class javax.swing.JLabel
checkHorizontalKey, checkVerticalKey, getAccessibleContext, getDisabledIcon, getDisplayedMnemonic, getDisplayedMnemonicIndex, getHorizontalAlignment, getHorizontalTextPosition, getIcon, getIconTextGap, getLabelFor, getText, getUI, getUIClassID, getVerticalAlignment, getVerticalTextPosition, imageUpdate, paramString, setDisabledIcon, setDisplayedMnemonic, setDisplayedMnemonic, setDisplayedMnemonicIndex, setHorizontalAlignment, setHorizontalTextPosition, setIcon, setIconTextGap, setLabelFor, setText, setUI, setVerticalAlignment, setVerticalTextPosition, updateUI
 
Methods inherited from class javax.swing.JComponent
addAncestorListener, addNotify, addPropertyChangeListener, addPropertyChangeListener, addVetoableChangeListener, computeVisibleRect, contains, createToolTip, disable, enable, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, fireVetoableChange, getActionForKeyStroke, getActionMap, getAlignmentX, getAlignmentY, getAncestorListeners, getAutoscrolls, getBorder, getBounds, getClientProperty, getComponentGraphics, getConditionForKeyStroke, getDebugGraphicsOptions, getDefaultLocale, getGraphics, getHeight, getInputMap, getInputMap, getInputVerifier, getInsets, getInsets, getListeners, getLocation, getMaximumSize, getMinimumSize, getNextFocusableComponent, getPreferredSize, getPropertyChangeListeners, getPropertyChangeListeners, getRegisteredKeyStrokes, getRootPane, getSize, getToolTipLocation, getToolTipText, getToolTipText, getTopLevelAncestor, getTransferHandler, getVerifyInputWhenFocusTarget, getVetoableChangeListeners, getVisibleRect, getWidth, getX, getY, grabFocus, isDoubleBuffered, isLightweightComponent, isManagingFocus, isMaximumSizeSet, isMinimumSizeSet, isOpaque, isOptimizedDrawingEnabled, isPaintingTile, isPreferredSizeSet, isRequestFocusEnabled, isValidateRoot, paint, paintBorder, paintChildren, paintComponent, paintImmediately, paintImmediately, print, printAll, printBorder, printChildren, printComponent, processComponentKeyEvent, processKeyBinding, processKeyEvent, processMouseMotionEvent, putClientProperty, registerKeyboardAction, registerKeyboardAction, removeAncestorListener, removeNotify, removePropertyChangeListener, removePropertyChangeListener, removeVetoableChangeListener, repaint, repaint, requestDefaultFocus, requestFocus, requestFocus, requestFocusInWindow, requestFocusInWindow, resetKeyboardActions, reshape, revalidate, scrollRectToVisible, setActionMap, setAlignmentX, setAlignmentY, setAutoscrolls, setBackground, setBorder, setDebugGraphicsOptions, setDefaultLocale, setDoubleBuffered, setEnabled, setFont, setForeground, 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, applyComponentOrientation, areFocusTraversalKeysSet, countComponents, deliverEvent, doLayout, findComponentAt, findComponentAt, getComponent, getComponentAt, getComponentAt, getComponentCount, getComponents, getContainerListeners, getFocusTraversalKeys, getFocusTraversalPolicy, getLayout, insets, invalidate, isAncestorOf, isFocusCycleRoot, isFocusCycleRoot, isFocusTraversalPolicySet, layout, list, list, locate, minimumSize, paintComponents, preferredSize, printComponents, processContainerEvent, processEvent, remove, remove, removeAll, removeContainerListener, setFocusCycleRoot, setFocusTraversalKeys, setFocusTraversalPolicy, setLayout, transferFocusBackward, 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, getBackground, getBounds, getColorModel, getComponentListeners, getComponentOrientation, getCursor, getDropTarget, getFocusCycleRootAncestor, getFocusListeners, getFocusTraversalKeysEnabled, getFont, getFontMetrics, getForeground, getGraphicsConfiguration, getHierarchyBoundsListeners, getHierarchyListeners, getIgnoreRepaint, getInputContext, getInputMethodListeners, getInputMethodRequests, getKeyListeners, getLocale, getLocation, getLocationOnScreen, getMouseListeners, getMouseMotionListeners, getMouseWheelListeners, getName, getParent, getPeer, getSize, getToolkit, getTreeLock, gotFocus, handleEvent, hasFocus, hide, inside, isBackgroundSet, isCursorSet, isDisplayable, isEnabled, isFocusable, isFocusOwner, isFocusTraversable, isFontSet, isForegroundSet, isLightweight, 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, processMouseEvent, processMouseWheelEvent, remove, removeComponentListener, removeFocusListener, removeHierarchyBoundsListener, removeHierarchyListener, removeInputMethodListener, removeKeyListener, removeMouseListener, removeMouseMotionListener, removeMouseWheelListener, repaint, repaint, repaint, resize, resize, setBounds, setBounds, setComponentOrientation, setCursor, setDropTarget, setFocusable, setFocusTraversalKeysEnabled, setIgnoreRepaint, setLocale, setLocation, setLocation, setName, setSize, setSize, show, show, size, toString, transferFocus, transferFocusUpCycle
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

EMPTY_PARAM_LIST

protected static final Object[] EMPTY_PARAM_LIST
A convenience object for some of the reflection calls in the properties window.


SINGLE_PARAM_LIST

protected static final Object[] SINGLE_PARAM_LIST
A convenience object for some of the reflection calls in the properties window.


EMPTY_PARAM_CLASS_LIST

protected static final Class[] EMPTY_PARAM_CLASS_LIST
A convenience object for some of the reflection calls in the properties window.


SINGLE_PARAM_CLASS_LIST

protected static final Class[] SINGLE_PARAM_CLASS_LIST
A convenience object for some of the reflection calls in the properties window.


SCREEN_SIZE

protected static final Dimension SCREEN_SIZE
A convenience object for sizing and moving the properties window.


SHOW_PROPERTIES

protected static final String SHOW_PROPERTIES
The string identified with the "show properties" action.

See Also:
Constant Field Values

value

protected Object value
The node in the underlying graph that this JNode represents


menu

protected JPopupMenu menu
The popup menu for options associated with this JNode.


propertiesWindow

protected JNode.PropertiesWindow propertiesWindow
The properties window associated with this JNode.


radius

protected int radius
The radius of self loops, -1 indicates default radius.

Constructor Detail

JNode

public JNode(Object newValue)
Construct a new JNode with a given node to represent.

Parameters:
newValue - The node in the underlying graph.
Method Detail

getValue

public Object getValue()
Returns the node that this JNode represents in the underlying graph.

Returns:
The node that this JNode represents in the underlying graph.

getRadius

public int getRadius()
Returns the radius of all self-loops. A negative value indicates the default size.

Returns:
The radius of all self-loops.

setValue

public void setValue(Object newValue)
Sets the node that this JNode represents.

Parameters:
newValue - The new node that this JNode will represent.

setRadius

public void setRadius(int newRadius)
Sets the radius of self drawn loops. Negative values indicate the default size.

Parameters:
newRadius - The radius of self drawn loops.

makePopupMenu

protected void makePopupMenu()
Called from the constructor to make the popup menu and associate it with this JNode object.


actionPerformed

public void actionPerformed(ActionEvent ae)
Specified by:
actionPerformed in interface ActionListener

showProperties

public void showProperties()
Called when the "show properties" action is chosen in the popup menu for this JNode. It makes the properties window for this JNode visible. This is also where the properties window is created if it is null. This method should be overridden to use a subclass of properties window if a subclass is desired.


mouseEntered

public void mouseEntered(MouseEvent me)
Description copied from interface: DCMouseEventReceiver
This method will be called whenever the mouse cursor enters the generating component. See java.awt.event.MouseListener.mouseEntered(MouseEvent) for details.

Specified by:
mouseEntered in interface DCMouseEventReceiver
Parameters:
me - The generated event.

mouseExited

public void mouseExited(MouseEvent me)
Description copied from interface: DCMouseEventReceiver
This method will be called whenever the mouse cursor exits the generating component. See java.awt.event.MouseListener.mouseExited(MouseEvent) for details.

Specified by:
mouseExited in interface DCMouseEventReceiver
Parameters:
me - The generated event.

mouseClicked

public void mouseClicked(MouseEvent me)
Description copied from interface: DCMouseEventReceiver
This method will be called whenever a mouse button is clicked on top of the generating component. See java.awt.event.MouseListener.mouseClicked(MouseEvent) for details.

Specified by:
mouseClicked in interface DCMouseEventReceiver
Parameters:
me - The generated event.

mousePressed

public void mousePressed(MouseEvent me)
Description copied from interface: DCMouseEventReceiver
This method will be called whenever a mouse button is pressed on top of the generating component. See java.awt.event.MouseListener.mousePressed(MouseEvent) for details.

Specified by:
mousePressed in interface DCMouseEventReceiver
Parameters:
me - The generated event.

mouseReleased

public void mouseReleased(MouseEvent me)
Description copied from interface: DCMouseEventReceiver
This method will be called whenever a mouse button is released on top of the generating component. See java.awt.event.MouseListener.mouseReleased(MouseEvent) for details.

Specified by:
mouseReleased in interface DCMouseEventReceiver
Parameters:
me - The generated event.