Exemple #1
0
  /**
   * Zoom in/out based on center of viewing rectangle!
   *
   * @param zov : zoom value (value based on current value.)
   */
  boolean zoom(float zov) {
    zov = _zov * zov;
    if (zov < WConstants.ZOOM_MIN_VALUE) zov = WConstants.ZOOM_MIN_VALUE;

    if (zov > WConstants.ZOOM_MAX_VALUE) zov = WConstants.ZOOM_MAX_VALUE;

    Rect r = _rectA;

    r.set(_rar);
    WUtil.expand(r, zov);

    if (r.width() > _sheet.width()) return false;
    else {
      _zov = zov;
      _ar.set(r);

      WUtil.adjust(_ar, _sheet.boundary());

      float rw = _ar.width() / 2.0f;
      float rh = _ar.height() / 2.0f;
      _rar.l = WUtil.roundOff(_ar.l + rw - rw / _zov);
      _rar.t = WUtil.roundOff(_ar.t + rh - rh / _zov);
      _rar.r = _rar.l + _sw;
      _rar.b = _rar.t + _sh;

      moveActiveRegionTo(this, _ar.l, _ar.t);

      return true;
    }
  }
Exemple #2
0
  void shift(int vx, int vy) {
    // TODO : sliding effect is not implemented yet
    int absx = (vx > 0) ? vx : -vx;
    int absy = (vy > 0) ? vy : -vy;
    int ox = _sw / 4;
    int oy = _sh / 4;
    int dx, dy;

    if (0 == vx) {
      dx = 0;
      dy = (vy > 0) ? oy : -oy;
    } else if (0 == vy) {
      dy = 0;
      dx = (vx > 0) ? ox : -ox;
    } else {
      if (absy * ox > oy * absx) {
        dx = absx * oy / absy;
        dx = (vx > 0) ? dx : -dx;
        dy = (vy > 0) ? oy : -oy;
      } else {
        dy = absy * ox / absx;
        dy = (vy > 0) ? dy : -dy;
        dx = (vx > 0) ? ox : -ox;
      }
    }

    Rect tmpR = _rectA;

    tmpR.set(_ar);
    tmpR.offset(_c2s(dx), _c2s(dy));
    WUtil.adjust(tmpR, _sheet.boundary());

    moveActiveRegionTo(this, tmpR.l, tmpR.t);
  }
Exemple #3
0
  void moveActiveRegion(Object trigger_owner, int dx, int dy) {
    Rect tmpR = _rectA;
    tmpR.set(_ar);
    tmpR.offset(_c2s(dx), _c2s(dy));
    WUtil.adjust(tmpR, _sheet.boundary());

    moveActiveRegionTo(this, tmpR.l, tmpR.t);
  }
Exemple #4
0
 private Rect _compensateThickness(Rect r, byte thick) {
   WUtil.expand(r, thick, thick);
   WUtil.adjust(r, _sheet.boundary());
   return r;
 }