public abstract class AbstractVisualEncoder extends java.lang.Object implements IPerceptualEncoder
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.COMMONREALITY_IDENTIFIER_META_KEY
Constructor and Description |
---|
AbstractVisualEncoder(java.lang.String chunkTypeName) |
Modifier and Type | Method and Description |
---|---|
protected abstract boolean |
canEncodeVisualObjectType(IAfferentObject afferentObject)
returns true if this particular encoder can be used for this object
|
IChunk |
encode(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() , |
protected static IVisualPropertyHandler |
getHandler() |
static double[] |
getLocation(IChunk visualLocation) |
static IChunk |
getVisualLocation(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
|
protected java.lang.String |
guessChunkName(IAfferentObject afferentObject) |
protected boolean |
isAttendedSticky(IIdentifier perceptId,
IChunk encoding,
IVisualMemory visualMemory)
if
IVisualMemory.isStickyAttentionEnabled() and the chunk is in the
visual buffer. |
boolean |
isDirty(IAfferentObject afferentObject,
IChunk oldChunk,
IPerceptualMemory memory)
checks the expected visual location against the previously encoded visual
location.
|
boolean |
isInterestedIn(IAfferentObject afferentObject)
returns true if the percept has the
IVisualPropertyHandler.IS_VISUAL property. |
protected boolean |
isTooDirty(IAfferentObject afferentObject,
IChunk oldChunk,
IVisualMemory visualMemory)
used to trigger a reencoding if the old chunk is too dirty.
|
IChunk |
update(IAfferentObject afferentObject,
IChunk oldChunk,
IPerceptualMemory memory)
called to update the encoding of a chunk.
|
protected void |
updateSlots(IAfferentObject afferentObject,
IChunk encoding,
IVisualMemory memory)
fill the slot values of the encoded chunk.
|
public AbstractVisualEncoder(java.lang.String chunkTypeName)
chunkTypeName
- name of the chunktype that is to be createdpublic static IChunk getVisualLocation(IAfferentObject afferentObject, IVisualMemory visualMemory)
IVisualPropertyHandler.RETINAL_LOCATION
) of the object. If no
location is defined, it is outside the visual field, or it is not visible,
null is returnedafferentObject
- visualMemory
- public static IChunk getVisualLocation(IChunk visualChunk, IVisualMemory visualMemory)
visualChunk
- protected static IVisualPropertyHandler getHandler()
public boolean isDirty(IAfferentObject afferentObject, IChunk oldChunk, IPerceptualMemory memory)
isDirty
in interface IPerceptualEncoder
afferentObject
- oldChunk
- memory
- IPerceptualEncoder.isDirty(org.commonreality.object.IAfferentObject,
org.jactr.core.chunk.IChunk,
org.jactr.modules.pm.common.memory.IPerceptualMemory)
protected boolean isTooDirty(IAfferentObject afferentObject, IChunk oldChunk, IVisualMemory visualMemory)
afferentObject
- oldChunk
- visualMemory
- protected boolean isAttendedSticky(IIdentifier perceptId, IChunk encoding, IVisualMemory visualMemory)
IVisualMemory.isStickyAttentionEnabled()
and the chunk is in the
visual buffer. OR, if the latest search found the matching perceptencoding
- visualMemory
- public static boolean exceedsMovementTolerance(IChunk oldVisualLocation, IChunk newVisualLocation, IVisualMemory visualMemory)
IVisualMemory.getMovementTolerance()
,oldVisualLocation
- newVisualLocation
- visualMemory
- public static double[] getLocation(IChunk visualLocation)
public boolean isInterestedIn(IAfferentObject afferentObject)
IVisualPropertyHandler.IS_VISUAL
property.isInterestedIn
in interface IPerceptualEncoder
afferentObject
- IPerceptualEncoder.isInterestedIn(org.commonreality.object.IAfferentObject)
protected abstract boolean canEncodeVisualObjectType(IAfferentObject afferentObject)
afferentObject
- protected void updateSlots(IAfferentObject afferentObject, IChunk encoding, IVisualMemory memory)
afferentObject
- encoding
- memory
- protected java.lang.String guessChunkName(IAfferentObject afferentObject)
public IChunk encode(IAfferentObject afferentObject, IPerceptualMemory memory)
encode
in interface IPerceptualEncoder
public IChunk update(IAfferentObject afferentObject, IChunk oldChunk, IPerceptualMemory memory)
isTooDirty(IAfferentObject, IChunk, IVisualMemory)
.
The write lock will have already been acquired.update
in interface IPerceptualEncoder
afferentObject
- oldChunk
- memory
- IPerceptualEncoder.update(org.commonreality.object.IAfferentObject,
org.jactr.core.chunk.IChunk,
org.jactr.modules.pm.common.memory.IPerceptualMemory)