private void paintMobileRobot(Graphics g) {

    paintDevice(g, model.getRobot().getPlatform());

    for (Device sensor : model.getRobot().getSensors()) {
      paintDevice(g, sensor);
    }
  }
 /** Invoked when an action occurs. */
 @Override
 public void actionPerformed(ActionEvent e) {
   if (e.getSource() instanceof Environment) {
     Environment model = (Environment) e.getSource();
     this.obstacles = model.getObstacles();
   }
   repaint();
 }
  private void paintDevice(Graphics g, Device d) {
    // reads the robot's current position

    model.getRobot().readPosition(d.getRobotPosition());
    Polygon currentShape = d.getShape();
    // draws the shape
    Polygon globalShape = new Polygon();
    Point2D point = new Point2D.Double();
    for (int i = 0; i < currentShape.npoints; i++) {
      point.setLocation(currentShape.xpoints[i], currentShape.ypoints[i]);
      // calculates the coordinates of the point according to the local position
      d.getLocalPosition().rotateAroundAxis(point);
      // calculates the coordinates of the point according to the robot position
      d.getRobotPosition().rotateAroundAxis(point);
      // adds the point to the global shape
      globalShape.addPoint((int) Math.round(point.getX()), (int) Math.round(point.getY()));
    }
    g.setColor(d.getBackgroundColor());
    g.fillPolygon(globalShape);
    g.setColor(d.getForegroundColor());
    g.drawPolygon(globalShape);
  }