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, 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

skew

public static int skew
The skew angle used for key navigating. This determines the "0°" position (the default of -90 sets 0° to the twelve o'clock position).


autoCenter

public static boolean autoCenter
Flag enabling auto-centering. (This does not start the Thread, only enable it.)


magneticMouse

public static boolean magneticMouse
Flag enabling magnetic mouse. (This does not start the Thread, only enable it.)


BIT_vgrid

public static final int BIT_vgrid
Bitwise Variable indicating the vertical grid lines should be drawn.

See Also:
Constant Field Values

BIT_hgrid

public static final int BIT_hgrid
Bitwise Variable indicating the horizontal grid lines should be drawn.

See Also:
Constant Field Values

COLOR_BACKGROUND

public Color COLOR_BACKGROUND
The background color of this GraphPanel. The default is set to TGPanel.BACK_COLOR, and overwritten by the stylesheet.


fasterDraw

public 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). For very large graphs this may be set to true to improve performance, or when display of edge direction is unimportant. Default is false.


COLOR_EMPTY_GRAPH

public static Color COLOR_EMPTY_GRAPH
The background color of empty GraphPanels. The default is Color.gray, but generally is set by the stylesheet from the properties file.


COLOR_TEXT_FOREGROUND

public static Color COLOR_TEXT_FOREGROUND

STROKE_DOTTED

public static final BasicStroke STROKE_DOTTED
The stroke used to draw the grid axis.


tgsp

protected TGScrollPane tgsp

mh

protected MessageHandler mh

provisionalNode

public Node provisionalNode

hilighted

protected GraphNode hilighted

outlined

protected GraphNode outlined

connected

protected StackSet connected

previouslySelectedNodes

protected HashSet previouslySelectedNodes

m_bgimage

protected ImageIcon m_bgimage

m_bgimageURL

protected URL m_bgimageURL

m_selmgr

protected SelectionManager m_selmgr

mouseIsDragging

protected boolean mouseIsDragging

m_gridMode

public int m_gridMode

scrolling

protected boolean scrolling
Constructor Detail

GraphPanel

public GraphPanel()
Default constructor for a GraphPanel. This leaves the parent TGScrollPane null and disables focusability and any key-based event listeners.


GraphPanel

public GraphPanel(TGScrollPane tgScrollPane)
Constructor for a GraphPanel with a TGScrollPane tgScrollPane.

Method Detail

acceptDroppedString

protected boolean acceptDroppedString(String uri,
                                      Point p)
Receive a drag and dropped URI, returning true if accepted at the given Point. Currently, this always returns false, since this class doesn't do anything with the drop. In subclasses this might return true on acceptable node types, false on bad node types. Dropping on the background might also have a specific meaning.


setTGScrollPane

public void setTGScrollPane(TGScrollPane tgScrollPane)
Sets the TGScrollPane parent of this GraphPanel to tgScrollPane.


getTGScrollPane

public TGScrollPane getTGScrollPane()
Returns the TGScrollPane parent of this GraphPanel.


setMessageFadeTime

public static void setMessageFadeTime(int value)
Sets the message fade time (in seconds). Values outside of the range 1-30 are ignored.


getMessageFadeTime

public static int getMessageFadeTime()
Returns the current value of the message fade time (in seconds, not milliseconds); This delay is repeated multiple times.


setAutoCenteringFrequency

public static void setAutoCenteringFrequency(int value)
Sets the auto-center frequency (in seconds). Values outside of the range 1-30 are ignored.


getAutoCenteringFrequency

public static int getAutoCenteringFrequency()
Returns the current value of auto-center frequency (in seconds).


isAutoCentering

public boolean isAutoCentering()
Returns true when autocentering is enabled.


setAutoCentering

public void setAutoCentering(boolean enabled)
Starts the auto-centering Thread when true, stops it when false. Redundant method calls are ignored, although a call to start an existing Timer will reset it, enabling changes to the frequency.


setMagneticMouse

public void setMagneticMouse(boolean enabled)
Starts the magnetic mouse Thread when true, stops it when false. Redundant method calls are ignored, although a call to start an existing Timer will reset it, enabling changes to the frequency.

The trick here will be to continue magnetizing the last node until a new one is mouseover'd, up to a certain distance, then let go.


followNode

public void followNode(Node node)
Nudge the Node node nearer to the cursor position. If node is null, nothing happens. (Currently unfinished.)


getBackgroundImage

public ImageIcon getBackgroundImage()
Returns the background image as an ImageIcon, null if not set. Note that this class does not support setting the background image; this method is provided for any subclasses that do.


getBackgroundImageURL

