edu.uci.ics.jung.visualization
Class BasicVisualizationServer<V,E>

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 edu.uci.ics.jung.visualization.BasicVisualizationServer<V,E>
All Implemented Interfaces:
ChangeEventSupport, VisualizationServer<V,E>, ImageObserver, MenuContainer, Serializable, EventListener, Accessible, ChangeListener
Direct Known Subclasses:
VisualizationImageServer, VisualizationViewer

public class BasicVisualizationServer<V,E>
extends JPanel
implements ChangeListener, ChangeEventSupport, VisualizationServer<V,E>

A class that maintains many of the details necessary for creating visualizations of graphs. This is the old VisualizationViewer without tooltips and mouse behaviors. Its purpose is to be a base class that can also be used on the server side of a multi-tiered application.

Author:
Joshua O'Madadhain, Tom Nelson, Danyel Fisher
See Also:
Serialized Form

Nested Class Summary
protected  class BasicVisualizationServer.VisualizationListener
          VisualizationListener reacts to changes in the size of the VisualizationViewer.
 
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
 
Nested classes/interfaces inherited from interface edu.uci.ics.jung.visualization.VisualizationServer
VisualizationServer.Paintable
 
Field Summary
protected  ChangeEventSupport changeSupport
           
protected  boolean doubleBuffered
          user-settable choice to use the offscreen image or not.
protected  VisualizationModel<V,E> model
          holds the state of this View
protected  BufferedImage offscreen
          an offscreen image to render the graph Used if doubleBuffered is set to true
protected  Graphics2D offscreenG2d
          graphics context for the offscreen image Used if doubleBuffered is set to true
protected  PickedState<E> pickedEdgeState
          holds the state of which edges of the graph are currently 'picked'
protected  PickedState<V> pickedVertexState
          holds the state of which vertices of the graph are currently 'picked'
protected  ItemListener pickEventListener
          a listener used to cause pick events to result in repaints, even if they come from another view
protected  List<VisualizationServer.Paintable> postRenderers
          a collection of user-implementable functions to render over the topology (after the graph is rendered)
protected  List<VisualizationServer.Paintable> preRenderers
          a collection of user-implementable functions to render under the topology (before the graph is rendered)
protected  RenderContext<V,E> renderContext
           
protected  Renderer<V,E> renderer
          handles the actual drawing of graph elements
protected  Map<RenderingHints.Key,Object> renderingHints
          rendering hints used in drawing.
 
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
BasicVisualizationServer(Layout<V,E> layout)
          Create an instance with passed parameters.
BasicVisualizationServer(Layout<V,E> layout, Dimension preferredSize)
          Create an instance with passed parameters.
BasicVisualizationServer(VisualizationModel<V,E> model)
          Create an instance with passed parameters.
BasicVisualizationServer(VisualizationModel<V,E> model, Dimension preferredSize)
          Create an instance with passed parameters.
 
Method Summary
 void addChangeListener(ChangeListener l)
          Adds a ChangeListener.
 void addPostRenderPaintable(VisualizationServer.Paintable paintable)
           
 void addPreRenderPaintable(VisualizationServer.Paintable paintable)
           
protected  void checkOffscreenImage(Dimension d)
          Ensure that, if doubleBuffering is enabled, the offscreen image buffer exists and is the correct size.
 void fireStateChanged()
          Notifies all listeners that have registered interest for notification on this event type.
 Point2D getCenter()
           
 ChangeListener[] getChangeListeners()
          Returns an array of all the ChangeListeners added with addChangeListener().
 Layout<V,E> getGraphLayout()
          Returns the current graph layout.
 VisualizationModel<V,E> getModel()
           
 PickedState<E> getPickedEdgeState()
           
 PickedState<V> getPickedVertexState()
           
 GraphElementAccessor<V,E> getPickSupport()
           
 RenderContext<V,E> getRenderContext()
           
 Renderer<V,E> getRenderer()
          Returns the renderer used by this instance.
 Map<RenderingHints.Key,Object> getRenderingHints()
           
 Dimension getSize()
          Always sanity-check getSize so that we don't use a value that is improbable
 boolean isDoubleBuffered()
          whether this class uses double buffering.
