public class VisualizationViewer extends javax.swing.JPanel implements Transformer, LayoutTransformer, ViewTransformer, HasGraphLayout, javax.swing.event.ChangeListener, ChangeEventSupport
| Modifier and Type | Class and Description |
|---|---|
static interface |
VisualizationViewer.GraphMouse
a convenience type to represent a class that
processes all types of mouse events for the graph
|
protected class |
VisualizationViewer.GraphMouseImpl
this is the original GraphMouse class, renamed to use GraphMouse as the interface name,
and updated to correctly apply the vv transform to the point point
|
static interface |
VisualizationViewer.Paintable
an interface for the preRender and postRender
|
static interface |
VisualizationViewer.ToolTipListener
The interface for the tool tip listener.
|
protected static class |
VisualizationViewer.ToolTipListenerWrapper
used internally to wrap any legacy ToolTipListener
implementations so they can be used as a ToolTipFunction
|
protected class |
VisualizationViewer.VisualizationListener
VisualizationListener reacts to changes in the size of the
VisualizationViewer.
|
javax.swing.JPanel.AccessibleJPaneljavax.swing.JComponent.AccessibleJComponent| Modifier and Type | Field and Description |
|---|---|
protected ChangeEventSupport |
changeSupport |
protected boolean |
doubleBuffered
user-settable choice to use the offscreen image
or not.
|
protected VisualizationViewer.GraphMouse |
graphMouse
provides MouseListener, MouseMotionListener, and MouseWheelListener
events to the graph
|
protected MutableTransformer |
layoutTransformer |
protected java.util.Map |
locationMap
if true, then when the View is resized, the current Layout
is resized to the same size.
|
protected VisualizationModel |
model
holds the state of this View
|
protected java.awt.image.BufferedImage |
offscreen
an offscreen image to render the graph
Used if doubleBuffered is set to true
|
protected java.awt.Graphics2D |
offscreenG2d
graphics context for the offscreen image
Used if doubleBuffered is set to true
|
protected PickedState |
pickedState
holds the state of which elements of the graph are
currently 'picked'
|
protected java.awt.event.ItemListener |
pickEventListener
a listener used to cause pick events to result in
repaints, even if they come from another view
|
protected PickSupport |
pickSupport
pluggable support for picking graph elements by
finding them based on their coordinates.
|
protected java.util.List |
postRenderers
a collection of user-implementable functions to render over the
topology (after the graph is rendered)
|
protected java.util.List |
preRenderers
a collection of user-implementable functions to render under
the topology (before the graph is rendered)
|
protected Renderer |
renderer
handles the actual drawing of graph elements
|
protected java.util.Map |
renderingHints
rendering hints used in drawing.
|
protected ToolTipFunction |
toolTipFunction
should be set to user-defined class to provide
tooltips on the graph elements
|
protected MutableTransformer |
viewTransformer
Provides support for mutating the AffineTransform that
is supplied to the rendering Graphics2D
|
accessibleContext, listenerList, TOOL_TIP_TEXT_KEY, ui, UNDEFINED_CONDITION, WHEN_ANCESTOR_OF_FOCUSED_COMPONENT, WHEN_FOCUSED, WHEN_IN_FOCUSED_WINDOW| Constructor and Description |
|---|
VisualizationViewer(Layout layout,
Renderer renderer)
Create an instance with passed parameters.
|
VisualizationViewer(Layout layout,
Renderer renderer,
java.awt.Dimension preferredSize)
Create an instance with passed parameters.
|
VisualizationViewer(VisualizationModel model,
Renderer renderer)
Create an instance with passed parameters.
|
VisualizationViewer(VisualizationModel model,
Renderer renderer,
java.awt.Dimension preferredSize)
Create an instance with passed parameters.
|
| Modifier and Type | Method and Description |
|---|---|
void |
addChangeListener(javax.swing.event.ChangeListener l)
Adds a
ChangeListener. |
void |
addGraphMouseListener(GraphMouseListener gel)
This is the interface for adding a mouse listener.
|
void |
addPostRenderPaintable(VisualizationViewer.Paintable paintable) |
void |
addPreRenderPaintable(VisualizationViewer.Paintable paintable) |
protected double |
average(long[] paintTimes)
Returns the double average of a number of long values.
|
protected void |
checkOffscreenImage(java.awt.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.
|
java.awt.geom.Point2D |
getCenter() |
javax.swing.event.ChangeListener[] |
getChangeListeners()
Returns an array of all the
ChangeListeners added
with addChangeListener(). |
Layout |
getGraphLayout()
Returns the current graph layout.
|
VisualizationViewer.GraphMouse |
getGraphMouse() |
MutableTransformer |
getLayoutTransformer() |
VisualizationModel |
getModel() |
double |
getOffsetX()
Deprecated.
use getTranslateX
|
double |
getOffsetY()
Deprecated.
use getTranslateY()
|
PickedState |
getPickedState() |
PickSupport |
getPickSupport() |
Renderer |
getRenderer()
Returns the renderer used by this instance.
|
java.util.Map |
getRenderingHints() |
double |
getScaleX()
Deprecated.
access via getViewTransformer method
|
double |
getScaleY()
Deprecated.
access via getViewTransformer method
|
java.lang.String |
getToolTipText(java.awt.event.MouseEvent event)
called by the superclass to display tooltips
|
double |
getTranslateX()
Deprecated.
access via getViewTransformer method
|
double |
getTranslateY()
Deprecated.
access via getViewTransformer method
|
MutableTransformer |
getViewTransformer() |
void |
init()
Pre-relaxes and starts a visRunner thread
Passes thru to the model
|
protected void |
initMouseClicker()
Deprecated.
replaced by setGraphMouse()
|
java.awt.geom.Point2D |
inverseLayoutTransform(java.awt.geom.Point2D p)
convert the supplied screen coordinate to the
graph coordinate.
|
java.awt.geom.Point2D |
inverseTransform(java.awt.geom.Point2D p)
Transform the mouse point with the inverse transform
of the VisualizationViewer.
|
java.awt.geom.Point2D |
inverseViewTransform(java.awt.geom.Point2D p)
convert the supplied screen coordinate to the
graph coordinate.
|
boolean |
isDoubleBuffered()
whether this class uses double buffering.
|
boolean |
isPicked(Edge e)
Deprecated.
Use
getPickedState.isPicked(e). |
boolean |
isPicked(Vertex v)
Deprecated.
Use
getPickedState.isPicked(e). |
boolean |
isVisRunnerRunning()
Returns a flag that says whether the visRunner thread is running.
|
java.awt.geom.Point2D |
layoutTransform(java.awt.geom.Point2D p)
convert the supplied graph coordinate to the
screen coordinate
|
protected void |
paintComponent(java.awt.Graphics g) |
protected void |
pick(Vertex picked,
boolean b)
Deprecated.
Use
getPickedState.pick(picked, b). |
void |
prerelax()
convenience pass-thru to the model
|
void |
removeChangeListener(javax.swing.event.ChangeListener l)
Removes a ChangeListener.
|
void |
removePostRenderPaintable(VisualizationViewer.Paintable paintable) |
void |
removePreRenderPaintable(VisualizationViewer.Paintable paintable) |
protected void |
renderGraph(java.awt.Graphics2D g2d) |
void |
restart()
Restarts layout, then calls init();
passes thru to the model
|
void |
scale(double scalex,
double scaley)
Deprecated.
access via getViewTransformer method
|
void |
scale(double scalex,
double scaley,
java.awt.geom.Point2D from)
Deprecated.
access via getViewTransformer method
|
protected void |
scaleToLayout(java.awt.Dimension layoutSize) |
void |
setDoubleBuffered(boolean doubleBuffered)
set whether this class uses its offscreen image or not.
|
void |
setGraphLayout(Layout layout)
Removes the current graph layout, and adds a new one.
|
void |
setGraphLayout(Layout layout,
boolean scaleToLayout)
Removes the current graph layout, and adds a new one,
optionally re-scaling the view to show the entire layout
|
void |
setGraphMouse(VisualizationViewer.GraphMouse graphMouse)
a setter for the GraphMouse.
|
void |
setLayoutTransformer(MutableTransformer transformer) |
void |
setModel(VisualizationModel model) |
void |
setOffset(double offsetx,
double offsety)
Deprecated.
use setTranslate(double, offset, double offset)
|
void |
setPickedState(PickedState pickedState) |
void |
setPickSupport(PickSupport pickSupport) |
void |
setRenderer(Renderer r)
Sets the showing Renderer to be the input Renderer.
|
void |
setRenderingHints(java.util.Map renderingHints) |
void |
setScale(double scalex,
double scaley)
Deprecated.
access via getViewTransformer method
|
void |
setScale(double scalex,
double scaley,
java.awt.geom.Point2D from)
Deprecated.
access via getViewTransformer method
|
void |
setTextCallback(StatusCallback scb)
convenience pass-thru to model
|
void |
setToolTipFunction(ToolTipFunction toolTipFunction) |
void |
setToolTipListener(VisualizationViewer.ToolTipListener listener)
sets the tooltip listener to the user's defined implementation
of ToolTipListener
|
void |
setTranslate(double tx,
double ty)
Deprecated.
access via getViewTransformer method
|
void |
setViewTransformer(MutableTransformer transformer) |
void |
setVisible(boolean aFlag) |
protected void |
start()
convenience pass-thru to the model
|
void |
stateChanged(javax.swing.event.ChangeEvent e)
In response to changes from the model, repaint the
view, then fire an event to any listeners.
|
void |
stop()
convenience pass-thru to model
|
void |
suspend()
convenience pass-thru to the model
|
java.awt.geom.Point2D |
transform(java.awt.geom.Point2D p)
Transform the mouse point with the current transform
of the VisualizationViewer.
|
void |
translate(double tx,
double ty)
Deprecated.
access via getViewTransformer method
|
void |
unsuspend()
convenience pass-thru to the model
|
java.awt.geom.Point2D |
viewTransform(java.awt.geom.Point2D p)
convert the supplied graph coordinate to the
screen coordinate
|
getAccessibleContext, getUI, getUIClassID, paramString, setUI, updateUIaddAncestorListener, 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, getTopLevelAncestor, getTransferHandler, getVerifyInputWhenFocusTarget, getVetoableChangeListeners, getVisibleRect, getWidth, getX, getY, grabFocus, 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, updateadd, 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, validateTreeaction, 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, getSize, 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, transferFocusBackward, transferFocusUpCycleprotected ChangeEventSupport changeSupport
protected VisualizationModel model
protected Renderer renderer
protected ToolTipFunction toolTipFunction
protected java.util.Map renderingHints
protected PickSupport pickSupport
protected PickedState pickedState
protected java.awt.event.ItemListener pickEventListener
protected java.awt.image.BufferedImage offscreen
protected java.awt.Graphics2D offscreenG2d
protected boolean doubleBuffered
protected MutableTransformer viewTransformer
protected MutableTransformer layoutTransformer
protected java.util.List preRenderers
protected java.util.List postRenderers
protected VisualizationViewer.GraphMouse graphMouse
protected java.util.Map locationMap
public VisualizationViewer(Layout layout, Renderer renderer)
layout - The Layout to apply, with its associated Graphrenderer - The Renderer to draw it withpublic VisualizationViewer(Layout layout, Renderer renderer, java.awt.Dimension preferredSize)
layout - The Layout to apply, with its associated Graphrenderer - The Renderer to draw it withpreferredSize - the preferred size of this Viewpublic VisualizationViewer(VisualizationModel model, Renderer renderer)
model - renderer - public VisualizationViewer(VisualizationModel model, Renderer renderer, java.awt.Dimension preferredSize)
model - renderer - preferredSize - initial preferred size of the viewpublic void setDoubleBuffered(boolean doubleBuffered)
setDoubleBuffered in class javax.swing.JComponentpublic boolean isDoubleBuffered()
isDoubleBuffered in class javax.swing.JComponentprotected void checkOffscreenImage(java.awt.Dimension d)
d - public VisualizationModel getModel()
public void setModel(VisualizationModel model)
model - The model to set.public void stateChanged(javax.swing.event.ChangeEvent e)
stateChanged in interface javax.swing.event.ChangeListenerprotected void initMouseClicker()
VisualizationViewer.GraphMouseImplpublic void setTextCallback(StatusCallback scb)
scb - public void setGraphMouse(VisualizationViewer.GraphMouse graphMouse)
graphMouse - new valuepublic VisualizationViewer.GraphMouse getGraphMouse()
GraphMousepublic void setRenderer(Renderer r)
public Renderer getRenderer()
public void setGraphLayout(Layout layout)
layout - the new layout to setpublic void setGraphLayout(Layout layout, boolean scaleToLayout)
layout - the new layout to setscaleToLayout - whether to scale the view to show the whole layoutprotected void scaleToLayout(java.awt.Dimension layoutSize)
public Layout getGraphLayout()
getGraphLayout in interface HasGraphLayoutpublic void addGraphMouseListener(GraphMouseListener gel)
gel - public void init()
public void restart()
public void setVisible(boolean aFlag)
setVisible in class javax.swing.JComponentJComponent.setVisible(boolean)public void prerelax()
protected void start()
public void suspend()
public void unsuspend()
public boolean isPicked(Vertex v)
getPickedState.isPicked(e).public boolean isPicked(Edge e)
getPickedState.isPicked(e).protected void pick(Vertex picked, boolean b)
getPickedState.pick(picked, b).public boolean isVisRunnerRunning()
public void scale(double scalex,
double scaley)
scalex - scaley - public void scale(double scalex,
double scaley,
java.awt.geom.Point2D from)
scalex - scaley - from - public void setScale(double scalex,
double scaley)
scalex - scaley - public void setScale(double scalex,
double scaley,
java.awt.geom.Point2D from)
scalex - scaley - public double getScaleX()
public double getScaleY()
public double getOffsetX()
public double getTranslateX()
public double getOffsetY()
public double getTranslateY()
public void setOffset(double offsetx,
double offsety)
offsetx - offsety - public void setTranslate(double tx,
double ty)
tx - ty - public void translate(double tx,
double ty)
public java.awt.geom.Point2D inverseTransform(java.awt.geom.Point2D p)
inverseTransform in interface Transformerp - the point to transform (typically, a mouse point)public java.awt.geom.Point2D inverseViewTransform(java.awt.geom.Point2D p)
ViewTransformerinverseViewTransform in interface ViewTransformerp - screen point to convertpublic java.awt.geom.Point2D inverseLayoutTransform(java.awt.geom.Point2D p)
LayoutTransformerinverseLayoutTransform in interface LayoutTransformerp - screen point to convertpublic java.awt.geom.Point2D transform(java.awt.geom.Point2D p)
transform in interface Transformerp - the point to transformpublic java.awt.geom.Point2D viewTransform(java.awt.geom.Point2D p)
ViewTransformerviewTransform in interface ViewTransformerp - graph point to convertpublic java.awt.geom.Point2D layoutTransform(java.awt.geom.Point2D p)
LayoutTransformerlayoutTransform in interface LayoutTransformerp - graph point to convertpublic void setViewTransformer(MutableTransformer transformer)
transformer - The transformer to set.public void setLayoutTransformer(MutableTransformer transformer)
public MutableTransformer getViewTransformer()
public MutableTransformer getLayoutTransformer()
public java.util.Map getRenderingHints()
public void setRenderingHints(java.util.Map renderingHints)
renderingHints - The renderingHints to set.protected void paintComponent(java.awt.Graphics g)
paintComponent in class javax.swing.JComponentprotected void renderGraph(java.awt.Graphics2D g2d)
protected double average(long[] paintTimes)
paintTimes - an array of longspublic void stop()
public void setToolTipListener(VisualizationViewer.ToolTipListener listener)
listener - the listener to serpublic void setToolTipFunction(ToolTipFunction toolTipFunction)
public java.lang.String getToolTipText(java.awt.event.MouseEvent event)
getToolTipText in class javax.swing.JComponentpublic void addPreRenderPaintable(VisualizationViewer.Paintable paintable)
paintable - The paintable to add.public void removePreRenderPaintable(VisualizationViewer.Paintable paintable)
paintable - The paintable to remove.public void addPostRenderPaintable(VisualizationViewer.Paintable paintable)
paintable - The paintable to add.public void removePostRenderPaintable(VisualizationViewer.Paintable paintable)
paintable - The paintable to remove.public void addChangeListener(javax.swing.event.ChangeListener l)
ChangeListener.addChangeListener in interface ChangeEventSupportl - the listener to be addedpublic void removeChangeListener(javax.swing.event.ChangeListener l)
removeChangeListener in interface ChangeEventSupportl - the listener to be removedpublic javax.swing.event.ChangeListener[] getChangeListeners()
ChangeListeners added
with addChangeListener().getChangeListeners in interface ChangeEventSupportChangeListeners added or an empty
array if no listeners have been addedpublic void fireStateChanged()
fireStateChanged in interface ChangeEventSupportEventListenerListpublic PickedState getPickedState()
public void setPickedState(PickedState pickedState)
pickedState - The pickedState to set.public PickSupport getPickSupport()
public void setPickSupport(PickSupport pickSupport)
pickSupport - The pickSupport to set.public java.awt.geom.Point2D getCenter()