org.ceryle.graph
Class GraphPanel

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 com.touchgraph.graphlayout.TGPanel
                      extended by org.ceryle.graph.GraphPanel
All Implemented Interfaces:
FocusListener, ImageObserver, MenuContainer, Serializable, EventListener, Accessible
Direct Known Subclasses:
TMPanel

public class GraphPanel
extends TGPanel
implements FocusListener

GraphPanel extends TouchGraph's TGPanel, providing additional features used in the Ceryle application.

Version:
$Id: GraphPanel.java,v 3.21 2007-06-20 01:28:10 altheim Exp $
Author:
Murray Altheim
See Also:
TGPanel, Serialized Form

Nested Class Summary
 class GraphPanel.ExtendedMouseMotionListener
           
 class GraphPanel.GraphKeyListener
          Internal class implements KeyAdapter to capture key events.
 class GraphPanel.SwitchSelectUI
           
 
Nested classes/interfaces inherited from class com.touchgraph.graphlayout.TGPanel
TGPanel.AdjustOriginLens, TGPanel.BasicMouseListener, TGPanel.BasicMouseMotionListener
 
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.BltBufferStrategy, Component.FlipBufferStrategy
 
Field Summary
static boolean autoCenter
          Flag enabling auto-centering.
static int BIT_hgrid
          Bitwise Variable indicating the horizontal grid lines should be drawn.
static int BIT_vgrid
          Bitwise Variable indicating the vertical grid lines should be drawn.
 Color COLOR_BACKGROUND
          The background color of this GraphPanel.
static Color COLOR_EMPTY_GRAPH
          The background color of empty GraphPanels.
static Color COLOR_TEXT_FOREGROUND
           
protected  StackSet connected
           
static boolean fasterDraw
          A variable that when true indicates that a faster drawing mode is enabled (which likely simplifies the graph correspondingly, such as using non-directed edges rather than calculating small triangles).
protected  GraphNode hilighted
           
protected  ImageIcon m_bgimage
           
protected  URL m_bgimageURL
           
 int m_gridMode
           
protected  SelectionManager m_selmgr
           
static boolean magneticMouse
          Flag enabling magnetic mouse.
protected  MessageHandler mh
           
protected  boolean mouseIsDragging
           
protected  GraphNode outlined
           
protected  HashSet previouslySelectedNodes
           
 Node provisionalNode
           
protected  boolean scrolling
           
static int skew
          The skew angle used for key navigating.
static BasicStroke STROKE_DOTTED
          The stroke used to draw the grid axis.
protected  TGScrollPane tgsp
           
 
Fields inherited from class com.touchgraph.graphlayout.TGPanel
BACK_COLOR, basicMML, bottomRightDraw, completeEltSet, dragNode, fixedIsPinned, graphListeners, handCursor, localityUtils, maintainMouseOver, mouseOverE, mouseOverN, mousePos, moveCursor, offgraphics, offscreen, offscreensize, paintListeners, select, TG_THREADGROUP_ID, tgLayout, threadgroup, topLeftDraw, visibleLocality
 
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
GraphPanel()
          Default constructor for a GraphPanel.
GraphPanel(TGScrollPane tgScrollPane)
          Constructor for a GraphPanel with a TGScrollPane tgScrollPane.
 
Method Summary
protected  boolean acceptDroppedString(String uri, Point p)
          Receive a drag and dropped URI, returning true if accepted at the given Point.
