From 1747c13213df381bc19cdae38b0d616d642cccfc Mon Sep 17 00:00:00 2001 From: Radek Oslejsek <oslejsek@fi.muni.cz> Date: Tue, 13 Apr 2021 15:09:09 +0200 Subject: [PATCH] Basic refactoring and decumention --- .../java/cz/fidentis/analyst/Project.java | 29 ++++++------- ...dTopComponent.form => ProjectTopComp.form} | 14 +++--- ...dTopComponent.java => ProjectTopComp.java} | 43 ++++++++++--------- .../cz/fidentis/analyst/gui/Bundle.properties | 14 +++--- 4 files changed, 48 insertions(+), 52 deletions(-) rename GUI/src/main/java/cz/fidentis/analyst/gui/{DashboardTopComponent.form => ProjectTopComp.form} (92%) rename GUI/src/main/java/cz/fidentis/analyst/gui/{DashboardTopComponent.java => ProjectTopComp.java} (84%) diff --git a/Comparison/src/main/java/cz/fidentis/analyst/Project.java b/Comparison/src/main/java/cz/fidentis/analyst/Project.java index 73640d5c..8b53ffec 100644 --- a/Comparison/src/main/java/cz/fidentis/analyst/Project.java +++ b/Comparison/src/main/java/cz/fidentis/analyst/Project.java @@ -1,26 +1,21 @@ -/* - * To change this license header, choose License Headers in Project Properties. - * To change this template file, choose Tools | Templates - * and open the template in the editor. - */ package cz.fidentis.analyst; import cz.fidentis.analyst.face.HumanFace; import java.util.ArrayList; +import java.util.Collections; +import java.util.List; /** - * This class encapsulates data for creating project with primary face and - * secondary faces. + * This class encapsulates data for a "comparison project", i.e., a project + * enabling analysts to compare and investigate human faces. * * @author Matej Kovar */ public class Project { private HumanFace primaryFace; - private ArrayList<HumanFace> secondaryFaces = new ArrayList<>(); + private List<HumanFace> secondaryFaces = new ArrayList<>(); - public Project() {} - public HumanFace getPrimaryFace() { return primaryFace; } @@ -29,28 +24,28 @@ public class Project { this.primaryFace = primaryFace; } - public ArrayList<HumanFace> getSecondaryFaces() { - return secondaryFaces; + public List<HumanFace> getSecondaryFaces() { + return Collections.unmodifiableList(secondaryFaces); } - public void setSecondaryFaces(ArrayList<HumanFace> secondaryFaces) { - this.secondaryFaces = secondaryFaces; + public void setSecondaryFaces(List<HumanFace> secondaryFaces) { + this.secondaryFaces.clear(); + this.secondaryFaces.addAll(secondaryFaces); } - public void addSecondaryFace(HumanFace face) { this.secondaryFaces.add(face); } public void removeSecondaryFace(HumanFace face) { for (int i = 0; i < secondaryFaces.size(); i++) { - if (secondaryFaces.get(i) == face) { + if (secondaryFaces.get(i).equals(face)) { secondaryFaces.remove(i); } } } - public void removeSelected(ArrayList<HumanFace> faces) { + public void removeSelected(List<HumanFace> faces) { for (int i = 0; i < faces.size(); i++) { this.removeSecondaryFace(faces.get(i)); } diff --git a/GUI/src/main/java/cz/fidentis/analyst/gui/DashboardTopComponent.form b/GUI/src/main/java/cz/fidentis/analyst/gui/ProjectTopComp.form similarity index 92% rename from GUI/src/main/java/cz/fidentis/analyst/gui/DashboardTopComponent.form rename to GUI/src/main/java/cz/fidentis/analyst/gui/ProjectTopComp.form index a75afca0..e213ebed 100644 --- a/GUI/src/main/java/cz/fidentis/analyst/gui/DashboardTopComponent.form +++ b/GUI/src/main/java/cz/fidentis/analyst/gui/ProjectTopComp.form @@ -110,7 +110,7 @@ <Font name="Tahoma" size="12" style="0"/> </Property> <Property name="text" type="java.lang.String" editor="org.netbeans.modules.i18n.form.FormI18nStringEditor"> - <ResourceString bundle="cz/fidentis/analyst/gui/Bundle.properties" key="DashboardTopComponent.addButton1.text" replaceFormat="org.openide.util.NbBundle.getMessage({sourceFileName}.class, "{key}")"/> + <ResourceString bundle="cz/fidentis/analyst/gui/Bundle.properties" key="ProjectTopComp.addButton1.text" replaceFormat="org.openide.util.NbBundle.getMessage({sourceFileName}.class, "{key}")"/> </Property> </Properties> <Constraints> @@ -125,7 +125,7 @@ <Font name="Tahoma" size="12" style="0"/> </Property> <Property name="text" type="java.lang.String" editor="org.netbeans.modules.i18n.form.FormI18nStringEditor"> - <ResourceString bundle="cz/fidentis/analyst/gui/Bundle.properties" key="DashboardTopComponent.removeButton1.text" replaceFormat="org.openide.util.NbBundle.getMessage({sourceFileName}.class, "{key}")"/> + <ResourceString bundle="cz/fidentis/analyst/gui/Bundle.properties" key="ProjectTopComp.removeButton1.text" replaceFormat="org.openide.util.NbBundle.getMessage({sourceFileName}.class, "{key}")"/> </Property> </Properties> <Constraints> @@ -140,7 +140,7 @@ <Font name="Tahoma" size="12" style="0"/> </Property> <Property name="text" type="java.lang.String" editor="org.netbeans.modules.i18n.form.FormI18nStringEditor"> - <ResourceString bundle="cz/fidentis/analyst/gui/Bundle.properties" key="DashboardTopComponent.selectAllButton1.text" replaceFormat="org.openide.util.NbBundle.getMessage({sourceFileName}.class, "{key}")"/> + <ResourceString bundle="cz/fidentis/analyst/gui/Bundle.properties" key="ProjectTopComp.selectAllButton1.text" replaceFormat="org.openide.util.NbBundle.getMessage({sourceFileName}.class, "{key}")"/> </Property> </Properties> <Constraints> @@ -155,7 +155,7 @@ <Font name="Tahoma" size="12" style="0"/> </Property> <Property name="text" type="java.lang.String" editor="org.netbeans.modules.i18n.form.FormI18nStringEditor"> - <ResourceString bundle="cz/fidentis/analyst/gui/Bundle.properties" key="DashboardTopComponent.deselectAllButton1.text" replaceFormat="org.openide.util.NbBundle.getMessage({sourceFileName}.class, "{key}")"/> + <ResourceString bundle="cz/fidentis/analyst/gui/Bundle.properties" key="ProjectTopComp.deselectAllButton1.text" replaceFormat="org.openide.util.NbBundle.getMessage({sourceFileName}.class, "{key}")"/> </Property> </Properties> <Constraints> @@ -170,7 +170,7 @@ <Font name="Tahoma" size="12" style="0"/> </Property> <Property name="text" type="java.lang.String" editor="org.netbeans.modules.i18n.form.FormI18nStringEditor"> - <ResourceString bundle="cz/fidentis/analyst/gui/Bundle.properties" key="DashboardTopComponent.collapseButton1.text" replaceFormat="org.openide.util.NbBundle.getMessage({sourceFileName}.class, "{key}")"/> + <ResourceString bundle="cz/fidentis/analyst/gui/Bundle.properties" key="ProjectTopComp.collapseButton1.text" replaceFormat="org.openide.util.NbBundle.getMessage({sourceFileName}.class, "{key}")"/> </Property> </Properties> <Constraints> @@ -185,7 +185,7 @@ <Font name="Tahoma" size="12" style="0"/> </Property> <Property name="text" type="java.lang.String" editor="org.netbeans.modules.i18n.form.FormI18nStringEditor"> - <ResourceString bundle="cz/fidentis/analyst/gui/Bundle.properties" key="DashboardTopComponent.inflateButton1.text" replaceFormat="org.openide.util.NbBundle.getMessage({sourceFileName}.class, "{key}")"/> + <ResourceString bundle="cz/fidentis/analyst/gui/Bundle.properties" key="ProjectTopComp.inflateButton1.text" replaceFormat="org.openide.util.NbBundle.getMessage({sourceFileName}.class, "{key}")"/> </Property> <Property name="alignmentX" type="float" value="0.5"/> </Properties> @@ -204,7 +204,7 @@ <Font name="Tahoma" size="12" style="0"/> </Property> <Property name="text" type="java.lang.String" editor="org.netbeans.modules.i18n.form.FormI18nStringEditor"> - <ResourceString bundle="cz/fidentis/analyst/gui/Bundle.properties" key="DashboardTopComponent.analyzeButton1.text" replaceFormat="org.openide.util.NbBundle.getMessage({sourceFileName}.class, "{key}")"/> + <ResourceString bundle="cz/fidentis/analyst/gui/Bundle.properties" key="ProjectTopComp.analyzeButton1.text" replaceFormat="org.openide.util.NbBundle.getMessage({sourceFileName}.class, "{key}")"/> </Property> <Property name="alignmentX" type="float" value="0.5"/> </Properties> diff --git a/GUI/src/main/java/cz/fidentis/analyst/gui/DashboardTopComponent.java b/GUI/src/main/java/cz/fidentis/analyst/gui/ProjectTopComp.java similarity index 84% rename from GUI/src/main/java/cz/fidentis/analyst/gui/DashboardTopComponent.java rename to GUI/src/main/java/cz/fidentis/analyst/gui/ProjectTopComp.java index 2172534b..0d5645ee 100644 --- a/GUI/src/main/java/cz/fidentis/analyst/gui/DashboardTopComponent.java +++ b/GUI/src/main/java/cz/fidentis/analyst/gui/ProjectTopComp.java @@ -13,41 +13,42 @@ import org.openide.util.NbBundle.Messages; import cz.fidentis.analyst.Project; /** + * The main panel enabling analysts to select the primary and secondary faces, + * and to perform basic batch processing. This panel also serves as an entry point + * for detailed face analysis and face-to-face comparison. * - * @author Matej Kovár - * - * Window for dashboard + * @author Matej Kovar */ @ConvertAsProperties( dtd = "-//cz.fidentis.analyst.gui//Dashboard//EN", autostore = false ) @TopComponent.Description( - preferredID = "DashboardTopComponent", + preferredID = "ProjectTopComp", //iconBase="SET/PATH/TO/ICON/HERE", persistenceType = TopComponent.PERSISTENCE_ALWAYS ) @TopComponent.Registration(mode = "editor", openAtStartup = true) -@ActionID(category = "Window", id = "cz.fidentis.analyst.gui.DashboardTopComponent") +@ActionID(category = "Window", id = "cz.fidentis.analyst.gui.ProjectTopComp") @ActionReference(path = "Menu/Window" /*, position = 333 */) @TopComponent.OpenActionRegistration( - displayName = "#CTL_DashboardTopComponentAction", - preferredID = "DashboardTopComponent" + displayName = "#CTL_ProjectTopCompAction", + preferredID = "ProjectTopComp" ) @Messages({ - "CTL_DashboardTopComponentAction=Project", - "CTL_DashboardTopComponentTopComponent=Project", - "HINT_DashboardTopComponentTopComponent=This is a Project window" + "CTL_ProjectTopCompAction=Project", + "CTL_ProjectTopCompTopComponent=Project", + "HINT_ProjectTopCompTopComponent=This is a Project window" }) -public final class DashboardTopComponent extends TopComponent { +public final class ProjectTopComp extends TopComponent { private Project project; - public DashboardTopComponent() { + public ProjectTopComp() { project = new Project(); initComponents(); - setName(Bundle.CTL_DashboardTopComponentTopComponent()); - setToolTipText(Bundle.HINT_DashboardTopComponentTopComponent()); + setName(Bundle.CTL_ProjectTopCompTopComponent()); + setToolTipText(Bundle.HINT_ProjectTopCompTopComponent()); putClientProperty(TopComponent.PROP_CLOSING_DISABLED, Boolean.TRUE); putClientProperty(TopComponent.PROP_DRAGGING_DISABLED, Boolean.TRUE); putClientProperty(TopComponent.PROP_UNDOCKING_DISABLED, Boolean.TRUE); @@ -86,7 +87,7 @@ public final class DashboardTopComponent extends TopComponent { jPanel5.setLayout(new java.awt.GridBagLayout()); addButton1.setFont(new java.awt.Font("Tahoma", 0, 12)); // NOI18N - org.openide.awt.Mnemonics.setLocalizedText(addButton1, org.openide.util.NbBundle.getMessage(DashboardTopComponent.class, "DashboardTopComponent.addButton1.text")); // NOI18N + org.openide.awt.Mnemonics.setLocalizedText(addButton1, org.openide.util.NbBundle.getMessage(ProjectTopComp.class, "ProjectTopComp.addButton1.text")); // NOI18N gridBagConstraints = new java.awt.GridBagConstraints(); gridBagConstraints.gridx = 0; gridBagConstraints.gridy = 0; @@ -96,7 +97,7 @@ public final class DashboardTopComponent extends TopComponent { jPanel5.add(addButton1, gridBagConstraints); removeButton1.setFont(new java.awt.Font("Tahoma", 0, 12)); // NOI18N - org.openide.awt.Mnemonics.setLocalizedText(removeButton1, org.openide.util.NbBundle.getMessage(DashboardTopComponent.class, "DashboardTopComponent.removeButton1.text")); // NOI18N + org.openide.awt.Mnemonics.setLocalizedText(removeButton1, org.openide.util.NbBundle.getMessage(ProjectTopComp.class, "ProjectTopComp.removeButton1.text")); // NOI18N gridBagConstraints = new java.awt.GridBagConstraints(); gridBagConstraints.gridx = 1; gridBagConstraints.gridy = 0; @@ -105,7 +106,7 @@ public final class DashboardTopComponent extends TopComponent { jPanel5.add(removeButton1, gridBagConstraints); selectAllButton1.setFont(new java.awt.Font("Tahoma", 0, 12)); // NOI18N - org.openide.awt.Mnemonics.setLocalizedText(selectAllButton1, org.openide.util.NbBundle.getMessage(DashboardTopComponent.class, "DashboardTopComponent.selectAllButton1.text")); // NOI18N + org.openide.awt.Mnemonics.setLocalizedText(selectAllButton1, org.openide.util.NbBundle.getMessage(ProjectTopComp.class, "ProjectTopComp.selectAllButton1.text")); // NOI18N gridBagConstraints = new java.awt.GridBagConstraints(); gridBagConstraints.gridx = 2; gridBagConstraints.gridy = 0; @@ -114,7 +115,7 @@ public final class DashboardTopComponent extends TopComponent { jPanel5.add(selectAllButton1, gridBagConstraints); deselectAllButton1.setFont(new java.awt.Font("Tahoma", 0, 12)); // NOI18N - org.openide.awt.Mnemonics.setLocalizedText(deselectAllButton1, org.openide.util.NbBundle.getMessage(DashboardTopComponent.class, "DashboardTopComponent.deselectAllButton1.text")); // NOI18N + org.openide.awt.Mnemonics.setLocalizedText(deselectAllButton1, org.openide.util.NbBundle.getMessage(ProjectTopComp.class, "ProjectTopComp.deselectAllButton1.text")); // NOI18N gridBagConstraints = new java.awt.GridBagConstraints(); gridBagConstraints.gridx = 3; gridBagConstraints.gridy = 0; @@ -123,7 +124,7 @@ public final class DashboardTopComponent extends TopComponent { jPanel5.add(deselectAllButton1, gridBagConstraints); collapseButton1.setFont(new java.awt.Font("Tahoma", 0, 12)); // NOI18N - org.openide.awt.Mnemonics.setLocalizedText(collapseButton1, org.openide.util.NbBundle.getMessage(DashboardTopComponent.class, "DashboardTopComponent.collapseButton1.text")); // NOI18N + org.openide.awt.Mnemonics.setLocalizedText(collapseButton1, org.openide.util.NbBundle.getMessage(ProjectTopComp.class, "ProjectTopComp.collapseButton1.text")); // NOI18N gridBagConstraints = new java.awt.GridBagConstraints(); gridBagConstraints.gridx = 4; gridBagConstraints.gridy = 0; @@ -132,7 +133,7 @@ public final class DashboardTopComponent extends TopComponent { jPanel5.add(collapseButton1, gridBagConstraints); inflateButton1.setFont(new java.awt.Font("Tahoma", 0, 12)); // NOI18N - org.openide.awt.Mnemonics.setLocalizedText(inflateButton1, org.openide.util.NbBundle.getMessage(DashboardTopComponent.class, "DashboardTopComponent.inflateButton1.text")); // NOI18N + org.openide.awt.Mnemonics.setLocalizedText(inflateButton1, org.openide.util.NbBundle.getMessage(ProjectTopComp.class, "ProjectTopComp.inflateButton1.text")); // NOI18N inflateButton1.setAlignmentX(0.5F); gridBagConstraints = new java.awt.GridBagConstraints(); gridBagConstraints.gridx = 5; @@ -143,7 +144,7 @@ public final class DashboardTopComponent extends TopComponent { analyzeButton1.setBackground(new java.awt.Color(183, 240, 240)); analyzeButton1.setFont(new java.awt.Font("Tahoma", 0, 12)); // NOI18N - org.openide.awt.Mnemonics.setLocalizedText(analyzeButton1, org.openide.util.NbBundle.getMessage(DashboardTopComponent.class, "DashboardTopComponent.analyzeButton1.text")); // NOI18N + org.openide.awt.Mnemonics.setLocalizedText(analyzeButton1, org.openide.util.NbBundle.getMessage(ProjectTopComp.class, "ProjectTopComp.analyzeButton1.text")); // NOI18N analyzeButton1.setAlignmentX(0.5F); gridBagConstraints = new java.awt.GridBagConstraints(); gridBagConstraints.insets = new java.awt.Insets(16, 43, 13, 25); diff --git a/GUI/src/main/resources/cz/fidentis/analyst/gui/Bundle.properties b/GUI/src/main/resources/cz/fidentis/analyst/gui/Bundle.properties index c6936b9c..735652e9 100644 --- a/GUI/src/main/resources/cz/fidentis/analyst/gui/Bundle.properties +++ b/GUI/src/main/resources/cz/fidentis/analyst/gui/Bundle.properties @@ -5,14 +5,14 @@ PreferencesTopComponent.jSlider2.toolTipText= PreferencesTopComponent.jLabel2.text=Rotation speed PreferencesTopComponent.jSlider1.toolTipText= PreferencesTopComponent.jLabel3.text=Movement speed -DashboardTopComponent.inflateButton1.text=Inflate -DashboardTopComponent.collapseButton1.text=Collapse -DashboardTopComponent.deselectAllButton1.text=Deselect all -DashboardTopComponent.selectAllButton1.text=Select all -DashboardTopComponent.removeButton1.text=Remove -DashboardTopComponent.addButton1.text=Add -DashboardTopComponent.analyzeButton1.text=Open 1:1 AligmentTopComponent.jLabel1.text=Registration AligmentTopComponent.jButton1.text=Register AligmentTopComponent.jLabel2.text=Primary color AligmentTopComponent.jLabel3.text=Secondary color +ProjectTopComp.deselectAllButton1.text=Deselect all +ProjectTopComp.selectAllButton1.text=Select all +ProjectTopComp.removeButton1.text=Remove +ProjectTopComp.addButton1.text=Add +ProjectTopComp.analyzeButton1.text=Open 1:1 +ProjectTopComp.inflateButton1.text=Inflate +ProjectTopComp.collapseButton1.text=Collapse -- GitLab