@Override public void onReleased(Point pos) { FilledRectDrawCommand rect = new FilledRectDrawCommand(startPos, pos, startPosPixel, clear, canvasController); rect.execute(); canvasController.pushNewHistory(rect); }
@Override public void onDragged(Point pos) { int x, y; Point lt = new Point(Math.min(startPos.x, pos.x), Math.min(startPos.y, pos.y)); Point rb = new Point(Math.max(startPos.x, pos.x), Math.max(startPos.y, pos.y)); canvasController.showOptionPos(" -> " + (rb.x - lt.x + 1) + "*" + (rb.y - lt.y + 1)); for (x = lt.x, y = lt.y; x <= rb.x; x++) canvasController.drawPreview(x, y, startPosPixel, clear); if (!(lt.y == rb.y)) { for (x = lt.x, y = rb.y; x <= rb.x; x++) canvasController.drawPreview(x, y, startPosPixel, clear); } for (x = lt.x, y = lt.y + 1; y < rb.y; y++) canvasController.drawPreview(x, y, startPosPixel, clear); if (!(lt.x == rb.x)) { for (x = rb.x, y = lt.y + 1; y < rb.y; y++) canvasController.drawPreview(x, y, startPosPixel, clear); } }