Class FacesProxyDecorator

java.lang.Object
cz.fidentis.analyst.project.FacesProxy
cz.fidentis.analyst.gui.task.batch.FacesProxyDecorator

public class FacesProxyDecorator extends FacesProxy
In contrast to the FacesProxy, which deals with faces that are the subject of batch processing, this class add handling of the (optionally computed) average face. While the faces can be temporarily dumped, the average face is always in the memory. It is assumed that the average face is added as the first item of a menu (combo box), whenever is computed. This class provides methods for such menu (combo box) management and synchronization.
  • Constructor Details

    • FacesProxyDecorator

      public FacesProxyDecorator(FacesProxy facesProxy)
      Constructor.
      Parameters:
      facesProxy - original faces proxy dealing with faces to be processed
  • Method Details

    • getFacesProxy

      public FacesProxy getFacesProxy()
    • getAvgFace

      public HumanFace getAvgFace()
      Returns the average human face or null
      Returns:
      the average human face or null
    • syncSelectionMenu

      public void syncSelectionMenu(HumanFace avgFace, boolean selectNewAvgFace, JComboBox<String> cbox)
      Fill the menu (combo box) with names of faces, including the average face, if provided as input parameter. The average face is stored. An action event is triggered automatically by the cbox with with the originally selected item or the newly added average face.
      Parameters:
      avgFace - The average face, can be null
      selectNewAvgFace - If true and a new average is added, then the average face is automatically selected. If the avgFace is null, then this parameter has no effect.
      cbox - A combo box (menu)
    • syncSelectionMenu

      public void syncSelectionMenu(boolean selectNewAvgFace, JComboBox<String> cbox)
      Fill the menu (combo box) with names of faces stored in the face proxy, plus the optional average face. An action event is triggered automatically by the cbox with the originally selected item or the newly added average face.
      Parameters:
      selectNewAvgFace - If true and a new average is added, then the average face is automatically selected.
      cbox - A combo box (menu)
    • getSelectedFace

      public HumanFace getSelectedFace(JComboBox<String> cbox)
      Returns the face selected in a menu.
      Parameters:
      cbox - A combo box (menu)
      Returns:
      The face selected in a menu. This is either some face from the dataset, or the average face.
    • haveAvgFace

      public boolean haveAvgFace()
      Determines whether the average face has been already computed.
      Returns:
      true if the average face has been already computed
    • isAvgFaceSelected

      public boolean isAvgFaceSelected(JComboBox<String> cbox)
      Returns true if the item selected in the combo box is the average face
      Parameters:
      cbox - A combo box (menu)
      Returns:
      true if the item selected in the combo box is the average face
    • serialize

      public void serialize(ObjectOutputStream out) throws IOException
      Description copied from class: FacesProxy
      Serializes current state.
      Overrides:
      serialize in class FacesProxy
      Parameters:
      out - Output stream
      Throws:
      IOException - on IO error
    • getFaceFiles

      public List<File> getFaceFiles()
      Description copied from class: FacesProxy
      Returns the list of paths to faces.
      Overrides:
      getFaceFiles in class FacesProxy
      Returns:
      the list of paths to faces.
    • getFaceFile

      public File getFaceFile(int index)
      Description copied from class: FacesProxy
      Returns the file of a given face.
      Overrides:
      getFaceFile in class FacesProxy
      Parameters:
      index - index of the face
      Returns:
      the file of a given face or null
    • getFaceFile

      public File getFaceFile(String faceName)
      Description copied from class: FacesProxy
      Returns the file of a given face.
      Overrides:
      getFaceFile in class FacesProxy
      Parameters:
      faceName - name of the face
      Returns:
      the file of a given face or null
    • getFace

      public HumanFace getFace(int index)
      Description copied from class: FacesProxy
      Instantiates (if not yet instantiated) and returns a human face.
      Overrides:
      getFace in class FacesProxy
      Parameters:
      index - index of the face
      Returns:
      human face or null
    • getFaceIndex

      public int getFaceIndex(String faceName)
      Description copied from class: FacesProxy
      Returns index of the face described by its canonical name,
      Overrides:
      getFaceIndex in class FacesProxy
      Parameters:
      faceName - Canonical name of the face
      Returns:
      index or -1
    • addFace

      public int addFace(File file, boolean unique)
      Description copied from class: FacesProxy
      Adds a face to the set.
      Overrides:
      addFace in class FacesProxy
      Parameters:
      file - path to the face OBJ file
      unique - If true, then avoid adding a single face twice
      Returns:
      index of the added face, -1 the file is null, -2 if unique is true and the face is already in the set.
    • removeFace

      public boolean removeFace(String faceName)
      Description copied from class: FacesProxy
      Removes face from the proxy.
      Overrides:
      removeFace in class FacesProxy
      Parameters:
      faceName - Canonical name of the face
      Returns:
      false of the face does not exist or was not loaded
    • isInMemory

      public boolean isInMemory(int index)
      Description copied from class: FacesProxy
      Checks whether the face is already loaded in the memory.
      Overrides:
      isInMemory in class FacesProxy
      Parameters:
      index - index of the face
      Returns:
      true is the face is loaded.
    • getFaceName

      public String getFaceName(int index)
      Description copied from class: FacesProxy
      Returns short (canonical) name of the face. In contrast to the getFace(x).getShortName(), this method does not need face instance allocated in the memory.
      Overrides:
      getFaceName in class FacesProxy
      Parameters:
      index - index of the face
      Returns:
      short name of the face
    • getFacePath

      public String getFacePath(int index, FacesProxy.FaceFileType type)
      Description copied from class: FacesProxy
      Returns path to the given face file or null.
      Overrides:
      getFacePath in class FacesProxy
      Parameters:
      index - index of the face
      type - face file type
      Returns:
      path or null
    • getFaceDir

      public String getFaceDir(int index)
      Description copied from class: FacesProxy
      Returns path to the face directory or null.
      Overrides:
      getFaceDir in class FacesProxy
      Parameters:
      index - index of the face
      Returns:
      path to face folder or null
    • getPrimaryFace

      public HumanFace getPrimaryFace()
      Description copied from class: FacesProxy
      Instantiates (if not yet instantiated) and returns the first face from the list of faces. The first face is called primary.
      Overrides:
      getPrimaryFace in class FacesProxy
      Returns:
      the first (primary) face from the list of faces
    • getSecondaryFace

      public HumanFace getSecondaryFace()
      Description copied from class: FacesProxy
      Instantiates (if not yet instantiated) and returns the second face from the list of faces. The second face is called secondary.
      Overrides:
      getSecondaryFace in class FacesProxy
      Returns:
      the second (secondary) face from the list of faces
    • getNumFaces

      public int getNumFaces()
      Description copied from class: FacesProxy
      Returns the number of faces
      Overrides:
      getNumFaces in class FacesProxy
      Returns:
      the number of faces
    • getTaskName

      public String getTaskName()
      Description copied from class: FacesProxy
      Returns the task name that encodes names of faces.
      Overrides:
      getTaskName in class FacesProxy
      Returns:
      a text that encodes names of faces.
    • equals

      public boolean equals(Object obj)
      Overrides:
      equals in class FacesProxy
    • hashCode

      public int hashCode()
      Overrides:
      hashCode in class FacesProxy
    • getFactory

      public HumanFaceMemoryManager getFactory()
      Overrides:
      getFactory in class FacesProxy