Package org.graphstream.stream.thread

Examples of org.graphstream.stream.thread.ThreadProxyPipe


  // ----- On the receiver side -----
  // build the receiver that waits for events
  receiver = new JSONReceiver("localhost", 8080, "workspace0");
  // receiver.setDebug(true);
  ThreadProxyPipe pipe = receiver.getStream();
  // plug the pipe to the sink of the graph
  // pipe.addSink(graph);
  pipe.addElementSink(graph);

  // ----- On the sender side -----
  new Thread() {
      public void run() {
    // build a sender that sends events(layout information) to Gephi
    JSONSender sender = new JSONSender("localhost", 8080,
      "workspace0");
    // sender.setDebug(true);
    layout.addSink(sender);
      }
  }.start();

  // The receiver pro-actively checks for events on the ThreadProxyPipe
  pipe.pump();
  while (!graph.hasAttribute("ui.viewClosed")) {
      pipe.pump();
      fromViewer.pump();
      layout.compute();
  }
    }
View Full Code Here


  // - the receiver that waits for events
  JSONReceiver receiver = new JSONReceiver("localhost", 8080,
    "workspace0");
  receiver.setDebug(true);
  // - received events end up in the "default" pipe
  ThreadProxyPipe pipe = receiver.getStream();
  // - plug the pipe to the sink of the graph
  pipe.addSink(g);
  // ----- The sender side (in another thread) ------
  //
  new Thread() {
      public void run() {
    // - the original graph from which events are generated
    Graph g = new MultiGraph("G");
    // - the sender
    JSONSender sender = new JSONSender("localhost", 8080,
      "workspace0");
    // - plug the graph to the sender so that graph events can be
    // sent automatically
    g.addSink(sender);
    // - generate some events on the client side
    String style = "node{fill-mode:plain;fill-color:#567;size:6px;}";
    g.addAttribute("stylesheet", style);
    g.addAttribute("ui.antialias", true);
    g.addAttribute("layout.stabilization-limit", 0);
    for (int i = 0; i < 50; i++) {
        g.addNode(i + "");
        if (i > 0) {
      g.addEdge(i + "-" + (i - 1), i + "", (i - 1) + "");
      g.addEdge(i + "--" + (i / 2), i + "", (i / 2) + "");
        }
    }
      }
  }.start();

  // ----- Back to the receiver side -----
  //
  // -The receiver pro-actively checks for events on the ThreadProxyPipe
  while (true) {
      pipe.pump();
      Thread.sleep(100);
  }
    }
View Full Code Here

  JSONReceiver receiver = new JSONReceiver("localhost", 8080,
    "workspace0");

  receiver.setDebug(true);

  ThreadProxyPipe pipe = receiver.getStream();

  Graph g = new MultiGraph("workspace0", false, true);

  pipe.addSink(g);

  g.addSink(new SinkAdapter() {

      public void graphAttributeAdded(String sourceId, long timeId,
        String attribute, Object value) {
    System.out.println("Graph Attribtue Added");
      }
  });

  new Thread() {

      public void run() {

    Graph g = new MultiGraph("workspace0", false, true);
    JSONSender sender = new JSONSender("localhost", 8080,
      "workspace0");

    sender.setDebug(true);

    g.addSink(sender);

    g.addAttribute("attribute", "foo");
    g.changeAttribute("attribute", false);

    Edge e = g.addEdge("AB", "A", "B");
    e.addAttribute("attribute", "foo");
    e.changeAttribute("attribute", false);
    Node n = e.getNode0();
    n.addAttribute("attribute", "foo");
    n.changeAttribute("attribute", false);

      }
  }.start();

  try {
      Thread.sleep(100);
  } catch (InterruptedException e) {
      e.printStackTrace();
  }

  // The receiver pro-actively checks for events on the ThreadProxyPipe
  pipe.pump();

  // assertEquals(false, g.getAttribute("attribute"));
  // assertEquals(false, g.getEdge("AB").getAttribute("attribute"));
  // assertEquals(false,
  // g.getEdge("AB").getNode0().getAttribute("attribute"));
View Full Code Here

  JSONReceiver receiver = new JSONReceiver("localhost", 8080,
    "workspace0");

  // receiver.setDebug(true);

  ThreadProxyPipe pipe = receiver.getStream();

  pipe.addSink(g);

  launchClient("localhost", 8080, "workspace0", "0");
  launchClient("localhost", 8080, "workspace0", "1");

  for (int i = 0; i < 10; i++) {
      pipe.pump();

      try {
    Thread.sleep(100);
      } catch (InterruptedException e) {
    e.printStackTrace();
      }
  }

  pipe.pump();

  // assertEquals("workspace0", g.getAttribute("id"));
  assertEquals(180, g.getNodeCount());
    }
