Package org.graphstream.graph.implementations

Examples of org.graphstream.graph.implementations.MultiGraph


  }

  protected boolean loop = true;

  public DemoViewerColorInterpolation() {
    Graph graph = new MultiGraph("main graph");
    ViewerPipe pipe = graph.display(false).newViewerPipe();

    // graph.addAttribute( "ui.quality" );
    graph.addAttribute("ui.antialias");

    pipe.addViewerListener(this);

    Node A = graph.addNode("A");
    Node B = graph.addNode("B");
    Node C = graph.addNode("C");

    graph.addEdge("AB", "A", "B", true);
    graph.addEdge("BC", "B", "C", true);
    graph.addEdge("CA", "C", "A", true);

    A.addAttribute("xyz", 0, 1, 0);
    B.addAttribute("xyz", 1, 0, 0);
    C.addAttribute("xyz", -1, 0, 0);

    graph.addAttribute("ui.stylesheet", styleSheet);

    float color = 0;
    float dir = 0.01f;

    while (loop) {
View Full Code Here


  }
 
  public DemoAllInSwing() {
    // On est dans le thread main.
   
    Graph graph  = new MultiGraph("mg");
   
    // On demande au viewer de consid�rer que le graphe ne sera lu et modifi� que
    // dans le thread Swing.
   
    Viewer viewer = new Viewer(graph, Viewer.ThreadingModel.GRAPH_IN_GUI_THREAD);
View Full Code Here

public class TestGraph {
  @Test
  public void testBasic() {
    testBasic(new SingleGraph("sg"));
    testBasic(new MultiGraph("mg"));
    testBasic(new AdjacencyListGraph("alg"));
    testBasic(new AdjacencyListGraph("AL")); // XXX
    testBasic(new SingleGraph("S")); // XXX
    testBasic(new MultiGraph("M")); // XXX
  }
View Full Code Here

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

  }

  @Test
  public void testDirected() {
    testDirected(new SingleGraph("sg"));
    testDirected(new MultiGraph("mg"));
    // testDirected( new AdjacencyListGraph( "alg" ) );
    testDirected(new AdjacencyListGraph("AL")); // XXX
    testDirected(new SingleGraph("S")); // XXX
    testDirected(new MultiGraph("M")); // XXX
  }
View Full Code Here

    assertEquals(A, AA.getTargetNode());   
  }

  @Test
  public void testMulti() {
    MultiGraph graph = new MultiGraph("g");
    MultiNode A = graph.addNode("A");
    MultiNode B = graph.addNode("B");

    graph.addEdge("AB1", "A", "B");
    graph.addEdge("AB2", "A", "B");

    assertEquals(2, A.getDegree());
    assertEquals(2, B.getDegree());
   
    // loop edges
    graph.addEdge("AA1", "A", "B");
    graph.addEdge("AA2", "A", "B", true);
   
    assertEquals(4, A.getDegree());
  }
View Full Code Here

  }

  @Test
  public void testIterables() {
    testIterables(new SingleGraph("sg"));
    testIterables(new MultiGraph("mg"));
    // testIterables( new AdjacencyListGraph( "alg" ) );
    testIterables(new AdjacencyListGraph("AL")); // XXX
    testIterables(new SingleGraph("S")); // XXX
    testIterables(new MultiGraph("M")); // XXX
  }
View Full Code Here

  }

  @Test
  public void testRemoval() {
    testRemoval(new SingleGraph("sg"));
    testRemoval(new MultiGraph("mg"));
    // testRemoval( new AdjacencyListGraph( "alg" ) );
    testRemoval(new AdjacencyListGraph("AL")); // XXX
    testRemoval(new SingleGraph("S")); // XXX
    testRemoval(new MultiGraph("M")); // XXX
  }
View Full Code Here

  }

  @Test
  public void testGraphListener() {
    testGraphListener(new SingleGraph("sg"));
    testGraphListener(new MultiGraph("mg"));
    // testGraphListener( new AdjacencyListGraph( "alg" ) );
    testGraphListener(new AdjacencyListGraph("AL")); // XXX
    testGraphListener(new SingleGraph("S")); // XXX
    testGraphListener(new MultiGraph("M")); // XXX
  }
View Full Code Here

    // (input).
    // We populate (or remove elements from) the input and check the output
    // to see
    // if it is a copy of the input.

    Graph output = new MultiGraph("outout");

    input.addSink(output);

    Node A = input.addNode("A");
    input.addNode("B");
    input.addNode("C");

    input.addEdge("AB", "A", "B");
    Edge BC = input.addEdge("BC", "B", "C");
    input.addEdge("CA", "C", "A");

    A.addAttribute("foo", "bar");
    BC.addAttribute("foo", "bar");

    assertEquals(3, input.getNodeCount());
    assertEquals(3, output.getNodeCount());
    assertEquals(3, input.getEdgeCount());
    assertEquals(3, output.getEdgeCount());

    assertNotNull(output.getNode("A"));
    assertNotNull(output.getNode("B"));
    assertNotNull(output.getNode("C"));
    assertNotNull(output.getEdge("AB"));
    assertNotNull(output.getEdge("BC"));
    assertNotNull(output.getEdge("CA"));

    assertEquals("bar", output.getNode("A").getAttribute("foo"));
    assertEquals("bar", output.getEdge("BC").getAttribute("foo"));

    // Now remove an attribute.

    A.removeAttribute("foo");

    assertFalse(output.hasAttribute("foo"));

    // Now remove a node.

    input.removeNode("A");

    assertEquals(2, input.getNodeCount());
    assertEquals(1, input.getEdgeCount());
    assertEquals(2, output.getNodeCount());
    assertEquals(1, output.getEdgeCount());

    // Now check that attribute change works.

    BC.changeAttribute("foo", "truc");

    assertEquals("truc", BC.getAttribute("foo"));
    assertEquals("truc", output.getEdge("BC").getAttribute("foo"));
  }
View Full Code Here

TOP

Related Classes of org.graphstream.graph.implementations.MultiGraph

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.