public URL getBackgroundImageURL()
Returns the URL reference to the background image source, null if not set. Note that this class does not support setting the background image; this method is provided for any subclasses that do.


isMouseDragging

public boolean isMouseDragging()
Returns true if the mouse is currently being dragged.


setMouseIsDragging

public void setMouseIsDragging(boolean isDragging)
Sets the indicator of whether the mouse is currently being dragged.


getNodesByClass

public Iterator getNodesByClass(Class c,
                                boolean inverse)
Returns an iterator over a set of the GraphNodes currently available from this GraphPanel having Class c. If the boolean inverse is true, all nodes except those of the provided class are returned.


nodeCountByClass

public int nodeCountByClass(Class c,
                            boolean inverse)
Returns an iterator over a set of the GraphNodes currently available from this GraphLayoutPanel having Class c. If the boolean inverse is true, all nodes except those of the provided class are counted.


addEnMasse

public void addEnMasse(Set nodes)
Adds the Set of nodes all at once (en masse). This avoids resetDamper() being called on each node. Note that handling addition of Edges is affected by their respective Nodes not being available in the graph.


centerNode

public void centerNode(Node node,
                       boolean fast)
Scrolls the panel to center Node node, faster if fast is true. If node is null, centers the selected node.


fastScrollToCenter

public void fastScrollToCenter(Node n)
Modified from TG's HVScroll version, this is adjustable for speed.


removeEdgesOfType

public void removeEdgesOfType(int type)
Removes all GraphEdges having a type/style of int type. Values for type include GraphEdge.UNDIRECTED, GraphEdge.DIRECTED_FROM, GraphEdge.DIRECTED_TO and GraphEdge.ARROW_FORWARD. If type is -1, all edges are removed.


getSharedEdge

public static GraphEdge getSharedEdge(GraphNode n1,
                                      GraphNode n2)
Return the first shared edge between the two GraphNodes, null if they do not share an edge.


selectAll

public void selectAll()
Selects all of the graph nodes. The boolean unfiltered is not used in this class.


getSelectionManager

public SelectionManager getSelectionManager()
Return the SelectionManager handling the selection for this GraphPanel.


getSelectedCount

public int getSelectedCount()
Return the number of selected GraphNodes.


getSelectedComposition

public int getSelectedComposition()
Return the composition of selected GraphNodes using an int code.

See Also:
SelectionManager

addToSelection

public boolean addToSelection(GraphNode node)
Adds the GraphNode node to the selection, if it is not already part of the Set.

Returns:
returns true if the GraphNode was added.

removeFromSelection

public void removeFromSelection(GraphNode node)
Removes the GraphNode node from the selection. If it is not part of the Set, nothing happens.


clearSelection

public void clearSelection()
Clears the current selection.


getMultiSelected

public Iterator getMultiSelected()
Returns a Iterator over the Set containing all selected GraphNodes, null if there is no selection.

See Also:
SelectionManager.getMultiSelected()

setSelected

public void setSelected(GraphNode node)
Selects the Node node. If node is already the selected node, the message is ignored. This replaces TouchGraph's TGPanel.setSelect(Node), but returns the Node subclass GraphNode.


selectFirstNode

public void selectFirstNode()
A convenience method that selects the first node of a graph, so that hiding works. Overrides TGPanel's method of the same name. If the graph is empty, nothing happens (unsurprisingly).

Overrides:
selectFirstNode in class TGPanel

addSelectionListener

public void addSelectionListener(ListDataListener listener)
Adds a ListDataListener to the SelectionManager to monitor the selection. Combine this with the size and composition of the selection to provide the necessary filtering.


getFirstGraphNode

public GraphNode getFirstGraphNode()
Returns the selected node. This replaces TouchGraph's /** A convenience method that returns the first node of a graph.


getLocalityUtils

protected LocalityUtils getLocalityUtils()
Returns the LocalityUtils used by this GraphPanel, primarily for use by the SelectionManager.


getSelected

public GraphNode getSelected()
Returns the selected node. This replaces TouchGraph's TGPanel.getSelect(), but returns the Node subclass GraphNode.


isSelected

public boolean isSelected(GraphNode node)
Returns true if the GraphNode node is a selected node. More than one node may return true if there is a multiple selection. To test for a single selection, use a match on getSelected().


beginMultiSelect

public 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.


endMultiSelect

public void endMultiSelect(MouseEvent e)
Receives notification of the end of a drag event, used to clear the selection buffer supporting multiple selection.


multiSelect

public void multiSelect(Point2D.Double from,
                        Point2D.Double to,
                        MouseEvent e)