View Full Code Here

  Graph g = new DefaultGraph("workspace0", false, true);

  JSONReceiver receiver = new JSONReceiver("localhost", 8080,
    "workspace0");

  ThreadProxyPipe pipe = receiver.getStream();

  pipe.addSink(g);

  g.addSink(new SinkAdapter() {
      /*
       * public void graphAttributeAdded(String sourceId, long timeId,
       * String attribute, Object value) { assertEquals(0, value);
       * assertEquals("graphAttribute", attribute); }
       *
       * public void graphAttributeChanged(String sourceId, long timeId,
       * String attribute, Object oldValue, Object newValue) {
       * assertTrue((Integer) newValue == 0 || (Integer) newValue == 1);
       * assertEquals("graphAttribute", attribute); }
       *
       * public void graphAttributeRemoved(String sourceId, long timeId,
       * String attribute) { assertEquals("graphAttribute", attribute); }
       *
       * public void nodeAttributeAdded(String sourceId, long timeId,
       * String nodeId, String attribute, Object value) { assertEquals(0,
       * value); assertEquals("nodeAttribute", attribute); }
       *
       * public void nodeAttributeChanged(String sourceId, long timeId,
       * String nodeId, String attribute, Object oldValue, Object
       * newValue) { assertTrue((Integer) newValue == 0 || (Integer)
       * newValue == 1); assertEquals("nodeAttribute", attribute); }
       *
       * public void nodeAttributeRemoved(String sourceId, long timeId,
       * String nodeId, String attribute) { assertEquals("nodeAttribute",
       * attribute); }
       *
       * public void edgeAttributeAdded(String sourceId, long timeId,
       * String edgeId, String attribute, Object value) { assertEquals(0,
       * value); assertEquals("edgeAttribute", attribute); }
       *
       * public void edgeAttributeChanged(String sourceId, long timeId,
       * String edgeId, String attribute, Object oldValue, Object
       * newValue) { assertTrue((Integer) newValue == 0 || (Integer)
       * newValue == 1); assertEquals("edgeAttribute", attribute); }
       *
       * public void edgeAttributeRemoved(String sourceId, long timeId,
       * String edgeId, String attribute) { assertEquals("edgeAttribute",
       * attribute); }
       */

      public void nodeAdded(String sourceId, long timeId, String nodeId) {
    assertTrue("node0".equals(nodeId) || "node1".equals(nodeId));
      }

      public void nodeRemoved(String sourceId, long timeId, String nodeId) {
    assertTrue("node0".equals(nodeId) || "node1".equals(nodeId));
      }

      public void edgeAdded(String sourceId, long timeId, String edgeId,
        String fromNodeId, String toNodeId, boolean directed) {
    assertEquals("edge", edgeId);
    assertEquals("node0", fromNodeId);
    assertEquals("node1", toNodeId);
    assertEquals(true, directed);
      }

      public void edgeRemoved(String sourceId, long timeId, String edgeId) {
    assertEquals("edge", edgeId);
      }

      public void graphCleared(String sourceId, long timeId) {

      }

      public void stepBegins(String sourceId, long timeId, double step) {
    assertEquals(1.1, step);
      }
  });

  new Thread() {

      @Override
      public void run() {
    Graph g = new MultiGraph("workspace0", false, true);

    JSONSender sender = new JSONSender("localhost", 8080,
      "workspace0");

    g.addSink(sender);

    Node node0 = g.addNode("node0");
    Edge edge = g.addEdge("edge", "node0", "node1", true);
    /*
     * node0.addAttribute("nodeAttribute", 0);
     * node0.changeAttribute("nodeAttribute", 1);
     * node0.removeAttribute("nodeAttribute");
     * edge.addAttribute("edgeAttribute", 0);
     * edge.changeAttribute("edgeAttribute", 1);
     * edge.removeAttribute("edgeAttribute");
     * g.addAttribute("graphAttribute", 0);
     * g.changeAttribute("graphAttribute", 1);
     * g.removeAttribute("graphAttribute");
     */
    g.stepBegins(1.1);
    g.removeEdge("edge");
    g.removeNode("node0");
    g.clear();
      }
  }.start();

  try {
      Thread.sleep(100);
  } catch (InterruptedException e) {
      e.printStackTrace();
  }

  pipe.pump();
    }
View Full Code Here

  g.display();
  // the receiver that waits for events
  JSONReceiver receiver = new JSONReceiver("localhost", 8080,
    "workspace0");
  receiver.setDebug(true);
  ThreadProxyPipe pipe = receiver.getStream();
  // plug the pipe to the sink of the graph
  pipe.addSink(g);
  // The receiver pro-actively checks for events on the ThreadProxyPipe
  while (true) {
      pipe.pump();
  }
    }
View Full Code Here

  this.sourceId = String.format("<Gephi json stream %x>",
    System.nanoTime());
  this.debug = false;

  this.sourceTime = new SourceTime(this.sourceId);
  currentStream = new ThreadProxyPipe();
  init();
  start();
    }
View Full Code Here

  this.workspace = workspace;
  this.sourceId = String.format("<Gephi json stream %x>",
    System.nanoTime());
  this.debug = debug;

  currentStream = new ThreadProxyPipe();
  init();
  start();
    }
View Full Code Here

    outputRunnerAlive = on;

    if (outputRunnerAlive) {
      if (outputRunnerProxy == null) {
        outputRunnerProxy = new ThreadProxyPipe();
        outputRunnerProxy.init(gg);
      }

      sink = outputRunnerProxy;
      outputRunner = new OutputRunner();
View Full Code Here

      enableXYZfeedback(true);
      break;
    case GRAPH_IN_ANOTHER_THREAD:
      graphInAnotherThread = true;
     
      ThreadProxyPipe tpp = new ThreadProxyPipe();
      tpp.init(graph, true);

      init(new GraphicGraph(newGGId()), tpp, (Source) null);
      enableXYZfeedback(false);
      break;
    case GRAPH_ON_NETWORK:
View Full Code Here

TOP

Related Classes of org.graphstream.stream.thread.ThreadProxyPipe

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.