websphinx.workbench
Class GraphLayout

java.lang.Object
  |
  +--java.awt.Component
        |
        +--java.awt.Canvas
              |
              +--websphinx.workbench.GraphLayout
All Implemented Interfaces:
javax.accessibility.Accessible, java.awt.image.ImageObserver, java.awt.MenuContainer, java.lang.Runnable, java.io.Serializable
Direct Known Subclasses:
WebGraph

public class GraphLayout
extends java.awt.Canvas
implements java.lang.Runnable, java.awt.image.ImageObserver


Nested Class Summary
 
Nested classes inherited from class java.awt.Canvas
java.awt.Canvas.AccessibleAWTCanvas
 
Nested classes inherited from class java.awt.Component
java.awt.Component.AccessibleAWTComponent, java.awt.Component.BltBufferStrategy, java.awt.Component.FlipBufferStrategy
 
Field Summary
 
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
GraphLayout()
          Make a GraphLayout.
 
Method Summary
 void addEdge(RenderedEdge edge)
          Add an edge.
 void addNode(RenderedNode node)
          Add a node.
 void changedGraph()
          Notify background thread that the graph has changed.
 void clear()
          Erase the graph.
protected  void finalize()
           
 gd.GDAlgorithm getAlgorithm()
          Get the graph-drawing algorithm in use.
 boolean getAutomaticLayout()
          Test whether the graph is laid out automatically.
 java.awt.Color getEdgeColor()
          Get the edge color.
 java.awt.FontMetrics getFontMetrics()
           
 graph.Graph getGraph()
          Get the graph.
 int getInterval()
          Get the refresh interval (measured in seconds).
 int getIterations()
          Get the layout algorithm iterations per refresh.
 double getNodeCharge()
          Get the node charge.
 java.awt.Color getNodeColor()
          Get the node background color.
 boolean getQuiescent()
          Test whether the graph is quiescent (not changing in the background).
 double getRestLength()
          Get the default rest length for new edges.
 boolean getRunning()
          Test whether the graph layout thread is running in the background
 RenderedEdge getSelectedEdge()
          Get edge currently under the mouse pointer, or null if no edge is under the mouse.
 RenderedNode getSelectedNode()
          Get node currently under the mouse pointer, or null if no node is under the mouse.
 double getSpringConstant()
          Get the spring constant.
 double getThreshold()
          Get the threshold.
 java.awt.Color getTipColor()
          Get the popup tip color.
 boolean handleEvent(java.awt.Event event)
           
 boolean imageUpdate(java.awt.Image img, int infoflags, int x, int y, int width, int height)
          Handle a loaded image.
 void paint(java.awt.Graphics g)
           
 java.lang.Object pick(int x, int y)
          Find the object (Node or Edge) at position (x,y) relative to the window.
 void placeNodeOnGraph(RenderedNode n, double x, double y)
           
 void placeNodeOnScreen(RenderedNode n, int x, int y)
           
 void removeEdge(RenderedEdge edge)
          Remove an edge.
 void removeNode(RenderedNode node)
          Remove a node.
 void repaint()
          Notify background thread that the view has changed.
 void run()
           
 void setAlgorithm(gd.GDAlgorithm algorithm)
          Set the graph-drawing algorithm.
 void setAutomaticLayout(boolean f)
          Set whether the graph is laid out automatically.
 void setEdgeColor(java.awt.Color edgeColor)
          Set the edge color.
 void setFont(java.awt.Font f)
           
 void setGraph(graph.Graph graph)
          Set the graph.
 void setInterval(int interval)
          Set the refresh interval (in seconds).
 void setIterations(int iterations)
          Set the layout algorithm iterations per refresh.
 void setNodeCharge(double nodeCharge)
          Set the node charge.
 void setNodeColor(java.awt.Color nodeColor)
          Set the node background color.
 void setRestLength(double restLength)
          Set the default rest length for new edges.
 void setSpringConstant(double springConstant)
          Set the spring constant.
 void setThreshold(double threshold)
          Set the threshold.
 void setTipColor(java.awt.Color tipColor)
          Set the popup tip color.
 void showControlPanel()
          Show control panel for changing graph layout parameters.
 void start()
          Start automatic graph layout (in the background).
 void stop()
          Stop automatic graph layout.
 void update(java.awt.Graphics g)
           
 
