adams.gui.visualization.instance
Class InstancePointHitDetector

java.lang.Object
  extended by adams.core.ConsoleObject
      extended by adams.gui.visualization.core.plot.AbstractHitDetector
          extended by adams.gui.visualization.core.plot.AbstractDistanceBasedHitDetector
              extended by adams.gui.visualization.instance.InstancePointHitDetector
All Implemented Interfaces:
CleanUpHandler, SizeOfHandler, Serializable

public class InstancePointHitDetector
extends AbstractDistanceBasedHitDetector

Detects selections of instance points in the instance panel.

Version:
$Revision: 4584 $
Author:
fracpete (fracpete at waikato dot ac dot nz)
See Also:
Serialized Form

Field Summary
protected  InstancePanel m_Owner
          the owner of this detector.
 
Fields inherited from class adams.gui.visualization.core.plot.AbstractDistanceBasedHitDetector
m_MinimumPixelDifference
 
Fields inherited from class adams.gui.visualization.core.plot.AbstractHitDetector
m_Debug, m_Enabled
 
Constructor Summary
InstancePointHitDetector(InstancePanel owner)
          Initializes the hit detector.
 
Method Summary
 void cleanUp()
          Cleans up data structures, frees up memory.
protected  int findClosestAttributeIndex(Instance inst, double x)
          Returns the closest attribute index for the given x.
protected  int[] findEnclosingAttributeIndices(Instance inst, double x)
          Determines the enclosing attribute indices for the given x value.
protected  InstancePoint findInstancePoint(Instance inst, int index)
          Returns the Instance point at the specified position.
 InstancePanel getOwner()
          Returns the owner.
protected  Object isHit(MouseEvent e)
          Checks for a hit.
protected  Object processHit(MouseEvent e, Object hit)
          Performs the action when a hit is detected.
 
Methods inherited from class adams.gui.visualization.core.plot.AbstractDistanceBasedHitDetector
distance, getMinimumPixelDifference, setMinimumPixelDifference
 
Methods inherited from class adams.gui.visualization.core.plot.AbstractHitDetector
detect, getDebug, isEnabled, setDebug, setEnabled
 
Methods inherited from class adams.core.ConsoleObject
getDebugging, getSystemErr, getSystemOut, sizeOf
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

m_Owner

protected InstancePanel m_Owner
the owner of this detector.

Constructor Detail

InstancePointHitDetector

public InstancePointHitDetector(InstancePanel owner)
Initializes the hit detector.

Parameters:
owner - the panel that uses this detector
Method Detail

getOwner

public InstancePanel getOwner()
Returns the owner.

Returns:
the owning panel

findEnclosingAttributeIndices

protected int[] findEnclosingAttributeIndices(Instance inst,
                                              double x)
Determines the enclosing attribute indices for the given x value. If the given x happens to be an exact point, then this points will be stored at index 0. If no index could be determined, then -1 will be stored.

Parameters:
inst - the underlying instance
x - the x on the plot
Returns:
the indices

findClosestAttributeIndex

protected int findClosestAttributeIndex(Instance inst,
                                        double x)
Returns the closest attribute index for the given x.

Parameters:
inst - the underlying Instance
x - the x to get the index for
Returns:
the index

findInstancePoint

protected InstancePoint findInstancePoint(Instance inst,
                                          int index)
Returns the Instance point at the specified position.

Parameters:
inst - the Instance data structure to search
index - the attribute index (original dataset)
Returns:
the InstancePoint, null if not found

isHit

protected Object isHit(MouseEvent e)
Checks for a hit.

For calculating distance between point and line, see here

Specified by:
isHit in class AbstractHitDetector
Parameters:
e - the MouseEvent (for coordinates)
Returns:
the associated object with the hit, otherwise null

processHit

protected Object processHit(MouseEvent e,
                            Object hit)
Performs the action when a hit is detected.

Specified by:
processHit in class AbstractHitDetector
Parameters:
e - the MouseEvent (for coordinates)
hit - the object that got determined by the hit
Returns:
the generated appendix for the tiptext

cleanUp

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

Specified by:
cleanUp in interface CleanUpHandler
Overrides:
cleanUp in class AbstractHitDetector


Copyright © 2012 University of Waikato, Hamilton, NZ. All Rights Reserved.