Overrides TouchGraph's method, storing the selected nodes via the SelectionManager. This isn't quite an override, since this method's signature includes the MouseEvent, which may be used to capture key modifier presses in subclasses.


findMouseOver

protected void findMouseOver()
Overrides the method in TGPanel to ignore the provisional node created during drag and drop.

Overrides:
findMouseOver in class TGPanel

updateLocality

public 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.


setSelect

public void setSelect(Node node)
Deprecated. use setSelected(GraphNode) instead

Overrides TouchGraph's method in order to deprecate its use here.

Overrides:
setSelect in class TGPanel

getSelect

public Node getSelect()
Deprecated. use getSelected() instead

Overrides TouchGraph's method in order to deprecate its use here.

Overrides:
getSelect in class TGPanel

clearSelect

public void clearSelect()
Deprecated. use clearSelection() instead

Overrides TouchGraph's method in order to deprecate its use here.

Overrides:
clearSelect in class TGPanel

activateMMListener

protected void activateMMListener(boolean activate)
Activates or deactivate the ExtendedMouseMotionListener.

Overrides:
activateMMListener in class TGPanel

handleMouseEvent

public void handleMouseEvent(MouseEvent e)
Processes mouse entered or exited events from the ExtendedMouseListener.

Overrides:
handleMouseEvent in class TGPanel

handleMouseMotionEvent

public 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.

Overrides:
handleMouseMotionEvent in class TGPanel

focusGained

public void focusGained(FocusEvent fe)
Indicates that the GraphPanel has gained the focus.

Specified by:
focusGained in interface FocusListener

focusLost

public void focusLost(FocusEvent fe)
Indicates that the GraphPanel has lost the focus.

Specified by:
focusLost in interface FocusListener

paintBackground

public void paintBackground(Graphics g,
                            Dimension d)
Overrides TGPanel's method to allow the drawing of vertical and horizontal grid lines. When the graph is empty, the Color GraphPanel.COLOR_BACKGROUND is set null, which causes the background to be drawn in a checkerboard-pattern TexturePaint.

Also, in TGPanel the background color is static (the same across all instances), whereas here it is set to COLOR_BACKGROUND, whose default value is TGPanel.BACK_COLOR.

Overrides:
paintBackground in class TGPanel

paintForeground

public 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.

Overrides:
paintForeground in class TGPanel

blitText

public void blitText(String[] lines,
                     Font font,
                     Color color,
                     Point p)
Displays the provided foreground text temporarily, fading after a number of seconds to invisible. The Font, Color, and Point are all optional.


setForegroundText

public void setForegroundText(String[] lines,
                              Font font,
                              Point p)
Set the foreground text (displayed at Point p using Font font) to the String array lines. Set to null to disable. Both the Font and the Point are optional, defaulting to (30,30), as displayed from the upper left corner. The Font used will either be the default graph Font or the previously-set Font if null. If successive method calls don't set a location, the existing location will be used.


getForegroundText

public String[] getForegroundText()
Return the current foreground text as an array of Strings, or null if not set.


getGridCellSize

public int getGridCellSize()
Returns the size of a horizontal grid cell.


paintGrid

public void paintGrid(Graphics2D g2,
                      Dimension d)
Overrides TGPanel's method to allow the drawing of vertical and horizontal grid lines.


clearHilights

public void clearHilights()
Clears the hilights of Set s set by keyNavigate(), nulling it when done.


setHilighted

public void setHilighted(GraphNode graphnode)
Hilights GraphNode gnode, also quickly scrolling it to the center of the screen if not within the view rectangle.


clearOutlined

public void clearOutlined()
Clears the nodes outlined by keyNavigate().


setOutlined

public void setOutlined(GraphNode graphnode)
Outlines GraphNode gnode, also quickly scrolling it to the center of the screen if not within the view rectangle.


keyNavigate

public 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).


getAngleDBetweenNodes

public int getAngleDBetweenNodes(Node n1,
                                 Node n2,
                                 int skew)
Returns the angle (in degrees) formed by the Nodes n1 and n2. The specific coordinate system is skewed by skewAngle to alter the 0° position (eg., -90 sets it at 12 o'clock; if set to zero the 0° position is at 9 o'clock). This method takes into account the panel's rotation angle.


getAngleRBetweenNodes

public double getAngleRBetweenNodes(Node n1,
                                    Node n2,
                                    boolean noisy)
Returns the angle (in radians) formed by the Nodes n1 and n2. This method takes into account the panel's rotation angle.



The Ceryle Project. Copyright ©2001-2007 Murray Altheim, All Rights Reserved. See LICENSE included with distribution.