Methods inherited from class java.awt.Canvas
addNotify, createBufferStrategy, createBufferStrategy, getAccessibleContext, getBufferStrategy
 
Methods inherited from class java.awt.Component
action, add, addComponentListener, addFocusListener, addHierarchyBoundsListener, addHierarchyListener, addInputMethodListener, addKeyListener, addMouseListener, addMouseMotionListener, addMouseWheelListener, addPropertyChangeListener, addPropertyChangeListener, applyComponentOrientation, areFocusTraversalKeysSet, bounds, checkImage, checkImage, coalesceEvents, contains, contains, createImage, createImage, createVolatileImage, createVolatileImage, deliverEvent, disable, disableEvents, dispatchEvent, doLayout, enable, enable, enableEvents, enableInputMethods, firePropertyChange, firePropertyChange, firePropertyChange, getAlignmentX, getAlignmentY, getBackground, getBounds, getBounds, getColorModel, getComponentAt, getComponentAt, getComponentListeners, getComponentOrientation, getCursor, getDropTarget, getFocusCycleRootAncestor, getFocusListeners, getFocusTraversalKeys, getFocusTraversalKeysEnabled, getFont, getFontMetrics, getForeground, getGraphics, getGraphicsConfiguration, getHeight, getHierarchyBoundsListeners, getHierarchyListeners, getIgnoreRepaint, getInputContext, getInputMethodListeners, getInputMethodRequests, getKeyListeners, getListeners, getLocale, getLocation, getLocation, getLocationOnScreen, getMaximumSize, getMinimumSize, getMouseListeners, getMouseMotionListeners, getMouseWheelListeners, getName, getParent, getPeer, getPreferredSize, getPropertyChangeListeners, getPropertyChangeListeners, getSize, getSize, getToolkit, getTreeLock, getWidth, getX, getY, gotFocus, hasFocus, hide, inside, invalidate, isBackgroundSet, isCursorSet, isDisplayable, isDoubleBuffered, isEnabled, isFocusable, isFocusCycleRoot, isFocusOwner, isFocusTraversable, isFontSet, isForegroundSet, isLightweight, isOpaque, isShowing, isValid, isVisible, keyDown, keyUp, layout, list, list, list, list, list, locate, location, lostFocus, minimumSize, mouseDown, mouseDrag, mouseEnter, mouseExit, mouseMove, mouseUp, move, nextFocus, paintAll, paramString, postEvent, preferredSize, prepareImage, prepareImage, print, printAll, processComponentEvent, processEvent, processFocusEvent, processHierarchyBoundsEvent, processHierarchyEvent, processInputMethodEvent, processKeyEvent, processMouseEvent, processMouseMotionEvent, processMouseWheelEvent, remove, removeComponentListener, removeFocusListener, removeHierarchyBoundsListener, removeHierarchyListener, removeInputMethodListener, removeKeyListener, removeMouseListener, removeMouseMotionListener, removeMouseWheelListener, removeNotify, removePropertyChangeListener, removePropertyChangeListener, repaint, repaint, repaint, requestFocus, requestFocus, requestFocusInWindow, requestFocusInWindow, reshape, resize, resize, setBackground, setBounds, setBounds, setComponentOrientation, setCursor, setDropTarget, setEnabled, setFocusable, setFocusTraversalKeys, setFocusTraversalKeysEnabled, setForeground, setIgnoreRepaint, setLocale, setLocation, setLocation, setName, setSize, setSize, setVisible, show, show, size, toString, transferFocus, transferFocusBackward, transferFocusUpCycle, validate
 
Methods inherited from class java.lang.Object
clone, equals, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

GraphLayout

public GraphLayout()
Make a GraphLayout.

Method Detail

clear

public void clear()
Erase the graph.


getGraph

public graph.Graph getGraph()
Get the graph.


setGraph

public void setGraph(graph.Graph graph)
Set the graph.


getAlgorithm

public gd.GDAlgorithm getAlgorithm()
Get the graph-drawing algorithm in use.


setAlgorithm

public void setAlgorithm(gd.GDAlgorithm algorithm)
Set the graph-drawing algorithm.


