public class SwingViewer
extends org.graphstream.ui.view.Viewer
implements java.awt.event.ActionListener
The viewer class is in charge of maintaining :
The graphic graph can be created by the viewer or given at construction (to share it with another viewer).
Once created, the viewer runs in a loop inside the Swing thread. You
cannot call methods on it directly if you are not in this thread. The
only operation that you can use in other threads is the constructor, the
Viewer.addView(View), Viewer.removeView(String) and the close()
methods. Other methods are not protected from concurrent accesses.
Some constructors allow a ProxyPipe as argument. If given, the
graphic graph is made listener of this pipe and the pipe is "pumped" during
the view loop. This allows to run algorithms on a graph in the main thread
(or any other thread) while letting the viewer run in the swing thread.
Be very careful: due to the nature of graph events in GraphStream, the viewer
is not aware of events that occured on the graph before its creation.
There is a special mechanism that replay the graph if you use a proxy pipe or
if you pass the graph directly. However, when you create the viewer by
yourself and only pass a Source, the viewer will not display
the events that occured on the source before it is connected to it.
| Modifier and Type | Field and Description |
|---|---|
static java.lang.String |
DEFAULT_VIEW_ID
Name of the default view.
|
protected int |
delay
Delay in milliseconds between frames.
|
protected javax.swing.Timer |
timer
Timer in the Swing thread.
|
| Constructor and Description |
|---|
SwingViewer(org.graphstream.ui.graphicGraph.GraphicGraph graph)
We draw a pre-existing graphic graph.
|
SwingViewer(org.graphstream.graph.Graph graph,
org.graphstream.ui.view.Viewer.ThreadingModel threadingModel)
New viewer on an existing graph.
|
SwingViewer(org.graphstream.stream.ProxyPipe source)
The graph or source of graph events is in another thread or on another
machine, but the pipe already exists.
|
| Modifier and Type | Method and Description |
|---|---|
void |
actionPerformed(java.awt.event.ActionEvent arg0)
Called on a regular basis by the timer.
|
org.graphstream.ui.view.View |
addDefaultView(boolean openInAFrame,
org.graphstream.ui.view.GraphRenderer<?,?> renderer)
Build the default graph view and insert it.
|
void |
close()
Close definitively this viewer and all its views.
|
java.lang.String |
getDefaultID() |
void |
init(org.graphstream.ui.graphicGraph.GraphicGraph graph,
org.graphstream.stream.ProxyPipe ppipe,
org.graphstream.stream.Source source)
Initialise the viewer.
|
org.graphstream.ui.view.GraphRenderer<?,?> |
newDefaultGraphRenderer()
Create a new instance of the default graph renderer.
|
addDefaultView, addView, addView, addView, computeGraphMetrics, disableAutoLayout, enableAutoLayout, enableAutoLayout, enableXYZfeedback, getCloseFramePolicy, getDefaultView, getGraphicGraph, getView, newGGId, newThreadProxyOnGraphicGraph, newViewerPipe, removeView, replayGraph, setCloseFramePolicyprotected javax.swing.Timer timer
protected int delay
public static java.lang.String DEFAULT_VIEW_ID
public SwingViewer(org.graphstream.stream.ProxyPipe source)
source - The source of graph events.public SwingViewer(org.graphstream.ui.graphicGraph.GraphicGraph graph)
graph - THe graph to draw.public SwingViewer(org.graphstream.graph.Graph graph,
org.graphstream.ui.view.Viewer.ThreadingModel threadingModel)
graph - The graph to render.threadingModel - The threading model.public java.lang.String getDefaultID()
getDefaultID in class org.graphstream.ui.view.Viewerpublic void init(org.graphstream.ui.graphicGraph.GraphicGraph graph,
org.graphstream.stream.ProxyPipe ppipe,
org.graphstream.stream.Source source)
init in class org.graphstream.ui.view.Viewergraph - The graphic graph.ppipe - The source of events from another thread or machine (null if
source != null).source - The source of events from this thread (null if ppipe != null).public void close()
close in class org.graphstream.ui.view.Viewerpublic org.graphstream.ui.view.GraphRenderer<?,?> newDefaultGraphRenderer()
newDefaultGraphRenderer in class org.graphstream.ui.view.Viewerpublic org.graphstream.ui.view.View addDefaultView(boolean openInAFrame,
org.graphstream.ui.view.GraphRenderer<?,?> renderer)
DEFAULT_VIEW_ID. You can request the view to be open in its own
frame.renderer - openInAFrame - It true, the view is placed in a frame, else the view is only
created and you must embed it yourself in your application.public void actionPerformed(java.awt.event.ActionEvent arg0)
actionPerformed in interface java.awt.event.ActionListener