protected  void activateMMListener(boolean activate)
          Activates or deactivate the ExtendedMouseMotionListener.
 void addEnMasse(Set nodes)
          Adds the Set of nodes all at once (en masse).
 void addSelectionListener(ListDataListener listener)
          Adds a ListDataListener to the SelectionManager to monitor the selection.
 boolean addToSelection(GraphNode node)
          Adds the GraphNode node to the selection, if it is not already part of the Set.
 void beginMultiSelect(MouseEvent e)
          Receives notification of the beginning of a drag event, used to capture the existing selection prior to modification if the Shift key is down.
 void blitText(String[] lines, Font font, Color color, Point p)
          Displays the provided foreground text temporarily, fading after a number of seconds to invisible.
 void centerNode(Node node, boolean fast)
          Scrolls the panel to center Node node, faster if fast is true.
 void clearHilights()
          Clears the hilights of Set s set by keyNavigate(), nulling it when done.
 void clearOutlined()
          Clears the nodes outlined by keyNavigate().
 void clearSelect()
          Deprecated. use clearSelection() instead
 void clearSelection()
          Clears the current selection.
 void endMultiSelect(MouseEvent e)
          Receives notification of the end of a drag event, used to clear the selection buffer supporting multiple selection.
 void fastScrollToCenter(Node n)
          Modified from TG's HVScroll version, this is adjustable for speed.
protected  void findMouseOver()
          Overrides the method in TGPanel to ignore the provisional node created during drag and drop.
 void focusGained(FocusEvent fe)
          Indicates that the GraphPanel has gained the focus.
 void focusLost(FocusEvent fe)
          Indicates that the GraphPanel has lost the focus.
 void followNode(Node node)
          Nudge the Node node nearer to the cursor position.
 int getAngleDBetweenNodes(Node n1, Node n2, int skew)
          Returns the angle (in degrees) formed by the Nodes n1 and n2.
 double getAngleRBetweenNodes(Node n1, Node n2, boolean noisy)
          Returns the angle (in radians) formed by the Nodes n1 and n2.
static int getAutoCenteringFrequency()
          Returns the current value of auto-center frequency (in seconds).
 ImageIcon getBackgroundImage()
          Returns the background image as an ImageIcon, null if not set.
 URL getBackgroundImageURL()
          Returns the URL reference to the background image source, null if not set.
 GraphNode getFirstGraphNode()
          Returns the selected node.
 String[] getForegroundText()
          Return the current foreground text as an array of Strings, or null if not set.
 int getGridCellSize()
          Returns the size of a horizontal grid cell.
protected  LocalityUtils getLocalityUtils()
          Returns the LocalityUtils used by this GraphPanel, primarily for use by the SelectionManager.
static int getMessageFadeTime()
          Returns the current value of the message fade time (in seconds, not milliseconds); This delay is repeated multiple times.
 Iterator getMultiSelected()
          Returns a Iterator over the Set containing all selected GraphNodes, null if there is no selection.
 Iterator getNodesByClass(Class c, boolean inverse)
          Returns an iterator over a set of the GraphNodes currently available from this GraphPanel having Class c.
 Node getSelect()
          Deprecated. use getSelected() instead
 GraphNode getSelected()
          Returns the selected node.
 int getSelectedComposition()
          Return the composition of selected GraphNodes using an int code.
 int getSelectedCount()
          Return the number of selected GraphNodes.
 SelectionManager getSelectionManager()
          Return the SelectionManager handling the selection for this GraphPanel.
static GraphEdge getSharedEdge(GraphNode n1, GraphNode n2)
          Return the first shared edge between the two GraphNodes, null if they do not share an edge.
 TGScrollPane getTGScrollPane()
          Returns the TGScrollPane parent of this GraphPanel.
 void handleMouseEvent(MouseEvent e)
          Processes mouse entered or exited events from the ExtendedMouseListener.
 void handleMouseMotionEvent(MouseEvent e)
          Processes mouse motion dragged or moved events from the ExtendedMouseMotionListener, passing them on to the superclass method unless the current mouse position is within the Vernier.
 boolean isAutoCentering()
          Returns true when autocentering is enabled.
 boolean isMouseDragging()
          Returns true if the mouse is currently being dragged.
 boolean isSelected(GraphNode node)
          Returns true if the GraphNode node is a selected node.
 void keyNavigate(int key)
          This is unimplemented in the base class, as navigation will depend on specific node semantics (as found in subclasses of this class).
 void multiSelect(Point2D.Double from, Point2D.Double to, MouseEvent e)
          Overrides TouchGraph's method, storing the selected nodes via the SelectionManager.
 int nodeCountByClass(Class c, boolean inverse)
          Returns an iterator over a set of the GraphNodes currently available from this GraphLayoutPanel having Class c.
 void paintBackground(Graphics g, Dimension d)
          Overrides TGPanel's method to allow the drawing of vertical and horizontal grid lines.
 void paintForeground(Graphics g, Dimension d)
          If the foreground text has been set (via setForegroundText(String[],Font,Point)), this method displays its contents as an overlay on the graph.
 void paintGrid(Graphics2D g2, Dimension d)
          Overrides TGPanel's method to allow the drawing of vertical and horizontal grid lines.
 void removeEdgesOfType(int type)
          Removes all GraphEdges having a type/style of int type.
 void removeFromSelection(GraphNode node)
          Removes the GraphNode node from the selection.
 void selectAll()
          Selects all of the graph nodes.
 void selectFirstNode()
          A convenience method that selects the first node of a graph, so that hiding works.
 void setAutoCentering(boolean enabled)
          Starts the auto-centering Thread when true, stops it when false.
