예제 #1
0
  public void updateLayouts(float Azi, float zAngle, Location l) {
    /*
    if(l.hasAccuracy()) this.gpsIcon.disconnect();
    else gpsIcon.update(l.getAccuracy());
    */
    if (Azi != -1) {
      // Process the accelerometor stuff
      // Manages mobile orientation
      float leftArm = Azi - (xAngleWidth / 2);
      float rightArm = Azi + (xAngleWidth / 2);
      if (leftArm < 0) leftArm = leftArm + 360;
      if (rightArm > 360) rightArm = rightArm - 360;

      if (this.curLeftArm == -1) this.curLeftArm = leftArm;
      if (this.curRightArm == -1) this.curRightArm = rightArm;

      if (!(aChanger(curLeftArm, leftArm, (float) 0.05))) leftArm = this.curLeftArm;
      else this.curLeftArm = leftArm;
      if (!(aChanger(this.curRightArm, rightArm, (float) 0.05))) rightArm = this.curRightArm;
      else this.curRightArm = rightArm;

      if (leftArm < 0) leftArm = leftArm + 360;
      if (rightArm > 360) rightArm = rightArm - 360;

      // gere l'orientation du mobile en hauteur
      float upperArm = zAngle + (yAngleWidth / 2);
      float lowerArm = zAngle - (yAngleWidth / 2);

      if (this.curUpperArm == -1) this.curUpperArm = upperArm;
      if (this.curLowerArm == -1) this.curLowerArm = lowerArm;

      if (!(aChanger(this.curUpperArm, upperArm, (float) 0.05))) upperArm = this.curUpperArm;
      else this.curUpperArm = upperArm;
      if (!(aChanger(this.curLowerArm, lowerArm, (float) 0.05))) lowerArm = this.curLowerArm;
      else this.curLowerArm = lowerArm;

      Enumeration<ARSphericalView> e = getArViews().elements();

      if (getArViews().size() == 0) return;

      while (e.hasMoreElements()) {
        // If we have a location, and the view has one, update it's data
        try {
          ARSphericalView view = e.nextElement();
          // ------------
          if (view.isVisible()) {

            if (l != null && view.getLocation() != null) {
              float old_azi = view.getAzimuth();
              float old_incli = view.getInclination();
              float new_incli;
              if (aChanger(old_azi, l.bearingTo(view.getLocation()), (float) 0.05)) {
                view.setAzimuth((l.bearingTo(view.getLocation())) - 90);
              }
              if (view.getAzimuth() < 0) view.setAzimuth(360 + view.getAzimuth());
              if (l.hasAltitude() && view.getLocation().hasAltitude()) {
                new_incli =
                    (float)
                        Math.atan(
                            ((view.getLocation().getAltitude() - l.getAltitude())
                                / l.distanceTo(view.getLocation())));
                if (aChanger(old_incli, new_incli, (float) 0.05)) view.setInclination(new_incli);
              }
            }
          }

          //				if(!isVisibleX(leftArm, rightArm, view.azimuth))
          //				{
          //					view.visible = false;
          //					continue;
          //				}
          //				if(!isVisibleY(lowerArm, upperArm, view.inclination))
          //				{
          //					view.visible = false;
          //						continue;
          //				}
          //					view.setVisible(true);
          int tmp_x = (int) calcXvalue(leftArm, rightArm, view.getAzimuth());
          int tmp_y = (int) calcYvalue(lowerArm, upperArm, view.getInclination());

          if (view instanceof MagnitudePOI) {
            view.layout(
                (int) (((MagnitudePOI) view).getShiftX() + tmp_x),
                (int) (((MagnitudePOI) view).getShiftY() + tmp_y),
                (int)
                    ((((MagnitudePOI) view).getShiftX())
                        + tmp_x
                        + ((MagnitudePOI) view).getViewWidth()),
                (int)
                    (((MagnitudePOI) view).getShiftY()
                        + tmp_y
                        + ((MagnitudePOI) view).getViewHeight()));
          } else view.layout(tmp_x, tmp_y, tmp_x, tmp_y);
        } catch (Exception x) {
          Log.e("ArLayout", x.getMessage());
        }
      }
    }
    // 37.763557,-122.410719
  }
예제 #2
0
  @Override
  public void onDraw(Canvas c) {
    // Log.e("Spec","Updating "+arViews.size()+" views");
    // long time = System.currentTimeMillis();
    Enumeration<ARSphericalView> e = getArViews().elements();
    Enumeration<ARSphericalView> e2 = getArViews().elements();
    Paint p = new Paint();
    float precision = 10000;

    if (DEBUG) {
      p.setColor(Color.WHITE);

      c.drawText(
          "Compass:"******"Inclination" + String.valueOf(Math.round(getInclination() * precision) / precision),
          150,
          20,
          p);
      // ---------------------------------
      ARSphericalView view;
      if (e2.hasMoreElements()) {
        view = e2.nextElement();
        c.drawText("POI1: " + view.isVisible(), 20, 80, p);
      }
      if (e2.hasMoreElements()) {
        view = e2.nextElement();
        c.drawText("POI2: " + view.isVisible(), 20, 100, p);
      }
      if (e2.hasMoreElements()) {
        view = e2.nextElement();
        c.drawText("POI3: " + view.isVisible(), 20, 120, p);
      }
      // ------------------
      if (getCurLocation() != null) {
        c.drawText("Lat : " + String.valueOf(getCurLocation().getLatitude()), 20, 60, p);
        c.drawText("Long : " + String.valueOf(getCurLocation().getLongitude()), 250, 60, p);
      }
    }
    while (e.hasMoreElements()) {
      MagnitudePOI view = (MagnitudePOI) e.nextElement();

      if (view.getAzimuth() < 330 && view.getAzimuth() > 30) {
        if (Math.abs(view.getAzimuth() - direction) < 30) {
          view.drawLine(c);
        }
      } else {
        view.drawLine(c);
      }
    }
    e = getArViews().elements();
    while (e.hasMoreElements()) {
      MagnitudePOI view = (MagnitudePOI) e.nextElement();

      if (view.getAzimuth() < 330 && view.getAzimuth() > 30) {
        if (Math.abs(view.getAzimuth() - direction) < 30) {
          view.setVisible(true);
          view.draw(c);
        } else {
          view.setVisible(false);
        }
      } else {
        view.setVisible(true);
        view.draw(c);
      }
    }

    if (TITLEBAR) titleBar.draw(c);
    if (RADAR) radar.draw(c);
    if (SCROLL) rightSlide.draw(c);
    if (GPS) gpsIcon.draw(c);
    if (poiMove) poiReinit.draw(c);
    if (SPLASH && gpsIcon.getGpsStatus() == GpsIndicator.GPS_STATUS_DISCONNECTED) splash.draw(c);
  }