public class MouseListener extends Listener implements java.awt.event.MouseWheelListener, javax.swing.event.MouseInputListener
addMouseListener method. When
the mouse event occurs, that object's appropriate
method is invoked.
MouseEvent
Listener.EmptyStringException
Constructor and Description |
---|
MouseListener(OceanInterface model,
OceanGUIInterface view)
Instantiates a new mouse listener.
|
Modifier and Type | Method and Description |
---|---|
private void |
clickAddAndSetPosition(java.awt.Point cP)
Automatically put the coordinates of the mouse click into the x and y
position input fields and click the add button.
|
private void |
createOcenObjectName(java.lang.String type)
Creates the oceanobject's name.
|
private OceanObject |
getObjectFromClickPosition(java.awt.Point cP)
Gets the object from click position.
|
void |
mouseClicked(java.awt.event.MouseEvent e)
This method gets an MouseEvent e an executes the specific code.
|
void |
mouseDragged(java.awt.event.MouseEvent arg0) |
void |
mouseEntered(java.awt.event.MouseEvent arg0) |
void |
mouseExited(java.awt.event.MouseEvent arg0) |
void |
mouseMoved(java.awt.event.MouseEvent arg0) |
void |
mousePressed(java.awt.event.MouseEvent arg0) |
void |
mouseReleased(java.awt.event.MouseEvent arg0) |
void |
mouseWheelMoved(java.awt.event.MouseWheelEvent e)
This method speeds up or slows down the ocean's movement.
|
private void |
setAllFieldsRandom(java.awt.event.MouseEvent e)
Set all fields (name, maximumAge, x/y-value) random.
|
private void |
tagAndSetFields(java.awt.event.MouseEvent e,
java.awt.Point cP)
Tag the object and set the x/y-value-fields (left-Button)
|
getMyOcean, getMyOceanGUI, message, repaintOcean, setMyModel, setMyView, sleep, updateGUI, updateStatusPanel
public MouseListener(OceanInterface model, OceanGUIInterface view)
model
- the OceanInterface that describes the ocean we work withview
- the OceanGUIInterface that describes the GUI we work withprivate void clickAddAndSetPosition(java.awt.Point cP)
cP
- the clicked positionprivate void createOcenObjectName(java.lang.String type)
type
- An OceanObject type like: Shark, Fishprivate OceanObject getObjectFromClickPosition(java.awt.Point cP)
cP
- clicked Positionpublic void mouseClicked(java.awt.event.MouseEvent e)
mouseClicked
in interface java.awt.event.MouseListener
e
- the generated mouse eventpublic void mouseDragged(java.awt.event.MouseEvent arg0)
mouseDragged
in interface java.awt.event.MouseMotionListener
public void mouseEntered(java.awt.event.MouseEvent arg0)
mouseEntered
in interface java.awt.event.MouseListener
public void mouseExited(java.awt.event.MouseEvent arg0)
mouseExited
in interface java.awt.event.MouseListener
public void mouseMoved(java.awt.event.MouseEvent arg0)
mouseMoved
in interface java.awt.event.MouseMotionListener
public void mousePressed(java.awt.event.MouseEvent arg0)
mousePressed
in interface java.awt.event.MouseListener
public void mouseReleased(java.awt.event.MouseEvent arg0)
mouseReleased
in interface java.awt.event.MouseListener
public void mouseWheelMoved(java.awt.event.MouseWheelEvent e)
mouseWheelMoved
in interface java.awt.event.MouseWheelListener
e
- the MouseWheelEvent that occurs when the wheel is turnedprivate void setAllFieldsRandom(java.awt.event.MouseEvent e)
e
- the MouseEventprivate void tagAndSetFields(java.awt.event.MouseEvent e, java.awt.Point cP)
e
- MouseEventcP
- clicked Position.