use of org.graphstream.graph.Node in project gs-ui-javafx by graphstream.
the class TestSprite method chooseNextEdge.
public void chooseNextEdge() {
Edge edge = (Edge) getAttachment();
Node node = edge.getSourceNode();
if (dir > 0)
node = edge.getTargetNode();
Edge next = randomEdge(node);
double pos = 0;
if (node == next.getSourceNode()) {
dir = 0.01f;
pos = 0;
} else {
dir = -0.01f;
pos = 1;
}
attachToEdge(next.getId());
setPosition(pos);
}
use of org.graphstream.graph.Node in project gs-ui-javafx by graphstream.
the class DemoViewerFxEdgeSelection method showSelection.
protected static 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 fmv by f-agu.
the class FilterGraphUI method createRootNode.
/**
* @param inputProcessor
* @param outputKey
* @return
*/
private Node createRootNode(InputProcessor inputProcessor, OutputKey outputKey) {
Node node = graph.addNode(filterNaming.generate(outputKey.getLabel()));
node.addAttribute("ui.label", inputProcessor.getInput().toString());
node.addAttribute("ui.class", "root");
return node;
}
use of org.graphstream.graph.Node in project gs-ui-javafx by graphstream.
the class MovingEdgeSprite method move.
public void move() {
double p = getX();
p += speed;
if (p < 0 || p > 1) {
Edge edge = null;
if (getAttachment() instanceof Edge)
edge = (Edge) getAttachment();
if (edge != null) {
Node node = edge.getSourceNode();
if (p > 1)
node = edge.getTargetNode();
Edge other = randomOutEdge(node);
if (other == null) {
System.err.println("node " + node.getId() + " out=" + node.getOutDegree() + " null !!");
}
if (node.getOutDegree() > 1) {
while (other.equals(edge)) other = randomOutEdge(node);
}
attachToEdge(other.getId());
if (node.equals(other.getSourceNode())) {
setPosition(units, 0, off, 0);
speed = SPEED;
} else {
setPosition(units, 1, off, 0);
speed = -SPEED;
}
}
} else {
setPosition(units, p, off, 0);
}
}
use of org.graphstream.graph.Node in project gs-ui-javafx by graphstream.
the class BTest method run.
public void run() {
try {
MultiGraph graph = new MultiGraph("TestSize");
Viewer viewer = new FxViewer(graph, FxViewer.ThreadingModel.GRAPH_IN_ANOTHER_THREAD);
ViewerPipe pipeIn = viewer.newViewerPipe();
FxDefaultView view = (FxDefaultView) viewer.addView("view1", new FxGraphRenderer());
DefaultApplication.init(view, graph);
new Thread(() -> Application.launch(DefaultApplication.class)).start();
pipeIn.addAttributeSink(graph);
pipeIn.addViewerListener(this);
pipeIn.pump();
graph.setAttribute("ui.stylesheet", styleSheet);
graph.setAttribute("ui.antialias");
graph.setAttribute("ui.quality");
Node A = graph.addNode("A");
Node B = graph.addNode("B");
Node C = graph.addNode("C");
Node D = graph.addNode("D");
Node E = graph.addNode("E");
Node F = graph.addNode("F");
Edge AB = graph.addEdge("AB", "A", "B", true);
Edge BC = graph.addEdge("BC", "B", "C", true);
Edge CD = graph.addEdge("CD", "C", "D", true);
Edge DA = graph.addEdge("DA", "D", "A", true);
Edge BB = graph.addEdge("BB", "B", "B", true);
Edge DE = graph.addEdge("DE", "D", "E", true);
Edge DF = graph.addEdge("DF", "D", "F", true);
Edge CF = graph.addEdge("CF", "C", "F", true);
A.setAttribute("xyz", new double[] { 0, 1, 0 });
B.setAttribute("xyz", new double[] { 1, 0.8, 0 });
C.setAttribute("xyz", new double[] { 0.8, 0, 0 });
D.setAttribute("xyz", new double[] { 0, 0, 0 });
E.setAttribute("xyz", new double[] { 0.5, 0.5, 0 });
F.setAttribute("xyz", new double[] { 0.5, 0.25, 0 });
A.setAttribute("label", "A");
B.setAttribute("label", "Long label ...");
C.setAttribute("label", "C");
D.setAttribute("label", "A long label ...");
E.setAttribute("label", "Another very long label");
F.setAttribute("label", "F");
double size = 20f;
double sizeInc = 1f;
while (loop) {
pipeIn.pump();
sleep(40);
A.setAttribute("ui.size", size);
size += sizeInc;
if (size > 50) {
sizeInc = -1f;
size = 50f;
} else if (size < 20) {
sizeInc = 1f;
size = 20f;
}
}
} catch (Exception e) {
e.printStackTrace();
}
System.out.println("bye bye");
System.exit(0);
}
Aggregations