org.ceryle.graph
Class GraphLayoutPanel

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.ceryle.graph.GraphLayoutPanel
All Implemented Interfaces:
TGScrollPane, ImageObserver, MenuContainer, Serializable, Accessible
Direct Known Subclasses:
TMLayoutPanel

public class GraphLayoutPanel
extends JPanel
implements TGScrollPane

GraphLayoutPanel extends JPanel in providing support for a TouchGraph implementation, an analogue to TG's GLPanel (i.e., its demo panel). It also provides methods for navigating and manipulating nodes and edges and an improved tool bar over GLPanel.

NOTE: after calling its constructor, initialize() must be called to establish the graph engine and its GUI support.

Author:
Murray Altheim
See Also:
Serialized Form

Nested Class Summary
 class GraphLayoutPanel.ButtonListener
          The listener class to handle button events.
 
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
protected  JRadioButton btn_hyper
           
protected  JButton btn_infinity
           
protected  JRadioButton btn_locality
           
protected  JRadioButton btn_rotate
           
protected  JRadioButton btn_sequence
           
protected  JRadioButton btn_zoom
           
static int DEFAULT_HYPERBOLIC
          An int value indicating the default setting (default=0) of the Hyperbolic distortion scroll bar.
static int DEFAULT_LOCALITY
          An int value indicating the default setting (default=4) of the Locality scroll bar.
static int DEFAULT_SEQUENCE
          An int value indicating the default setting (default=0) of the Sequence scroll bar.
protected static Color defaultColor
           
protected  GLEditUI editUI
           
protected  GraphPanel gp
           
protected  GraphPopupMenu gPopupMenu
           
protected  HVScroll hvScroll
           
static int HYPER_SCROLL
          An enumerated int value indicating the Hyperbolic scroll bar.
protected  JScrollBar hyperSB
           
protected  HyperScroll hyperScroll
           
static boolean includeEdit
          If true, include the "Edit" checkbox.
static int INFINITE_LOCALITY
          An int constant indicating infinite locality, derived from LocalityUtils.
protected  Point2D.Double lastClick
           
static int LOCALITY_SCROLL
          An enumerated int value indicating the Locality scroll bar.
protected  JScrollBar localitySB
           
protected  GraphLocalityScroll localityScroll
           
protected  Desktop m_desktop
           
protected  JComponent m_graphContainer
           
protected  JPanel m_legendPanel
           
protected  boolean m_localityEnabled
          Allows the locality scroll bar to be disabled.
protected  MouseWheelListener m_mouseWheelListener
           
protected  JScrollBar m_selectedSB
           
protected  boolean m_verbose
           
protected  View m_view
           
static int MAXIMUM_LOCALITY
          An int value indicating the maximum setting (default=20) of the Locality scroll bar.
protected  MessageHandler mh
           
protected  JCheckBox modeSelect
           
protected  GraphNavigateUI navigateUI
           
protected  PropertyManager pm
           
protected  JPanel popPanel
           
static int ROTATE_SCROLL
          An enumerated int value indicating the Rotate scroll bar.
protected  JScrollBar rotateSB
           
protected  RotateScroll rotateScroll
           
protected  JPanel scrollPanel
           
static int SEQUENCE_SCROLL
          An enumerated int value indicating the Sequence scroll bar.
protected  JScrollBar sequenceSB
           
protected  SequenceScroll sequenceScroll
           
protected  Services srvs
           
protected  TGLensSet tgLensSet
           
protected  TGUIManager tgUIManager
           
static int UI_EDIT
          An enumerated int value indicating the Edit UI manager.
static int UI_NAVIGATE
          An enumerated int value indicating the Navigate UI manager.
static int UI_ROTATEDRAG
          An enumerated int value indicating the RotateDrag UI manager.
static Point2D.Double zero
           
static int ZOOM_SCROLL
          An enumerated int value indicating the Zoom scroll bar.
protected  JScrollBar zoomSB
           
protected  ZoomScroll zoomScroll
           
 
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
GraphLayoutPanel(View view)
          Constructor provided a reference to the parent view.
 
Method Summary
 void activateUI(int ui)
          Activates the indicated UI manager.
