Package org.graphstream.stream

Examples of org.graphstream.stream.ProxyPipe


  public DemoLayoutAndViewer() {
    boolean loop = true;
    Graph graph = new MultiGraph("test");
    Viewer viewer = new Viewer(new ThreadProxyPipe(graph));
    ProxyPipe fromViewer = viewer.newThreadProxyOnGraphicGraph();
    LinLog layout = new LinLog(false);
   
    layout.configure(a, r, true, force);

    graph.addAttribute("ui.antialias");
    graph.addAttribute("ui.stylesheet", styleSheet);
    fromViewer.addSink(graph);
    viewer.addDefaultView(true);
    graph.addSink(layout);
    layout.addAttributeSink(graph);

    FileSource dgs = GRAPH.endsWith(".gml") ? new FileSourceGML() : new FileSourceDGS();

    dgs.addSink(graph);
    try {
      dgs.begin(getClass().getResourceAsStream(GRAPH));
      for (int i = 0; i < 5000 && dgs.nextEvents(); i++) {
//        fromViewer.pump();
//        layout.compute();
//        sleep(100);
      }
      dgs.end();
    } catch (IOException e1) {
      e1.printStackTrace();
      System.exit(1);
    }
   
    System.out.println("Finished creating the graph.");

    while (loop) {
      fromViewer.pump();

      if (graph.hasAttribute("ui.viewClosed")) {
        loop = false;
      } else {
        //sleep(1000);       
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);
    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")) {
View Full Code Here

TOP

Related Classes of org.graphstream.stream.ProxyPipe

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.