getRestLength

public double getRestLength()
Get the default rest length for new edges.


setRestLength

public void setRestLength(double restLength)
Set the default rest length for new edges.


getSpringConstant

public double getSpringConstant()
Get the spring constant.


setSpringConstant

public void setSpringConstant(double springConstant)
Set the spring constant.


getNodeCharge

public double getNodeCharge()
Get the node charge.


setNodeCharge

public void setNodeCharge(double nodeCharge)
Set the node charge.


getInterval

public int getInterval()
Get the refresh interval (measured in seconds).


setInterval

public void setInterval(int interval)
Set the refresh interval (in seconds).


getIterations

public int getIterations()
Get the layout algorithm iterations per refresh.


setIterations

public void setIterations(int iterations)
Set the layout algorithm iterations per refresh.


getAutomaticLayout

public boolean getAutomaticLayout()
Test whether the graph is laid out automatically.


setAutomaticLayout

public void setAutomaticLayout(boolean f)
Set whether the graph is laid out automatically.


getQuiescent

public boolean getQuiescent()
Test whether the graph is quiescent (not changing in the background).


getRunning

public boolean getRunning()
Test whether the graph layout thread is running in the background


getThreshold

public double getThreshold()
Get the threshold.


setThreshold

public void setThreshold(double threshold)
Set the threshold.


getNodeColor

public java.awt.Color getNodeColor()
Get the node background color.


setNodeColor

public void setNodeColor(java.awt.Color nodeColor)
Set the node background color.


getEdgeColor

public java.awt.Color getEdgeColor()
Get the edge color.


setEdgeColor

public void setEdgeColor(java.awt.Color edgeColor)
Set the edge color.


getTipColor

public java.awt.Color getTipColor()
Get the popup tip color.


setTipColor

public void setTipColor(java.awt.Color tipColor)
Set the popup tip color.


getSelectedNode

public RenderedNode getSelectedNode()
Get node currently under the mouse pointer, or null if no node is under the mouse.


getSelectedEdge

public RenderedEdge getSelectedEdge()
Get edge currently under the mouse pointer, or null if no edge is under the mouse.


addNode

public void addNode(RenderedNode node)
Add a node.


addEdge

public void addEdge(RenderedEdge edge)
Add an edge.


removeNode

public void removeNode(RenderedNode node)
Remove a node.


removeEdge

public void removeEdge(RenderedEdge edge)
Remove an edge.


imageUpdate

public boolean imageUpdate(java.awt.Image img,
                           int infoflags,
                           int x,
                           int y,
                           int width,
                           int height)
Handle a loaded image.

Specified by:
imageUpdate in interface java.awt.image.ImageObserver
Overrides:
imageUpdate in class java.awt.Component

start

public void start()
Start automatic graph layout (in the background).


stop

public void stop()
Stop automatic graph layout.


run

public void run()
Specified by:
run in interface java.lang.Runnable

changedGraph

public void changedGraph()
Notify background thread that the graph has changed.


repaint

public void repaint()
Notify background thread that the view has changed.

Overrides:
repaint in class java.awt.Component

showControlPanel

public void showControlPanel()
Show control panel for changing graph layout parameters.


finalize

protected void finalize()
                 throws java.lang.Throwable
Overrides:
finalize in class java.lang.Object

placeNodeOnScreen

public void placeNodeOnScreen(RenderedNode n,
                              int x,
                              int y)

placeNodeOnGraph

public void placeNodeOnGraph(RenderedNode n,
                             double x,
                             double y)

update

public void update(java.awt.Graphics g)
Overrides:
update in class java.awt.Canvas

paint

public void paint(java.awt.Graphics g)
Overrides:
paint in class java.awt.Canvas

getFontMetrics

public java.awt.FontMetrics getFontMetrics()

setFont

public void setFont(java.awt.Font f)
Overrides:
setFont in class java.awt.Component

handleEvent

public boolean handleEvent(java.awt.Event event)
Overrides:
handleEvent in class java.awt.Component

pick

public java.lang.Object pick(int x,
                             int y)
Find the object (Node or Edge) at position (x,y) relative to the window.

Parameters:
x - X position
y - Y position
Returns:
topmost object under (x,y), or null if none