public boolean mouseDrag(Event e, int x, int y) { if ((rubberBand == true) && (drawArea.inside(x, y))) { endX = x; endY = y; } // tracks mouse's movement else if (drawArea.inside(x, y)) { oldX = newX; oldY = newY; newX = x; newY = y; } repaint(); return true; }
public boolean mouseDown(Event e, int x, int y) { // defines when something is clicked to not draw in last coordinates first = true; // checks if mouse is clicked inside one of the buttons if (black.inside(x, y)) numColor = 1; else if (red.inside(x, y)) numColor = 2; else if (blue.inside(x, y)) numColor = 3; else if (green.inside(x, y)) numColor = 4; else if (yellow.inside(x, y)) numColor = 5; else if (gray.inside(x, y)) numColor = 6; else if (magenta.inside(x, y)) numColor = 7; else if (cyan.inside(x, y)) numColor = 8; else if (orange.inside(x, y)) numColor = 9; else if (pink.inside(x, y)) numColor = 10; else if (eraser.inside(x, y)) { numColor = 11; numSize = 6; rubberBand = false; size = 1; } else if (clear.inside(x, y)) { numDraw = 1; } else if (pen.inside(x, y)) { if (numColor == 11) numColor = 1; numSize = 1; rubberBand = false; } else if (brush.inside(x, y)) { if (numColor == 11) numColor = 1; numSize = 2; rubberBand = false; } else if (roller.inside(x, y)) { if (numColor == 11) numColor = 1; numSize = 3; rubberBand = false; } else if (spray.inside(x, y)) { if (numColor == 11) numColor = 1; numSize = 4; rubberBand = false; size = 1; } else if (band.inside(x, y)) { if (numColor == 11) numColor = 1; numSize = 5; rubberBand = true; } else if (small.inside(x, y)) size = 1; else if (medium.inside(x, y)) size = 2; else if (large.inside(x, y)) size = 3; else if (drawArea.inside(x, y)) // default to drawing when a button isn't clicked { newX = x; newY = y; oldX = newX; oldY = newY; first = false; } if (rubberBand == true) { startX = x; startY = y; endX = x; endY = y; } repaint(); return true; }