Пример #1
0
  private void handleReleaseView(Point point) {
    assert point != null;
    assert mouseLast != null;
    assert Game.hasInstance();
    assert !Game.getInstance().isPaused();

    final int dx = point.x - mouseLast.x;
    final int dy = point.y - mouseLast.y;
    final GameView view = GameView.getInstance();
    if (view.hasActiveTile()) {
      assert !dragBoard;
      deactivateOnRelease = view.dropActiveTile(point, deactivateOnRelease);
      repaint();

    } else if (dragBoard) {
      view.translate(dx, dy);
      dragBoardPixelCount += Math.abs(dx) + Math.abs(dy);

      if (dragBoardPixelCount < DRAG_THRESHOLD) {
        /*
         * Board drags shorter than six pixels (clicks, basically)
         * also serve to alter or un-target the target cell.
         */
        view.toggleTargetCell(point);
      }

      // done dragging the board
      dragBoard = false;
      setCursor(Cursor.getDefaultCursor());
      repaint();
    }
  }