protected  void paintComponent(Graphics g)
           
 void prependPostRenderPaintable(VisualizationServer.Paintable paintable)
           
 void prependPreRenderPaintable(VisualizationServer.Paintable paintable)
           
 void removeChangeListener(ChangeListener l)
          Removes a ChangeListener.
 void removePostRenderPaintable(VisualizationServer.Paintable paintable)
           
 void removePreRenderPaintable(VisualizationServer.Paintable paintable)
           
protected  void renderGraph(Graphics2D g2d)
           
 void scaleToLayout(ScalingControl scaler)
           
 void setDoubleBuffered(boolean doubleBuffered)
          set whether this class uses its offscreen image or not.
 void setGraphLayout(Layout<V,E> layout)
          Removes the current graph layout, and adds a new one.
 void setModel(VisualizationModel<V,E> model)
           
 void setPickedEdgeState(PickedState<E> pickedEdgeState)
           
 void setPickedVertexState(PickedState<V> pickedVertexState)
           
 void setPickSupport(GraphElementAccessor<V,E> pickSupport)
           
 void setRenderContext(RenderContext<V,E> renderContext)
           
 void setRenderer(Renderer<V,E> r)
          Sets the showing Renderer to be the input Renderer.
 void setRenderingHints(Map<RenderingHints.Key,Object> renderingHints)
           
 void setVisible(boolean aFlag)
           
 void stateChanged(ChangeEvent e)
          In response to changes from the model, repaint the view, then fire an event to any listeners.
 
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, isLightweightComponent, isManagingFocus, isOpaque, isOptimizedDrawingEnabled, isPaintingTile, isRequestFocusEnabled, isValidateRoot, paint, paintBorder, paintChildren, 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, setEnabled, setFocusTraversalKeys, setFont, setForeground, setInheritsPopupMenu, setInputMap, setInputVerifier, setMaximumSize, setMinimumSize, setNextFocusableComponent, setOpaque, setPreferredSize, setRequestFocusEnabled, setToolTipText, setTransferHandler, setUI, setVerifyInputWhenFocusTarget, 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, 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
 
Methods inherited from interface edu.uci.ics.jung.visualization.VisualizationServer
repaint
 

Field Detail

changeSupport

protected ChangeEventSupport changeSupport

model

protected VisualizationModel<V,E> model
holds the state of this View


renderer

protected Renderer<V,E> renderer
handles the actual drawing of graph elements


renderingHints

protected Map<RenderingHints.Key,Object> renderingHints
rendering hints used in drawing. Anti-aliasing is on by default


pickedVertexState

protected PickedState<V> pickedVertexState
holds the state of which vertices of the graph are currently 'picked'


pickedEdgeState

protected PickedState<E> pickedEdgeState
holds the state of which edges of the graph are currently 'picked'


pickEventListener

protected ItemListener pickEventListener
a listener used to cause pick events to result in repaints, even if they come from another view


offscreen

protected BufferedImage offscreen
an offscreen image to render the graph Used if doubleBuffered is set to true


offscreenG2d

protected Graphics2D offscreenG2d
graphics context for the offscreen image Used if doubleBuffered is set to true


doubleBuffered

protected boolean doubleBuffered
user-settable choice to use the offscreen image or not. 'false' by default


preRenderers

protected List<VisualizationServer.Paintable> preRenderers
a collection of user-implementable functions to render under the topology (before the graph is rendered)


postRenderers

protected List<VisualizationServer.Paintable> postRenderers
a collection of user-implementable functions to render over the topology (after the graph is rendered)


renderContext

protected RenderContext<V,E> renderContext
Constructor Detail

BasicVisualizationServer

public BasicVisualizationServer(Layout<V,E> layout)
Create an instance with passed parameters.

Parameters:
layout - The Layout to apply, with its associated Graph
renderer - The Renderer to draw it with

BasicVisualizationServer

public BasicVisualizationServer(Layout<V,E> layout,
                                Dimension preferredSize)
Create an instance with passed parameters.

Parameters:
layout - The Layout to apply, with its associated Graph
renderer - The Renderer to draw it with
preferredSize - the preferred size of this View

