use of org.graphstream.graph.Node in project gs-ui-javafx by graphstream.
the class TutorialDiagrams method diagram1.
public Scene diagram1(String title, String styleSheet) {
MultiGraph graph = new MultiGraph(title);
Scene s = diagram(graph, styleSheet, title, 500, 250);
Node G = graph.addNode("Graph");
Node V = graph.addNode("Viewer");
Edge E = graph.addEdge("G->V", "Graph", "Viewer", true);
G.setAttribute("xyz", new double[] { 0, 0, 0 });
V.setAttribute("xyz", new double[] { 1, 0, 0 });
G.setAttribute("ui.label", "Graph");
V.setAttribute("ui.label", "Viewer");
return s;
}
use of org.graphstream.graph.Node in project gs-ui-javafx by graphstream.
the class DemoViewerFxColorInterpolation method showSelection.
protected void showSelection(Graph graph) {
boolean selection = false;
StringBuilder sb = new StringBuilder();
sb.append("[");
for (Node node : graph) {
if (node.hasAttribute("ui.selected")) {
sb.append(String.format(" %s", node.getId()));
selection = true;
}
if (node.hasAttribute("ui.clicked")) {
System.err.printf("node %s clicked%n", node.getId());
}
}
sb.append(" ]");
if (selection)
System.err.printf("selection = %s%n", sb.toString());
}
use of org.graphstream.graph.Node in project gs-ui-javafx by graphstream.
the class DemoViewerFxEdgeSelection method main.
public static void main(String[] args) {
System.setProperty("org.graphstream.ui", "org.graphstream.ui.javafx.util.Display");
Graph graph = new MultiGraph("main graph");
viewPanel = (FxViewPanel) graph.display(true).getDefaultView();
FxViewer view = (FxViewer) viewPanel.getViewer();
view.getDefaultView().setMouseManager(new FxMouseManager(EnumSet.of(InteractiveElement.EDGE, InteractiveElement.NODE, InteractiveElement.SPRITE)));
ViewerPipe pipe = view.newViewerPipe();
// graph.setAttribute( "ui.quality" );
graph.setAttribute("ui.antialias");
pipe.addViewerListener(new DemoViewerFxEdgeSelection());
for (String nodeId : new String[] { "A", "B", "C" }) {
Node node = graph.addNode(nodeId);
node.setAttribute("ui.label", nodeId);
}
graph.addEdge("AB", "A", "B", true);
graph.addEdge("BC", "B", "C", true);
graph.addEdge("CA", "C", "A", true);
graph.setAttribute("ui.stylesheet", styleSheet);
float color = 0;
float dir = 0.01f;
while (loop) {
try {
Thread.sleep(100);
} catch (InterruptedException e) {
e.printStackTrace();
}
pipe.pump();
color += dir;
if (color > 1) {
color = 1;
dir = -dir;
} else if (color < 0) {
color = 0;
dir = -dir;
}
showSelection(graph);
}
}
use of org.graphstream.graph.Node in project abstools by abstools.
the class MyGMLWriter method addObject.
@Override
public void addObject(final ObjectView o, final boolean COG) {
super.addObject(o, COG);
Node n = graph.addNode(getID(o));
n.addAttribute("ui.label", getID(o));
n.addAttribute("label", getLabel(o));
n.addAttribute("cog", getID(getCOGOwner(o)));
n.addAttribute("class", o.getClassName());
if (COG) {
n.addAttribute("layout.weight", 0.5f);
n.addAttribute("ui.class", "cog");
// n.addAttribute("ui.size", "25");
n.addAttribute("Size", 20);
n.addAttribute("Color", "[0,255,0]");
n.addAttribute("kind", "cog");
} else {
n.addAttribute("layout.weight", 0.5f);
n.addAttribute("ui.class", "obj");
n.addAttribute("ui.size", "20");
n.addAttribute("Size", 10);
n.addAttribute("Color", "[255,0,0]");
n.addAttribute("kind", "object");
}
if (o.equals("Main 1")) {
n.addAttribute("ui.hide");
System.out.println("YES");
}
if (!COG) {
addEdge(o, getCOGOwner(o), true);
}
}
use of org.graphstream.graph.Node in project fmv by f-agu.
the class FilterGraphUI method addTail.
/**
*/
private void addTail() {
// TODO autoMap by outputProcessor
AutoMap autoMap = operation.getAutoMap();
Set<Label> labels = autoMap.find(operation);
Node node = graph.addNode("output");
node.addAttribute("ui.label", "output");
node.addAttribute("ui.class", "root");
for (Label label : labels) {
// System.out.println(filterNaming.generate(label));
Set<FilterComplex> fcs = filterGraph.getByOut(label);
for (FilterComplex outFC : fcs) {
Node inNode = createOrGetNode(outFC);
graph.addEdge("output" + label, inNode, node);
}
}
}
Aggregations