// setLAF();
new DemoViewerJComponents();
}
public DemoViewerJComponents() {
Graph graph = new MultiGraph("main graph");
ThreadProxyPipe toSwing = new ThreadProxyPipe(graph);
Viewer viewer = new Viewer(toSwing);
ProxyPipe fromSwing = viewer.newThreadProxyOnGraphicGraph();
SpriteManager sman = new SpriteManager(graph);
fromSwing.addAttributeSink(graph);
viewer.addDefaultView(true);
Node A = graph.addNode("A");
Node B = graph.addNode("B");
Node C = graph.addNode("C");
graph.addEdge("AB", "A", "B");
graph.addEdge("BC", "B", "C");
graph.addEdge("CA", "C", "A");
A.addAttribute("xyz", 0, 1, 0);
B.addAttribute("xyz", 1, 0, 0);
C.addAttribute("xyz", -1, 0, 0);
A.addAttribute("ui.label", "Quit");
B.addAttribute("ui.label", "Editable text");
C.addAttribute("ui.label", "Click to edit");
graph.addAttribute("ui.stylesheet", styleSheet);
Sprite s1 = sman.addSprite("S1");
Sprite s2 = sman.addSprite("S2");
Sprite s3 = sman.addSprite("S3");
s1.attachToNode("B");
s2.attachToEdge("BC");
s1.setPosition(StyleConstants.Units.PX, 1, 0, 0);
s2.setPosition(0.5f);
s3.setPosition(0, 0.5f, 0);
s1.addAttribute("ui.label", "1");
s2.addAttribute("ui.label", "2");
// s3.addAttribute( "ui.label", "" );
boolean loop = true;
// float x = 0;
// float y = 1;
// float dir = 0.005f;
float angle = 0;
while (loop) {
try {
Thread.sleep(30);
} catch (InterruptedException e) {
e.printStackTrace();
}
fromSwing.pump();
if (graph.hasAttribute("ui.viewClosed")) {
loop = false;
} else {
if (A.hasAttribute("ui.clicked")) {
System.err.printf("A clicked (%s)%n",
A.getLabel("ui.label"));