Class FxViewer
public class FxViewer
extends org.graphstream.ui.view.Viewer
The viewer class is in charge of maintaining :
- A "graphic graph" (a special graph that internally stores the graph under the form of style sets of "graphic" elements, suitable to draw the graph, but not to adapted to used it as a general graph),
- The eventual proxy pipe from which the events come from (but graph events can come from any kind of source),
- A default view, and eventually more views on the graphic graph.
- A flag that allows to repaint the view only if the graphic graph changed.
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 UI 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 ui 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.
-
Nested Class Summary
-
Field Summary
Fields Modifier and Type Field Description static String
DEFAULT_VIEW_ID
Name of the default view. -
Constructor Summary
Constructors Constructor Description FxViewer(org.graphstream.graph.Graph graph, org.graphstream.ui.view.Viewer.ThreadingModel threadingModel)
New viewer on an existing graph.FxViewer(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.FxViewer(org.graphstream.ui.graphicGraph.GraphicGraph graph)
We draw a pre-existing graphic graph. -
Method Summary
Modifier and Type Method Description void
actionPerformed()
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.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()
Methods inherited from class org.graphstream.ui.view.Viewer
addDefaultView, addView, addView, addView, computeGraphMetrics, disableAutoLayout, enableAutoLayout, enableAutoLayout, enableXYZfeedback, getCloseFramePolicy, getDefaultView, getGraphicGraph, getView, newGGId, newThreadProxyOnGraphicGraph, newViewerPipe, removeView, replayGraph, setCloseFramePolicy
-
Field Details
-
DEFAULT_VIEW_ID
Name of the default view.
-
-
Constructor Details
-
FxViewer
public FxViewer(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. The graphic graph displayed by this viewer is created.- Parameters:
source
- The source of graph events.
-
FxViewer
public FxViewer(org.graphstream.ui.graphicGraph.GraphicGraph graph)We draw a pre-existing graphic graph. The graphic graph is maintained by its creator.- Parameters:
graph
- THe graph to draw.
-
FxViewer
public FxViewer(org.graphstream.graph.Graph graph, org.graphstream.ui.view.Viewer.ThreadingModel threadingModel)New viewer on an existing graph. The viewer always run in the UI thread, therefore, you must specify how it will take graph events from the graph you give. If the graph you give will be accessed only from the UI thread use ThreadingModel.GRAPH_IN_GUI_THREAD. If the graph you use is accessed in another thread use ThreadingModel.GRAPH_IN_ANOTHER_THREAD. This last scheme is more powerful since it allows to run algorithms on the graph in parallel with the viewer.- Parameters:
graph
- The graph to render.threadingModel
- The threading model.
-
-
Method Details
-
getDefaultID
- Specified by:
getDefaultID
in classorg.graphstream.ui.view.Viewer
-
init
public void init(org.graphstream.ui.graphicGraph.GraphicGraph graph, org.graphstream.stream.ProxyPipe ppipe, org.graphstream.stream.Source source)Initialise the viewer.- Specified by:
init
in classorg.graphstream.ui.view.Viewer
- Parameters:
graph
- 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).
-
close
public void close()Close definitively this viewer and all its views.- Specified by:
close
in classorg.graphstream.ui.view.Viewer
-
newDefaultGraphRenderer
public org.graphstream.ui.view.GraphRenderer<?,?> newDefaultGraphRenderer()- Specified by:
newDefaultGraphRenderer
in classorg.graphstream.ui.view.Viewer
-
addDefaultView
public org.graphstream.ui.view.View addDefaultView(boolean openInAFrame, org.graphstream.ui.view.GraphRenderer<?,?> renderer)Build the default graph view and insert it. The view identifier isDEFAULT_VIEW_ID
. You can request the view to be open in its own frame.- Parameters:
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.
-
actionPerformed
public void actionPerformed()Called on a regular basis by the timer. Checks if some events occurred from the graph pipe or from the layout pipe, and if the graph changed, triggers a repaint. Never call this method, it is called by a UI Timer automatically.
-