com.realtime.crossfire.jxclient.faces
Class DefaultFacesManager

java.lang.Object
  extended by com.realtime.crossfire.jxclient.faces.AbstractFacesManager
      extended by com.realtime.crossfire.jxclient.faces.DefaultFacesManager
All Implemented Interfaces:
FacesManager

public class DefaultFacesManager
extends AbstractFacesManager

Retrieves Face information by face ID. If a face is not available in-memory, an "unknown" (question mark) face is returned immediately. Asynchronously, the face is loaded from the file cache. If loading fails, the face is requested from the server (and later stored into the file cache). As soon as the face becomes available, all registered FacesManagerListeners are notified.


Field Summary
private  FaceImages emptyFaceImages
          The empty face; returned for face ID 0.
private  FaceQueue faceQueue
          The FaceQueue instance used to load faces not present in-memory.
private  FaceQueueListener faceQueueListener
          The FaceQueueListener registered to faceQueue.
private  FaceImages unknownFaceImages
          The unknown face.
 
Constructor Summary
DefaultFacesManager(FaceCache faceCache, FaceQueue faceQueue)
          Creates a new instance.
 
Method Summary
protected  FaceImages getFaceImages(int faceNum)
          Returns the FaceImages information for a face ID.
 void reset()
          Forgets about pending faces.
 
Methods inherited from class com.realtime.crossfire.jxclient.faces.AbstractFacesManager
addFacesManagerListener, fireFaceUpdated, getFace, getFace2, getMagicMapImageIcon, getOriginalImageIcon, getScaledImageIcon, lookupFace, removeFacesManagerListener
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

emptyFaceImages

@NotNull
private final FaceImages emptyFaceImages
The empty face; returned for face ID 0.


faceQueue

@NotNull
private final FaceQueue faceQueue
The FaceQueue instance used to load faces not present in-memory.


faceQueueListener

@NotNull
private final FaceQueueListener faceQueueListener
The FaceQueueListener registered to faceQueue.


unknownFaceImages

@NotNull
private final FaceImages unknownFaceImages
The unknown face.

Constructor Detail

DefaultFacesManager

public DefaultFacesManager(@NotNull
                           FaceCache faceCache,
                           @NotNull
                           FaceQueue faceQueue)
                    throws java.io.IOException
Creates a new instance.

Parameters:
faceCache - the face cache instance for storing in-memory faces
faceQueue - the face queue to use
Throws:
java.io.IOException - if the unknown image resource cannot be loaded
Method Detail

getFaceImages

@NotNull
protected FaceImages getFaceImages(int faceNum)
Returns the FaceImages information for a face ID. This function returns immediately even if the face is not loaded. A not loaded face will be updated as soon as loading has finished.

Specified by:
getFaceImages in class AbstractFacesManager
Parameters:
faceNum - the face ID
Returns:
the face images information

reset

public void reset()
Forgets about pending faces.

Specified by:
reset in interface FacesManager
Overrides:
reset in class AbstractFacesManager