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
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static classMouseController.MouseMode -
Field Summary
Fields Modifier and Type Field Description private static MouseController.MouseModecurrentModeprivate MyShapehandprivate DrawingPanelpanelprivate StackControllerstackController -
Constructor Summary
Constructors Constructor Description MouseController(StackController sc, DrawingPanel panel)create a controller for the mouse actions -
Method Summary
Modifier and Type Method Description private voiddrawingUpdate(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 datastatic MouseController.MouseModegetCurrentMode()get the current mode the mouse is working in- click or dragvoidmouseClicked(java.awt.event.MouseEvent e)voidmouseDragged(java.awt.event.MouseEvent e)voidmouseEntered(java.awt.event.MouseEvent e)voidmouseExited(java.awt.event.MouseEvent e)voidmouseMoved(java.awt.event.MouseEvent e)voidmousePressed(java.awt.event.MouseEvent e)voidmouseReleased(java.awt.event.MouseEvent e)voidpaintHand(java.awt.Graphics g)paint the content of the handprivate voidstartAndStopDrawing(java.awt.event.MouseEvent e)if the mouse is pressed check if there is need to start or stop drawing the data.static MouseController.MouseModetoggleMode()toggle the mode of the mouse between drag and click
-
Field Details
-
Constructor Details
-
MouseController
create a controller for the mouse actions- Parameters:
sc- the stack that the mouse controllerspanel- the drawing pane that the mouse affects
-
-
Method Details
-
mouseClicked
public void mouseClicked(java.awt.event.MouseEvent e)- Specified by:
mouseClickedin interfacejava.awt.event.MouseListener
-
mousePressed
public void mousePressed(java.awt.event.MouseEvent e)- Specified by:
mousePressedin interfacejava.awt.event.MouseListener
-
mouseReleased
public void mouseReleased(java.awt.event.MouseEvent e)- Specified by:
mouseReleasedin interfacejava.awt.event.MouseListener
-
mouseEntered
public void mouseEntered(java.awt.event.MouseEvent e)- Specified by:
mouseEnteredin interfacejava.awt.event.MouseListener
-
mouseExited
public void mouseExited(java.awt.event.MouseEvent e)- Specified by:
mouseExitedin interfacejava.awt.event.MouseListener
-
mouseDragged
public void mouseDragged(java.awt.event.MouseEvent e)- Specified by:
mouseDraggedin interfacejava.awt.event.MouseMotionListener
-
mouseMoved
public void mouseMoved(java.awt.event.MouseEvent e)- Specified by:
mouseMovedin interfacejava.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
toggle the mode of the mouse between drag and click -
getCurrentMode
get the current mode the mouse is working in- click or drag- Returns:
- a MouseMode
-