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
  void moveActiveRegionTo(Object trigger_owner, int left, int top) {
    int dx = left - _ar.l;
    int dy = top - _ar.t;

    // we just re-calculate all!!!
    Rect tmpR = _rectA;
    // till now, we only consider "l, t" value.
    D2d.fill(_pixels, _sw, _sh, _bgcolor, 0, 0, _sw, _sh); // erase all.
    tmpR.set(left, top, _ar.r + dx, _ar.b + dy);
    _compensateThickness(tmpR, WConstants.LIMIT_THICK);
    _sheet.draw(_pixels, _sw, _sh, left, top, tmpR.l, tmpR.t, tmpR.r, tmpR.b, _zf());

    _ar.offset(dx, dy);
    _rar.offset(dx, dy);
    _platboard.invalidatePlatBoard();
    if (null != _activie_region_moved_listener)
      _activie_region_moved_listener.onMoved(
          trigger_owner,
          _ar.l / (float) _sheet.width(),
          _ar.t / (float) _sheet.height(),
          _ar.r / (float) _sheet.width(),
          _ar.b / (float) _sheet.height());
  }
Exemple #5
0
 void drawSheet(int left, int top, int right, int bottom) {
   getInvalidateArea(_tmpR, left, top, right, bottom, WConstants.LIMIT_THICK);
   _sheet.draw(
       _pixels,
       _sw,
       _sh,
       _ar.l,
       _ar.t,
       _ar.l + _c2s(_tmpR.l),
       _ar.t + _c2s(_tmpR.t),
       _ar.l + _c2s(_tmpR.r),
       _ar.t + _c2s(_tmpR.b),
       _zf());
 }
Exemple #6
0
  void updateCurve(LinkedList<G2d.Point> points, byte thick, int color) {
    if (!points.isEmpty()) {
      // Change from board coordinate to sheet coordinate
      ListIterator<G2d.Point> iter = points.listIterator();
      G2d.Point pt;
      while (iter.hasNext()) {
        pt = iter.next();
        pt.x = _c2s(pt.x) + _ar.l;
        pt.y = _c2s(pt.y) + _ar.t;
      }

      // TODO!!!! ---
      _sheet.addCurve(points, thick, color);
    }
  }
Exemple #7
0
 int sheetWidth() {
   return _sheet.width();
 }
Exemple #8
0
 void cutoutEnd() {
   _sheet.actionEnd();
 }
Exemple #9
0
 void cutoutSheet(int left, int top, int right, int bottom) {
   _sheet.cutout(_ar.l + _c2s(left), _ar.t + _c2s(top), _ar.l + _c2s(right), _ar.t + _c2s(bottom));
 }
Exemple #10
0
 int sheetHeight() {
   return _sheet.height();
 }
Exemple #11
0
 void saveSheet(String fpath) throws IOException {
   _sheet.save(fpath);
 }
Exemple #12
0
  void loadSheet(String fpath) throws IOException {
    if (null != _sheet) _sheet.destroy();

    _sheet = WSheet.createWSheet();
    _sheet.load(fpath);
  }
Exemple #13
0
 void undo() {
   _sheet.undo();
 }
Exemple #14
0
 void redo() {
   _sheet.redo();
 }
Exemple #15
0
 void destroy() {
   _sheet.destroy();
 }
Exemple #16
0
 void zmvEnd() {
   _sheet.actionEnd();
 }
Exemple #17
0
 // Draw active rectangle fully.
 void drawSheet() {
   _sheet.draw(_pixels, _sw, _sh, _ar.l, _ar.t, _ar.l, _ar.t, _ar.r, _ar.b, _zf());
 }
Exemple #18
0
 void cutoutStart() {
   _sheet.actionStart(WSheet.ACT_CUTOUT);
 }
Exemple #19
0
 void curveEnd() {
   _sheet.actionEnd();
 }
Exemple #20
0
 // action interfaces - Just Wrapper!!!
 void curveStart() {
   _sheet.actionStart(WSheet.ACT_CURVE);
 }
Exemple #21
0
  void createNew(int divW, int divH, int colN, int rowN) {
    if (null != _sheet) _sheet.destroy();

    _sheet = WSheet.createWSheet();
    _sheet.init(divW, divH, colN, rowN);
  }
Exemple #22
0
 void zmvStart() {
   _sheet.actionStart(WSheet.ACT_ZMV);
 }
Exemple #23
0
 private Rect _compensateThickness(Rect r, byte thick) {
   WUtil.expand(r, thick, thick);
   WUtil.adjust(r, _sheet.boundary());
   return r;
 }