Set of views on a graphic graph.
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 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 {@link #addView(View)}, {@link #removeView(String)} and the {@link #close()}methods. Other methods are not protected from concurrent accesses.
Some constructors allow a {@link ProxyPipe} as argument. If given, thegraphic 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 {@link Source}, the viewer will not display the events that occured on the source before it is connected to it.