edu.uci.ics.jung.visualization
Class GraphDraw

java.lang.Object
  extended byjava.awt.Component
      extended byjava.awt.Container
          extended byjavax.swing.JComponent
              extended byedu.uci.ics.jung.visualization.GraphDraw
All Implemented Interfaces:
java.awt.image.ImageObserver, java.awt.MenuContainer, java.io.Serializable, StatusCallback

public class GraphDraw
extends javax.swing.JComponent
implements StatusCallback

A Swing-only component for drawing graphs. Allows a series of manipulations to access and show graphs, to set their various colors and lines, and to dynamically change values. This is a good starting place for getting a graph up quickly.

Author:
Danyel Fisher
See Also:
Serialized Form

Nested Class Summary
 
Nested classes inherited from class javax.swing.JComponent
javax.swing.JComponent.AccessibleJComponent
 
Field Summary
 
Fields inherited from class javax.swing.JComponent
TOOL_TIP_TEXT_KEY, 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
GraphDraw(Graph g)
          Creates a graph drawing environment that draws this graph object.
 
Method Summary
 void addGraphMouseListener(GraphMouseListener gel)
          This is the interface for adding a mouse listener.
 javax.swing.JSlider addSlider(LevelFilter l, int low, int high, int defaultVal)
          Creates a new slider based off of a LevelFilter.
 void addStaticFilter(Filter f)
          Adds a Filter that doesn't slide.
 void addTool(javax.swing.JComponent jc)
          Adds a tool to the toolbar.
 void callBack(java.lang.String status)
           
 Layout getGraphLayout()
          Returns the currently operative layout.
 SettableRenderer getRender()
           
 VisualizationViewer getVisualizationViewer()
          Returns the visualizationviewer that actually does the graph drawing.
 void hideStatus()
          Hides the status bar at bottom left
 void removeAllFilters()
          Removes all the filters, deleting the sliders that drive them.
 void resetRenderer()
           
 void restartLayout()
          This is the "scramble" button--it resets the layout.
 void setBackground(java.awt.Color bg)
           
 void setBackgroundColor(java.awt.Color bgColor)
           
 void setEdgeColor(java.awt.Color c)
          A passthrough to the function at originalRenderer.
 void setEdgeColorFunction(EdgeColorFunction ecf)
          A passthrough to the function at originalRenderer.
 void setEdgeThickness(int i)
          A passthrough to the function at originalRenderer.
 void setEdgeThicknessFunction(EdgeThicknessFunction etf)
          A passthrough to the function at originalRenderer.
 void setGraphLayout(Layout l)
          Dynamically chooses a new GraphLayout.
 void setRenderer(Renderer r)
          A method to set the renderer.
 void setVertexBGColor(java.awt.Color vertexColor)
          A passthrough to the function at originalRenderer.
 void setVertexColorFunction(VertexColorFunction vcf)
          A passthrough to the function at originalRenderer.
 void setVertexForegroundColor(java.awt.Color vertexColor)
          A passthrough to the function at originalRenderer.
 void setVertexPickedColor(java.awt.Color vertexColor)
          A passthrough to the function at originalRenderer.
 void showStatus()
          Shows the status bar at bottom left
 void stop()
           
 
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, getAccessibleContext, getActionForKeyStroke, getActionMap, getAlignmentX, getAlignmentY, getAncestorListeners, getAutoscrolls, getBorder, getBounds, getClientProperty, 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, getUIClassID, getVerifyInputWhenFocusTarget, getVetoableChangeListeners, getVisibleRect, getWidth, getX, getY, grabFocus, isDoubleBuffered, isLightweightComponent, isManagingFocus, isMaximumSizeSet, isMinimumSizeSet, isOpaque, isOptimizedDrawingEnabled, isPaintingTile, isPreferredSizeSet, isRequestFocusEnabled, isValidateRoot, paint, paintImmediately, paintImmediately, print, printAll, putClientProperty, registerKeyboardAction, registerKeyboardAction, removeAncestorListener, removeNotify, removePropertyChangeListener, removePropertyChangeListener, removeVetoableChangeListener, repaint, repaint, requestDefaultFocus, requestFocus, requestFocus, requestFocusInWindow, resetKeyboardActions, reshape, revalidate, scrollRectToVisible, setActionMap, setAlignmentX, setAlignmentY, setAutoscrolls, setBorder, setDebugGraphicsOptions, setDefaultLocale, setDoubleBuffered, setEnabled, setFont, setForeground, setInputMap, setInputVerifier, setMaximumSize, setMinimumSize, setNextFocusableComponent, setOpaque, setPreferredSize, setRequestFocusEnabled, setToolTipText, setTransferHandler, setVerifyInputWhenFocusTarget, setVisible, unregisterKeyboardAction, update, updateUI
 
