Package org.graphstream.graph

Examples of org.graphstream.graph.Node


        if (e instanceof Node) {
          x = viewBox.convertX((Node) e);
          y = viewBox.convertY((Node) e);
        } else if (e instanceof Edge) {
          Node n0, n1;

          n0 = ((Edge) e).getNode0();
          n1 = ((Edge) e).getNode0();

          x = viewBox.convertX((getX(n0) + getX(n1)) / 2);
View Full Code Here


        concat(buffer, " L ", d(viewBox.x2), " ", d(viewBox.y1));
        concat(buffer, " L ", d(viewBox.x2), " ", d(viewBox.y2));
        concat(buffer, " L ", d(viewBox.x1), " ", d(viewBox.y2));
        concat(buffer, " Z");
      } else if (e instanceof Edge) {
        Node src, trg;

        double x1, y1;
        double x2, y2;

        src = ((Edge) e).getSourceNode();
View Full Code Here

   * .String, long, java.lang.String, java.lang.String, java.lang.Object)
   */
  public void nodeAttributeAdded(String sourceId, long timeId, String nodeId,
      String attribute, Object value) {
    if (sinkTime.isNewEvent(sourceId, timeId)) {
      Node node = g.getNode(nodeId);
      if (node != null) {
        passYourWay = true;

        try {
          node.addAttribute(attribute, value);
        } finally {
          passYourWay = false;
        }

        sendNodeAttributeAdded(sourceId, timeId, nodeId, attribute,
View Full Code Here

   * java.lang.Object)
   */
  public void nodeAttributeChanged(String sourceId, long timeId,
      String nodeId, String attribute, Object oldValue, Object newValue) {
    if (sinkTime.isNewEvent(sourceId, timeId)) {
      Node node = g.getNode(nodeId);
      if (node != null) {
        passYourWay = true;

        if (oldValue == null)
          oldValue = node.getAttribute(attribute);

        try {
          node.changeAttribute(attribute, newValue);
        } finally {
          passYourWay = false;
        }

        sendNodeAttributeChanged(sourceId, timeId, nodeId, attribute,
View Full Code Here

   * .String, long, java.lang.String, java.lang.String)
   */
  public void nodeAttributeRemoved(String sourceId, long timeId,
      String nodeId, String attribute) {
    if (sinkTime.isNewEvent(sourceId, timeId)) {
      Node node = g.getNode(nodeId);
      if (node != null) {
        sendNodeAttributeRemoved(sourceId, timeId, nodeId, attribute);
        passYourWay = true;

        try {
          node.removeAttribute(attribute);
        } finally {
          passYourWay = false;
        }
      }
    }
View Full Code Here

        && g2.getAttributeCount() == 0
        && (g1.getNodeCount() > 0 || g1.getEdgeCount() > 0)) {
      events.add(new GraphCleared(g1));
    } else {
      for (int idx = 0; idx < g2.getNodeCount(); idx++) {
        Node n2 = g2.getNode(idx);
        Node n1 = g1.getNode(n2.getId());

        if (n1 == null)
          events.add(new NodeAdded(n2.getId()));

        attributeDiff(ElementType.NODE, n1, n2);
      }

      for (int idx = 0; idx < g1.getNodeCount(); idx++) {
        Node n1 = g1.getNode(idx);
        Node n2 = g2.getNode(n1.getId());

        if (n2 == null) {
          attributeDiff(ElementType.NODE, n1, n2);
          events.add(new NodeRemoved(n1.getId()));
        }
View Full Code Here

  public static void main(String... args) throws Exception {
    Graph g1 = new AdjacencyListGraph("g1");
    Graph g2 = new AdjacencyListGraph("g2");

    Node a1 = g1.addNode("A");
    a1.addAttribute("attr1", "test");
    a1.addAttribute("attr2", 10.0);
    a1.addAttribute("attr3", 12);

    Node a2 = g2.addNode("A");
    a2.addAttribute("attr1", "test1");
    a2.addAttribute("attr2", 10.0);
    g2.addNode("B");
    g2.addNode("C");

    GraphDiff diff = new GraphDiff(g2, g1);
    System.out.println(diff);
View Full Code Here

     *
     * @see org.graphstream.stream.ElementSink#nodeRemoved(java.lang.String,
     * long, java.lang.String)
     */
    public void nodeRemoved(String sourceId, long timeId, String nodeId) {
      Node n = g.getNode(nodeId);

      for (String key : n.getAttributeKeySet())
        nodeAttributeRemoved(sourceId, timeId, nodeId, key);

      Event e;
      e = new NodeRemoved(nodeId);
      events.add(e);
View Full Code Here

      // the graphic graph and should be propagated (synchronised) to the
      // main graph.
      // When we encounter the "ui.STOP" event we stop the timer.

      if (graphic.hasAttribute("ui.EQUIP")) {
        Node A = graphic.getNode("A");
        Node B = graphic.getNode("B");
        Node C = graphic.getNode("C");

        if (A != null)
          A.addAttribute("xyz", 4, 3, 2);
        if (B != null)
          B.addAttribute("xyz", 2, 1, 0);
        if (C != null)
          C.addAttribute("xyz", 3, 2, 1);

        GraphicSprite S1 = graphic.getSprite("S1");
        GraphicSprite S2 = graphic.getSprite("S2");

        if (S2 != null) {
View Full Code Here

  @Test
  public void testReplay() {
    AbstractGraph g1 = new AdjacencyListGraph("g1");
    Graph g2 = new AdjacencyListGraph("g2");

    Node A1 = g1.addNode("A");
    Node B1 = g1.addNode("B");
    Node C1 = g1.addNode("C");

    Edge AB1 = g1.addEdge("AB", "A", "B");
    Edge BC1 = g1.addEdge("BC", "B", "C");
    Edge CA1 = g1.addEdge("CA", "C", "A");

    A1.addAttribute("string", "an example");
    B1.addAttribute("double", 42.0);
    C1.addAttribute("array", new int[] { 1, 2, 3 });

    AB1.addAttribute("string", "an example");
    BC1.addAttribute("double", 42.0);
    CA1.addAttribute("array", new int[] { 1, 2, 3 });

    Replayable.Controller controller = g1.getReplayController();
    controller.addSink(g2);
    controller.replay();

    Node A2 = g2.getNode("A");
    Node B2 = g2.getNode("B");
    Node C2 = g2.getNode("C");

    assertNotNull(A2);
    assertNotNull(B2);
    assertNotNull(C2);
View Full Code Here

TOP

Related Classes of org.graphstream.graph.Node

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.