Class FacesProxyDecorator
java.lang.Object
cz.fidentis.analyst.project.FacesProxy
cz.fidentis.analyst.gui.task.batch.FacesProxyDecorator
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.-
Nested Class Summary
Nested classes/interfaces inherited from class cz.fidentis.analyst.project.FacesProxy
FacesProxy.FaceFileType
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionint
Adds a face to the set.boolean
Returns the average human face ornull
getFace
(int index) Instantiates (if not yet instantiated) and returns a human face.getFaceDir
(int index) Returns path to the face directory ornull
.getFaceFile
(int index) Returns the file of a given face.getFaceFile
(String faceName) Returns the file of a given face.Returns the list of paths to faces.int
getFaceIndex
(String faceName) Returns index of the face described by its canonical name,getFaceName
(int index) Returns short (canonical) name of the face.getFacePath
(int index, FacesProxy.FaceFileType type) Returns path to the given face file ornull
.int
Returns the number of facesInstantiates (if not yet instantiated) and returns the first face from the list of faces.Instantiates (if not yet instantiated) and returns the second face from the list of faces.getSelectedFace
(JComboBox<String> cbox) Returns the face selected in a menu.Returns the task name that encodes names of faces.int
hashCode()
boolean
Determines whether the average face has been already computed.boolean
isAvgFaceSelected
(JComboBox<String> cbox) Returnstrue
if the item selected in the combo box is the average faceboolean
isInMemory
(int index) Checks whether the face is already loaded in the memory.boolean
removeFace
(String faceName) Removes face from the proxy.void
Serializes current state.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.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.Methods inherited from class cz.fidentis.analyst.project.FacesProxy
getCanonicalName
-
Constructor Details
-
FacesProxyDecorator
Constructor.- Parameters:
facesProxy
- original faces proxy dealing with faces to be processed
-
-
Method Details
-
getFacesProxy
-
getAvgFace
Returns the average human face ornull
- Returns:
- the average human face or
null
-
syncSelectionMenu
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 thecbox
with with the originally selected item or the newly added average face.- Parameters:
avgFace
- The average face, can benull
selectNewAvgFace
- Iftrue
and a new average is added, then the average face is automatically selected. If theavgFace
isnull
, then this parameter has no effect.cbox
- A combo box (menu)
-
syncSelectionMenu
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 thecbox
with the originally selected item or the newly added average face.- Parameters:
selectNewAvgFace
- Iftrue
and a new average is added, then the average face is automatically selected.cbox
- A combo box (menu)
-
getSelectedFace
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
Returnstrue
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
Description copied from class:FacesProxy
Serializes current state.- Overrides:
serialize
in classFacesProxy
- Parameters:
out
- Output stream- Throws:
IOException
- on IO error
-
getFaceFiles
Description copied from class:FacesProxy
Returns the list of paths to faces.- Overrides:
getFaceFiles
in classFacesProxy
- Returns:
- the list of paths to faces.
-
getFaceFile
Description copied from class:FacesProxy
Returns the file of a given face.- Overrides:
getFaceFile
in classFacesProxy
- Parameters:
index
- index of the face- Returns:
- the file of a given face or
null
-
getFaceFile
Description copied from class:FacesProxy
Returns the file of a given face.- Overrides:
getFaceFile
in classFacesProxy
- Parameters:
faceName
- name of the face- Returns:
- the file of a given face or
null
-
getFace
Description copied from class:FacesProxy
Instantiates (if not yet instantiated) and returns a human face.- Overrides:
getFace
in classFacesProxy
- Parameters:
index
- index of the face- Returns:
- human face or
null
-
getFaceIndex
Description copied from class:FacesProxy
Returns index of the face described by its canonical name,- Overrides:
getFaceIndex
in classFacesProxy
- Parameters:
faceName
- Canonical name of the face- Returns:
- index or -1
-
addFace
Description copied from class:FacesProxy
Adds a face to the set.- Overrides:
addFace
in classFacesProxy
- Parameters:
file
- path to the face OBJ fileunique
- Iftrue
, then avoid adding a single face twice- Returns:
- index of the added face, -1 the
file
is null, -2 ifunique
istrue
and the face is already in the set.
-
removeFace
Description copied from class:FacesProxy
Removes face from the proxy.- Overrides:
removeFace
in classFacesProxy
- 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 classFacesProxy
- Parameters:
index
- index of the face- Returns:
true
is the face is loaded.
-
getFaceName
Description copied from class:FacesProxy
Returns short (canonical) name of the face. In contrast to thegetFace(x).getShortName()
, this method does not need face instance allocated in the memory.- Overrides:
getFaceName
in classFacesProxy
- Parameters:
index
- index of the face- Returns:
- short name of the face
-
getFacePath
Description copied from class:FacesProxy
Returns path to the given face file ornull
.- Overrides:
getFacePath
in classFacesProxy
- Parameters:
index
- index of the facetype
- face file type- Returns:
- path or
null
-
getFaceDir
Description copied from class:FacesProxy
Returns path to the face directory ornull
.- Overrides:
getFaceDir
in classFacesProxy
- Parameters:
index
- index of the face- Returns:
- path to face folder or
null
-
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 classFacesProxy
- Returns:
- the first (primary) face from the list of faces
-
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 classFacesProxy
- 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 classFacesProxy
- Returns:
- the number of faces
-
getTaskName
Description copied from class:FacesProxy
Returns the task name that encodes names of faces.- Overrides:
getTaskName
in classFacesProxy
- Returns:
- a text that encodes names of faces.
-
equals
- Overrides:
equals
in classFacesProxy
-
hashCode
public int hashCode()- Overrides:
hashCode
in classFacesProxy
-
getFactory
- Overrides:
getFactory
in classFacesProxy
-