use of org.graphstream.ui.graphicGraph.GraphicGraph in project gs-ui-javafx by graphstream.
the class FxViewer method init.
/**
* Initialise the viewer.
*
* @param graph
* The graphic graph.
* @param ppipe
* The source of events from another thread or machine (null if
* source != null).
* @param source
* The source of events from this thread (null if ppipe != null).
*/
public void init(GraphicGraph graph, ProxyPipe ppipe, Source source) {
super.graph = graph;
super.pumpPipe = ppipe;
super.sourceInSameThread = source;
this.timeline = new Timeline(new KeyFrame(Duration.millis(delay), actionEvent -> actionPerformed()));
assert ((ppipe != null && source == null) || (ppipe == null && source != null));
if (pumpPipe != null)
pumpPipe.addSink(graph);
if (sourceInSameThread != null) {
if (source instanceof Graph)
replayGraph((Graph) source);
sourceInSameThread.addSink(graph);
}
// timer.setCoalesce(true);
// timer.setRepeats(true);
// timer.start();
timeline.setCycleCount(Timeline.INDEFINITE);
timeline.play();
}
use of org.graphstream.ui.graphicGraph.GraphicGraph in project gs-ui-javafx by graphstream.
the class DefaultCamera method allGraphicElementsIn.
@Override
public Collection<GraphicElement> allGraphicElementsIn(GraphicGraph graph, EnumSet<InteractiveElement> types, double x1, double y1, double x2, double y2) {
List<GraphicElement> elts = new ArrayList<GraphicElement>();
Stream nodeStream = null;
Stream edgeStream = null;
Stream spriteStream = null;
if (types.contains(InteractiveElement.NODE)) {
nodeStream = graph.nodes().filter(n -> isNodeIn((GraphicNode) n, x1, y1, x2, y2));
} else {
nodeStream = Stream.empty();
}
if (types.contains(InteractiveElement.EDGE)) {
edgeStream = graph.edges().filter(e -> isEdgeIn((GraphicEdge) e, x1, y1, x2, y2));
} else {
edgeStream = Stream.empty();
}
if (types.contains(InteractiveElement.SPRITE)) {
spriteStream = graph.sprites().filter(e -> isSpriteIn((GraphicSprite) e, x1, y1, x2, y2));
} else {
spriteStream = Stream.empty();
}
Stream<GraphicElement> s = Stream.concat(nodeStream, Stream.concat(edgeStream, spriteStream));
return s.collect(Collectors.toList());
}
Aggregations