Methods inherited from class java.awt.Container
add, add, add, add, add, addContainerListener, 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, remove, remove, removeAll, removeContainerListener, setFocusCycleRoot, setFocusTraversalKeys, setFocusTraversalPolicy, setLayout, transferFocusBackward, transferFocusDownCycle, validate
 
Methods inherited from class java.awt.Component
action, add, addComponentListener, addFocusListener, addHierarchyBoundsListener, addHierarchyListener, addInputMethodListener, addKeyListener, addMouseListener, addMouseMotionListener, addMouseWheelListener, bounds, checkImage, checkImage, contains, createImage, createImage, createVolatileImage, createVolatileImage, dispatchEvent, enable, 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, imageUpdate, 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, 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
equals, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

GraphDraw

public GraphDraw(Graph g)
Creates a graph drawing environment that draws this graph object. By default, uses the Spring layout, the Fade renderer and the AbstractSettable renderer, the Drop Solo Nodes filter, and no adjustable filters at all. By default, now HIDES the status bar; call showStatus() to show it.

Parameters:
g -
Method Detail

getVisualizationViewer

public VisualizationViewer getVisualizationViewer()
Returns the visualizationviewer that actually does the graph drawing.

Returns:

addGraphMouseListener

public void addGraphMouseListener(GraphMouseListener gel)
This is the interface for adding a mouse listener. The GEL will be called back with mouse clicks on vertices.

Parameters:
gel -

showStatus

public void showStatus()
Shows the status bar at bottom left


hideStatus

public void hideStatus()
Hides the status bar at bottom left


setBackground

public void setBackground(java.awt.Color bg)

callBack

public void callBack(java.lang.String status)
Specified by:
callBack in interface StatusCallback

setRenderer

public void setRenderer(Renderer r)
A method to set the renderer.

Parameters:
r - the new renderer

resetRenderer

public void resetRenderer()

getRender

public SettableRenderer getRender()

setEdgeColor

public void setEdgeColor(java.awt.Color c)
A passthrough to the function at originalRenderer.

Parameters:
c - the new edge color

setEdgeColorFunction

public void setEdgeColorFunction(EdgeColorFunction ecf)
A passthrough to the function at originalRenderer.

Parameters:
ecf - the new EdgeColorFunction

setEdgeThickness

public void setEdgeThickness(int i)
A passthrough to the function at originalRenderer.

Parameters:
i - the thickness of the edge

setEdgeThicknessFunction

public void setEdgeThicknessFunction(EdgeThicknessFunction etf)
A passthrough to the function at originalRenderer.

Parameters:
etf - the new EdgeThicknessFunction

setVertexForegroundColor

public void setVertexForegroundColor(java.awt.Color vertexColor)
A passthrough to the function at originalRenderer.

Parameters:
vertexColor - the new foreground color of the vertices

setVertexPickedColor

public void setVertexPickedColor(java.awt.Color vertexColor)
A passthrough to the function at originalRenderer.

Parameters:
vertexColor - the new picked color of the vertices

setVertexBGColor

public void setVertexBGColor(java.awt.Color vertexColor)
A passthrough to the function at originalRenderer.

Parameters:
vertexColor - the background color of the vertex that is to be set

setVertexColorFunction

public void setVertexColorFunction(VertexColorFunction vcf)
A passthrough to the function at originalRenderer.

Parameters:
vcf - the new VertexColorFunction

setGraphLayout

public void setGraphLayout(Layout l)
Dynamically chooses a new GraphLayout.

Parameters:
l - the new graph layout algorithm

removeAllFilters

public void removeAllFilters()
Removes all the filters, deleting the sliders that drive them.


addStaticFilter

public void addStaticFilter(Filter f)
Adds a Filter that doesn't slide.

Parameters:
f -

addSlider

public javax.swing.JSlider addSlider(LevelFilter l,
                                     int low,
                                     int high,
                                     int defaultVal)
Creates a new slider based off of a LevelFilter. The function adds the Filter into the sequence of filters preserved by the current visualization, creates a JSlider to go with it, and then returns it.

TODO: The situation may not be entirely right until applyFilter has been called.

Parameters:
l - The Filter to use.
low - The low value on the filter: this will be the low point on the slider
high - The high value on the filter: this will be the high point on the slider
defaultVal - The starting point on the filter
Returns:
the slider (which will have been also added to the Sliders panel)

addTool

public void addTool(javax.swing.JComponent jc)
Adds a tool to the toolbar.

Parameters:
jc - the tool--any JComponent--to be added to the Toolbar on the left side

getGraphLayout

public Layout getGraphLayout()
Returns the currently operative layout.


restartLayout

public void restartLayout()
This is the "scramble" button--it resets the layout.


stop

public void stop()

setBackgroundColor

public void setBackgroundColor(java.awt.Color bgColor)