protected  GraphEdge addEdge(GraphNode node1, GraphNode node2, int length, int directed)
          Creates an edge between GraphNode node and node2 with a length of length, and edge direction of int directed (whose values may be GraphEdge.UNDIRECTED, GraphEdge.DIRECTED_TO, or GraphEdge.DIRECTED_FROM).
protected  void addGraphPanel(GraphPanel graphpanel)
          Adds the provided GraphPanel to this GraphLayoutPanel.
protected  void addUIs()
           
protected  void buildLens()
          Builds the set of lenses.
protected  void buildScrollBars()
          Builds the set of lenses.
protected  void buildScrollPanel()
          Adds the Zoom, Rotate and Locality scroll bars to the graph tool bar and creates the TouchGraph panel.
 void centerNode(GraphNode node)
          Quickly centers GraphNode node.
 void centerSelectedNode()
          Quickly centers the selected node.
 void centerSelectedNode(boolean fast)
          Centers the selected node, faster if the boolean is true.
 void clearGraph()
          Clears the graph area.
 void defloat(boolean shifted)
          Clusters all floating (unfixed), unattached GraphNodes around the selected node.
 boolean deleteNode(GraphNode node, boolean confirm)
          Deletes the GraphNode node, what happens depends on its type.
 boolean deleteSelected(boolean confirm)
          Deletes the selected nodes, depending on the number of type.
 Node findNode(String id)
          A convenience method that calls findNode(id,true) (searching the entire graph).
 Node findNode(String id, boolean searchAll)
          Returns the Node whose ID is the String id.
 Iterator getAllEdges()
          Returns all Edges in the graph as an Iterator, null if it is empty.
 GraphPanel getGraphPanel()
          Return a lazily-created GraphPanel used with this GraphLayoutPanel.
 GraphView getGraphView()
          Returns the parent GraphView of this GraphLayoutPanel.
 HVScroll getHVScroll()
          Return the HVScroll used with this GraphLayoutPanel.
 int getHyperbolicDistortion()
          Return the hyperbolic distortion of this GraphLayoutPanel.
 int getHyperRadius()
          Returns the radius of the circle at which points stay a constant distance away from the center despite the hyperbolic (fisheye) effect.
 HyperScroll getHyperScroll()
          Return the HyperScroll used with this GraphLayoutPanel.
 Point2D.Double getLastClickPoint()
          Returns the stored last-clicked point.
 double getLeftOf(GraphNode node)
          Returns a value corresponding to the X value of the left edge of GraphNode node.
 JPanel getLegend()
          Lazily-created east panel (uses a Y Box layout), used for legends.
 int getLocalityRadius()
          Return the locality radius of this GraphLayoutPanel.
 LocalityScroll getLocalityScroll()
          Return the LocalityScroll used with this GraphLayoutPanel.
 int getNodeCount()
          A convenience method; returns the number of nodes in the current graph.
 Font getNodeFont()
          Returns the font of the node text.
 Point getOffset()
          Return the viewport's horizontal and vertical offset position as a Point.
 JPanel getPopPanel()
          Returns the unused panel located to the left of the radio buttons.
 JPopupMenu getPopupMenu()
          Return the JPopupMenu used (actually, a GraphPopupMenu).
