/**
  * Finish a mouse drag operation. Nothing is done unless the current tool is a shape tool. For
  * shape tools, the user's shape is drawn to the off-screen canvas, making it a permanent part
  * of the picture, and then the repaint() method is called to show the modified picture on the
  * screen.
  */
 @Override
 public void mouseReleased(MouseEvent evt) {
   dragging = false;
   if (SHAPE_TOOLS.contains(currentTool)) {
     Graphics g = OSC.getGraphics();
     g.setColor(currentColor);
     putCurrentShape(g);
     g.dispose();
     repaint();
   }
 }
 /**
  * Continue a drag operation when the user drags the mouse. For the CURVE tool, a line is drawn
  * from the previous mouse position to the current mouse position in the off-screen canvas, and
  * the repaint() method is called for a rectangle that contains the line segment that was drawn.
  * For shape tools, the off-screen canvas is not changed, but the repaint() method is called so
  * that the paintComponent() method can redraw the picture with the user's shape in the new
  * position. For the SMUDGE and ERASE tools, the tool is applied along a line from the previous
  * mouse position to the current position;
  */
 @Override
 public void mouseDragged(MouseEvent evt) {
   currentX = evt.getX();
   currentY = evt.getY();
   if (currentTool == Tool.CURVE) {
     Graphics g = OSC.getGraphics();
     g.setColor(currentColor);
     g.drawLine(prevX, prevY, currentX, currentY);
     g.dispose();
     repaintRect(prevX, prevY, currentX, currentY);
   } else if (SHAPE_TOOLS.contains(currentTool)) {
     // Repaint the rectangles occupied by the previous position of
     // the shape and by its current position.
     repaintRect(startX, startY, prevX, prevY);
     repaintRect(startX, startY, currentX, currentY);
   } else {
     // Tool has to be ERASE or SMUDGE
     applyToolAlongLine(prevX, prevY, currentX, currentY);
   }
   prevX = currentX;
   prevY = currentY;
 }