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

Merge branch '168-adapt-filter-tab' into 'master'

Resolve "Adapt Filter tab"

Closes #168

See merge request grp-fidentis/analyst2!184
parents a1d037ac be46d007
No related branches found
No related tags found
No related merge requests found
Showing
with 1644 additions and 521 deletions
......@@ -110,5 +110,35 @@ public class Project {
}
return null;
}
/**
* Checks whether model saved in this project has in the same directory
* file with feature points
* @param name String name of face
* @return true if feature points file was found, false otherwise
*/
public boolean hasFPByName(String name) {
Path path = this.getCfg().getPathToFaceByName(name);
if (path != null) {
String filePath = path.toString().split(".obj")[0] + "_landmarks.csv";
if ((new File(filePath)).exists()) {
return true;
}
filePath = path.toString().split("_ECA")[0] + "_landmarks.csv";
if ((new File(filePath)).exists()) {
return true;
}
filePath = path.toString().split("_CA")[0] + "_landmarks.csv";
if ((new File(filePath)).exists()) {
return true;
}
}
return false;
}
}
......@@ -64,7 +64,7 @@ public class ProjectConfiguration {
* @param name String name of file
* @return Path to face
*/
public Path getPathToFaceByName(String name) {
public Path getPathToFaceByName(String name) {
for (Path p : paths) {
if (p.toString().substring(p.toString().lastIndexOf(File.separatorChar) + 1, p.toString().lastIndexOf('.')).equals(name)) {
return p;
......
package cz.fidentis.analyst.project;
package cz.fidentis.analyst.faceState;
import java.util.List;
......
......@@ -47,7 +47,7 @@
<Property name="border" type="javax.swing.border.Border" editor="org.netbeans.modules.form.editors2.BorderEditor">
<Border info="org.netbeans.modules.form.compat2.border.TitledBorderInfo">
<TitledBorder title="File info">
<ResourceString PropertyName="titleX" bundle="cz/fidentis/analyst/project/Bundle.properties" key="FaceStatePanel.filePanel.border.title" replaceFormat="org.openide.util.NbBundle.getMessage({sourceFileName}.class, &quot;{key}&quot;)"/>
<ResourceString PropertyName="titleX" bundle="cz/fidentis/analyst/faceState/Bundle.properties" key="FaceStatePanel.filePanel.border.title" replaceFormat="org.openide.util.NbBundle.getMessage({sourceFileName}.class, &quot;{key}&quot;)"/>
<Font PropertyName="font" name="Dialog" size="14" style="1"/>
</TitledBorder>
</Border>
......@@ -55,7 +55,7 @@
</Properties>
<AccessibilityProperties>
<Property name="AccessibleContext.accessibleName" type="java.lang.String" editor="org.netbeans.modules.i18n.form.FormI18nStringEditor">
<ResourceString bundle="cz/fidentis/analyst/project/Bundle.properties" key="FaceStatePanel.filePanel.AccessibleContext.accessibleName" replaceFormat="org.openide.util.NbBundle.getMessage({sourceFileName}.class, &quot;{key}&quot;)"/>
<ResourceString bundle="cz/fidentis/analyst/faceState/Bundle.properties" key="FaceStatePanel.filePanel.AccessibleContext.accessibleName" replaceFormat="org.openide.util.NbBundle.getMessage({sourceFileName}.class, &quot;{key}&quot;)"/>
</Property>
</AccessibilityProperties>
......@@ -125,7 +125,7 @@
<Font name="Tahoma" size="10" 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="FaceStatePanel.pathLabel.text" replaceFormat="org.openide.util.NbBundle.getMessage({sourceFileName}.class, &quot;{key}&quot;)"/>
<ResourceString bundle="cz/fidentis/analyst/faceState/Bundle.properties" key="FaceStatePanel.pathLabel.text" replaceFormat="org.openide.util.NbBundle.getMessage({sourceFileName}.class, &quot;{key}&quot;)"/>
</Property>
<Property name="enabled" type="boolean" value="false"/>
</Properties>
......@@ -133,7 +133,7 @@
<Component class="javax.swing.JLabel" name="pathOutput">
<Properties>
<Property name="text" type="java.lang.String" editor="org.netbeans.modules.i18n.form.FormI18nStringEditor">
<ResourceString bundle="cz/fidentis/analyst/project/Bundle.properties" key="FaceStatePanel.pathOutput.text" replaceFormat="org.openide.util.NbBundle.getMessage({sourceFileName}.class, &quot;{key}&quot;)"/>
<ResourceString bundle="cz/fidentis/analyst/faceState/Bundle.properties" key="FaceStatePanel.pathOutput.text" replaceFormat="org.openide.util.NbBundle.getMessage({sourceFileName}.class, &quot;{key}&quot;)"/>
</Property>
</Properties>
</Component>
......@@ -143,7 +143,7 @@
<Font name="Tahoma" size="10" 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="FaceStatePanel.sizeLabel.text" replaceFormat="org.openide.util.NbBundle.getMessage({sourceFileName}.class, &quot;{key}&quot;)"/>
<ResourceString bundle="cz/fidentis/analyst/faceState/Bundle.properties" key="FaceStatePanel.sizeLabel.text" replaceFormat="org.openide.util.NbBundle.getMessage({sourceFileName}.class, &quot;{key}&quot;)"/>
</Property>
<Property name="enabled" type="boolean" value="false"/>
</Properties>
......@@ -151,7 +151,7 @@
<Component class="javax.swing.JLabel" name="sizeOutput">
<Properties>
<Property name="text" type="java.lang.String" editor="org.netbeans.modules.i18n.form.FormI18nStringEditor">
<ResourceString bundle="cz/fidentis/analyst/project/Bundle.properties" key="FaceStatePanel.sizeOutput.text" replaceFormat="org.openide.util.NbBundle.getMessage({sourceFileName}.class, &quot;{key}&quot;)"/>
<ResourceString bundle="cz/fidentis/analyst/faceState/Bundle.properties" key="FaceStatePanel.sizeOutput.text" replaceFormat="org.openide.util.NbBundle.getMessage({sourceFileName}.class, &quot;{key}&quot;)"/>
</Property>
</Properties>
</Component>
......@@ -161,7 +161,7 @@
<Font name="Tahoma" size="10" 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="FaceStatePanel.featurePointsLabel.text" replaceFormat="org.openide.util.NbBundle.getMessage({sourceFileName}.class, &quot;{key}&quot;)"/>
<ResourceString bundle="cz/fidentis/analyst/faceState/Bundle.properties" key="FaceStatePanel.featurePointsLabel.text" replaceFormat="org.openide.util.NbBundle.getMessage({sourceFileName}.class, &quot;{key}&quot;)"/>
</Property>
<Property name="enabled" type="boolean" value="false"/>
</Properties>
......@@ -169,7 +169,7 @@
<Component class="javax.swing.JLabel" name="featurePointsOutput">
<Properties>
<Property name="text" type="java.lang.String" editor="org.netbeans.modules.i18n.form.FormI18nStringEditor">
<ResourceString bundle="cz/fidentis/analyst/project/Bundle.properties" key="FaceStatePanel.featurePointsOutput.text" replaceFormat="org.openide.util.NbBundle.getMessage({sourceFileName}.class, &quot;{key}&quot;)"/>
<ResourceString bundle="cz/fidentis/analyst/faceState/Bundle.properties" key="FaceStatePanel.featurePointsOutput.text" replaceFormat="org.openide.util.NbBundle.getMessage({sourceFileName}.class, &quot;{key}&quot;)"/>
</Property>
</Properties>
</Component>
......@@ -179,7 +179,7 @@
<Font name="Tahoma" size="10" 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="FaceStatePanel.previewLabel.text" replaceFormat="org.openide.util.NbBundle.getMessage({sourceFileName}.class, &quot;{key}&quot;)"/>
<ResourceString bundle="cz/fidentis/analyst/faceState/Bundle.properties" key="FaceStatePanel.previewLabel.text" replaceFormat="org.openide.util.NbBundle.getMessage({sourceFileName}.class, &quot;{key}&quot;)"/>
</Property>
<Property name="enabled" type="boolean" value="false"/>
</Properties>
......@@ -187,7 +187,7 @@
<Component class="javax.swing.JLabel" name="previewOutput">
<Properties>
<Property name="text" type="java.lang.String" editor="org.netbeans.modules.i18n.form.FormI18nStringEditor">
<ResourceString bundle="cz/fidentis/analyst/project/Bundle.properties" key="FaceStatePanel.previewOutput.text" replaceFormat="org.openide.util.NbBundle.getMessage({sourceFileName}.class, &quot;{key}&quot;)"/>
<ResourceString bundle="cz/fidentis/analyst/faceState/Bundle.properties" key="FaceStatePanel.previewOutput.text" replaceFormat="org.openide.util.NbBundle.getMessage({sourceFileName}.class, &quot;{key}&quot;)"/>
</Property>
</Properties>
</Component>
......@@ -197,7 +197,7 @@
<Font name="Tahoma" size="10" 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="FaceStatePanel.textureLabel.text" replaceFormat="org.openide.util.NbBundle.getMessage({sourceFileName}.class, &quot;{key}&quot;)"/>
<ResourceString bundle="cz/fidentis/analyst/faceState/Bundle.properties" key="FaceStatePanel.textureLabel.text" replaceFormat="org.openide.util.NbBundle.getMessage({sourceFileName}.class, &quot;{key}&quot;)"/>
</Property>
<Property name="enabled" type="boolean" value="false"/>
</Properties>
......@@ -205,7 +205,7 @@
<Component class="javax.swing.JLabel" name="textureOutput">
<Properties>
<Property name="text" type="java.lang.String" editor="org.netbeans.modules.i18n.form.FormI18nStringEditor">
<ResourceString bundle="cz/fidentis/analyst/project/Bundle.properties" key="FaceStatePanel.textureOutput.text" replaceFormat="org.openide.util.NbBundle.getMessage({sourceFileName}.class, &quot;{key}&quot;)"/>
<ResourceString bundle="cz/fidentis/analyst/faceState/Bundle.properties" key="FaceStatePanel.textureOutput.text" replaceFormat="org.openide.util.NbBundle.getMessage({sourceFileName}.class, &quot;{key}&quot;)"/>
</Property>
</Properties>
</Component>
......@@ -216,7 +216,7 @@
<Property name="border" type="javax.swing.border.Border" editor="org.netbeans.modules.form.editors2.BorderEditor">
<Border info="org.netbeans.modules.form.compat2.border.TitledBorderInfo">
<TitledBorder title="Geometry info">
<ResourceString PropertyName="titleX" bundle="cz/fidentis/analyst/project/Bundle.properties" key="FaceStatePanel.geometryPanel.border.title" replaceFormat="org.openide.util.NbBundle.getMessage({sourceFileName}.class, &quot;{key}&quot;)"/>
<ResourceString PropertyName="titleX" bundle="cz/fidentis/analyst/faceState/Bundle.properties" key="FaceStatePanel.geometryPanel.border.title" replaceFormat="org.openide.util.NbBundle.getMessage({sourceFileName}.class, &quot;{key}&quot;)"/>
<Font PropertyName="font" name="Dialog" size="14" style="1"/>
</TitledBorder>
</Border>
......@@ -291,7 +291,7 @@
<Font name="Tahoma" size="10" 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="FaceStatePanel.verticesLabel.text" replaceFormat="org.openide.util.NbBundle.getMessage({sourceFileName}.class, &quot;{key}&quot;)"/>
<ResourceString bundle="cz/fidentis/analyst/faceState/Bundle.properties" key="FaceStatePanel.verticesLabel.text" replaceFormat="org.openide.util.NbBundle.getMessage({sourceFileName}.class, &quot;{key}&quot;)"/>
</Property>
<Property name="enabled" type="boolean" value="false"/>
</Properties>
......@@ -299,7 +299,7 @@
<Component class="javax.swing.JLabel" name="verticesOutput">
<Properties>
<Property name="text" type="java.lang.String" editor="org.netbeans.modules.i18n.form.FormI18nStringEditor">
<ResourceString bundle="cz/fidentis/analyst/project/Bundle.properties" key="FaceStatePanel.verticesOutput.text" replaceFormat="org.openide.util.NbBundle.getMessage({sourceFileName}.class, &quot;{key}&quot;)"/>
<ResourceString bundle="cz/fidentis/analyst/faceState/Bundle.properties" key="FaceStatePanel.verticesOutput.text" replaceFormat="org.openide.util.NbBundle.getMessage({sourceFileName}.class, &quot;{key}&quot;)"/>
</Property>
</Properties>
</Component>
......@@ -309,7 +309,7 @@
<Font name="Tahoma" size="10" 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="FaceStatePanel.facetsLabel.text" replaceFormat="org.openide.util.NbBundle.getMessage({sourceFileName}.class, &quot;{key}&quot;)"/>
<ResourceString bundle="cz/fidentis/analyst/faceState/Bundle.properties" key="FaceStatePanel.facetsLabel.text" replaceFormat="org.openide.util.NbBundle.getMessage({sourceFileName}.class, &quot;{key}&quot;)"/>
</Property>
<Property name="enabled" type="boolean" value="false"/>
</Properties>
......@@ -317,7 +317,7 @@
<Component class="javax.swing.JLabel" name="facetsOutput">
<Properties>
<Property name="text" type="java.lang.String" editor="org.netbeans.modules.i18n.form.FormI18nStringEditor">
<ResourceString bundle="cz/fidentis/analyst/project/Bundle.properties" key="FaceStatePanel.facetsOutput.text" replaceFormat="org.openide.util.NbBundle.getMessage({sourceFileName}.class, &quot;{key}&quot;)"/>
<ResourceString bundle="cz/fidentis/analyst/faceState/Bundle.properties" key="FaceStatePanel.facetsOutput.text" replaceFormat="org.openide.util.NbBundle.getMessage({sourceFileName}.class, &quot;{key}&quot;)"/>
</Property>
</Properties>
</Component>
......@@ -327,7 +327,7 @@
<Font name="Tahoma" size="10" 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="FaceStatePanel.fpLabel.text" replaceFormat="org.openide.util.NbBundle.getMessage({sourceFileName}.class, &quot;{key}&quot;)"/>
<ResourceString bundle="cz/fidentis/analyst/faceState/Bundle.properties" key="FaceStatePanel.fpLabel.text" replaceFormat="org.openide.util.NbBundle.getMessage({sourceFileName}.class, &quot;{key}&quot;)"/>
</Property>
<Property name="enabled" type="boolean" value="false"/>
</Properties>
......@@ -348,7 +348,7 @@
<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="FaceStatePanel.loadInfoButton.text" replaceFormat="org.openide.util.NbBundle.getMessage({sourceFileName}.class, &quot;{key}&quot;)"/>
<ResourceString bundle="cz/fidentis/analyst/faceState/Bundle.properties" key="FaceStatePanel.loadInfoButton.text" replaceFormat="org.openide.util.NbBundle.getMessage({sourceFileName}.class, &quot;{key}&quot;)"/>
</Property>
</Properties>
</Component>
......@@ -359,7 +359,7 @@
<Property name="border" type="javax.swing.border.Border" editor="org.netbeans.modules.form.editors2.BorderEditor">
<Border info="org.netbeans.modules.form.compat2.border.TitledBorderInfo">
<TitledBorder title="Photo">
<ResourceString PropertyName="titleX" bundle="cz/fidentis/analyst/project/Bundle.properties" key="FaceStatePanel.photoPanel.border.title" replaceFormat="org.openide.util.NbBundle.getMessage({sourceFileName}.class, &quot;{key}&quot;)"/>
<ResourceString PropertyName="titleX" bundle="cz/fidentis/analyst/faceState/Bundle.properties" key="FaceStatePanel.photoPanel.border.title" replaceFormat="org.openide.util.NbBundle.getMessage({sourceFileName}.class, &quot;{key}&quot;)"/>
<Font PropertyName="font" name="Dialog" size="14" style="1"/>
</TitledBorder>
</Border>
......@@ -393,7 +393,7 @@
<Image iconType="3" name="/face160x160.png"/>
</Property>
<Property name="text" type="java.lang.String" editor="org.netbeans.modules.i18n.form.FormI18nStringEditor">
<ResourceString bundle="cz/fidentis/analyst/project/Bundle.properties" key="FaceStatePanel.photo.text" replaceFormat="org.openide.util.NbBundle.getMessage({sourceFileName}.class, &quot;{key}&quot;)"/>
<ResourceString bundle="cz/fidentis/analyst/faceState/Bundle.properties" key="FaceStatePanel.photo.text" replaceFormat="org.openide.util.NbBundle.getMessage({sourceFileName}.class, &quot;{key}&quot;)"/>
</Property>
</Properties>
<Events>
......
package cz.fidentis.analyst.project;
package cz.fidentis.analyst.faceState;
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.awt.image.BufferedImage;
import java.io.File;
import java.io.IOException;
import java.nio.file.Files;
......@@ -20,6 +20,7 @@ import javax.imageio.ImageIO;
import javax.swing.DefaultComboBoxModel;
import javax.swing.ImageIcon;
import javax.swing.JOptionPane;
import org.imgscalr.Scalr;
/**
*
......@@ -299,16 +300,16 @@ public class FaceStatePanel extends ControlPanel {
public void showFaceState(String faceName, Path path) {
photo.setIcon(getPhoto(path));
pathOutput.setText(getPathText(path));
sizeOutput.setText(getSizeText(path));
featurePointsOutput.setText(getFeaturePointsText(path));
previewOutput.setText(getPreviewText(path));
textureOutput.setText(getTextureText(path));
verticesOutput.setText(getNumberOfVertices(faceName));
facetsOutput.setText(getNumberOfFacets(faceName));
loadFeaturePoints(faceName);
loadFeaturePoints(faceName);
}
......@@ -324,7 +325,6 @@ public class FaceStatePanel extends ControlPanel {
*/
private ImageIcon getPhoto(Path path) {
ImageIcon image;
previewFace = null;
Dimension screenSize = Toolkit.getDefaultToolkit().getScreenSize();
......@@ -335,10 +335,14 @@ public class FaceStatePanel extends ControlPanel {
try {
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));
BufferedImage image = ImageIO.read(preview.toFile());
BufferedImage zoomedImage = Scalr.resize(image, (int)screenSize.getWidth() / 2, (int)screenSize.getHeight() / 2);
BufferedImage smallImage = Scalr.resize(image, 240, 160);
previewFace = new ImageIcon(zoomedImage);
photo.setToolTipText("Click to enlarge the image");
return image;
return new ImageIcon(smallImage);
} catch (IOException ex) {
//Exceptions.printStackTrace(ex);)
}
......
package cz.fidentis.analyst.filter;
import cz.fidentis.analyst.feature.FeaturePointType;
import cz.fidentis.analyst.feature.provider.FeaturePointTypeProvider;
import java.awt.GridBagConstraints;
import java.awt.GridBagLayout;
import java.awt.Insets;
import java.awt.event.ActionEvent;
import java.util.ArrayList;
import java.util.List;
import java.util.Map;
import java.util.stream.Collectors;
import javax.swing.AbstractAction;
import javax.swing.JCheckBox;
import javax.swing.JPanel;
/**
*
* @author Matej Kovar
*/
public class FeaturePointsFilterPanel extends JPanel {
private List<JCheckBox> featurePointCheckBoxes;
private List<FeaturePointType> selectedFeaturePoints = new ArrayList<>();
/**
* Constructor
*/
public void initComponents() {
setLayout(new GridBagLayout());
// Load all types of feature points
FeaturePointTypeProvider typeProvider = FeaturePointTypeProvider.getInstance();
Map<Integer, FeaturePointType> fpMap = typeProvider.getFeaturePointTypesById();
List<FeaturePointType> featurePoints = fpMap.values().stream()
.collect(Collectors.toList());
featurePointCheckBoxes = new ArrayList<>();
for (int i = 0; i < featurePoints.size(); i++) {
addRow(i, featurePoints.get(i));
}
}
protected void addRow(int row, FeaturePointType featurePoint) {
GridBagConstraints c1 = new GridBagConstraints();
c1.insets = new Insets(0, 0, 0, 0);
c1.gridwidth = 1;
c1.gridx = 0;
c1.gridy = row;
c1.anchor = GridBagConstraints.WEST;
c1.fill = GridBagConstraints.NONE;
JCheckBox checkBox = new JCheckBox();
checkBox.setSelected(false);
checkBox.setEnabled(false);
checkBox.setText(featurePoint.getName());
add(checkBox, c1);
featurePointCheckBoxes.add(checkBox);
checkBox.addActionListener(new AbstractAction() {
@Override
public void actionPerformed(ActionEvent e) {
if (!selectedFeaturePoints.remove(featurePoint)) {
selectedFeaturePoints.add(featurePoint);
}
}
});
}
/**
* Deselects and disables(enables) all check boxes with each feature point type
* @param enable enables or disables check boxes
*/
public void disableCheckBoxes(boolean enable) {
featurePointCheckBoxes.forEach(ch -> {
if (!enable) {
ch.setSelected(false);
}
ch.setEnabled(enable);
});
}
public List<FeaturePointType> getSelectedFeaturePoints() {
return selectedFeaturePoints;
}
@Override
public void setEnabled(boolean enable) {
this.getParent().setEnabled(enable);
disableCheckBoxes(enable);
}
}
package cz.fidentis.analyst.filter;
import java.util.ArrayList;
import java.util.List;
/**
* History of filtering, holds information of each filtering (which faces were filtered)
*
* @author Matej Kovar
*/
public class FilterHistory {
// List of each filterings
private List<List<String>> filteredFaces = new ArrayList<>();
// Sum of all filtered faces
private int totalFaces = 0;
/**
* Checks if none faces are filtered
* @return true if none faces are filtered, false otherwise
*/
public boolean isEmpty() {
return filteredFaces.isEmpty();
}
/**
* Gets amount of faces filtered
* @return how many faces are currently filtered
*/
public int getTotalFaces() {
return totalFaces;
}
/**
* Adds newly filtered faces to list
* @param faces list of filtered faces
*/
public void addFaces(List<String> faces) {
if (!faces.isEmpty()) {
filteredFaces.add(faces);
}
totalFaces += faces.size();
}
/**
* Removes face which is currently filtered
* @param faceName name of face
*/
public void removeFilteredFace(String faceName) {
filteredFaces.forEach(faces -> {
faces.removeIf(face -> face.equals(faceName));
});
totalFaces -= 1;
}
/**
* Reverts last filtering, i.e. removes lastly filtered faces from list
* @return sum of lastly filtered faces
*/
public int revertLastFiltering() {
int sumFaces = filteredFaces.get(filteredFaces.size() - 1).size();
filteredFaces.remove(filteredFaces.size() - 1);
totalFaces -= sumFaces;
return sumFaces;
}
/**
* Removes all faces filtered
* @return amount of filtered faces
*/
public int clear() {
filteredFaces.clear();
int total = totalFaces;
totalFaces = 0;
return total;
}
}
This diff is collapsed.
package cz.fidentis.analyst.filter;
import java.awt.event.ActionEvent;
import java.util.HashMap;
import java.util.Map;
import javax.swing.AbstractAction;
import javax.swing.JCheckBox;
import javax.swing.JComponent;
import javax.swing.JTextField;
/**
*
* @author Matej Kovar
*/
public class FilterSection {
// key is checkbox, value is list of all additional
// components checkbox has
private Map<JCheckBox, JComponent> options = new HashMap<>();
/**
* Adds new pair of checkbox and corresponding additional JComponent to this checkbox
* @param checkbox JCheckBox
* @param additional JComponent, null if checkbox doesn't need another component
*/
public void add(JCheckBox checkbox, JComponent additional) {
options.put(checkbox, additional);
checkbox.addActionListener(new AbstractAction() {
@Override
public void actionPerformed(ActionEvent e) {
checkboxSelected(checkbox, checkbox.isSelected());
}
});
}
/**
* Enables/disables JComponent which is associated with checkbox
* @param checkbox JCheckbox
* @param enable Boolean - true if checkbox is selected, false otherwise
*/
private void checkboxSelected(JCheckBox checkbox, boolean enable) {
JComponent c = options.get(checkbox);
if (c != null) {
c.setEnabled(enable);
}
if (c instanceof JTextField) {
((JTextField) c).setText("");
}
disableOtherComponents(checkbox);
}
/**
* Disable other components from this section, i.e. disables other checkboxes
* and their associated JComponents
* @param checkbox JCheckbox
*/
private void disableOtherComponents(JCheckBox checkbox) {
options.keySet()
.stream()
.filter(key -> (key != checkbox))
.map(key -> {
key.setSelected(false);
return key;
})
.forEachOrdered(key -> {
JComponent c = options.get(key);
if (c != null) {
c.setEnabled(false);
}
if (c instanceof JTextField) {
((JTextField) c).setText("");
}
});
}
/**
* Disables all checkboxes and components in this section
*/
public void disableAllComponents() {
options.keySet()
.stream()
.map(key -> {
key.setSelected(false);
return key;
})
.forEachOrdered(key -> {
JComponent c = options.get(key);
if (c != null) {
c.setEnabled(false);
}
if (c instanceof JTextField) {
((JTextField) c).setText("");
}
});
}
}
package cz.fidentis.analyst.filter;
import cz.fidentis.analyst.core.ProgressDialog;
import cz.fidentis.analyst.project.ModelsTableModel;
import java.util.ArrayList;
import java.util.List;
import javax.swing.SwingWorker;
/**
* A task that filters table and selects models which should be removed
*
* @author Matej Kovar
*/
public class FilterTask extends SwingWorker<Boolean, Integer>{
private final FilterPanel filterPanel;
private ModelsTableModel model;
private final ProgressDialog progressDialog;
private boolean completed = false;
private List<Integer> filteredRows = new ArrayList<>();
/**
* Constructor
*
* @param model ModelsTableModel
* @param filterPanel FilterPanel
* @param progressDialog ProgressDialog
*/
public FilterTask(ModelsTableModel model, FilterPanel filterPanel, ProgressDialog progressDialog) {
this.filterPanel = filterPanel;
this.model = model;
this.progressDialog = progressDialog;
}
@Override
protected Boolean doInBackground() throws Exception {
filteredRows.clear();
// Selects only models from list which are not filtered yet (are not in the bottom of list)
for (int row = 0; row < model.getRowCount() - filterPanel.getFilterHistory().getTotalFaces(); row++) {
if (isCancelled()) {
completed = false;
filteredRows.clear();
return false;
}
String faceName = model.getValueAt(row, 1).toString();
if (filterPanel.applyFilterOptions(faceName)) {
filteredRows.add(row);
}
int progress = (int)Math.round(100.0 * (row + 1) / model.getRowCount());
progressDialog.setValue(progress);
}
completed = true;
return true;
}
@Override
protected void done() {
progressDialog.dispose();
if (isCancelled()) {
completed = false;
filteredRows.clear();
return;
}
completed = true;
}
public boolean getCompleted() {
return completed;
}
public List<Integer> getFilteredRows() {
return filteredRows;
}
}
package cz.fidentis.analyst.project;
import cz.fidentis.analyst.core.ControlPanel;
import java.awt.event.ActionListener;
import javax.swing.ImageIcon;
import javax.swing.JCheckBox;
/**
*
* @author Matej Kovar
*/
public class FilterPanel extends ControlPanel {
private boolean kdTreeFilter = false;
private boolean featurePointsFilter = false;
private boolean alphabeticalFilter = false;
public static final String ICON = "filter28x28.png";
public static final String NAME = "Filter";
/**
* Creates new form FilterPanel
*/
public FilterPanel(ActionListener listenerLoadAllFaces) {
this.setName(NAME);
initComponents();
loadAllModelsButton.addActionListener(listenerLoadAllFaces);
}
/**
* This method is called from within the constructor to initialize the form.
* WARNING: Do NOT modify this code. The content of this method is always
* regenerated by the Form Editor.
*/
@SuppressWarnings("unchecked")
// <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
private void initComponents() {
filterPanel = new javax.swing.JPanel();
hasFP = new javax.swing.JCheckBox();
hasKD = new javax.swing.JCheckBox();
alphabetical = new javax.swing.JCheckBox();
applyFilterButton = new javax.swing.JButton();
warningLabel = new javax.swing.JLabel();
faceNotLoadedLabel = new javax.swing.JLabel();
loadAllModelsButton = new javax.swing.JButton();
filterPanel.setBorder(javax.swing.BorderFactory.createTitledBorder(null, org.openide.util.NbBundle.getMessage(FilterPanel.class, "FilterPanel.filterPanel.border.title"), javax.swing.border.TitledBorder.DEFAULT_JUSTIFICATION, javax.swing.border.TitledBorder.DEFAULT_POSITION, new java.awt.Font("Dialog", 1, 12))); // NOI18N
org.openide.awt.Mnemonics.setLocalizedText(hasFP, org.openide.util.NbBundle.getMessage(FilterPanel.class, "FilterPanel.hasFP.text")); // NOI18N
hasFP.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
hasFPActionPerformed(evt);
}
});
org.openide.awt.Mnemonics.setLocalizedText(hasKD, org.openide.util.NbBundle.getMessage(FilterPanel.class, "FilterPanel.hasKD.text")); // NOI18N
hasKD.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
hasKDActionPerformed(evt);
}
});
org.openide.awt.Mnemonics.setLocalizedText(alphabetical, org.openide.util.NbBundle.getMessage(FilterPanel.class, "FilterPanel.alphabetical.text")); // NOI18N
alphabetical.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
alphabeticalActionPerformed(evt);
}
});
applyFilterButton.setFont(new java.awt.Font("Tahoma", 1, 12)); // NOI18N
org.openide.awt.Mnemonics.setLocalizedText(applyFilterButton, org.openide.util.NbBundle.getMessage(FilterPanel.class, "FilterPanel.applyFilterButton.text")); // NOI18N
applyFilterButton.setEnabled(false);
warningLabel.setIcon(new javax.swing.ImageIcon(getClass().getResource("/warning16x16.png"))); // NOI18N
org.openide.awt.Mnemonics.setLocalizedText(warningLabel, org.openide.util.NbBundle.getMessage(FilterPanel.class, "FilterPanel.warningLabel.text")); // NOI18N
warningLabel.setVisible(false);
faceNotLoadedLabel.setFont(new java.awt.Font("Tahoma", 1, 12)); // NOI18N
org.openide.awt.Mnemonics.setLocalizedText(faceNotLoadedLabel, org.openide.util.NbBundle.getMessage(FilterPanel.class, "FilterPanel.faceNotLoadedLabel.text")); // NOI18N
faceNotLoadedLabel.setVisible(false);
loadAllModelsButton.setFont(new java.awt.Font("Tahoma", 1, 12)); // NOI18N
org.openide.awt.Mnemonics.setLocalizedText(loadAllModelsButton, org.openide.util.NbBundle.getMessage(FilterPanel.class, "FilterPanel.loadAllModelsButton.text")); // NOI18N
loadAllModelsButton.setVisible(false);
javax.swing.GroupLayout filterPanelLayout = new javax.swing.GroupLayout(filterPanel);
filterPanel.setLayout(filterPanelLayout);
filterPanelLayout.setHorizontalGroup(
filterPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(filterPanelLayout.createSequentialGroup()
.addGap(38, 38, 38)
.addGroup(filterPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING)
.addComponent(applyFilterButton)
.addGroup(filterPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addComponent(alphabetical)
.addComponent(hasKD)
.addComponent(hasFP)))
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, 201, Short.MAX_VALUE)
.addComponent(loadAllModelsButton)
.addGap(89, 89, 89))
.addGroup(javax.swing.GroupLayout.Alignment.TRAILING, filterPanelLayout.createSequentialGroup()
.addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
.addComponent(warningLabel)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
.addComponent(faceNotLoadedLabel)
.addGap(22, 22, 22))
);
filterPanelLayout.setVerticalGroup(
filterPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(filterPanelLayout.createSequentialGroup()
.addGap(40, 40, 40)
.addComponent(hasFP)
.addGap(18, 18, 18)
.addComponent(hasKD)
.addGap(18, 18, 18)
.addComponent(alphabetical)
.addGap(19, 19, 19)
.addGroup(filterPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING)
.addComponent(warningLabel)
.addComponent(faceNotLoadedLabel))
.addGap(23, 23, 23)
.addGroup(filterPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
.addComponent(applyFilterButton)
.addComponent(loadAllModelsButton))
.addContainerGap(69, Short.MAX_VALUE))
);
javax.swing.GroupLayout layout = new javax.swing.GroupLayout(this);
this.setLayout(layout);
layout.setHorizontalGroup(
layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(layout.createSequentialGroup()
.addContainerGap()
.addComponent(filterPanel, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
.addContainerGap())
);
layout.setVerticalGroup(
layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(layout.createSequentialGroup()
.addContainerGap()
.addComponent(filterPanel, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
.addContainerGap(270, Short.MAX_VALUE))
);
}// </editor-fold>//GEN-END:initComponents
/**
* Sets attribute to corresponding value based on checkbox
* @param evt
*/
private void hasFPActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_hasFPActionPerformed
featurePointsFilter = (((JCheckBox)evt.getSource()).isSelected());
}//GEN-LAST:event_hasFPActionPerformed
/**
* Sets attribute to corresponding value based on checkbox
* @param evt
*/
private void hasKDActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_hasKDActionPerformed
kdTreeFilter = (((JCheckBox)evt.getSource()).isSelected());
}//GEN-LAST:event_hasKDActionPerformed
/**
* Sets attribute to corresponding value based on checkbox
* @param evt
*/
private void alphabeticalActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_alphabeticalActionPerformed
alphabeticalFilter = (((JCheckBox)evt.getSource()).isSelected());
}//GEN-LAST:event_alphabeticalActionPerformed
@Override
public ImageIcon getIcon() {
return new ImageIcon(FilterPanel.class.getClassLoader().getResource("/" + ICON));
}
/**
* Sets ActionListener to apply filter button
* @param applyFilterListener ActionListener
*/
public void setFilterActionListener(ActionListener applyFilterListener) {
applyFilterButton.addActionListener(applyFilterListener);
}
public boolean isKdTreeFilter() {
return kdTreeFilter;
}
public boolean isFeaturePointsFilter() {
return featurePointsFilter;
}
public boolean isAlphabeticalFilter() {
return alphabeticalFilter;
}
/**
* Checks if all faces in list are loaded. If not, button which loads all
* faces from list shows up
* @param isAllFacesLoaded Boolean
*/
public void checkAllFacesLoaded(boolean isAllFacesLoaded) {
warningLabel.setVisible(!isAllFacesLoaded);
faceNotLoadedLabel.setVisible(!isAllFacesLoaded);
loadAllModelsButton.setVisible(!isAllFacesLoaded);
applyFilterButton.setEnabled(isAllFacesLoaded);
}
// Variables declaration - do not modify//GEN-BEGIN:variables
private javax.swing.JCheckBox alphabetical;
private javax.swing.JButton applyFilterButton;
private javax.swing.JLabel faceNotLoadedLabel;
private javax.swing.JPanel filterPanel;
private javax.swing.JCheckBox hasFP;
private javax.swing.JCheckBox hasKD;
private javax.swing.JButton loadAllModelsButton;
private javax.swing.JLabel warningLabel;
// End of variables declaration//GEN-END:variables
}
package cz.fidentis.analyst.project;
import cz.fidentis.analyst.faceState.FaceStatePanel;
import java.awt.Graphics2D;
import java.awt.image.BufferedImage;
import java.awt.Image;
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.List;
import javax.imageio.ImageIO;
import javax.swing.ImageIcon;
import javax.swing.table.DefaultTableModel;
......@@ -16,19 +23,22 @@ import org.imgscalr.Scalr;
*/
public class ModelsTableModel extends DefaultTableModel {
//private final ImageIcon notCheck = new ImageIcon(FaceStatePanel.class.getClassLoader().getResource("/" + "notCheck16x16.png"));
//private final ImageIcon check = new ImageIcon(FaceStatePanel.class.getClassLoader().getResource("/" + "check16x16.png"));
// Black silhouette inserted when face has no preview
private final ImageIcon previewBasic = new ImageIcon(FaceStatePanel.class.getClassLoader().getResource("/" + "face32x32.png"));
private final ImageIcon previewBasicGray = new ImageIcon(FaceStatePanel.class.getClassLoader().getResource("/" + "face_gray32x32.png"));
// List of previews of faces which are currently filtered
private List<Path> pathsToFilteredFaces = new ArrayList<>();
private Integer filteredRows = 0;
/**
* Constructor
* @param columnNames names of Columns
* @param rowCount number of rows
*/
public ModelsTableModel(Object[] columnNames, int rowCount) {
super(columnNames, rowCount);
public ModelsTableModel() {
super(new Object[]{"", "Models", "Preview"}, 0);
}
private Class[] types = new Class [] {
java.lang.Boolean.class, java.lang.String.class, ImageIcon.class
};
......@@ -43,8 +53,66 @@ public class ModelsTableModel extends DefaultTableModel {
@Override
public boolean isCellEditable(int rowIndex, int columnIndex) {
if (rowIndex >= getRowCount() - filteredRows) {
return false;
}
return canEdit [columnIndex];
}
@Override
public void setRowCount(int rowCount) {
super.setRowCount(rowCount);
if (rowCount == 0) {
pathsToFilteredFaces.clear();
filteredRows = 0;
}
}
@Override
public void removeRow(int row) {
super.removeRow(row);
String faceName = this.getValueAt(row, 1).toString();
pathsToFilteredFaces.removeIf(path -> {
return path.toString().substring(path.toString()
.lastIndexOf(File.separatorChar) + 1,
path.toString().lastIndexOf('.')).equals(faceName);
});
}
/**
* (De)selects all editable rows based on value passed to this function
* @param selection (de)selects all editable rows
*/
public void setAllRowsSelection(boolean selection) {
for (int row = 0; row < this.getRowCount() - filteredRows; row++) {
this.setValueAt(selection, row, 0);
}
}
/**
* Inflates selection
*/
public void inflateSelection() {
for (int row = 0; row < this.getRowCount() - filteredRows; row++) {
if (this.getValueAt(row, 0) == (Object) true) {
this.setValueAt(false, row, 0);
} else {
this.setValueAt(true, row, 0);
}
}
}
public Class[] getTypes() {
return types;}
......@@ -58,38 +126,148 @@ public class ModelsTableModel extends DefaultTableModel {
this.canEdit = canEdit;
}
/**
* Converts a given Image into a BufferedImage
*
* @param img The Image to be converted
* @return The converted BufferedImage
*/
public static BufferedImage toBufferedImage(Image img) {
if (img instanceof BufferedImage) {
return (BufferedImage) img;
}
if (img == null) {
return null;
}
// Create a buffered image with transparency
BufferedImage bimage = new BufferedImage(img.getWidth(null), img.getHeight(null), BufferedImage.TYPE_INT_ARGB);
// Draw the image on to the buffered image
Graphics2D bGr = bimage.createGraphics();
bGr.drawImage(img, 0, 0, null);
bGr.dispose();
// Return the buffered image
return bimage;
}
/**
* Disables row because it is being filtered, i.e. disables preview
* @param row which is currently filtered
*/
public void disableRow(int row, Path path) {
if (path != null && !pathsToFilteredFaces.contains(path)) {
Image iconImage = ((ImageIcon)this.getValueAt(row, 2)).getImage();
Path previewPath = this.getPreviewPath(path);
if (previewPath == null || !previewPath.toFile().exists()) {
this.setValueAt(previewBasicGray, row, 2);
} else {
BufferedImage image = toBufferedImage(iconImage);
// Scalr.OP_DARKER passed 5 times to grey preview by 50%
image = Scalr.apply(image, Scalr.OP_DARKER, Scalr.OP_DARKER,
Scalr.OP_DARKER, Scalr.OP_DARKER, Scalr.OP_DARKER);
this.setValueAt(new ImageIcon(image), row, 2);
}
pathsToFilteredFaces.add(path);
}
}
/**
* Enables row because it is not longer filtered, i.e. enables preview
* @param row which is not longer filtered
*/
public void enableRow(int row, Path path) {
if (path != null && pathsToFilteredFaces.contains(path)) {
Path previewPath = this.getPreviewPath(path);
ImageIcon preview = null;
if (previewPath == null || !previewPath.toFile().exists()) {
preview = previewBasic;
} else {
try {
BufferedImage image = ImageIO.read(previewPath.toFile());
// Scale image to fit into column
BufferedImage scaledImage = Scalr.resize(image, 70, 55);
preview = new ImageIcon(scaledImage);
} catch (IOException ex) {
Exceptions.printStackTrace(ex);
}
}
this.setValueAt(preview, row, 2);
pathsToFilteredFaces.remove(path);
}
}
/**
* Moves row to the bottom of the list (to filtered rows)
* @param row index of row which is about to be moved/filtered
*/
public void filterRow(int row) {
moveRow(row, row, getRowCount() - 1);
filteredRows++;
}
/**
* Moves filtered rows to the top of the list (unfilters rows)
* @param totalRows amount of rows which are about to be moved to the top
*/
public void unfilterRows(int totalRows) {
if (totalRows != 0) {
moveRow(getRowCount() - totalRows, getRowCount() - 1, 0);
filteredRows -= totalRows;
}
}
/**
* Gets path to preview image
* @param path path to face
* @return path to preview if preview is found, null otherwise
*/
public Path getPreviewPath(Path path) {
Path preview = Paths.get(path.toString().substring(0, path.toString().lastIndexOf(".")).concat("_preview.jpg"));
return preview;
}
/**
* Adds new row to model
* @param name String name of the face
* @param Path path to preview (if null than default preview is set)
* @param Path path to face
*/
public void addRowWithName(String name, Path path) {
if (!path.toFile().exists()) {
addRow(new Object[]{false, name, previewBasic});
Path preview = this.getPreviewPath(path);
int index = this.getRowCount() - filteredRows;
if (preview == null || !preview.toFile().exists()) {
insertRow(index, new Object[]{false, name, previewBasic});
} else {
try {
BufferedImage image = ImageIO.read(path.toFile());
BufferedImage image = ImageIO.read(preview.toFile());
// Scale image to fit into column
BufferedImage scaledImage = Scalr.resize(image, 70, 55);
addRow(new Object[]{false, name, new ImageIcon(scaledImage)});
insertRow(index, new Object[]{false, name, new ImageIcon(scaledImage)});
} catch (IOException ex) {
Exceptions.printStackTrace(ex);
}
}
}
}
/*
*
public void sortAlphabeticaly() {
List<String> rows = new ArrayList();
for (int i = 0; i < getRowCount(); i++) {
rows.add(getValueAt(i, 1).toString());
}
Collections.sort(rows);
}
*/
}
......@@ -19,24 +19,26 @@
<Group type="102" alignment="0" attributes="0">
<EmptySpace min="-2" pref="41" max="-2" attributes="0"/>
<Group type="103" groupAlignment="0" attributes="0">
<Component id="tablePanel" alignment="1" min="-2" max="-2" attributes="0"/>
<Component id="buttonsPanel" min="-2" pref="969" max="-2" attributes="0"/>
<Component id="buttonsPanel" pref="1025" max="32767" attributes="0"/>
<Component id="tableScrollPane" max="32767" attributes="0"/>
</Group>
<EmptySpace min="-2" pref="4" max="-2" attributes="0"/>
<Group type="103" groupAlignment="0" attributes="0">
<Group type="103" alignment="1" groupAlignment="0" attributes="0">
<Group type="102" alignment="0" attributes="0">
<EmptySpace min="-2" pref="78" max="-2" attributes="0"/>
<Group type="103" groupAlignment="0" attributes="0">
<Group type="102" attributes="0">
<EmptySpace min="-2" pref="50" max="-2" attributes="0"/>
<Component id="newProjectButton" min="-2" max="-2" attributes="0"/>
</Group>
<Component id="openProjectButton" alignment="1" min="-2" max="-2" attributes="0"/>
<Group type="102" alignment="1" attributes="0">
<EmptySpace max="-2" attributes="0"/>
<Component id="saveProjectButton" min="-2" max="-2" attributes="0"/>
</Group>
</Group>
<Group type="102" alignment="1" attributes="0">
<EmptySpace min="-2" pref="78" max="-2" attributes="0"/>
<Component id="saveProjectButton" min="-2" max="-2" attributes="0"/>
<EmptySpace max="-2" attributes="0"/>
<Component id="openProjectButton" min="-2" max="-2" attributes="0"/>
</Group>
</Group>
<EmptySpace max="32767" attributes="0"/>
<EmptySpace max="-2" attributes="0"/>
</Group>
</Group>
</DimensionLayout>
......@@ -44,25 +46,22 @@
<Group type="103" groupAlignment="0" attributes="0">
<Group type="102" alignment="0" attributes="0">
<Group type="103" groupAlignment="0" 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">
<Group type="102" alignment="0" attributes="0">
<Component id="buttonsPanel" min="-2" pref="56" max="-2" attributes="0"/>
<EmptySpace max="-2" attributes="0"/>
<Component id="buttonsPanel" max="-2" attributes="0"/>
<Component id="tableScrollPane" pref="768" max="32767" attributes="0"/>
</Group>
</Group>
<EmptySpace max="-2" attributes="0"/>
<Group type="103" groupAlignment="0" attributes="0">
<Group type="102" alignment="0" attributes="0">
<EmptySpace min="-2" pref="61" max="-2" attributes="0"/>
<Component id="newProjectButton" min="-2" max="-2" attributes="0"/>
<EmptySpace type="separate" max="-2" attributes="0"/>
<Component id="saveProjectButton" min="-2" max="-2" attributes="0"/>
<EmptySpace type="separate" max="-2" attributes="0"/>
<Component id="openProjectButton" min="-2" max="-2" attributes="0"/>
<EmptySpace min="0" pref="0" max="32767" attributes="0"/>
</Group>
<Component id="tablePanel" min="-2" max="-2" attributes="0"/>
</Group>
<EmptySpace max="32767" attributes="0"/>
<EmptySpace pref="12" max="32767" attributes="0"/>
</Group>
</Group>
</DimensionLayout>
......@@ -90,13 +89,16 @@
<Property name="text" type="java.lang.String" editor="org.netbeans.modules.i18n.form.FormI18nStringEditor">
<ResourceString bundle="cz/fidentis/analyst/project/Bundle.properties" key="ProjectPanel.addButton.text" replaceFormat="org.openide.util.NbBundle.getMessage({sourceFileName}.class, &quot;{key}&quot;)"/>
</Property>
<Property name="preferredSize" type="java.awt.Dimension" editor="org.netbeans.beaninfo.editors.DimensionEditor">
<Dimension value="[100, 30]"/>
</Property>
</Properties>
<Events>
<EventHandler event="mouseClicked" listener="java.awt.event.MouseListener" parameters="java.awt.event.MouseEvent" handler="addButtonMouseClicked"/>
</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="0" insetsBottom="13" insetsRight="8" anchor="13" weightX="0.0" weightY="0.0"/>
<GridBagConstraints gridX="0" gridY="0" gridWidth="1" gridHeight="1" fill="0" ipadX="0" ipadY="0" insetsTop="5" insetsLeft="15" insetsBottom="5" insetsRight="15" anchor="13" weightX="0.0" weightY="0.0"/>
</Constraint>
</Constraints>
</Component>
......@@ -108,13 +110,16 @@
<Property name="text" type="java.lang.String" editor="org.netbeans.modules.i18n.form.FormI18nStringEditor">
<ResourceString bundle="cz/fidentis/analyst/project/Bundle.properties" key="ProjectPanel.removeButton.text" replaceFormat="org.openide.util.NbBundle.getMessage({sourceFileName}.class, &quot;{key}&quot;)"/>
</Property>
<Property name="preferredSize" type="java.awt.Dimension" editor="org.netbeans.beaninfo.editors.DimensionEditor">
<Dimension value="[100, 30]"/>
</Property>
</Properties>
<Events>
<EventHandler event="mouseClicked" listener="java.awt.event.MouseListener" parameters="java.awt.event.MouseEvent" handler="removeButtonMouseClicked"/>
</Events>
<Constraints>
<Constraint layoutClass="org.netbeans.modules.form.compat2.layouts.DesignGridBagLayout" value="org.netbeans.modules.form.compat2.layouts.DesignGridBagLayout$GridBagConstraintsDescription">
<GridBagConstraints gridX="1" gridY="0" gridWidth="1" gridHeight="1" fill="0" ipadX="0" ipadY="0" insetsTop="16" insetsLeft="22" insetsBottom="13" insetsRight="8" anchor="18" weightX="0.0" weightY="0.0"/>
<GridBagConstraints gridX="1" gridY="0" gridWidth="1" gridHeight="1" fill="0" ipadX="0" ipadY="0" insetsTop="5" insetsLeft="15" insetsBottom="5" insetsRight="15" anchor="13" weightX="0.0" weightY="0.0"/>
</Constraint>
</Constraints>
</Component>
......@@ -126,13 +131,16 @@
<Property name="text" type="java.lang.String" editor="org.netbeans.modules.i18n.form.FormI18nStringEditor">
<ResourceString bundle="cz/fidentis/analyst/project/Bundle.properties" key="ProjectPanel.selectAllButton.text" replaceFormat="org.openide.util.NbBundle.getMessage({sourceFileName}.class, &quot;{key}&quot;)"/>
</Property>
<Property name="preferredSize" type="java.awt.Dimension" editor="org.netbeans.beaninfo.editors.DimensionEditor">
<Dimension value="[100, 30]"/>
</Property>
</Properties>
<Events>
<EventHandler event="mouseClicked" listener="java.awt.event.MouseListener" parameters="java.awt.event.MouseEvent" handler="selectAllButtonMouseClicked"/>
</Events>
<Constraints>
<Constraint layoutClass="org.netbeans.modules.form.compat2.layouts.DesignGridBagLayout" value="org.netbeans.modules.form.compat2.layouts.DesignGridBagLayout$GridBagConstraintsDescription">
<GridBagConstraints gridX="2" gridY="0" gridWidth="1" gridHeight="1" fill="0" ipadX="0" ipadY="0" insetsTop="16" insetsLeft="22" insetsBottom="13" insetsRight="8" anchor="18" weightX="0.0" weightY="0.0"/>
<GridBagConstraints gridX="2" gridY="0" gridWidth="1" gridHeight="1" fill="0" ipadX="0" ipadY="0" insetsTop="5" insetsLeft="15" insetsBottom="5" insetsRight="15" anchor="13" weightX="0.0" weightY="0.0"/>
</Constraint>
</Constraints>
</Component>
......@@ -144,13 +152,16 @@
<Property name="text" type="java.lang.String" editor="org.netbeans.modules.i18n.form.FormI18nStringEditor">
<ResourceString bundle="cz/fidentis/analyst/project/Bundle.properties" key="ProjectPanel.deselectAllButton.text" replaceFormat="org.openide.util.NbBundle.getMessage({sourceFileName}.class, &quot;{key}&quot;)"/>
</Property>
<Property name="preferredSize" type="java.awt.Dimension" editor="org.netbeans.beaninfo.editors.DimensionEditor">
<Dimension value="[100, 30]"/>
</Property>
</Properties>
<Events>
<EventHandler event="mouseClicked" listener="java.awt.event.MouseListener" parameters="java.awt.event.MouseEvent" handler="deselectAllButtonMouseClicked"/>
</Events>
<Constraints>
<Constraint layoutClass="org.netbeans.modules.form.compat2.layouts.DesignGridBagLayout" value="org.netbeans.modules.form.compat2.layouts.DesignGridBagLayout$GridBagConstraintsDescription">
<GridBagConstraints gridX="3" gridY="0" gridWidth="1" gridHeight="1" fill="0" ipadX="0" ipadY="0" insetsTop="16" insetsLeft="22" insetsBottom="13" insetsRight="8" anchor="18" weightX="0.0" weightY="0.0"/>
<GridBagConstraints gridX="3" gridY="0" gridWidth="1" gridHeight="1" fill="0" ipadX="0" ipadY="0" insetsTop="5" insetsLeft="15" insetsBottom="5" insetsRight="15" anchor="13" weightX="0.0" weightY="0.0"/>
</Constraint>
</Constraints>
</Component>
......@@ -163,13 +174,16 @@
<ResourceString bundle="cz/fidentis/analyst/project/Bundle.properties" key="ProjectPanel.inflateButton.text" replaceFormat="org.openide.util.NbBundle.getMessage({sourceFileName}.class, &quot;{key}&quot;)"/>
</Property>
<Property name="alignmentX" type="float" value="0.5"/>
<Property name="preferredSize" type="java.awt.Dimension" editor="org.netbeans.beaninfo.editors.DimensionEditor">
<Dimension value="[100, 30]"/>
</Property>
</Properties>
<Events>
<EventHandler event="mouseClicked" listener="java.awt.event.MouseListener" parameters="java.awt.event.MouseEvent" handler="inflateButtonMouseClicked"/>
</Events>
<Constraints>
<Constraint layoutClass="org.netbeans.modules.form.compat2.layouts.DesignGridBagLayout" value="org.netbeans.modules.form.compat2.layouts.DesignGridBagLayout$GridBagConstraintsDescription">
<GridBagConstraints gridX="4" gridY="0" gridWidth="1" gridHeight="1" fill="0" ipadX="0" ipadY="0" insetsTop="16" insetsLeft="22" insetsBottom="13" insetsRight="8" anchor="18" weightX="0.0" weightY="0.0"/>
<GridBagConstraints gridX="4" gridY="0" gridWidth="1" gridHeight="1" fill="0" ipadX="0" ipadY="0" insetsTop="5" insetsLeft="15" insetsBottom="5" insetsRight="15" anchor="13" weightX="0.0" weightY="0.0"/>
</Constraint>
</Constraints>
</Component>
......@@ -181,13 +195,16 @@
<Property name="text" type="java.lang.String" editor="org.netbeans.modules.i18n.form.FormI18nStringEditor">
<ResourceString bundle="cz/fidentis/analyst/project/Bundle.properties" key="ProjectPanel.analyseButton.text" replaceFormat="org.openide.util.NbBundle.getMessage({sourceFileName}.class, &quot;{key}&quot;)"/>
</Property>
<Property name="preferredSize" type="java.awt.Dimension" editor="org.netbeans.beaninfo.editors.DimensionEditor">
<Dimension value="[100, 30]"/>
</Property>
</Properties>
<Events>
<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="5" gridY="0" gridWidth="1" gridHeight="1" fill="0" ipadX="0" ipadY="0" insetsTop="16" insetsLeft="170" 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="5" insetsLeft="100" insetsBottom="5" insetsRight="15" anchor="10" weightX="0.0" weightY="0.0"/>
</Constraint>
</Constraints>
</Component>
......@@ -238,40 +255,16 @@
<EventHandler event="mouseClicked" listener="java.awt.event.MouseListener" parameters="java.awt.event.MouseEvent" handler="newProjectButtonMouseClicked"/>
</Events>
</Component>
<Container class="javax.swing.JPanel" name="tablePanel">
<Properties>
<Property name="border" type="javax.swing.border.Border" editor="org.netbeans.modules.form.editors2.BorderEditor">
<Border info="org.netbeans.modules.form.compat2.border.EtchedBorderInfo">
<EtchetBorder/>
</Border>
</Property>
</Properties>
<Container class="javax.swing.JScrollPane" name="tableScrollPane">
<Layout>
<DimensionLayout dim="0">
<Group type="103" groupAlignment="0" attributes="0">
<EmptySpace min="0" pref="965" max="32767" attributes="0"/>
<Group type="103" rootIndex="1" groupAlignment="0" attributes="0">
<Component id="table" alignment="0" pref="965" max="32767" attributes="0"/>
</Group>
</Group>
</DimensionLayout>
<DimensionLayout dim="1">
<Group type="103" groupAlignment="0" attributes="0">
<EmptySpace min="0" pref="788" max="32767" attributes="0"/>
<Group type="103" rootIndex="1" groupAlignment="0" attributes="0">
<Component id="table" alignment="0" pref="788" max="32767" attributes="0"/>
</Group>
</Group>
</DimensionLayout>
</Layout>
<Layout class="org.netbeans.modules.form.compat2.layouts.support.JScrollPaneSupportLayout"/>
<SubComponents>
<Component class="javax.swing.JTable" name="table">
<Properties>
<Property name="font" type="java.awt.Font" editor="org.netbeans.beaninfo.editors.FontEditor" postCode="table.getTableHeader().setOpaque(false);&#xa;table.getTableHeader().setBackground(new java.awt.Color(204,204,204));&#xa;table.getTableHeader().setFont(new java.awt.Font(&quot;Tahoma&quot;, 0, 18));&#xa;model.addTableModelListener(new TableModelListener() {&#xa; public void tableChanged(TableModelEvent e) {&#xa; jTable1TableChanged(e);&#xa; }&#xa;});">
<Font name="Tahoma" size="18" style="0"/>
</Property>
<Property name="model" type="javax.swing.table.TableModel" editor="org.netbeans.modules.form.RADConnectionPropertyEditor" postCode="table.getColumnModel().getColumn(0).setMaxWidth(50);&#xa;table.getColumnModel().getColumn(2).setMaxWidth(85);&#xa;table.getTableHeader().getColumnModel().getColumn(0).setMaxWidth(50);&#xa;table.getTableHeader().getColumnModel().getColumn(2).setMaxWidth(75);">
<Property name="model" type="javax.swing.table.TableModel" editor="org.netbeans.modules.form.RADConnectionPropertyEditor" postCode="table.getColumnModel().getColumn(0).setMaxWidth(50);&#xa;table.getColumnModel().getColumn(2).setMaxWidth(75);&#xa;table.getTableHeader().getColumnModel().getColumn(0).setMaxWidth(50);&#xa;table.getTableHeader().getColumnModel().getColumn(2).setMaxWidth(85);">
<Connection code="model" type="code"/>
</Property>
<Property name="columnModel" type="javax.swing.table.TableColumnModel" editor="org.netbeans.modules.form.editors2.TableColumnModelEditor">
......@@ -291,7 +284,7 @@
<EventHandler event="mouseClicked" listener="java.awt.event.MouseListener" parameters="java.awt.event.MouseEvent" handler="tableMouseClicked"/>
</Events>
<AuxValues>
<AuxValue name="JavaCodeGenerator_InitCodePre" type="java.lang.String" value="table.setSize(tablePanel.getWidth(), tablePanel.getHeight());"/>
<AuxValue name="JavaCodeGenerator_InitCodePre" type="java.lang.String" value="table.setSize(tableScrollPane.getWidth(), tableScrollPane.getHeight());"/>
</AuxValues>
</Component>
</SubComponents>
......
package cz.fidentis.analyst.project;
import cz.fidentis.analyst.filter.FilterPanel;
import cz.fidentis.analyst.faceState.FaceStatePanel;
import cz.fidentis.analyst.core.ControlPanel;
import cz.fidentis.analyst.core.OutputWindowThread;
import cz.fidentis.analyst.core.TopControlPanel;
......@@ -48,9 +50,11 @@ public final class ProjectTopComp extends TopComponent {
private final ProjectPanel projectPanel;
private final TopControlPanel controlPanel;
private final JScrollPane projectPanelScrollPane;
//private final JScrollPane projectPanelScrollPane;
private final JScrollPane controlPanelScrollPane;
public static final int CONTROL_PANEL_TAB_POSITION_FILTER_PANEL = 1;
/**
* Project Top Component
*/
......@@ -64,12 +68,10 @@ public final class ProjectTopComp extends TopComponent {
projectPanel = new ProjectPanel();
controlPanel = new TopControlPanel();
projectPanelScrollPane = new JScrollPane(projectPanel);
controlPanelScrollPane = new JScrollPane(controlPanel);
initComponents();
OutputWindowThread.execute();
// Face State Panel
......@@ -85,21 +87,14 @@ public final class ProjectTopComp extends TopComponent {
projectPanel.setFaceStatePanel(facePanel);
// Filter Panel
FilterPanel filterPanel = new FilterPanel(projectPanel);
// Listener for loading all faces - to enable filtering
ActionListener listenerLoadAllFaces = (ActionEvent e) -> {
projectPanel.loadAllFaces();
ActionListener listenerChangeIcon = (ActionEvent e) -> {
this.controlPanel.setIconAt(CONTROL_PANEL_TAB_POSITION_FILTER_PANEL, filterPanel.getIcon());
};
FilterPanel filterPanel = new FilterPanel(listenerLoadAllFaces);
filterPanel.setListenerChangeIcon(listenerChangeIcon);
this.controlPanel.addTab(filterPanel.getName(), filterPanel.getIcon(), filterPanel);
// Listener for applying filter on faces
ActionListener listenerFilter = (ActionEvent e) -> {
projectPanel.applyFilter(filterPanel.isFeaturePointsFilter(), filterPanel.isKdTreeFilter(), filterPanel.isAlphabeticalFilter());
};
filterPanel.setFilterActionListener(listenerFilter);
projectPanel.setFilterPanel(filterPanel);
this.openAtTabPosition(0);
......@@ -111,6 +106,7 @@ public final class ProjectTopComp extends TopComponent {
// Pass this class to installer so it can call method of this class on close
Installer inst = new Installer(this);
this.repaint();
}
private void initComponents() {
......@@ -120,7 +116,7 @@ public final class ProjectTopComp extends TopComponent {
layout.createParallelGroup(GroupLayout.Alignment.LEADING)
.addGroup(layout.createSequentialGroup()
.addPreferredGap(LayoutStyle.ComponentPlacement.RELATED)
.addComponent(projectPanelScrollPane, GroupLayout.DEFAULT_SIZE, 651, Short.MAX_VALUE)
.addComponent(projectPanel, GroupLayout.DEFAULT_SIZE, 651, Short.MAX_VALUE)
.addPreferredGap(LayoutStyle.ComponentPlacement.RELATED)
// .addComponent(renderingToolBar, GroupLayout.PREFERRED_SIZE, RenderingToolBar.WIDTH, GroupLayout.PREFERRED_SIZE)
.addComponent(
......@@ -135,7 +131,7 @@ public final class ProjectTopComp extends TopComponent {
layout.createParallelGroup(GroupLayout.Alignment.LEADING)
.addGroup(layout.createSequentialGroup()
.addGroup(layout.createBaselineGroup(true, true)
.addComponent(projectPanelScrollPane)
.addComponent(projectPanel)
// .addComponent(renderingToolBar)
.addComponent(controlPanelScrollPane)
))
......@@ -151,7 +147,7 @@ public final class ProjectTopComp extends TopComponent {
public void componentClosed() {
// TODO add custom code on component closing
}
void writeProperties(java.util.Properties p) {
// better to version settings since initial version as advocated at
// http://wiki.apidesign.org/wiki/PropertyFiles
......
# 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.
FaceStatePanel.geometryPanel.border.title=Geometry info
FaceStatePanel.filePanel.AccessibleContext.accessibleName=File info
FaceStatePanel.filePanel.border.title=File info
FaceStatePanel.textureOutput.text=
FaceStatePanel.photo.text=
FaceStatePanel.textureLabel.text=Texture File :
FaceStatePanel.photoPanel.border.title=Photo
FaceStatePanel.previewOutput.text=
FaceStatePanel.loadInfoButton.text=(Re)Load info
FaceStatePanel.previewLabel.text=Preview File :
FaceStatePanel.featurePointsOutput.text=
FaceStatePanel.fpLabel.text=Feature points :
FaceStatePanel.featurePointsLabel.text=Feature Points File :
FaceStatePanel.facetsOutput.text=
FaceStatePanel.sizeOutput.text=
FaceStatePanel.facetsLabel.text=Number of facets :
FaceStatePanel.sizeLabel.text=Size :
FaceStatePanel.verticesOutput.text=
FaceStatePanel.pathOutput.text=
FaceStatePanel.verticesLabel.text=Number of vertices :
FaceStatePanel.pathLabel.text=Path :
# 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.
FilterPanel.filterPanel.border.title=Filter settings
FilterPanel.featurePointsPanel.border.title=Feature points
FilterPanel.applyFilterButton.text=Apply filter
FilterPanel.hasNotFPCheckbox.text=has not feature points
FilterPanel.hasFPCheckbox.text=has some feature point
FilterPanel.byFPLabel.text=By feature points
FilterPanel.byNameLabel.text=By name
FilterPanel.hasTextCheckbox.text=has text
FilterPanel.hasTextTextfield.text=
FilterPanel.hasNotTextCheckbox.text=has not text
FilterPanel.hasNotTextTextfield.text=
FilterPanel.hasSelectedFPCheckbox.text=has selected feature points
FilterPanel.clearFilteringButton.text=Clear filtering
FilterPanel.revertLastFilteringButton.text=Revert
......@@ -4,16 +4,6 @@ FaceStatePanel.pathLabel.text=Path :
FaceStatePanel.sizeLabel.text=Size :
FaceStatePanel.pathOutput.text=
FaceStatePanel.sizeOutput.text=
FaceStatePanel.photoPanel.border.title=Photo
FaceStatePanel.photo.text=
FilterPanel.filterPanel.border.title=Filter settings
FilterPanel.hasFP.text=has feature points
FilterPanel.hasKD.text=has kd-tree
FilterPanel.alphabetical.text=alphabetical
FilterPanel.applyFilterButton.text=Apply filter
FilterPanel.warningLabel.text=
FilterPanel.faceNotLoadedLabel.text=All models must be loaded for filtering
FilterPanel.loadAllModelsButton.text=Load all models
ProjectPanel.newProjectButton.text=
ProjectPanel.openProjectButton.text=
ProjectPanel.saveProjectButton.text=
......@@ -23,22 +13,4 @@ ProjectPanel.deselectAllButton.text=Deselect all
ProjectPanel.selectAllButton.text=Select all
ProjectPanel.removeButton.text=Remove
ProjectPanel.addButton.text=Add
FaceStatePanel.geometryPanel.border.title=Geometry info
FaceStatePanel.verticesLabel.text=Number of vertices :
FaceStatePanel.facetsLabel.text=Number of facets :
FaceStatePanel.fpLabel.text=Feature points :
FaceStatePanel.verticesOutput.text=
FaceStatePanel.facetsOutput.text=
FaceStatePanel.textureOutput.text=
FaceStatePanel.previewOutput.text=
FaceStatePanel.featurePointsOutput.text=
FaceStatePanel.textureLabel.text=Texture File :
FaceStatePanel.previewLabel.text=Preview File :
FaceStatePanel.featurePointsLabel.text=Feature Points File :
FaceStatePanel.sizeOutput.text=
FaceStatePanel.pathOutput.text=
FaceStatePanel.sizeLabel.text=Size :
FaceStatePanel.pathLabel.text=Path :
FaceStatePanel.filePanel.AccessibleContext.accessibleName=File info
FaceStatePanel.filePanel.border.title=File info
FaceStatePanel.loadInfoButton.text=(Re)Load info
FilterPanel.nameTextField.text=
GUI/src/main/resources/face_gray32x32.png

852 B

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