Class BasicVisualizationServer<V,E>
java.lang.Object
java.awt.Component
java.awt.Container
javax.swing.JComponent
javax.swing.JPanel
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.
- See Also:
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionprotected classVisualizationListener reacts to changes in the size of the VisualizationViewer.Nested classes/interfaces inherited from class JPanel
JPanel.AccessibleJPanelNested classes/interfaces inherited from class JComponent
JComponent.AccessibleJComponentNested classes/interfaces inherited from class Container
Container.AccessibleAWTContainerNested classes/interfaces inherited from class Component
Component.AccessibleAWTComponent, Component.BaselineResizeBehavior, Component.BltBufferStrategy, Component.FlipBufferStrategyNested classes/interfaces inherited from interface VisualizationServer
VisualizationServer.Paintable -
Field Summary
FieldsModifier and TypeFieldDescriptionprotected ChangeEventSupportprotected booleanuser-settable choice to use the offscreen image or not.protected VisualizationModel<V, E> holds the state of this Viewprotected BufferedImagean offscreen image to render the graph Used if doubleBuffered is set to trueprotected Graphics2Dgraphics context for the offscreen image Used if doubleBuffered is set to trueprotected PickedState<E> holds the state of which edges of the graph are currently 'picked'protected PickedState<V> holds the state of which vertices of the graph are currently 'picked'protected ItemListenera listener used to cause pick events to result in repaints, even if they come from another viewprotected List<VisualizationServer.Paintable> a collection of user-implementable functions to render over the topology (after the graph is rendered)protected List<VisualizationServer.Paintable> a collection of user-implementable functions to render under the topology (before the graph is rendered)protected RenderContext<V, E> handles the actual drawing of graph elementsprotected Map<RenderingHints.Key, Object> rendering hints used in drawing.Fields inherited from class JComponent
listenerList, TOOL_TIP_TEXT_KEY, ui, UNDEFINED_CONDITION, WHEN_ANCESTOR_OF_FOCUSED_COMPONENT, WHEN_FOCUSED, WHEN_IN_FOCUSED_WINDOWFields inherited from class Component
accessibleContext, BOTTOM_ALIGNMENT, CENTER_ALIGNMENT, LEFT_ALIGNMENT, RIGHT_ALIGNMENT, TOP_ALIGNMENTFields inherited from interface ImageObserver
ABORT, ALLBITS, ERROR, FRAMEBITS, HEIGHT, PROPERTIES, SOMEBITS, WIDTH -
Constructor Summary
ConstructorsConstructorDescriptionBasicVisualizationServer(Layout<V, E> layout) Create an instance with the specified Layout.BasicVisualizationServer(Layout<V, E> layout, Dimension preferredSize) Create an instance with the specified Layout and view dimension.BasicVisualizationServer(VisualizationModel<V, E> model) Create an instance with the specified model and a default dimension (600x600).BasicVisualizationServer(VisualizationModel<V, E> model, Dimension preferredSize) Create an instance with the specified model and view dimension. -
Method Summary
Modifier and TypeMethodDescriptionvoidAdds aChangeListener.voidvoidprotected voidEnsure that, if doubleBuffering is enabled, the offscreen image buffer exists and is the correct size.voidNotifies all listeners that have registered interest for notification on this event type.Returns an array of all theChangeListeners added with addChangeListener().getModel()getSize()Always sanity-check getSize so that we don't use a value that is improbablebooleanReturns whether this class uses double buffering.protected voidvoidvoidvoidRemoves a ChangeListener.voidvoidprotected voidrenderGraph(Graphics2D g2d) voidscaleToLayout(ScalingControl scaler) voidsetDoubleBuffered(boolean doubleBuffered) Specify whether this class uses its offscreen image or not.voidsetGraphLayout(Layout<V, E> layout) Replaces the current graph layout withlayout.voidsetModel(VisualizationModel<V, E> model) voidsetPickedEdgeState(PickedState<E> pickedEdgeState) voidsetPickedVertexState(PickedState<V> pickedVertexState) voidsetPickSupport(GraphElementAccessor<V, E> pickSupport) voidsetRenderContext(RenderContext<V, E> renderContext) voidsetRenderer(Renderer<V, E> r) Sets the showing Renderer to be the input Renderer.voidsetRenderingHints(Map<RenderingHints.Key, Object> renderingHints) voidsetVisible(boolean aFlag) Makes the component visible ifaFlagis true, or invisible if false.voidIn response to changes from the model, repaint the view, then fire an event to any listeners.Methods inherited from class JPanel
getAccessibleContext, getUI, getUIClassID, paramString, setUI, updateUIMethods inherited from class JComponent
addAncestorListener, addNotify, addVetoableChangeListener, computeVisibleRect, contains, createToolTip, disable, enable, firePropertyChange, firePropertyChange, firePropertyChange, fireVetoableChange, getActionForKeyStroke, getActionMap, getAlignmentX, getAlignmentY, getAncestorListeners, getAutoscrolls, getBaseline, getBaselineResizeBehavior, 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, hide, isLightweightComponent, isManagingFocus, isOpaque, isOptimizedDrawingEnabled, isPaintingForPrint, isPaintingOrigin, 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, updateMethods inherited from class 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, transferFocusDownCycle, validate, validateTreeMethods inherited from class 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, getPropertyChangeListeners, getPropertyChangeListeners, getToolkit, getTreeLock, gotFocus, handleEvent, hasFocus, 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, requestFocus, requestFocus, requestFocusInWindow, resize, resize, setBounds, setBounds, setComponentOrientation, setCursor, setDropTarget, setFocusable, setFocusTraversalKeysEnabled, setIgnoreRepaint, setLocale, setLocation, setLocation, setMixingCutoutShape, setName, setSize, setSize, show, show, size, toString, transferFocus, transferFocusBackward, transferFocusUpCycleMethods inherited from class Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, waitMethods inherited from interface VisualizationServer
repaint
-
Field Details
-
changeSupport
-
model
holds the state of this View -
renderer
-
renderingHints
rendering hints used in drawing. Anti-aliasing is on by default -
pickedVertexState
holds the state of which vertices of the graph are currently 'picked' -
pickedEdgeState
holds the state of which edges of the graph are currently 'picked' -
pickEventListener
a listener used to cause pick events to result in repaints, even if they come from another view -
offscreen
an offscreen image to render the graph Used if doubleBuffered is set to true -
offscreenG2d
graphics context for the offscreen image Used if doubleBuffered is set to true -
doubleBuffered
protected boolean doubleBuffereduser-settable choice to use the offscreen image or not. 'false' by default -
preRenderers
a collection of user-implementable functions to render under the topology (before the graph is rendered) -
postRenderers
a collection of user-implementable functions to render over the topology (after the graph is rendered) -
renderContext
-
-
Constructor Details
-
BasicVisualizationServer
-
BasicVisualizationServer
-
BasicVisualizationServer
Create an instance with the specified model and a default dimension (600x600).- Parameters:
model- the model to use
-
BasicVisualizationServer
Create an instance with the specified model and view dimension.- Parameters:
model- the model to usepreferredSize- initial preferred size of the view
-
-
Method Details
-
setDoubleBuffered
public void setDoubleBuffered(boolean doubleBuffered) Description copied from interface:VisualizationServerSpecify whether this class uses its offscreen image or not.- Specified by:
setDoubleBufferedin interfaceVisualizationServer<V,E> - Overrides:
setDoubleBufferedin classJComponent- Parameters:
doubleBuffered- if true, then doubleBuffering in the superclass is set to 'false'
-
isDoubleBuffered
public boolean isDoubleBuffered()Description copied from interface:VisualizationServerReturns whether this class uses double buffering. The superclass will be the opposite state.- Specified by:
isDoubleBufferedin interfaceVisualizationServer<V,E> - Overrides:
isDoubleBufferedin classJComponent- Returns:
- the double buffered state
-
getSize
-
checkOffscreenImage
Ensure that, if doubleBuffering is enabled, the offscreen image buffer exists and is the correct size.- Parameters:
d- the expected Dimension of the offscreen buffer
-
getModel
- Specified by:
getModelin interfaceVisualizationServer<V,E> - Returns:
- the model.
-
setModel
- Specified by:
setModelin interfaceVisualizationServer<V,E> - Parameters:
model- the model for this class to use
-
stateChanged
Description copied from interface:VisualizationServerIn 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:
stateChangedin interfaceChangeListener- Specified by:
stateChangedin interfaceVisualizationServer<V,E> - Parameters:
e- the change event
-
setRenderer
Description copied from interface:VisualizationServerSets the showing Renderer to be the input Renderer. Also tells the Renderer to refer to this instance 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:
setRendererin interfaceVisualizationServer<V,E> - Parameters:
r- the renderer to use
-
getRenderer
- Specified by:
getRendererin interfaceVisualizationServer<V,E> - Returns:
- the renderer used by this instance.
-
setGraphLayout
Description copied from interface:VisualizationServerReplaces the current graph layout withlayout.- Specified by:
setGraphLayoutin interfaceVisualizationServer<V,E> - Parameters:
layout- the new layout to set
-
scaleToLayout
-
getGraphLayout
- Specified by:
getGraphLayoutin interfaceVisualizationServer<V,E> - Returns:
- the current graph layout.
-
setVisible
public void setVisible(boolean aFlag) Description copied from interface:VisualizationServerMakes the component visible ifaFlagis true, or invisible if false.- Specified by:
setVisiblein interfaceVisualizationServer<V,E> - Overrides:
setVisiblein classJComponent- Parameters:
aFlag- true iff the component should be visible- See Also:
-
getRenderingHints
- Specified by:
getRenderingHintsin interfaceVisualizationServer<V,E> - Returns:
- the renderingHints
-
setRenderingHints
- Specified by:
setRenderingHintsin interfaceVisualizationServer<V,E> - Parameters:
renderingHints- The renderingHints to set.
-
paintComponent
- Overrides:
paintComponentin classJComponent
-
renderGraph
-
addPreRenderPaintable
- Specified by:
addPreRenderPaintablein interfaceVisualizationServer<V,E> - Parameters:
paintable- The paintable to add.
-
prependPreRenderPaintable
-
removePreRenderPaintable
- Specified by:
removePreRenderPaintablein interfaceVisualizationServer<V,E> - Parameters:
paintable- The paintable to remove.
-
addPostRenderPaintable
- Specified by:
addPostRenderPaintablein interfaceVisualizationServer<V,E> - Parameters:
paintable- The paintable to add.
-
prependPostRenderPaintable
-
removePostRenderPaintable
- Specified by:
removePostRenderPaintablein interfaceVisualizationServer<V,E> - Parameters:
paintable- The paintable to remove.
-
addChangeListener
Description copied from interface:VisualizationServerAdds aChangeListener.- Specified by:
addChangeListenerin interfaceChangeEventSupport- Specified by:
addChangeListenerin interfaceVisualizationServer<V,E> - Parameters:
l- the listener to be added
-
removeChangeListener
Description copied from interface:ChangeEventSupportRemoves a ChangeListener.- Specified by:
removeChangeListenerin interfaceChangeEventSupport- Specified by:
removeChangeListenerin interfaceVisualizationServer<V,E> - Parameters:
l- the listener to be removed
-
getChangeListeners
Description copied from interface:ChangeEventSupportReturns an array of all theChangeListeners added with addChangeListener().- Specified by:
getChangeListenersin interfaceChangeEventSupport- Specified by:
getChangeListenersin interfaceVisualizationServer<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:VisualizationServerNotifies all listeners that have registered interest for notification on this event type. The event instance is lazily created.- Specified by:
fireStateChangedin interfaceChangeEventSupport- Specified by:
fireStateChangedin interfaceVisualizationServer<V,E> - See Also:
-
getPickedVertexState
- Specified by:
getPickedVertexStatein interfaceVisualizationServer<V,E> - Returns:
- the vertex PickedState instance
-
getPickedEdgeState
- Specified by:
getPickedEdgeStatein interfaceVisualizationServer<V,E> - Returns:
- the edge PickedState instance
-
setPickedVertexState
- Specified by:
setPickedVertexStatein interfaceVisualizationServer<V,E>
-
setPickedEdgeState
- Specified by:
setPickedEdgeStatein interfaceVisualizationServer<V,E>
-
getPickSupport
- Specified by:
getPickSupportin interfaceVisualizationServer<V,E> - Returns:
- the GraphElementAccessor
-
setPickSupport
- Specified by:
setPickSupportin interfaceVisualizationServer<V,E> - Parameters:
pickSupport- The pickSupport to set.
-
getCenter
- Specified by:
getCenterin interfaceVisualizationServer<V,E>
-
getRenderContext
- Specified by:
getRenderContextin interfaceVisualizationServer<V,E>
-
setRenderContext
- Specified by:
setRenderContextin interfaceVisualizationServer<V,E>
-