Exemple #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
  }