protected  Integer getPosition(boolean horiz, GraphNode node)
          Returns an Integer corresponding to the X (horiz==true) or Y position of GraphNode node.
 Point getPosition(GraphNode node)
          Return the GraphNode position as a Point, adjusted to take into account all active lenses.
 RotateScroll getRotateScroll()
          Return the RotateScroll used with this GraphLayoutPanel.
 int getRotationAngle()
          Return the rotation angle of this GraphLayoutPanel.
 JPanel getScrollPanel()
          Returns the graph's scroll panel.
 int getSelectedCount()
          Returns the number of selected GraphNodes.
 Point getSelectedLocation()
          Returns a Point containing the location of the selected Node, null if unavailable.
 GraphNode getSelectedNode()
          Returns the selected GraphNode, null if unavailable.
 int getSequenceDistortion()
          Return the sequence distortion of this GraphLayoutPanel.
 SequenceScroll getSequenceScroll()
          Return the SequenceScroll used with this GraphLayoutPanel.
 TGPanel getTGPanel()
          Return the TGPanel used with this GraphLayoutPanel.
 double getTopOf(GraphNode node)
          Returns a value corresponding to the Y value of the top edge of GraphNode node.
 View getView()
          Returns the parent View of this GraphLayoutPanel.
 ZoomScroll getZoomScroll()
          Return the ZoomScroll used with this GraphLayoutPanel.
 int getZoomValue()
          Return the zoom value of this GraphLayoutPanel.
 int[] graphStatus()
          Returns some status info as an int array.
 void hideNode(Node node)
          Hides the Node node, unless it is the first node.
 void initialize()
          Initializes the panel, tool bar and lens.
 void initialize(GraphPanel graphpanel)
          Initializes the panel, tool bar and lens, using the supplied GraphPanel.
 boolean isEditActive()
          Return true if the GLEditUI considers the graph active.
 boolean isEmpty()
          A convenience method that returns true if the graph is empty (i.e., it contains no nodes).
 boolean isLocalityEnabled()
          Returns true if the locality scrollbar is enabled.
 void keyPressed(KeyEvent ke)
          Responds to KeyEvents sent to the GraphPanel's GraphKeyListener.
 void nodeClicked(Node node, MouseEvent e)
          An action method that indicates that the Node node has been clicked.
 void nodeDoubleClicked(Node node, MouseEvent e)
          An action method that indicates that the Node node has been double-clicked.
 GraphPanel releaseGraphPanel()
          Releases use of the current GraphPanel, effectively disabling this GraphLayoutPanel.
 void repaintNode(GraphNode node)
          Repaints the GraphNode node by jubbling it.
 void reset()
          Resets the display damper, making the graph slowly move again.
 void selectAll(boolean unfiltered)
          Selects all of the graph nodes.
 void selectFirstNode()
          Selects the first node, triggering locality.
 void selectFirstNode(int r)
          Selects the first node, triggering locality at a radius of r.
 boolean selectNode(Node node)
          Selects the Node node.
 boolean selectNode(String id)
          Selects the Node whose ID is the String id.
 void selectSB(int scroll)
          Shows the indicated scroll bar.
protected  void setDefaultStylesheet()
          Sets the default colors for this GraphLayoutPanel.
 void setFixedSelectedNode(boolean fixed)
          Sets the fixed state of the selected Node or Nodes.
 void setGraphPriority(boolean hasPriority)
          Checks the priority of current Threads in this ThreadGroup.
 void setGraphPriority(int priority)
          Sets the priority of current Threads in this ThreadGroup to priority.
 void setHyperbolicDistortion(int value)
          Set the hyperbolic distortion of this TGScrollPane (allowable values between 0 to 108).
protected  void setHyperRadius(int radius)
          Sets the radius of the circle at which points stay a constant distance away from the center despite the hyperbolic (fisheye) effect.
 void setLastClickPoint(Point2D.Double p)
          Sets the stored last-clicked point to p.
 void setLocalityEnabled(boolean enabled)
          Sets the enabled status of the locality scrollbar.
 void setLocalityRadius(int radius)
          Set the locality radius of this TGScrollPane.
 void setNavigateVerbosity(boolean verbose)
          Set the verbosity of the GraphNavigateUI, which displays clicked locations when verbose.
 void setNodeFont(Font font)
          Sets the font of the node text to the Font font.
 void setOffset(Point p)
          Sets the horizontal offset of the viewport to p.x, the vertical offset to p.y, given Point p.
 void setPosition(int x, int y)
          Relocation the graph to the position x,y.
 void setRotationAngle(int angle)
          Set the rotation angle of this GraphLayoutPanel (allowable values between 0 to 359).
 void setScrollBarsEnabled(boolean enabled)
          Enables or disables the selector buttons for the scroll bars.
 void setScrollPanelVisibility(boolean visible)
          Sets the visibility of the graph's scroll panel to the boolean visible.
 void setSequenceDistortion(int value)
          Set the sequence distortion of this TGScrollPane (allowable values between 0 to 100).
 void setStylesheet(String filename)
          Sets the graph color "stylesheet" according to the properties found in file filename, which is an XML properties file in the same notation as the Ceryle property file (".ceryle.prop").
 void setToolVisibility(boolean visible)
          Sets the visibility of the graph tools according to the value of the boolean visible.
 void setZoomValue(int zoomValue)
          Set the zoom value of this GraphLayoutPanel (allowable values between -100 to 100).
 void update()
          Updates the display.
 
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, 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, 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, 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,