public class BasicVisualizationServer<V,E> extends JPanel implements ChangeListener, ChangeEventSupport, VisualizationServer<V,E>
Modifier and Type | Class and Description |
---|---|
protected class |
BasicVisualizationServer.VisualizationListener
VisualizationListener reacts to changes in the size of the
VisualizationViewer.
|
JPanel.AccessibleJPanel
JComponent.AccessibleJComponent
Container.AccessibleAWTContainer
Component.AccessibleAWTComponent, Component.BaselineResizeBehavior, Component.BltBufferStrategy, Component.FlipBufferStrategy
VisualizationServer.Paintable
Modifier and Type | Field and Description |
---|---|
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.
|
listenerList, TOOL_TIP_TEXT_KEY, ui, UNDEFINED_CONDITION, WHEN_ANCESTOR_OF_FOCUSED_COMPONENT, WHEN_FOCUSED, WHEN_IN_FOCUSED_WINDOW
accessibleContext, BOTTOM_ALIGNMENT, CENTER_ALIGNMENT, LEFT_ALIGNMENT, RIGHT_ALIGNMENT, TOP_ALIGNMENT
ABORT, ALLBITS, ERROR, FRAMEBITS, HEIGHT, PROPERTIES, SOMEBITS, WIDTH
Constructor and Description |
---|
BasicVisualizationServer(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.
|
Modifier and Type | Method and Description |
---|---|
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
ChangeListener s added
with addChangeListener(). |
Layout<V,E> |
getGraphLayout() |
VisualizationModel<V,E> |
getModel() |
PickedState<E> |
getPickedEdgeState() |
PickedState<V> |
getPickedVertexState() |
GraphElementAccessor<V,E> |
getPickSupport() |
RenderContext<V,E> |
getRenderContext() |
Renderer<V,E> |
getRenderer() |
Map<RenderingHints.Key,Object> |
getRenderingHints() |
Dimension |
getSize()
Always sanity-check getSize so that we don't use a
value that is improbable
|
boolean |
isDoubleBuffered()
Returns 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)
Specify whether this class uses its offscreen image or not.
|
void |
setGraphLayout(Layout<V,E> layout)
Replaces the current graph layout with
layout . |
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)
Makes the component visible if
aFlag is true, or invisible if false. |
void |
stateChanged(ChangeEvent e)
In response to changes from the model, repaint the
view, then fire an event to any listeners.
|
getAccessibleContext, getUI, getUIClassID, paramString, setUI, updateUI
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, update
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, validateTree
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, 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, transferFocusBackward, transferFocusUpCycle
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
repaint
protected ChangeEventSupport changeSupport
protected VisualizationModel<V,E> model
protected Map<RenderingHints.Key,Object> renderingHints
protected PickedState<V> pickedVertexState
protected PickedState<E> pickedEdgeState
protected ItemListener pickEventListener
protected BufferedImage offscreen
protected Graphics2D offscreenG2d
protected boolean doubleBuffered
protected List<VisualizationServer.Paintable> preRenderers
protected List<VisualizationServer.Paintable> postRenderers
protected RenderContext<V,E> renderContext
public BasicVisualizationServer(Layout<V,E> layout)
layout
- The Layout to apply, with its associated Graphpublic BasicVisualizationServer(Layout<V,E> layout, Dimension preferredSize)
layout
- The Layout to apply, with its associated GraphpreferredSize
- the preferred size of this Viewpublic BasicVisualizationServer(VisualizationModel<V,E> model)
model
- the model to usepublic BasicVisualizationServer(VisualizationModel<V,E> model, Dimension preferredSize)
model
- the model to usepreferredSize
- initial preferred size of the viewpublic void setDoubleBuffered(boolean doubleBuffered)
VisualizationServer
setDoubleBuffered
in interface VisualizationServer<V,E>
setDoubleBuffered
in class JComponent
doubleBuffered
- if true, then doubleBuffering in the superclass is set to 'false'public boolean isDoubleBuffered()
VisualizationServer
isDoubleBuffered
in interface VisualizationServer<V,E>
isDoubleBuffered
in class JComponent
public Dimension getSize()
getSize
in class Component
Component.getSize()
protected void checkOffscreenImage(Dimension d)
d
- the expected Dimension of the offscreen bufferpublic VisualizationModel<V,E> getModel()
getModel
in interface VisualizationServer<V,E>
public void setModel(VisualizationModel<V,E> model)
setModel
in interface VisualizationServer<V,E>
model
- the model for this class to usepublic void stateChanged(ChangeEvent e)
VisualizationServer
stateChanged
in interface VisualizationServer<V,E>
stateChanged
in interface ChangeListener
e
- the change eventpublic void setRenderer(Renderer<V,E> r)
VisualizationServer
setRenderer
in interface VisualizationServer<V,E>
r
- the renderer to usepublic Renderer<V,E> getRenderer()
getRenderer
in interface VisualizationServer<V,E>
public void setGraphLayout(Layout<V,E> layout)
VisualizationServer
layout
.setGraphLayout
in interface VisualizationServer<V,E>
layout
- the new layout to setpublic void scaleToLayout(ScalingControl scaler)
public Layout<V,E> getGraphLayout()
getGraphLayout
in interface VisualizationServer<V,E>
public void setVisible(boolean aFlag)
VisualizationServer
aFlag
is true, or invisible if false.setVisible
in interface VisualizationServer<V,E>
setVisible
in class JComponent
aFlag
- true iff the component should be visibleJComponent.setVisible(boolean)
public Map<RenderingHints.Key,Object> getRenderingHints()
getRenderingHints
in interface VisualizationServer<V,E>
public void setRenderingHints(Map<RenderingHints.Key,Object> renderingHints)
setRenderingHints
in interface VisualizationServer<V,E>
renderingHints
- The renderingHints to set.protected void paintComponent(Graphics g)
paintComponent
in class JComponent
protected void renderGraph(Graphics2D g2d)
public void addPreRenderPaintable(VisualizationServer.Paintable paintable)
addPreRenderPaintable
in interface VisualizationServer<V,E>
paintable
- The paintable to add.public void prependPreRenderPaintable(VisualizationServer.Paintable paintable)
public void removePreRenderPaintable(VisualizationServer.Paintable paintable)
removePreRenderPaintable
in interface VisualizationServer<V,E>
paintable
- The paintable to remove.public void addPostRenderPaintable(VisualizationServer.Paintable paintable)
addPostRenderPaintable
in interface VisualizationServer<V,E>
paintable
- The paintable to add.public void prependPostRenderPaintable(VisualizationServer.Paintable paintable)
public void removePostRenderPaintable(VisualizationServer.Paintable paintable)
removePostRenderPaintable
in interface VisualizationServer<V,E>
paintable
- The paintable to remove.public void addChangeListener(ChangeListener l)
VisualizationServer
ChangeListener
.addChangeListener
in interface ChangeEventSupport
addChangeListener
in interface VisualizationServer<V,E>
l
- the listener to be addedpublic void removeChangeListener(ChangeListener l)
ChangeEventSupport
removeChangeListener
in interface ChangeEventSupport
removeChangeListener
in interface VisualizationServer<V,E>
l
- the listener to be removedpublic ChangeListener[] getChangeListeners()
ChangeEventSupport
ChangeListener
s added
with addChangeListener().getChangeListeners
in interface ChangeEventSupport
getChangeListeners
in interface VisualizationServer<V,E>
ChangeListener
s added or an empty
array if no listeners have been addedpublic void fireStateChanged()
VisualizationServer
fireStateChanged
in interface ChangeEventSupport
fireStateChanged
in interface VisualizationServer<V,E>
EventListenerList
public PickedState<V> getPickedVertexState()
getPickedVertexState
in interface VisualizationServer<V,E>
public PickedState<E> getPickedEdgeState()
getPickedEdgeState
in interface VisualizationServer<V,E>
public void setPickedVertexState(PickedState<V> pickedVertexState)
setPickedVertexState
in interface VisualizationServer<V,E>
public void setPickedEdgeState(PickedState<E> pickedEdgeState)
setPickedEdgeState
in interface VisualizationServer<V,E>
public GraphElementAccessor<V,E> getPickSupport()
getPickSupport
in interface VisualizationServer<V,E>
public void setPickSupport(GraphElementAccessor<V,E> pickSupport)
setPickSupport
in interface VisualizationServer<V,E>
pickSupport
- The pickSupport to set.public Point2D getCenter()
getCenter
in interface VisualizationServer<V,E>
public RenderContext<V,E> getRenderContext()
getRenderContext
in interface VisualizationServer<V,E>
public void setRenderContext(RenderContext<V,E> renderContext)
setRenderContext
in interface VisualizationServer<V,E>
Copyright © 2015. All rights reserved.