Package se.sics.contiki.collect

Examples of se.sics.contiki.collect.Link


        if (!hideNetwork) {
          FontMetrics fm = g.getFontMetrics();
          int fnHeight = fm.getHeight();
          int fnDescent = fm.getDescent();
          for (int j = 0, mu = n.node.getLinkCount(); j < mu; j++) {
            Link link = n.node.getLink(j);
            if (link.node.hasLocation()) {
              long age = (time - link.getLastActive()) / 100;
              int x2 = link.node.getX();
              int y2 = link.node.getY();
              if (n.isSelected) {
                if (age > LINK_COLOR.length) {
                  age = 100;
                } else {
                  age -= 50;
                }
              }
              line.setLine(x, y, x2, y2);
              if (age < LINK_COLOR.length) {
                g.setColor(age < 0 ? LINK_COLOR[0] : LINK_COLOR[(int) age]);
              } else {
                g.setColor(LINK_COLOR[LINK_COLOR.length - 1]);
              }
              g2d.draw(line);
//              g.setColor(Color.lightGray);
              int xn1, xn2, yn1, yn2;
              if (x <= x2) {
                xn1 = x; xn2 = x2;
                yn1 = y; yn2 = y2;
              } else {
                xn1 = x2; xn2 = x;
                yn1 = y2; yn2 = y;
              }
              int dx = xn1 + (xn2 - xn1) / 2 + 4;
              int dy = yn1 + (yn2 - yn1) / 2 - fnDescent;
              if (yn2 < yn1) {
                dy += fnHeight - fnDescent;
              }
              g.drawString("ETX:" + (((int)(link.getETX() * 100 + 0.5)) / 100.0), dx, dy);
            }
          }
        }

        n.paint(g, x, y);
View Full Code Here


        tick--;
        r = true;
      }

      for (int i = 0, n = node.getLinkCount(); i < n; i++) {
        Link link = node.getLink(i);
        long age = (time - link.getLastActive()) / 100;
        if (age < 200) {
          r = true;
          break;
        }
      }
View Full Code Here

    MapNode[] nodes = getNodeList();
    if (!isMap || !hideNetwork) {
      g.setColor(LINK_COLOR);
      for (MapNode n : nodes) {
        for (int j = 0, mu = n.node.getLinkCount(); j < mu; j++) {
          Link link = n.node.getLink(j);
          MapNode linkNode = addMapNode(link.node);
          int x2 = linkNode.x;
          int y2 = linkNode.y;
          g2d.drawLine(n.x, n.y, x2, y2);
          drawArrow(g, n.x, n.y, x2, y2, 3);
          if (!hideNetwork) {
            int xn1, xn2, yn1, yn2;
            if (n.x <= x2) {
              xn1 = n.x; xn2 = x2;
              yn1 = n.y; yn2 = y2;
            } else {
              xn1 = x2; xn2 = n.x;
              yn1 = y2; yn2 = n.y;
            }
            int dx = xn1 + (xn2 - xn1) / 2 + 4;
            int dy = yn1 + (yn2 - yn1) / 2 - fnDescent;
            if (yn2 < yn1) {
              dy += fnHeight - fnDescent;
            }
            g.drawString(
                Double.toString(((int) (link.getETX() * etxFactor * 100 + 0.5)) / 100.0),
                dx, dy);
          }
        }
      }
    }
View Full Code Here

    MapNode[] nodes = getNodeList();
    for (MapNode n : nodes) {

      // Attract connected nodes
      for(int i = 0, jn = n.node.getLinkCount(); i < jn; i++) {
        Link link = n.node.getLink(i);
        MapNode n2 = addMapNode(link.node);
        double vx = n2.x - n.x;
        double vy = n2.y - n.y;
        double dist = Math.sqrt(vx * vx + vy * vy);
        dist = dist == 0 ? 0.00001 : dist;
        double etx = link.getETX() * etxFactor;
        if (etx > 5) etx = 5;
        double factor = (etx * layoutAttract - dist) / (dist * 3);
        double dx = factor * vx;
        double dy = factor * vy;

 
View Full Code Here

TOP

Related Classes of se.sics.contiki.collect.Link

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.