BasicVisualizationServer

public BasicVisualizationServer(VisualizationModel<V,E> model)
Create an instance with passed parameters.

Parameters:
model -
renderer -

BasicVisualizationServer

public BasicVisualizationServer(VisualizationModel<V,E> model,
                                Dimension preferredSize)
Create an instance with passed parameters.

Parameters:
model -
renderer -
preferredSize - initial preferred size of the view
Method Detail

setDoubleBuffered

public void setDoubleBuffered(boolean doubleBuffered)
Description copied from interface: VisualizationServer
set whether this class uses its offscreen image or not. If true, then doubleBuffering in the superclass is set to 'false'

Specified by:
setDoubleBuffered in interface VisualizationServer<V,E>
Overrides:
setDoubleBuffered in class JComponent

isDoubleBuffered

public boolean isDoubleBuffered()
Description copied from interface: VisualizationServer
whether this class uses double buffering. The superclass will be the opposite state.

Specified by:
isDoubleBuffered in interface VisualizationServer<V,E>
Overrides:
isDoubleBuffered in class JComponent

getSize

public Dimension getSize()
Always sanity-check getSize so that we don't use a value that is improbable

Overrides:
getSize in class Component
See Also:
Component.getSize()

checkOffscreenImage

protected void checkOffscreenImage(Dimension d)
Ensure that, if doubleBuffering is enabled, the offscreen image buffer exists and is the correct size.

Parameters:
d -

getModel

public VisualizationModel<V,E> getModel()
Specified by:
getModel in interface VisualizationServer<V,E>
Returns:
Returns the model.

setModel

public void setModel(VisualizationModel<V,E> model)
Specified by:
setModel in interface VisualizationServer<V,E>
Parameters:
model - The model to set.

stateChanged

public void stateChanged(ChangeEvent e)
Description copied from interface: VisualizationServer
In response to changes from the model, repaint the view, then fire an event to any listeners. Examples of listeners are the GraphZoomScrollPane and the BirdsEyeVisualizationViewer

Specified by:
stateChanged in interface VisualizationServer<V,E>
Specified by:
stateChanged in interface ChangeListener

setRenderer

public void setRenderer(Renderer<V,E> r)
Description copied from interface: VisualizationServer
Sets the showing Renderer to be the input Renderer. Also tells the Renderer to refer to this visualizationviewer as a PickedKey. (Because Renderers maintain a small amount of state, such as the PickedKey, it is important to create a separate instance for each VV instance.)

Specified by:
setRenderer in interface VisualizationServer<V,E>

getRenderer

public Renderer<V,E> getRenderer()
Description copied from interface: VisualizationServer
Returns the renderer used by this instance.

Specified by:
getRenderer in interface VisualizationServer<V,E>

setGraphLayout

public void setGraphLayout(Layout<V,E> layout)
Description copied from interface: VisualizationServer
Removes the current graph layout, and adds a new one.

Specified by:
setGraphLayout in interface VisualizationServer<V,E>
Parameters:
layout - the new layout to set

scaleToLayout

public void scaleToLayout(ScalingControl scaler)

getGraphLayout

public Layout<V,E> getGraphLayout()
Description copied from interface: VisualizationServer
Returns the current graph layout. Passes thru to the model

Specified by:
getGraphLayout in interface VisualizationServer<V,E>

setVisible

public void setVisible(boolean aFlag)
Specified by:
setVisible in interface VisualizationServer<V,E>
Overrides:
setVisible in class JComponent
See Also:
JComponent.setVisible(boolean)

getRenderingHints

public Map<RenderingHints.Key,Object> getRenderingHints()
Specified by:
getRenderingHints in interface VisualizationServer<V,E>
Returns:
Returns the renderingHints.

setRenderingHints

public void setRenderingHints(Map<RenderingHints.Key,Object> renderingHints)
Specified by:
setRenderingHints in interface VisualizationServer<V,E>
Parameters:
renderingHints - The renderingHints to set.

paintComponent

protected void paintComponent(Graphics g)
Overrides:
paintComponent in class JComponent

