Class AbstractHitDetector<H,P>
- java.lang.Object
-
- adams.core.logging.LoggingObject
-
- adams.core.logging.CustomLoggingLevelObject
-
- adams.core.option.AbstractOptionHandler
-
- adams.gui.visualization.core.plot.AbstractHitDetector<H,P>
-
- Type Parameters:
H
- type of hit resultsP
- type of processed hits
- All Implemented Interfaces:
CleanUpHandler
,Destroyable
,GlobalInfoSupporter
,LoggingLevelHandler
,LoggingSupporter
,OptionHandler
,SizeOfHandler
,HitDetector<H,P>
,Serializable
- Direct Known Subclasses:
AbstractDistanceBasedHitDetector
public abstract class AbstractHitDetector<H,P> extends AbstractOptionHandler implements HitDetector<H,P>, CleanUpHandler
Abstract ancestor for classes that detect hits in in the plot panel.- Author:
- fracpete (fracpete at waikato dot ac dot nz)
- See Also:
- Serialized Form
-
-
Field Summary
Fields Modifier and Type Field Description protected boolean
m_Debug
whether debug mode is on.protected boolean
m_Enabled
whether the detector is enabled.-
Fields inherited from class adams.core.option.AbstractOptionHandler
m_OptionManager
-
Fields inherited from class adams.core.logging.LoggingObject
m_Logger, m_LoggingIsEnabled, m_LoggingLevel
-
-
Constructor Summary
Constructors Constructor Description AbstractHitDetector()
Initializes the detector.
-
Method Summary
All Methods Instance Methods Abstract Methods Concrete Methods Modifier and Type Method Description void
cleanUp()
Cleans up data structures, frees up memory.P
detect(MouseEvent e)
Detects hits and processes them.boolean
getDebug()
Returns whether debug mode is on or not.boolean
isEnabled()
Returns whether the detector is currently enabled.protected abstract H
isHit(MouseEvent e)
Checks for a hit.H
locate(MouseEvent e)
Detects hits and returns them without processing them.protected abstract P
processHit(MouseEvent e, H hit)
Performs the action when a hit is detected.void
setDebug(boolean value)
Turns the debug mode on or off.void
setEnabled(boolean value)
Sets whether the detector is enabled or not.-
Methods inherited from class adams.core.option.AbstractOptionHandler
cleanUpOptions, defineOptions, destroy, finishInit, getDefaultLoggingLevel, getOptionManager, globalInfo, initialize, loggingLevelTipText, newOptionManager, reset, setLoggingLevel, toCommandLine, toString
-
Methods inherited from class adams.core.logging.LoggingObject
configureLogger, getLogger, getLoggingLevel, initializeLogging, isLoggingEnabled, sizeOf
-
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
-
Methods inherited from interface adams.core.logging.LoggingLevelHandler
getLoggingLevel
-
-
-
-
Method Detail
-
setDebug
public void setDebug(boolean value)
Turns the debug mode on or off.- Specified by:
setDebug
in interfaceHitDetector<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 interfaceHitDetector<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 interfaceHitDetector<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 interfaceHitDetector<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 interfaceHitDetector<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 interfaceHitDetector<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 interfaceCleanUpHandler
-
-