*
* @param mousePoint the Point where the mouse currently is.
*/
public void processMouseMove(Point mousePoint) {
EditStatus editStatus = application.getEditStatus();
PicturePanel picturePanel = application.getPicturePanel();
// Update the status line on every mouse movement.
editStatus.updateMousePoint(mousePoint);
int x = editStatus.getMouseX();
int y = editStatus.getMouseY();
if (editStatus.getNumOfClicks() > 0) {
// Make sure that the mouse cursor can't leave the picture while a line
// is being drawn.
Point clickPoint = editStatus.getClickPoint();
int clickX = (int) clickPoint.getX();
int clickY = (int) clickPoint.getY();
int lineColour = editStatus.getTemporaryLineColour();
if (editStatus.isLineActive()) {
picturePanel.drawTemporaryLine(clickX, clickY, x, y, lineColour);
}
if (editStatus.isStepActive()) {
int dX = 0;
int dY = 0;
switch (editStatus.getNumOfClicks()) {
case 1:
dX = x - clickX;
dY = y - clickY;
if (Math.abs(dX) > Math.abs(dY)) {
y = clickY;
} else {
x = clickX;
}
picturePanel.drawTemporaryLine(clickX, clickY, x, y, lineColour);
break;
default:
if ((editStatus.isXCornerActive() && ((editStatus.getNumOfClicks() % 2) == 0)) || (editStatus.isYCornerActive() && ((editStatus.getNumOfClicks() % 2) > 0))) {
// X and Y corners toggle different direction based on number of clicks.
x = clickX;
} else {
y = clickY;
}
picturePanel.drawTemporaryLine(clickX, clickY, x, y, lineColour);
break;
}
}
if (editStatus.isPenActive()) {
x = clickX + adjustForPen(x - clickX, 6);
y = clickY + adjustForPen(y - clickY, 7);
picturePanel.drawTemporaryLine(clickX, clickY, x, y, lineColour);
}
// Move the mouse to the tool restricted x/y position (if applicable).
if ((robot != null) && ((x != editStatus.getMouseX()) || (y != editStatus.getMouseY()))) {
// Make sure the EditStatus has the tool adjusted mouse point.