Class AbstractHitDetector<H,​P>

    • Field Detail

      • m_Debug

        protected boolean m_Debug
        whether debug mode is on.
      • m_Enabled

        protected boolean m_Enabled
        whether the detector is enabled.
    • Constructor Detail

      • AbstractHitDetector

        public AbstractHitDetector()
        Initializes the detector.
    • Method Detail

      • setDebug

        public void setDebug​(boolean value)
        Turns the debug mode on or off.
        Specified by:
        setDebug in interface HitDetector<H,​P>
        Parameters:
        value - if true then the debug mode is turned on
      • getDebug

        public boolean getDebug()
        Returns whether debug mode is on or not.
        Specified by:
        getDebug in interface HitDetector<H,​P>
        Returns:
        true if debug mode is on
      • setEnabled

        public void setEnabled​(boolean value)
        Sets whether the detector is enabled or not.
        Specified by:
        setEnabled in interface HitDetector<H,​P>
        Parameters:
        value - if true then the detector is enabled
      • isEnabled

        public boolean isEnabled()
        Returns whether the detector is currently enabled.
        Specified by:
        isEnabled in interface HitDetector<H,​P>
        Returns:
        true if the detector is enabled.
      • isHit

        protected abstract H isHit​(MouseEvent e)
        Checks for a hit.
        Parameters:
        e - the MouseEvent (for coordinates)
        Returns:
        the associated object with the hit, otherwise null
      • processHit

        protected abstract P processHit​(MouseEvent e,
                                        H hit)
        Performs the action when a hit is detected.
        Parameters:
        e - the MouseEvent (for coordinates)
        hit - the object that got determined by the hit
        Returns:
        optional result of processing the event
      • detect

        public P detect​(MouseEvent e)
        Detects hits and processes them.
        Specified by:
        detect in interface HitDetector<H,​P>
        Parameters:
        e - the mouse event to analyze for a hit
        Returns:
        optional result of processing the event
      • locate

        public H locate​(MouseEvent e)
        Detects hits and returns them without processing them.
        Specified by:
        locate in interface HitDetector<H,​P>
        Parameters:
        e - the mouse event to analyze for a hit
        Returns:
        the hits if any, null otherwise
      • cleanUp

        public void cleanUp()
        Cleans up data structures, frees up memory.

        Default implementation does nothing.
        Specified by:
        cleanUp in interface CleanUpHandler