Package se.sics.cooja.interfaces

Examples of se.sics.cooja.interfaces.Position


      LED leds = mote.getInterfaces().getLED();
      if (leds == null) {
        continue;
      }

      Position pos = mote.getInterfaces().getPosition();
      Point pixel = visualizer.transformPositionToPixel(pos);

      int x = pixel.x - 2*Visualizer.MOTE_RADIUS;
     
      int y = pixel.y - Visualizer.MOTE_RADIUS;
View Full Code Here


      }
      if (msg == null) {
        continue;
      }

      Position pos = mote.getInterfaces().getPosition();
      Point pixel = visualizer.transformPositionToPixel(pos);

      int msgWidth = fm.stringWidth(msg);
      g.drawString(msg, pixel.x - msgWidth/2, pixel.y - Visualizer.MOTE_RADIUS);
    }
View Full Code Here

      String msg = getMoteString(mote);
      if (msg == null) {
        continue;
      }
     
      Position pos = mote.getInterfaces().getPosition();
      Point pixel = visualizer.transformPositionToPixel(pos);

      int msgWidth = fm.stringWidth(msg);
      g.drawString(msg, pixel.x - msgWidth/2, pixel.y + 2*Visualizer.MOTE_RADIUS + 3);
    }
View Full Code Here

        || selectedMote.getInterfaces().getRadio() == null) {
      return;
    }

    /* Paint transmission and interference range for selected mote */
    Position motePos = selectedMote.getInterfaces().getPosition();

    Point pixelCoord = visualizer.transformPositionToPixel(motePos);
    int x = pixelCoord.x;
    int y = pixelCoord.y;

    // Fetch current output power indicator (scale with as percent)
    Radio selectedRadio = selectedMote.getInterfaces().getRadio();
    double moteInterferenceRange =
      radioMedium.INTERFERENCE_RANGE
      * ((double) selectedRadio.getCurrentOutputPowerIndicator()
          / (double) selectedRadio.getOutputPowerIndicatorMax());
    double moteTransmissionRange =
      radioMedium.TRANSMITTING_RANGE
      * ((double) selectedRadio.getCurrentOutputPowerIndicator()
          / (double) selectedRadio.getOutputPowerIndicatorMax());

    Point translatedZero = visualizer.transformPositionToPixel(0.0, 0.0, 0.0);
    Point translatedInterference =
      visualizer.transformPositionToPixel(moteInterferenceRange, moteInterferenceRange, 0.0);
    Point translatedTransmission =
      visualizer.transformPositionToPixel(moteTransmissionRange, moteTransmissionRange, 0.0);
    Point translatedInterferenceMax =
      visualizer.transformPositionToPixel(radioMedium.INTERFERENCE_RANGE, radioMedium.INTERFERENCE_RANGE, 0.0);
    Point translatedTransmissionMax =
      visualizer.transformPositionToPixel(radioMedium.TRANSMITTING_RANGE, radioMedium.TRANSMITTING_RANGE, 0.0);

    translatedInterference.x = Math.abs(translatedInterference.x - translatedZero.x);
    translatedInterference.y = Math.abs(translatedInterference.y - translatedZero.y);
    translatedTransmission.x = Math.abs(translatedTransmission.x - translatedZero.x);
    translatedTransmission.y = Math.abs(translatedTransmission.y - translatedZero.y);
    translatedInterferenceMax.x = Math.abs(translatedInterferenceMax.x - translatedZero.x);
    translatedInterferenceMax.y = Math.abs(translatedInterferenceMax.y - translatedZero.y);
    translatedTransmissionMax.x = Math.abs(translatedTransmissionMax.x - translatedZero.x);
    translatedTransmissionMax.y = Math.abs(translatedTransmissionMax.y - translatedZero.y);

    /* Interference range */
    g.setColor(COLOR_INT);
    g.fillOval(
        x - translatedInterference.x,
        y - translatedInterference.y,
        2 * translatedInterference.x,
        2 * translatedInterference.y);

    /* Transmission range */
    g.setColor(COLOR_TX);
    g.fillOval(
        x - translatedTransmission.x,
        y - translatedTransmission.y,
        2 * translatedTransmission.x,
        2 * translatedTransmission.y);

    /* Interference range (MAX) */
    g.setColor(Color.GRAY);
    g.drawOval(
        x - translatedInterferenceMax.x,
        y - translatedInterferenceMax.y,
        2 * translatedInterferenceMax.x,
        2 * translatedInterferenceMax.y);

    /* Transmission range (MAX) */
    g.drawOval(
        x - translatedTransmissionMax.x,
        y - translatedTransmissionMax.y,
        2 * translatedTransmissionMax.x,
        2 * translatedTransmissionMax.y);


    FontMetrics fm = g.getFontMetrics();
    g.setColor(Color.BLACK);

    /* Print transmission success probabilities */
    for (Mote m: simulation.getMotes()) {
      if (m == selectedMote) {
        continue;
      }
      double prob =
        ((UDGM) simulation.getRadioMedium()).getSuccessProbability(selectedRadio, m.getInterfaces().getRadio());
      if (prob == 0.0d) {
        continue;
      }
      String msg = (((int)(1000*prob))/10.0) + "%";
      Position pos = m.getInterfaces().getPosition();
      Point pixel = visualizer.transformPositionToPixel(pos);
      int msgWidth = fm.stringWidth(msg);
      g.drawString(msg, pixel.x - msgWidth/2, pixel.y + 2*Visualizer.MOTE_RADIUS + 3);
    }

