/**
  * Get the current position and scale of the selected image. Called whenever a drag starts or is
  * reset.
  */
 public void getPositionAndScale(Img img, PositionAndScale objPosAndScaleOut) {
   // FIXME affine-izem (and fix the fact that the anisotropic_scale part requires averaging the
   // two scale factors)
   objPosAndScaleOut.set(
       img.getCenterX(),
       img.getCenterY(),
       (mUIMode & UI_MODE_ANISOTROPIC_SCALE) == 0,
       (img.getScaleX() + img.getScaleY()) / 2,
       (mUIMode & UI_MODE_ANISOTROPIC_SCALE) != 0,
       img.getScaleX(),
       img.getScaleY(),
       (mUIMode & UI_MODE_ROTATE) != 0,
       img.getAngle());
 }
예제 #2
0
  /*----------------------getPositionAndScale--------------------------------------------------------------------*/
  public void getPositionAndScale(KiwiGLSurfaceView obj, PositionAndScale pos) {

    float xOff = 0.0f;
    float yOff = 0.0f;
    float scale = 1.0f;
    float scaleX = 1.0f;
    float scaleY = 1.0f;
    float angle = 0.0f;
    boolean updateScale = true;
    boolean updateAngle = true;
    boolean updateScaleXY = false;

    Log.d(TAG, "getPositionAndScale");

    pos.set(xOff, yOff, updateScale, scale, updateScaleXY, scaleX, scaleY, updateAngle, angle);

    this.mLastTouchInfo = null;
  }
 /** Set the position and scale of an image in screen coordinates */
 public boolean setPos(PositionAndScale newImgPosAndScale) {
   return setPos(
       newImgPosAndScale.getXOff(),
       newImgPosAndScale.getYOff(),
       (mUIMode & UI_MODE_ANISOTROPIC_SCALE) != 0
           ? newImgPosAndScale.getScaleX()
           : newImgPosAndScale.getScale(),
       (mUIMode & UI_MODE_ANISOTROPIC_SCALE) != 0
           ? newImgPosAndScale.getScaleY()
           : newImgPosAndScale.getScale(),
       newImgPosAndScale.getAngle());
   // FIXME: anisotropic scaling jumps when axis-snapping
   // FIXME: affine-ize
   // return setPos(newImgPosAndScale.getXOff(), newImgPosAndScale.getYOff(),
   // newImgPosAndScale.getScaleAnisotropicX(),
   // newImgPosAndScale.getScaleAnisotropicY(), 0.0f);
 }
예제 #4
0
  /* (non-Javadoc)
   * @see com.ds.avare.MultiTouchController.MultiTouchObjectCanvas#setPositionAndScale(java.lang.Object, com.ds.avare.MultiTouchController.PositionAndScale, com.ds.avare.MultiTouchController.PointInfo)
   */
  public boolean setPositionAndScale(
      Object obj, PositionAndScale newObjPosAndScale, PointInfo touchPoint) {
    touchPointChanged(touchPoint);
    if (false == mCurrTouchPoint.isMultiTouch()) {

      /*
       * Do not move on drag
       */
      if (mDragPlanPoint >= 0) {
        return true;
      }

      /*
       * Do not move on multitouch
       */
      if (mDraw && mService != null) {
        float x = mCurrTouchPoint.getX() * mScale.getScaleFactor();
        float y = mCurrTouchPoint.getY() * mScale.getScaleFactor();
        /*
         * Threshold the drawing so we do not generate too many points
         */
        if (mPref.isTrackUp()) {
          double thetab = mGpsParams.getBearing();
          double p[] = new double[2];
          double c_x = mOrigin.getOffsetX(mGpsParams.getLongitude());
          double c_y = mOrigin.getOffsetY(mGpsParams.getLatitude());
          p = Helper.rotateCoord(c_x, c_y, thetab, x, y);
          mService.getDraw().addPoint((float) p[0], (float) p[1], mOrigin);
        } else {
          mService.getDraw().addPoint(x, y, mOrigin);
        }
        return true;
      }

      // Pan
      if (mPan.setMove(newObjPosAndScale.getXOff(), newObjPosAndScale.getYOff())) {
        /*
         * Query when we have moved one tile. This will happen in background.
         */
        loadTiles();
      }
    } else {

      // Zooming does not change drag
      mDragPlanPoint = -1;

      /*
       * on double touch find distance and bearing between two points.
       */

      if (mPointProjection == null) {
        double x0 = mCurrTouchPoint.getXs()[0];
        double y0 = mCurrTouchPoint.getYs()[0];
        double x1 = mCurrTouchPoint.getXs()[1];
        double y1 = mCurrTouchPoint.getYs()[1];

        double lon0, lat0, lon1, lat1;
        // convert to origin coord if Trackup
        if (mPref.isTrackUp()) {
          double c_x = mOrigin.getOffsetX(mGpsParams.getLongitude());
          double c_y = mOrigin.getOffsetY(mGpsParams.getLatitude());
          double thetab = mGpsParams.getBearing();
          double p0[], p1[];
          p0 = Helper.rotateCoord(c_x, c_y, thetab, x0, y0);
          p1 = Helper.rotateCoord(c_x, c_y, thetab, x1, y1);
          lon0 = mOrigin.getLongitudeOf(p0[0]);
          lat0 = mOrigin.getLatitudeOf(p0[1]);
          lon1 = mOrigin.getLongitudeOf(p1[0]);
          lat1 = mOrigin.getLatitudeOf(p1[1]);
        } else {
          lon0 = mOrigin.getLongitudeOf(x0);
          lat0 = mOrigin.getLatitudeOf(y0);
          lon1 = mOrigin.getLongitudeOf(x1);
          lat1 = mOrigin.getLatitudeOf(y1);
        }
        mPointProjection = new Projection(lon0, lat0, lon1, lat1);
      }

      /*
       * Clamp scaling.
       */

      mScale.setScaleFactor(newObjPosAndScale.getScale());
    }
    updateCoordinates();
    invalidate();
    return true;
  }
예제 #5
0
 /* (non-Javadoc)
  * @see com.ds.avare.MultiTouchController.MultiTouchObjectCanvas#getPositionAndScale(java.lang.Object, com.ds.avare.MultiTouchController.PositionAndScale)
  */
 public void getPositionAndScale(Object obj, PositionAndScale objPosAndScaleOut) {
   objPosAndScaleOut.set(
       mPan.getMoveX(), mPan.getMoveY(), true, mScale.getScaleFactorRaw(), false, 0, 0, false, 0);
 }