Package org.graphstream.ui.spriteManager

Examples of org.graphstream.ui.spriteManager.SpriteManager


    Node C = main.addNode("C");
    main.addEdge("AB", "A", "B");
    main.addEdge("BC", "B", "C");
    main.addEdge("CA", "C", "A");

    SpriteManager sman = new SpriteManager(main);
    Sprite S1 = sman.addSprite("S1");
    Sprite S2 = sman.addSprite("S2");
    Sprite S3 = sman.addSprite("S3");

    S3.setPosition(1, 2, 2);
    S3.setPosition(2, 3, 2);
    S3.setPosition(3, 2, 1);

    A.addAttribute("ui.foo", "bar");
    B.addAttribute("ui.bar", "foo");
    C.addAttribute("truc"); // Not prefixed by UI, will not pass.
    S1.addAttribute("ui.foo", "bar");
    main.stepBegins(1);

    toMain.pump();

    // We ask the Swing thread to modify the graphic graph.

    main.stepBegins(2);
    main.addAttribute("ui.EQUIP"); // Remember GraphicGraph filters
                    // attributes.

    // Wait and stop.

    toMain.pump();
    sleep(1000);
    toMain.pump();

    main.addAttribute("ui.STOP");

    toMain.pump();
    sleep(1000);
    toMain.pump();

    // ****************************************************************************************
    // Now we can begin the real test. We ensure the timer in the Swing
    // graph stopped and check
    // If the two graphs (main and graphic) synchronized correctly.

    GraphicGraph graphic = viewerThread.graphic;

    assertTrue(viewerThread.isStopped());
    assertFalse(main.hasAttribute("ui.EQUIP"));
    assertFalse(graphic.hasAttribute("ui.EQUIP"));
    assertTrue(main.hasAttribute("ui.STOP"));
    assertTrue(graphic.hasAttribute("ui.STOP"));

    assertEquals(3, graphic.getStep(), 0);
    assertEquals(2, main.getStep(), 0); // We do not listen at elements events
                      // the step 3
                      // of the graphic graph did not
                      // reached us.
    // Assert all events passed toward the graphic graph.

    assertEquals(3, graphic.getNodeCount());
    assertEquals(3, graphic.getEdgeCount());
    assertEquals(3, graphic.getSpriteCount());
    assertNotNull(graphic.getNode("A"));
    assertNotNull(graphic.getNode("B"));
    assertNotNull(graphic.getNode("C"));
    assertNotNull(graphic.getEdge("AB"));
    assertNotNull(graphic.getEdge("BC"));
    assertNotNull(graphic.getEdge("CA"));
    assertNotNull(graphic.getSprite("S1"));
    assertNotNull(graphic.getSprite("S2"));
    assertEquals("bar", graphic.getNode("A").getAttribute("ui.foo"));
    assertEquals("foo", graphic.getNode("B").getAttribute("ui.bar"));
    // assertNull( graphic.getNode("C").getAttribute( "truc" ) ); // Should
    // not pass the attribute filter.
    assertEquals("bar", graphic.getSprite("S1").getAttribute("ui.foo"));
    assertEquals("bar", sman.getSprite("S1").getAttribute("ui.foo"));

    // Assert attributes passed back to the graph from the graphic graph.

    Object xyz1[] = { 4, 3, 2 };
    Object xyz2[] = { 2, 1, 0 };
View Full Code Here


  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);
View Full Code Here

TOP

Related Classes of org.graphstream.ui.spriteManager.SpriteManager

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.