Commit c2339a54 authored by Radek Ošlejšek's avatar Radek Ošlejšek
Browse files

Merge branch '103-list-of-faces-in-project' into 'master'

Resolve "List of faces in project"

Closes #103

See merge request grp-fidentis/analyst2!118
parents e6d35d70 0bcb3c98
Loading
Loading
Loading
Loading
+41 −25
Original line number Diff line number Diff line
@@ -13,14 +13,15 @@ import java.util.List;
 */
public class Project {
    
    private HumanFace primaryFace;
    private List<HumanFace> secondaryFaces = new ArrayList<>();
    //private HumanFace primaryFace;
    private List<HumanFace> faces = new ArrayList<>();
    
    
    /**
     * Returns primary face
     * 
     * @return HumanFace primary face 
     */
     
    public HumanFace getPrimaryFace() {
        return primaryFace;
    }
@@ -30,7 +31,7 @@ public class Project {
     * 
     * @param primaryFace which will be new primary face
     * @throws IllegalArgumentException when argument primaryFace is null
     */
     
    public void setPrimaryFace(HumanFace primaryFace) {
        if (primaryFace == null) {
            throw new IllegalArgumentException("Primary face is null");
@@ -40,18 +41,19 @@ public class Project {
    
    /**
     * Removes primary face and sets primaryFace attribute to null
     */
     
    public void removePrimaryFace() {
        this.primaryFace = null;
    }
    }*/


    /**
     * Returns list of HumanFace secondary faces
     * 
     * @return list of secondary faces
     */
    public List<HumanFace> getSecondaryFaces() {
        return Collections.unmodifiableList(secondaryFaces);
    public List<HumanFace> getFaces() {
        return Collections.unmodifiableList(faces);
    }

    /**
@@ -61,60 +63,74 @@ public class Project {
     * secondary faces
     * @throws IllegalArgumentException if one of faces from argument is null
     */
    public void setSecondaryFaces(List<HumanFace> secondaryFaces) {
        this.secondaryFaces.clear();
    public void setFaces(List<HumanFace> secondaryFaces) {
        this.faces.clear();
        for (int i = 0; i < secondaryFaces.size(); i++) {
            if (secondaryFaces.get(i) == null) {
                throw new IllegalArgumentException("One of faces is null");
            }
        }
        this.secondaryFaces.addAll(secondaryFaces);
        this.faces.addAll(secondaryFaces);
    }
    
    /**
     * Adds new face to secondaryFaces
     * Adds new face to faces
     * 
     * @param face HumanFace which will be added to list of secondary faces
     * @throws IllegalArgumentException when argument face is null
     */
    public void addSecondaryFace(HumanFace face) {
    public void addFace(HumanFace face) {
        if (face == null) {
            throw new IllegalArgumentException("Face is null");
        }
        this.secondaryFaces.add(face);
        this.faces.add(face);
    }
    
    /**
     * Removes HumanFace from secondaryFaces
     * Removes HumanFace from faces
     * 
     * @param face HumanFace which will be removed from secondaryFaces
     * @param face HumanFace which will be removed from faces
     * @throws IllegalArgumentException when argument face is null
     */
    public void removeSecondaryFace(HumanFace face) {
    public void removeFace(HumanFace face) {
        if (face == null) {
            throw new IllegalArgumentException("Face is null");
        }
        
        for (int i = 0; i < secondaryFaces.size(); i++) {
            if (secondaryFaces.get(i).equals(face)) {
                secondaryFaces.remove(i);
        for (int i = 0; i < faces.size(); i++) {
            if (faces.get(i).equals(face)) {
                faces.remove(i);
            }
        } 
    }
    
    /**
     * Removes faces which are sent to this function by list of HumanFace
     * from secondaryFaces
     * from faces
     * 
     * @param faces List of HumanFace faces which should be removed from
     * secondaryFaces
     * faces
     */
    public void removeSelected(List<HumanFace> faces) {
        for (int i = 0; i < faces.size(); i++) {
            this.removeSecondaryFace(faces.get(i));
            this.removeFace(faces.get(i));
        }
    }
    
    
    /**
     * 
     * @param name String name of the model (face)
     * @return face from this project faces, if not in project than returns 
     * null
     */
    public HumanFace getFaceByName(String name) {
        for (HumanFace face : faces) {
            if (face.getShortName().equals(name)) {
                return face;
            }
        }
        return null;
    }
    
    /* TODO implement comparable and create comparators for filtering
    secondaryFaces */
}
+10 −0
Original line number Diff line number Diff line
@@ -225,6 +225,16 @@ public class HumanFace implements MeshListener, Serializable {
        return name;
    }
    
    /**
     * Returns short name of the face without its path in the name.
     * @return short name of the face without its path in the name
     */
    public String getShortName() {
        String name = this.getName();
        name = name.substring(name.lastIndexOf(File.separatorChar) + 1, name.length());
        return name;
    }
    
    /**
     * Returns already computed k-d tree of the triangular mesh or {@code null}.
     * @return Already computed k-d tree of the triangular mesh or {@code null}
+95 −94

File changed.

Preview size limit exceeded, changes collapsed.

+292 −100

File changed.

Preview size limit exceeded, changes collapsed.

+7 −2
Original line number Diff line number Diff line
@@ -10,9 +10,14 @@ PostRegistrationCP.rotationYFTF.text=0
PostRegistrationCP.jFormattedTextField1.text=jFormattedTextField1
SingleFaceTab.jButton2.text=jButton2
ProjectTopComp.addButton1.text=Add
ProjectTopComp.analyzeButton1.text=Open 1:1
ProjectTopComp.inflateButton1.text=Inflate
ProjectTopComp.collapseButton1.text=Collapse
ProjectTopComp.deselectAllButton1.text=Deselect all
ProjectTopComp.selectAllButton1.text=Select all
ProjectTopComp.removeButton1.text=Remove
ProjectTopComp.jTable1.columnModel.title0=Title 1
ProjectTopComp.jTable1.columnModel.title3=Title 4
ProjectTopComp.jTable1.columnModel.title1=Title 2
ProjectTopComp.jTable1.columnModel.title0_1=Models
ProjectTopComp.jTable1.columnModel.title1_1=
ProjectTopComp.oneOnOneButton1.text=Open 1:1
ProjectTopComp.analyseButton1.text=Analyse