View Full Code Here

    g.setColor(Color.BLACK);

    /* Paint position coordinates right of motes */
    Mote[] allMotes = simulation.getMotes();
    for (Mote mote: allMotes) {
      Position pos = mote.getInterfaces().getPosition();
      Point pixel = visualizer.transformPositionToPixel(pos);

      String msg = "";
      String posString;
      String[] parts;

      /* X */
      posString = String.valueOf(pos.getXCoordinate()) + "000";
      parts = posString.split("\\.");
      if (parts[0].length() >= 4) {
        msg += parts[0];
      } else {
        msg += posString.substring(0, 5);
      }
     
      /* Y */
      msg += ", ";
      posString = String.valueOf(pos.getYCoordinate()) + "000";
      parts = posString.split("\\.");
      if (parts[0].length() >= 4) {
        msg += parts[0];
      } else {
        msg += posString.substring(0, 5);
      }

      /* Z */
      if (pos.getZCoordinate() != 0) {
        msg += ", ";
        posString = String.valueOf(pos.getZCoordinate()) + "000";
        parts = posString.split("\\.");
        if (parts[0].length() >= 4) {
          msg += parts[0];
        } else {
          msg += posString.substring(0, 5);
View Full Code Here

      String[] as = getAttributesStrings(mote);
      if (as == null) {
        continue;
      }
     
      Position pos = mote.getInterfaces().getPosition();
      Point pixel = visualizer.transformPositionToPixel(pos);

      int y = pixel.y + 2*Visualizer.MOTE_RADIUS + 3;
      for (String a: as) {
        if (a.startsWith("color=")) {
View Full Code Here

  }

  public void paintBeforeMotes(Graphics g) {

    /* Background grid every 10 meters */
    Position upperLeft =
      visualizer.transformPixelToPosition(-10, -10);
    upperLeft.setCoordinates(
        ((int)(upperLeft.getXCoordinate()/10))*10,
        ((int)(upperLeft.getYCoordinate()/10))*10,
        0);
    Position lowerRight =
      visualizer.transformPixelToPosition(visualizer.getWidth(), visualizer.getHeight());
    lowerRight.setCoordinates(
        ((int)(lowerRight.getXCoordinate()/10))*10,
        ((int)(lowerRight.getYCoordinate()/10))*10,
        0);

    if ((lowerRight.getXCoordinate() - upperLeft.getXCoordinate())/10.0 < 200 &&
        (lowerRight.getYCoordinate() - upperLeft.getYCoordinate())/10.0 < 200) {
      /* X axis */
      for (double x = upperLeft.getXCoordinate(); x <= lowerRight.getXCoordinate(); x += 10.0) {
        int pixel = visualizer.transformPositionToPixel(x, 0, 0).x;
        if (x % 100 == 0) {
          g.setColor(Color.GRAY);
        } else {
          g.setColor(Color.LIGHT_GRAY);
        }
        g.drawLine(
            pixel,
            0,
            pixel,
            visualizer.getHeight()
        );
      }
      /* Y axis */
      for (double y = upperLeft.getYCoordinate(); y <= lowerRight.getYCoordinate(); y += 10.0) {
        int pixel = visualizer.transformPositionToPixel(0, y, 0).y;
        if (y % 100 == 0) {
          g.setColor(Color.GRAY);
        } else {
          g.setColor(Color.LIGHT_GRAY);
View Full Code Here

    g.setColor(Color.BLACK);
   
    /* Paint ID inside each mote */
    Mote[] allMotes = simulation.getMotes();
    for (Mote mote: allMotes) {
      Position pos = mote.getInterfaces().getPosition();
      Point pixel = visualizer.transformPositionToPixel(pos);

      String msg = "" + mote.getID();
      int msgWidth = fm.stringWidth(msg);
      g.drawString(msg, pixel.x - msgWidth/2, pixel.y + 5);
View Full Code Here

      float colorHistoryIndex = (float)connArrow.getAge() / (float)connArrow.getMaxAge();
      g.setColor(new Color(colorHistoryIndex, colorHistoryIndex, 1.0f));
      Radio source = connArrow.getConnection().getSource();
      Point sourcePoint = visualizer.transformPositionToPixel(source.getPosition());
      for (Radio destRadio : connArrow.getConnection().getDestinations()) {
        Position destPos = destRadio.getPosition();
        Point destPoint = visualizer.transformPositionToPixel(destPos);
        drawArrow(g, sourcePoint.x, sourcePoint.y, destPoint.x, destPoint.y, 8);
      }
    }
  }
View Full Code Here

        || selectedMote.getInterfaces().getRadio() == null) {
      return;
    }

    /* Paint transmission and interference range for selected mote */
    Position motePos = selectedMote.getInterfaces().getPosition();

    Point pixelCoord = visualizer.transformPositionToPixel(motePos);
    int x = pixelCoord.x;
    int y = pixelCoord.y;
    Radio selectedRadio = selectedMote.getInterfaces().getRadio();

    FontMetrics fm = g.getFontMetrics();
    g.setColor(Color.BLACK);

    DirectedGraphMedium radioMedium = (DirectedGraphMedium) simulation.getRadioMedium();

    /* Print transmission success probabilities */
    DestinationRadio[] dests = radioMedium.getPotentialDestinations(selectedRadio);
    if (dests == null || dests.length == 0) {
      String msg = "No edges";
      int msgWidth = fm.stringWidth(msg);
      g.setColor(Color.BLACK);
      g.drawString(msg, x - msgWidth/2, y + 2*Visualizer.MOTE_RADIUS + 3);
      return;
    }
    String msg = dests.length + " edges";
    int msgWidth = fm.stringWidth(msg);
    g.setColor(Color.BLACK);
    g.drawString(msg, x - msgWidth/2, y + 2*Visualizer.MOTE_RADIUS + 3);
    for (DestinationRadio r: dests) {
      double prob = ((DGRMDestinationRadio)r).ratio;
      if (prob == 0.0d) {
        continue;
      }
      msg = String.format("%1.1f%%", 100.0*prob);
      Position pos = r.radio.getPosition();
      Point pixel = visualizer.transformPositionToPixel(pos);
      msgWidth = fm.stringWidth(msg);
      g.setColor(new Color(1-(float)prob, (float)prob, 0.0f));
      g.drawLine(x, y, pixel.x, pixel.y);
      g.setColor(Color.BLACK);
View Full Code Here

TOP

Related Classes of se.sics.cooja.interfaces.Position

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.