Example #1
0
  @Override
  public void keyPressed(KeyEvent evt) {
    Figure f = getOwner();
    if (f.isTransformable()) {
      AffineTransform tx = new AffineTransform();

      switch (evt.getKeyCode()) {
        case KeyEvent.VK_UP:
          tx.translate(0, -1);
          evt.consume();
          break;
        case KeyEvent.VK_DOWN:
          tx.translate(0, +1);
          evt.consume();
          break;
        case KeyEvent.VK_LEFT:
          tx.translate(-1, 0);
          evt.consume();
          break;
        case KeyEvent.VK_RIGHT:
          tx.translate(+1, 0);
          evt.consume();
          break;
      }
      f.willChange();
      f.transform(tx);
      f.changed();
      fireUndoableEditHappened(new TransformEdit(f, tx));
    }
  }
Example #2
0
  @Override
  public void trackStep(Point anchor, Point lead, int modifiersEx) {
    Figure f = getOwner();
    if (f.isTransformable()) {
      Point2D.Double newPoint = view.getConstrainer().constrainPoint(view.viewToDrawing(lead));
      AffineTransform tx = new AffineTransform();
      tx.translate(newPoint.x - oldPoint.x, newPoint.y - oldPoint.y);
      f.willChange();
      f.transform(tx);
      f.changed();

      oldPoint = newPoint;
    }
  }