static void setAutoCenteringFrequency(int value)
          Sets the auto-center frequency (in seconds).
 void setForegroundText(String[] lines, Font font, Point p)
          Set the foreground text (displayed at Point p using Font font) to the String array lines.
 void setHilighted(GraphNode graphnode)
          Hilights GraphNode gnode, also quickly scrolling it to the center of the screen if not within the view rectangle.
 void setMagneticMouse(boolean enabled)
          Starts the magnetic mouse Thread when true, stops it when false.
static void setMessageFadeTime(int value)
          Sets the message fade time (in seconds).
 void setMouseIsDragging(boolean isDragging)
          Sets the indicator of whether the mouse is currently being dragged.
 void setOutlined(GraphNode graphnode)
          Outlines GraphNode gnode, also quickly scrolling it to the center of the screen if not within the view rectangle.
 void setSelect(Node node)
          Deprecated. use setSelected(GraphNode) instead
 void setSelected(GraphNode node)
          Selects the Node node.
 void setTGScrollPane(TGScrollPane tgScrollPane)
          Sets the TGScrollPane parent of this GraphPanel to tgScrollPane.
 void updateLocality(GraphNode node)
          This method should only be called by the SelectionManager as part of updating the graph following a change to the selection.
 
Methods inherited from class com.touchgraph.graphlayout.TGPanel
addEdge, addEdge, addGraphListener, addNode, addNode, addNode, addNode, addNode, addPaintListener, clearAll, collapseNode, convertDrawToReal, convertDrawToReal, convertDrawToReal, convertRealToDraw, convertRealToDraw, convertRealToDraw, deleteEdge, deleteEdge, deleteNode, deleteNodeById, edgeNum, expandNode, fastFinishAnimation, findEdge, findNode, findNodeLabelContaining, findNodesByLabel, findNodesByLabel, fireMovedEvent, fireResetEvent, getAdjustOriginLens, getAllEdges, getAllNodes, getAllNodesAsSet, getBottomRightDraw, getCenter, getDragNode, getDrawCenter, getEdgeCount, getGES, getMouseOverE, getMouseOverN, getMousePos, getNodeCount, getOffscreenImage, getOffscreenImageSize, getSwitchSelectUI, getThreadGroup, getTopLeftDraw, hideEdge, hideNode, isShiftingLocality, main, multiSelect, myBrighter, nodeNum, paint, processGraphMove, redraw, removeGraphListener, removePaintListener, repaintAfterMove, resetDamper, setBackColor, setDragNode, setGraphEltSet, setLensSet, setLocale, setLocale, setMaintainMouseOver, setMouseOverE, setMouseOverN, setMousePos, setTGLayout, sleepTGThread, startDamper, stopDamper, stopMotion, update, updateDrawPos, updateDrawPositions, updateGraphSize, updateLocalityFromVisibility, updatePosFromDraw, visibleEdgeCount, visibleNodeCount
 
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, 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, isPaintingTile, isRequestFocusEnabled, isValidateRoot, 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, setVisible, unregisterKeyboardAction
 
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, 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, 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,