|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectjava.awt.Component
java.awt.Container
javax.swing.JComponent
javax.swing.JPanel
edu.uci.ics.jung.visualization.VisualizationViewer
public class VisualizationViewer
A class that maintains many of the details necessary for creating visualizations of graphs.
Nested Class Summary | |
---|---|
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. |
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.BaselineResizeBehavior, Component.BltBufferStrategy, Component.FlipBufferStrategy |
Field Summary | |
---|---|
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 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 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 |
pickedState
holds the state of which elements 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 PickSupport |
pickSupport
pluggable support for picking graph elements by finding them based on their coordinates. |
protected List |
postRenderers
a collection of user-implementable functions to render over the topology (after the graph is rendered) |
protected 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 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 |
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 | |
---|---|
VisualizationViewer(Layout layout,
Renderer renderer)
Create an instance with passed parameters. |
|
VisualizationViewer(Layout layout,
Renderer renderer,
Dimension preferredSize)
Create an instance with passed parameters. |
|
VisualizationViewer(VisualizationModel model,
Renderer renderer)
Create an instance with passed parameters. |
|
VisualizationViewer(VisualizationModel model,
Renderer renderer,
Dimension preferredSize)
Create an instance with passed parameters. |
Method Summary | |
---|---|
void |
addChangeListener(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(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 |
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. |
Map |
getRenderingHints()
|
double |
getScaleX()
Deprecated. access via getViewTransformer method |
double |
getScaleY()
Deprecated. access via getViewTransformer method |
String |
getToolTipText(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() |
Point2D |
inverseLayoutTransform(Point2D p)
convert the supplied screen coordinate to the graph coordinate. |
Point2D |
inverseTransform(Point2D p)
Transform the mouse point with the inverse transform of the VisualizationViewer. |
Point2D |
inverseViewTransform(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. |
Point2D |
layoutTransform(Point2D p)
convert the supplied graph coordinate to the screen coordinate |
protected void |
paintComponent(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(ChangeListener l)
Removes a ChangeListener. |
void |
removePostRenderPaintable(VisualizationViewer.Paintable paintable)
|
void |
removePreRenderPaintable(VisualizationViewer.Paintable paintable)
|
protected void |
renderGraph(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,
Point2D from)
Deprecated. access via getViewTransformer method |
protected void |
scaleToLayout(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(Map renderingHints)
|
void |
setScale(double scalex,
double scaley)
Deprecated. access via getViewTransformer method |
void |
setScale(double scalex,
double scaley,
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(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 |
Point2D |
transform(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 |
Point2D |
viewTransform(Point2D p)
convert the supplied graph coordinate to the screen coordinate |
Methods inherited from class javax.swing.JPanel |
---|
getAccessibleContext, getUI, getUIClassID, paramString, setUI, updateUI |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait |
Field Detail |
---|
protected ChangeEventSupport changeSupport
protected VisualizationModel model
protected Renderer renderer
protected ToolTipFunction toolTipFunction
protected Map renderingHints
protected PickSupport pickSupport
protected PickedState pickedState
protected ItemListener pickEventListener
protected BufferedImage offscreen
protected Graphics2D offscreenG2d
protected boolean doubleBuffered
protected MutableTransformer viewTransformer
protected MutableTransformer layoutTransformer
protected List preRenderers
protected List postRenderers
protected VisualizationViewer.GraphMouse graphMouse
protected Map locationMap
Constructor Detail |
---|
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, 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, Dimension preferredSize)
model
- renderer
- preferredSize
- initial preferred size of the viewMethod Detail |
---|
public void setDoubleBuffered(boolean doubleBuffered)
setDoubleBuffered
in class JComponent
public boolean isDoubleBuffered()
isDoubleBuffered
in class JComponent
protected void checkOffscreenImage(Dimension d)
d
- public VisualizationModel getModel()
public void setModel(VisualizationModel model)
model
- The model to set.public void stateChanged(ChangeEvent e)
stateChanged
in interface ChangeListener
protected void initMouseClicker()
VisualizationViewer.GraphMouseImpl
public void setTextCallback(StatusCallback scb)
scb
- public void setGraphMouse(VisualizationViewer.GraphMouse graphMouse)
graphMouse
- new valuepublic VisualizationViewer.GraphMouse getGraphMouse()
GraphMouse
public 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(Dimension layoutSize)
public Layout getGraphLayout()
getGraphLayout
in interface HasGraphLayout
public void addGraphMouseListener(GraphMouseListener gel)
gel
- public void init()
public void restart()
public void setVisible(boolean aFlag)
setVisible
in class JComponent
JComponent.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, Point2D from)
scalex
- scaley
- from
- public void setScale(double scalex, double scaley)
scalex
- scaley
- public void setScale(double scalex, double scaley, 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 Point2D inverseTransform(Point2D p)
inverseTransform
in interface Transformer
p
- the point to transform (typically, a mouse point)
public Point2D inverseViewTransform(Point2D p)
ViewTransformer
inverseViewTransform
in interface ViewTransformer
p
- screen point to convert
public Point2D inverseLayoutTransform(Point2D p)
LayoutTransformer
inverseLayoutTransform
in interface LayoutTransformer
p
- screen point to convert
public Point2D transform(Point2D p)
transform
in interface Transformer
p
- the point to transform
public Point2D viewTransform(Point2D p)
ViewTransformer
viewTransform
in interface ViewTransformer
p
- graph point to convert
public Point2D layoutTransform(Point2D p)
LayoutTransformer
layoutTransform
in interface LayoutTransformer
p
- graph point to convert
public void setViewTransformer(MutableTransformer transformer)
transformer
- The transformer to set.public void setLayoutTransformer(MutableTransformer transformer)
public MutableTransformer getViewTransformer()
public MutableTransformer getLayoutTransformer()
public Map getRenderingHints()
public void setRenderingHints(Map renderingHints)
renderingHints
- The renderingHints to set.protected void paintComponent(Graphics g)
paintComponent
in class JComponent
protected void renderGraph(Graphics2D g2d)
protected double average(long[] paintTimes)
paintTimes
- an array of longs
public void stop()
public void setToolTipListener(VisualizationViewer.ToolTipListener listener)
listener
- the listener to serpublic void setToolTipFunction(ToolTipFunction toolTipFunction)
public String getToolTipText(MouseEvent event)
getToolTipText
in class JComponent
public 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(ChangeListener l)
ChangeListener
.
addChangeListener
in interface ChangeEventSupport
l
- the listener to be addedpublic void removeChangeListener(ChangeListener l)
removeChangeListener
in interface ChangeEventSupport
l
- the listener to be removedpublic ChangeListener[] getChangeListeners()
ChangeListener
s added
with addChangeListener().
getChangeListeners
in interface ChangeEventSupport
ChangeListener
s added or an empty
array if no listeners have been addedpublic void fireStateChanged()
fireStateChanged
in interface ChangeEventSupport
EventListenerList
public 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 Point2D getCenter()
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |