Skip to content
Snippets Groups Projects
Commit 394cd0cd authored by Radek Ošlejšek's avatar Radek Ošlejšek
Browse files

Merge branch...

Merge branch '158-upgrade-project-tab-load-landmarks-open-close-tabs-from-menu-save-project-when-closing-app' into 'master'

Resolve "Upgrade project tab (opening and closing app changes; analyse models; opening preview image)"

Closes #158

See merge request grp-fidentis/analyst2!176
parents 4719829d f5315c9b
No related branches found
No related tags found
No related merge requests found
Showing
with 258 additions and 191 deletions
......@@ -4,7 +4,6 @@ import cz.fidentis.analyst.face.HumanFace;
import java.io.File;
import java.io.IOException;
import java.nio.file.Path;
import java.nio.file.Paths;
import java.util.ArrayList;
import java.util.Collections;
import java.util.List;
......@@ -219,10 +218,7 @@ public class Project {
Path path = this.getCfg().getPathToFaceByName(name);
File file = path.toFile();
face = new HumanFace(file, true); // loads also landmarks, if exist
String pathString = path.toString();
Path preview = Paths.get(pathString.substring(0, pathString.lastIndexOf(".")).concat("_preview.jpg"));
//Path previewSmall = Paths.get(pathString.substring(0, pathString.lastIndexOf(".")).concat("_preview_small.png"));
Path preview = path.resolveSibling(name.concat("_preview.jpg"));
face.setPreview(preview);
this.addFace(face);
out.printDuration("Loaded model " + face.getShortName() +" with " + face.getMeshModel().getNumVertices() + " vertices");
......
......@@ -81,7 +81,9 @@ public class ProjectConfiguration {
List<File> f = new ArrayList<>();
paths.forEach(p -> {
f.add(p.toFile());
if (p.toFile().exists()) {
f.add(p.toFile());
}
});
return f;
......
package cz.fidentis.analyst.gui;
import cz.fidentis.analyst.project.ProjectTopComp;
import javax.swing.JOptionPane;
import javax.swing.UIManager;
import javax.swing.UnsupportedLookAndFeelException;
......@@ -11,7 +12,24 @@ import org.openide.modules.ModuleInstall;
* @author Radek Oslejsek
*/
public class Installer extends ModuleInstall {
private ProjectTopComp projectTopComp;
/**
* Constructor with projectTopComp
* @param projectTopComp ProjectTopComp
*/
public Installer(ProjectTopComp projectTopComp) {
this.projectTopComp = projectTopComp;
}
/**
* Default constructor
*/
public Installer() {
//super();
}
@Override
public void restored() {
try {
......@@ -40,9 +58,14 @@ public class Installer extends ModuleInstall {
@Override
public boolean closing() {
if (projectTopComp != null) {
projectTopComp.saveProjectOnClose();
}
int answer = JOptionPane.showConfirmDialog(null,
"Do you really want to close the application?", "", JOptionPane.YES_NO_OPTION, JOptionPane.WARNING_MESSAGE);
return answer == JOptionPane.YES_OPTION;
return answer == JOptionPane.YES_OPTION;
}
......
......@@ -301,6 +301,9 @@
<ResourceString bundle="cz/fidentis/analyst/project/Bundle.properties" key="FaceStatePanel.photo.text" replaceFormat="org.openide.util.NbBundle.getMessage({sourceFileName}.class, &quot;{key}&quot;)"/>
</Property>
</Properties>
<Events>
<EventHandler event="mouseClicked" listener="java.awt.event.MouseListener" parameters="java.awt.event.MouseEvent" handler="photoMouseClicked"/>
</Events>
</Component>
</SubComponents>
</Container>
......
......@@ -2,7 +2,9 @@ package cz.fidentis.analyst.project;
import cz.fidentis.analyst.core.ControlPanel;
import cz.fidentis.analyst.face.HumanFace;
import java.awt.Dimension;
import java.awt.Image;
import java.awt.Toolkit;
import java.awt.event.ActionListener;
import java.io.IOException;
import java.nio.file.Files;
......@@ -10,6 +12,7 @@ import java.nio.file.Path;
import java.nio.file.Paths;
import javax.imageio.ImageIO;
import javax.swing.ImageIcon;
import javax.swing.JOptionPane;
/**
*
......@@ -21,6 +24,7 @@ public class FaceStatePanel extends ControlPanel {
private final ImageIcon check = new ImageIcon(FaceStatePanel.class.getClassLoader().getResource("/" + "check16x16.png"));
//private final ImageIcon warning = new ImageIcon(FaceStatePanel.class.getClassLoader().getResource("/" + "warning16x16.png"));
private final ImageIcon anonymousFace = new ImageIcon(FaceStatePanel.class.getClassLoader().getResource("/" + "face160x160.png"));
private ImageIcon previewFace = null;
public static final String ICON = "head28x28.png";
public static final String NAME = "Face State";
......@@ -175,6 +179,11 @@ public class FaceStatePanel extends ControlPanel {
photo.setIcon(new javax.swing.ImageIcon(getClass().getResource("/face160x160.png"))); // NOI18N
org.openide.awt.Mnemonics.setLocalizedText(photo, org.openide.util.NbBundle.getMessage(FaceStatePanel.class, "FaceStatePanel.photo.text")); // NOI18N
photo.addMouseListener(new java.awt.event.MouseAdapter() {
public void mouseClicked(java.awt.event.MouseEvent evt) {
photoMouseClicked(evt);
}
});
javax.swing.GroupLayout photoPanelLayout = new javax.swing.GroupLayout(photoPanel);
photoPanel.setLayout(photoPanelLayout);
......@@ -219,6 +228,14 @@ public class FaceStatePanel extends ControlPanel {
filePanel.getAccessibleContext().setAccessibleName(org.openide.util.NbBundle.getMessage(FaceStatePanel.class, "FaceStatePanel.filePanel.AccessibleContext.accessibleName")); // NOI18N
}// </editor-fold>//GEN-END:initComponents
private void photoMouseClicked(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_photoMouseClicked
if (previewFace != null) {
JOptionPane.showMessageDialog(this.getParent(), previewFace, "Preview Image", JOptionPane.PLAIN_MESSAGE);
}
}//GEN-LAST:event_photoMouseClicked
/**
* Shows face information on panel
......@@ -250,11 +267,16 @@ public class FaceStatePanel extends ControlPanel {
private ImageIcon getPhoto(HumanFace face, Path path) {
ImageIcon image;
previewFace = null;
Dimension screenSize = Toolkit.getDefaultToolkit().getScreenSize();
if (face != null) {
if (face.getPreview() != null) {
previewFace = new ImageIcon(face.getPreview().getScaledInstance((int)screenSize.getWidth() - 100, (int)screenSize.getHeight() - 100, Image.SCALE_FAST));
photo.setToolTipText("Click to enlarge the image");
return new ImageIcon(face.getPreview().getScaledInstance(240, 160, Image.SCALE_FAST));
}
photo.setToolTipText("");
return anonymousFace;
}
......@@ -264,12 +286,16 @@ public class FaceStatePanel extends ControlPanel {
Path preview = Paths.get(pathString.substring(0, pathString.lastIndexOf(".")).concat("_preview.jpg"));
try {
image = new ImageIcon(ImageIO.read(preview.toFile()).getScaledInstance(240, 160, Image.SCALE_FAST));
previewFace = new ImageIcon(ImageIO.read(preview.toFile()).getScaledInstance((int)screenSize.getWidth() - 200, (int)screenSize.getHeight() - 200, Image.SCALE_FAST));
image = new ImageIcon(previewFace.getImage().getScaledInstance(240, 160, Image.SCALE_FAST));
photo.setToolTipText("Click to enlarge the image");
return image;
} catch (IOException ex) {
//Exceptions.printStackTrace(ex);)
}
}
photo.setToolTipText("");
return anonymousFace;
}
......
<?xml version="1.0" encoding="UTF-8" ?>
<Form version="1.5" maxVersion="1.9" type="org.netbeans.modules.form.forminfo.JPanelFormInfo">
<Form version="1.9" maxVersion="1.9" type="org.netbeans.modules.form.forminfo.JPanelFormInfo">
<AuxValues>
<AuxValue name="FormSettings_autoResourcing" type="java.lang.Integer" value="1"/>
<AuxValue name="FormSettings_autoSetComponentName" type="java.lang.Boolean" value="false"/>
......@@ -21,9 +21,9 @@
<Group type="103" groupAlignment="1" attributes="0">
<Component id="saveProjectButton" min="-2" max="-2" attributes="0"/>
<Group type="102" alignment="1" attributes="0">
<Group type="103" groupAlignment="0" max="-2" attributes="0">
<Component id="buttonsPanel" alignment="0" max="32767" attributes="0"/>
<Component id="faceTableScrollPanel" alignment="0" min="-2" pref="863" max="-2" attributes="0"/>
<Group type="103" groupAlignment="1" max="-2" attributes="0">
<Component id="faceTableScrollPanel" pref="863" max="32767" attributes="0"/>
<Component id="buttonsPanel" max="32767" attributes="0"/>
</Group>
<Group type="103" groupAlignment="0" attributes="0">
<Group type="102" alignment="0" attributes="0">
......@@ -44,17 +44,17 @@
<DimensionLayout dim="1">
<Group type="103" groupAlignment="0" attributes="0">
<Group type="102" alignment="0" attributes="0">
<EmptySpace min="-2" pref="12" max="-2" attributes="0"/>
<Group type="103" groupAlignment="0" attributes="0">
<Group type="102" alignment="0" attributes="0">
<Component id="buttonsPanel" min="-2" max="-2" attributes="0"/>
<EmptySpace min="-2" pref="6" max="-2" attributes="0"/>
<Group type="102" attributes="0">
<EmptySpace min="-2" pref="23" max="-2" attributes="0"/>
<Component id="newProjectButton" min="-2" max="-2" attributes="0"/>
</Group>
<Group type="102" alignment="1" attributes="0">
<Component id="newProjectButton" min="-2" max="-2" attributes="0"/>
<EmptySpace type="separate" max="-2" attributes="0"/>
<EmptySpace max="-2" attributes="0"/>
<Component id="buttonsPanel" max="-2" attributes="0"/>
</Group>
</Group>
<EmptySpace max="-2" attributes="0"/>
<Group type="103" groupAlignment="0" attributes="0">
<Component id="faceTableScrollPanel" min="-2" pref="768" max="-2" attributes="0"/>
<Group type="102" alignment="0" attributes="0">
......@@ -63,7 +63,7 @@
<Component id="openProjectButton" min="-2" max="-2" attributes="0"/>
</Group>
</Group>
<EmptySpace max="32767" attributes="0"/>
<EmptySpace pref="12" max="32767" attributes="0"/>
</Group>
</Group>
</DimensionLayout>
......@@ -97,7 +97,7 @@
</Events>
<Constraints>
<Constraint layoutClass="org.netbeans.modules.form.compat2.layouts.DesignGridBagLayout" value="org.netbeans.modules.form.compat2.layouts.DesignGridBagLayout$GridBagConstraintsDescription">
<GridBagConstraints gridX="0" gridY="0" gridWidth="1" gridHeight="1" fill="0" ipadX="20" ipadY="0" insetsTop="16" insetsLeft="16" insetsBottom="13" insetsRight="4" anchor="13" weightX="0.0" weightY="0.0"/>
<GridBagConstraints gridX="0" gridY="0" gridWidth="1" gridHeight="1" fill="0" ipadX="20" ipadY="0" insetsTop="16" insetsLeft="0" insetsBottom="13" insetsRight="4" anchor="13" weightX="0.0" weightY="0.0"/>
</Constraint>
</Constraints>
</Component>
......@@ -174,43 +174,6 @@
</Constraint>
</Constraints>
</Component>
<Component class="javax.swing.JButton" name="oneOnOneButton">
<Properties>
<Property name="font" type="java.awt.Font" editor="org.netbeans.beaninfo.editors.FontEditor">
<Font name="Tahoma" size="12" style="1"/>
</Property>
<Property name="text" type="java.lang.String" editor="org.netbeans.modules.i18n.form.FormI18nStringEditor">
<ResourceString bundle="cz/fidentis/analyst/project/Bundle.properties" key="ProjectPanel.oneOnOneButton.text" replaceFormat="org.openide.util.NbBundle.getMessage({sourceFileName}.class, &quot;{key}&quot;)"/>
</Property>
<Property name="alignmentX" type="float" value="0.5"/>
</Properties>
<Events>
<EventHandler event="mouseClicked" listener="java.awt.event.MouseListener" parameters="java.awt.event.MouseEvent" handler="oneOnOneButtonMouseClicked"/>
</Events>
<Constraints>
<Constraint layoutClass="org.netbeans.modules.form.compat2.layouts.DesignGridBagLayout" value="org.netbeans.modules.form.compat2.layouts.DesignGridBagLayout$GridBagConstraintsDescription">
<GridBagConstraints gridX="6" gridY="0" gridWidth="1" gridHeight="1" fill="0" ipadX="0" ipadY="0" insetsTop="16" insetsLeft="11" insetsBottom="13" insetsRight="4" anchor="18" weightX="0.0" weightY="0.0"/>
</Constraint>
</Constraints>
</Component>
<Component class="javax.swing.JButton" name="manyToManyButton">
<Properties>
<Property name="font" type="java.awt.Font" editor="org.netbeans.beaninfo.editors.FontEditor">
<Font name="Tahoma" size="12" style="1"/>
</Property>
<Property name="text" type="java.lang.String" editor="org.netbeans.modules.i18n.form.FormI18nStringEditor">
<ResourceString bundle="cz/fidentis/analyst/project/Bundle.properties" key="ProjectPanel.manyToManyButton.text" replaceFormat="org.openide.util.NbBundle.getMessage({sourceFileName}.class, &quot;{key}&quot;)"/>
</Property>
</Properties>
<Events>
<EventHandler event="mouseClicked" listener="java.awt.event.MouseListener" parameters="java.awt.event.MouseEvent" handler="manyToManyButtonMouseClicked"/>
</Events>
<Constraints>
<Constraint layoutClass="org.netbeans.modules.form.compat2.layouts.DesignGridBagLayout" value="org.netbeans.modules.form.compat2.layouts.DesignGridBagLayout$GridBagConstraintsDescription">
<GridBagConstraints gridX="5" gridY="0" gridWidth="1" gridHeight="1" fill="0" ipadX="0" ipadY="0" insetsTop="16" insetsLeft="30" insetsBottom="13" insetsRight="4" anchor="18" weightX="0.0" weightY="0.0"/>
</Constraint>
</Constraints>
</Component>
<Component class="javax.swing.JButton" name="analyseButton">
<Properties>
<Property name="font" type="java.awt.Font" editor="org.netbeans.beaninfo.editors.FontEditor">
......@@ -221,11 +184,11 @@
</Property>
</Properties>
<Events>
<EventHandler event="mouseClicked" listener="java.awt.event.MouseListener" parameters="java.awt.event.MouseEvent" handler="analyseButtonMouseClicked"/>
<EventHandler event="mouseClicked" listener="java.awt.event.MouseListener" parameters="java.awt.event.MouseEvent" handler="analyseFaces"/>
</Events>
<Constraints>
<Constraint layoutClass="org.netbeans.modules.form.compat2.layouts.DesignGridBagLayout" value="org.netbeans.modules.form.compat2.layouts.DesignGridBagLayout$GridBagConstraintsDescription">
<GridBagConstraints gridX="7" gridY="0" gridWidth="1" gridHeight="1" fill="0" ipadX="0" ipadY="0" insetsTop="16" insetsLeft="11" insetsBottom="13" insetsRight="4" anchor="10" weightX="0.0" weightY="0.0"/>
<GridBagConstraints gridX="5" gridY="0" gridWidth="1" gridHeight="1" fill="0" ipadX="0" ipadY="0" insetsTop="16" insetsLeft="75" insetsBottom="13" insetsRight="4" anchor="10" weightX="0.0" weightY="0.0"/>
</Constraint>
</Constraints>
</Component>
......
......@@ -3,9 +3,11 @@ package cz.fidentis.analyst.project;
import cz.fidentis.analyst.core.ControlPanel;
import cz.fidentis.analyst.core.OutputWindowThread;
import cz.fidentis.analyst.core.TopControlPanel;
import cz.fidentis.analyst.gui.Installer;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import javax.swing.GroupLayout;
import javax.swing.JOptionPane;
import javax.swing.JScrollPane;
import javax.swing.LayoutStyle;
import org.netbeans.api.settings.ConvertAsProperties;
......@@ -107,6 +109,8 @@ public final class ProjectTopComp extends TopComponent {
// Asks user whether he wants to create new project or open existing
projectPanel.openExistingOrNewProject();
// Pass this class to installer so it can call method of this class on close
Installer inst = new Installer(this);
}
private void initComponents() {
......@@ -160,9 +164,12 @@ public final class ProjectTopComp extends TopComponent {
// TODO read your settings according to their version
}
/*
@Override
public boolean canClose() {
/**
* Checks whether currently opened project is saved or not and asks user
* whether he wants to save it or not on close
*/
public void saveProjectOnClose() {
if (!projectPanel.isProjectSaved()) {
int save = JOptionPane.showConfirmDialog(null,
......@@ -172,6 +179,5 @@ public final class ProjectTopComp extends TopComponent {
projectPanel.saveProject();
}
}
return super.canClose(); //To change body of generated methods, choose Tools | Templates.
}*/
}
}
......@@ -26,8 +26,6 @@ ProjectPanel.newProjectButton.text=
ProjectPanel.openProjectButton.text=
ProjectPanel.saveProjectButton.text=
ProjectPanel.analyseButton.text=Analyse
ProjectPanel.manyToManyButton.text=N:N
ProjectPanel.oneOnOneButton.text=Open 1:1
ProjectPanel.inflateButton.text=Inflate
ProjectPanel.deselectAllButton.text=Deselect all
ProjectPanel.selectAllButton.text=Select all
......
GUI/src/main/resources/recent_project.png

3.64 KiB

0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment