Package Painting

Class MouseController

java.lang.Object
Painting.MouseController
All Implemented Interfaces:
java.awt.event.MouseListener, java.awt.event.MouseMotionListener, java.util.EventListener

public class MouseController
extends java.lang.Object
implements java.awt.event.MouseListener, java.awt.event.MouseMotionListener
controlls the mouse input and update the screen accordingly
  • Field Details

  • Constructor Details

    • MouseController

      public MouseController​(StackController sc, DrawingPanel panel)
      create a controller for the mouse actions
      Parameters:
      sc - the stack that the mouse controllers
      panel - the drawing pane that the mouse affects
  • Method Details

    • mouseClicked

      public void mouseClicked​(java.awt.event.MouseEvent e)
      Specified by:
      mouseClicked in interface java.awt.event.MouseListener
    • mousePressed

      public void mousePressed​(java.awt.event.MouseEvent e)
      Specified by:
      mousePressed in interface java.awt.event.MouseListener
    • mouseReleased

      public void mouseReleased​(java.awt.event.MouseEvent e)
      Specified by:
      mouseReleased in interface java.awt.event.MouseListener
    • mouseEntered

      public void mouseEntered​(java.awt.event.MouseEvent e)
      Specified by:
      mouseEntered in interface java.awt.event.MouseListener
    • mouseExited

      public void mouseExited​(java.awt.event.MouseEvent e)
      Specified by:
      mouseExited in interface java.awt.event.MouseListener
    • mouseDragged

      public void mouseDragged​(java.awt.event.MouseEvent e)
      Specified by:
      mouseDragged in interface java.awt.event.MouseMotionListener
    • mouseMoved

      public void mouseMoved​(java.awt.event.MouseEvent e)
      Specified by:
      mouseMoved in interface java.awt.event.MouseMotionListener
    • startAndStopDrawing

      private void startAndStopDrawing​(java.awt.event.MouseEvent e)
      if the mouse is pressed check if there is need to start or stop drawing the data.
      Parameters:
      e - the mouse event with the mouse point
    • drawingUpdate

      private void drawingUpdate​(java.awt.event.MouseEvent e)
      if the program is in the middle of drawing and there is mouse event then update the shape in the hand to the new data
      Parameters:
      e - the mouse event with the mouse point
    • paintHand

      public void paintHand​(java.awt.Graphics g)
      paint the content of the hand
      Parameters:
      g - the manager
    • toggleMode

      public static MouseController.MouseMode toggleMode()
      toggle the mode of the mouse between drag and click
    • getCurrentMode

      public static MouseController.MouseMode getCurrentMode()
      get the current mode the mouse is working in- click or drag
      Returns:
      a MouseMode