renderGraph

protected void renderGraph(Graphics2D g2d)

addPreRenderPaintable

public void addPreRenderPaintable(VisualizationServer.Paintable paintable)
Specified by:
addPreRenderPaintable in interface VisualizationServer<V,E>
Parameters:
paintable - The paintable to add.

prependPreRenderPaintable

public void prependPreRenderPaintable(VisualizationServer.Paintable paintable)

removePreRenderPaintable

public void removePreRenderPaintable(VisualizationServer.Paintable paintable)
Specified by:
removePreRenderPaintable in interface VisualizationServer<V,E>
Parameters:
paintable - The paintable to remove.

addPostRenderPaintable

public void addPostRenderPaintable(VisualizationServer.Paintable paintable)
Specified by:
addPostRenderPaintable in interface VisualizationServer<V,E>
Parameters:
paintable - The paintable to add.

prependPostRenderPaintable

public void prependPostRenderPaintable(VisualizationServer.Paintable paintable)

removePostRenderPaintable

public void removePostRenderPaintable(VisualizationServer.Paintable paintable)
Specified by:
removePostRenderPaintable in interface VisualizationServer<V,E>
Parameters:
paintable - The paintable to remove.

addChangeListener

public void addChangeListener(ChangeListener l)
Description copied from interface: VisualizationServer
Adds a ChangeListener.

Specified by:
addChangeListener in interface ChangeEventSupport
Specified by:
addChangeListener in interface VisualizationServer<V,E>
Parameters:
l - the listener to be added

removeChangeListener

public void removeChangeListener(ChangeListener l)
Description copied from interface: ChangeEventSupport
Removes a ChangeListener.

Specified by:
removeChangeListener in interface ChangeEventSupport
Specified by:
removeChangeListener in interface VisualizationServer<V,E>
Parameters:
l - the listener to be removed

getChangeListeners

public ChangeListener[] getChangeListeners()
Description copied from interface: ChangeEventSupport
Returns an array of all the ChangeListeners added with addChangeListener().

Specified by:
getChangeListeners in interface ChangeEventSupport
Specified by:
getChangeListeners in interface VisualizationServer<V,E>
Returns:
all of the ChangeListeners added or an empty array if no listeners have been added

fireStateChanged

public void fireStateChanged()
Description copied from interface: VisualizationServer
Notifies all listeners that have registered interest for notification on this event type. The event instance is lazily created.

Specified by:
fireStateChanged in interface ChangeEventSupport
Specified by:
fireStateChanged in interface VisualizationServer<V,E>
See Also:
EventListenerList

getPickedVertexState

public PickedState<V> getPickedVertexState()
Specified by:
getPickedVertexState in interface VisualizationServer<V,E>
Returns:
Returns the pickedState.

getPickedEdgeState

public PickedState<E> getPickedEdgeState()
Specified by:
getPickedEdgeState in interface VisualizationServer<V,E>
Returns:
Returns the pickedState.

setPickedVertexState

public void setPickedVertexState(PickedState<V> pickedVertexState)
Specified by:
setPickedVertexState in interface VisualizationServer<V,E>

setPickedEdgeState

public void setPickedEdgeState(PickedState<E> pickedEdgeState)
Specified by:
setPickedEdgeState in interface VisualizationServer<V,E>

getPickSupport

public GraphElementAccessor<V,E> getPickSupport()
Specified by:
getPickSupport in interface VisualizationServer<V,E>
Returns:
Returns the GraphElementAccessor.

setPickSupport

public void setPickSupport(GraphElementAccessor<V,E> pickSupport)
Specified by:
setPickSupport in interface VisualizationServer<V,E>
Parameters:
pickSupport - The pickSupport to set.

getCenter

public Point2D getCenter()
Specified by:
getCenter in interface VisualizationServer<V,E>

getRenderContext

public RenderContext<V,E> getRenderContext()
Specified by:
getRenderContext in interface VisualizationServer<V,E>

setRenderContext

public void setRenderContext(RenderContext<V,E> renderContext)
Specified by:
setRenderContext in interface VisualizationServer<V,E>


Copyright © 2009. All Rights Reserved.