org.jactr.modules.pm.visual.memory.impl.encoder
Class AbstractVisualEncoder

java.lang.Object
  extended by org.jactr.modules.pm.visual.memory.impl.encoder.AbstractVisualEncoder
All Implemented Interfaces:
IPerceptualEncoder
Direct Known Subclasses:
BasicTextEncoder, CursorEncoder, EmptySpaceEncoder, GUIEncoder, LineEncoder

public abstract class AbstractVisualEncoder
extends java.lang.Object
implements IPerceptualEncoder

abstract base implementation of a visual chunk encoder. Extenders must implement canEncodeVisualObjectType(IAfferentObject) which tests to see if this encoder can encode that type of percept. If there is any actual content in the encoded chunk, updateSlots(IAfferentObject, IChunk, IVisualMemory), isDirty(IAfferentObject, IChunk, IPerceptualMemory), and isTooDirty(IAfferentObject, IChunk, IVisualMemory) should be extended as well. This implementation handles the creation of new chunks as well as updating if they are dirty.

Author:
harrison

Field Summary
 
Fields inherited from interface org.jactr.modules.pm.common.memory.IPerceptualEncoder
COMMONREALITY_IDENTIFIER_META_KEY
 
Constructor Summary
AbstractVisualEncoder(java.lang.String chunkTypeName)
           
 
Method Summary
 IChunk encode(org.commonreality.object.IAfferentObject afferentObject, IPerceptualMemory memory)
           
static boolean exceedsMovementTolerance(IChunk oldVisualLocation, IChunk newVisualLocation, IVisualMemory visualMemory)
          returns true if the visual locations are separated by more than IVisualMemory.getMovementTolerance(),
static double[] getLocation(IChunk visualLocation)
           
static IChunk getVisualLocation(org.commonreality.object.IAfferentObject afferentObject, IVisualMemory visualMemory)
          return the visual location (defined by IVisualPropertyHandler.RETINAL_LOCATION) of the object.
static IChunk getVisualLocation(IChunk visualChunk, IVisualMemory visualMemory)
          return the contents of screen-pos, but only if it is a visual-location chunk
 boolean isDirty(org.commonreality.object.IAfferentObject afferentObject, IChunk oldChunk, IPerceptualMemory memory)
          checks the expected visual location against the previously encoded visual location.
 boolean isInterestedIn(org.commonreality.object.IAfferentObject afferentObject)
          returns true if the percept has the IVisualPropertyHandler.IS_VISUAL property.
 IChunk update(org.commonreality.object.IAfferentObject afferentObject, IChunk oldChunk, IPerceptualMemory memory)
          called to update the encoding of a chunk.
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

AbstractVisualEncoder

public AbstractVisualEncoder(java.lang.String chunkTypeName)
Parameters:
chunkTypeName - name of the chunktype that is to be created
Method Detail

getVisualLocation

public static IChunk getVisualLocation(org.commonreality.object.IAfferentObject afferentObject,
                                       IVisualMemory visualMemory)
return the visual location (defined by IVisualPropertyHandler.RETINAL_LOCATION) of the object. If no location is defined, it is outside the visual field, or it is not visible, null is returned

Parameters:
afferentObject -
visualMemory -
Returns:

getVisualLocation

public static IChunk getVisualLocation(IChunk visualChunk,
                                       IVisualMemory visualMemory)
return the contents of screen-pos, but only if it is a visual-location chunk

Parameters:
visualChunk -
Returns:

isDirty

public boolean isDirty(org.commonreality.object.IAfferentObject afferentObject,
                       IChunk oldChunk,
                       IPerceptualMemory memory)
checks the expected visual location against the previously encoded visual location. The read lock will already have been acquired.

Specified by:
isDirty in interface IPerceptualEncoder
Parameters:
afferentObject -
oldChunk -
memory -
Returns:
See Also:
IPerceptualEncoder.isDirty(org.commonreality.object.IAfferentObject, org.jactr.core.chunk.IChunk, org.jactr.modules.pm.common.memory.IPerceptualMemory)

exceedsMovementTolerance

public static boolean exceedsMovementTolerance(IChunk oldVisualLocation,
                                               IChunk newVisualLocation,
                                               IVisualMemory visualMemory)
returns true if the visual locations are separated by more than IVisualMemory.getMovementTolerance(),

Parameters:
oldVisualLocation -
newVisualLocation -
visualMemory -
Returns:

getLocation

public static double[] getLocation(IChunk visualLocation)

isInterestedIn

public boolean isInterestedIn(org.commonreality.object.IAfferentObject afferentObject)
returns true if the percept has the IVisualPropertyHandler.IS_VISUAL property.

Specified by:
isInterestedIn in interface IPerceptualEncoder
Parameters:
afferentObject -
Returns:
See Also:
IPerceptualEncoder.isInterestedIn(org.commonreality.object.IAfferentObject)

encode

public IChunk encode(org.commonreality.object.IAfferentObject afferentObject,
                     IPerceptualMemory memory)
Specified by:
encode in interface IPerceptualEncoder
Returns:

update

public IChunk update(org.commonreality.object.IAfferentObject afferentObject,
                     IChunk oldChunk,
                     IPerceptualMemory memory)
called to update the encoding of a chunk. A new chunk may be returned if the encoding isTooDirty(IAfferentObject, IChunk, IVisualMemory). The write lock will have already been acquired.

Specified by:
update in interface IPerceptualEncoder
Parameters:
afferentObject -
oldChunk -
memory -
Returns:
See Also:
IPerceptualEncoder.update(org.commonreality.object.IAfferentObject, org.jactr.core.chunk.IChunk, org.jactr.modules.pm.common.memory.IPerceptualMemory)