controller

Class MouseListener

    • Constructor Detail

      • MouseListener

        public MouseListener(OceanInterface model,
                     OceanGUIInterface view)
        Instantiates a new mouse listener.
        Parameters:
        model - the OceanInterface that describes the ocean we work with
        view - the OceanGUIInterface that describes the GUI we work with
    • Method Detail

      • clickAddAndSetPosition

        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.
        Parameters:
        cP - the clicked position
      • createOcenObjectName

        private void createOcenObjectName(java.lang.String type)
        Creates the oceanobject's name.
        Parameters:
        type - An OceanObject type like: Shark, Fish
      • getObjectFromClickPosition

        private OceanObject getObjectFromClickPosition(java.awt.Point cP)
        Gets the object from click position.
        Parameters:
        cP - clicked Position
        Returns:
        the clicked object, or null.
      • mouseClicked

        public void mouseClicked(java.awt.event.MouseEvent e)
        This method gets an MouseEvent e an executes the specific code.
        Specified by:
        mouseClicked in interface java.awt.event.MouseListener
        Parameters:
        e - the generated mouse event
      • mouseDragged

        public void mouseDragged(java.awt.event.MouseEvent arg0)
        Specified by:
        mouseDragged in interface java.awt.event.MouseMotionListener
      • mouseEntered

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

        public void mouseExited(java.awt.event.MouseEvent arg0)
        Specified by:
        mouseExited in interface java.awt.event.MouseListener
      • mouseMoved

        public void mouseMoved(java.awt.event.MouseEvent arg0)
        Specified by:
        mouseMoved in interface java.awt.event.MouseMotionListener
      • mousePressed

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

        public void mouseReleased(java.awt.event.MouseEvent arg0)
        Specified by:
        mouseReleased in interface java.awt.event.MouseListener
      • mouseWheelMoved

        public void mouseWheelMoved(java.awt.event.MouseWheelEvent e)
        This method speeds up or slows down the ocean's movement.
        Specified by:
        mouseWheelMoved in interface java.awt.event.MouseWheelListener
        Parameters:
        e - the MouseWheelEvent that occurs when the wheel is turned
      • setAllFieldsRandom

        private void setAllFieldsRandom(java.awt.event.MouseEvent e)
        Set all fields (name, maximumAge, x/y-value) random.
        Parameters:
        e - the MouseEvent
      • tagAndSetFields

        private void tagAndSetFields(java.awt.event.MouseEvent e,
                           java.awt.Point cP)
        Tag the object and set the x/y-value-fields (left-Button)
        Parameters:
        e - MouseEvent
        cP - clicked Position.