Skip to content
Snippets Groups Projects
Commit 009fae15 authored by Daniel Schramm's avatar Daniel Schramm
Browse files

Overview of Hausdorff distance statistics implemented

parent 6bb1fe5f
No related branches found
No related tags found
No related merge requests found
......@@ -129,18 +129,31 @@ public class ControlPanelBuilder {
public JLabel addCaptionLine(String caption) {
GridBagConstraints c = new GridBagConstraints();
c.insets = CAPTION_PADDING;
c.gridwidth = GridBagConstraints.REMAINDER;
c.gridx = col;
c.gridy = row;
c.anchor = GridBagConstraints.LINE_START;
c.fill = GridBagConstraints.NONE;
JLabel label = new JLabel(caption);
JLabel label = addLabelLineCustom(caption, c);
label.setFont(CAPTION_FONT);
controlPanel.add(label, c);
//addLine();
return label;
}
public JLabel addLabelLine(String caption) {
return addLabelLineCustom(caption, new GridBagConstraints());
}
private JLabel addLabelLineCustom(String caption, GridBagConstraints constraints) {
constraints.gridwidth = GridBagConstraints.REMAINDER;
constraints.gridx = col;
constraints.gridy = row;
constraints.anchor = GridBagConstraints.LINE_START;
constraints.fill = GridBagConstraints.NONE;
JLabel label = new JLabel(caption);
controlPanel.add(label, constraints);
return label;
}
/**
* Adds a line with slider option.
*
......@@ -238,18 +251,18 @@ public class ControlPanelBuilder {
List<JButton> retButtons = new ArrayList<>();
for (int i = 0; i < buttons.size(); i++) {
JButton button = addButton(buttons.get(i), actions.get(i), c);
JButton button = addButtonCustom(buttons.get(i), actions.get(i), c);
retButtons.add(button);
}
return retButtons;
}
public JButton addButtonSimple(String caption, ActionListener action) {
return addButton(caption, action, new GridBagConstraints());
public JButton addButton(String caption, ActionListener action) {
return addButtonCustom(caption, action, new GridBagConstraints());
}
private JButton addButton(String caption, ActionListener action, GridBagConstraints constraints) {
private JButton addButtonCustom(String caption, ActionListener action, GridBagConstraints constraints) {
JButton button = new JButton();
button.setText(caption);
button.addActionListener(action);
......
......@@ -10,6 +10,7 @@ import cz.fidentis.analyst.visitors.face.HausdorffDistancePrioritized;
import cz.fidentis.analyst.visitors.mesh.HausdorffDistance.Strategy;
import java.awt.Color;
import java.awt.event.ActionEvent;
import java.util.DoubleSummaryStatistics;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
......@@ -114,9 +115,21 @@ public class DistanceAction extends ControlPanelAction {
getSecondaryDrawableFace().getHumanFace().accept(visitor);
}
getSecondaryDrawableFace().setHeatMap(calculateHausdorffDistance());
final Map<MeshFacet, List<Double>> hausdorffDistance = calculateHausdorffDistance();
getSecondaryDrawableFace().setHeatMap(hausdorffDistance);
final DoubleSummaryStatistics distanceStats = hausdorffDistance.values()
.stream()
.flatMap(List::stream)
.mapToDouble(distance -> distance)
.summaryStatistics();
controlPanel.updateHausdorffDistanceStats(
distanceStats.getAverage(),
distanceStats.getMax(),
distanceStats.getMin()
);
}
private Map<MeshFacet, List<Double>> calculateHausdorffDistance() {
if (weightedDist) {
// TODO Merge the map of distances with the map of priorities
......
......@@ -12,6 +12,7 @@ import java.util.List;
import javax.swing.ImageIcon;
import javax.swing.JButton;
import javax.swing.JCheckBox;
import javax.swing.JLabel;
import javax.swing.JPanel;
import javax.swing.JTextField;
......@@ -46,6 +47,8 @@ public class DistancePanel extends ControlPanel {
public static final String STRATEGY_POINT_TO_POINT = "Point to point";
public static final String STRATEGY_POINT_TO_TRIANGLE = "Point to triangle";
private final JLabel avgHD, maxHD, minHD;
/**
* Constructor.
* @param action Action listener
......@@ -111,7 +114,7 @@ public class DistancePanel extends ControlPanel {
builder.addScrollPane(featurePointsPanel);
builder.addLine();
final JButton recomputeButton = builder.addButtonSimple(
final JButton recomputeButton = builder.addButton(
"Recompute",
createListener(action, ACTION_COMMAND_WEIGHTED_DIST_RECOMPUTE)
);
......@@ -151,6 +154,26 @@ public class DistancePanel extends ControlPanel {
createListener(action, ACTION_COMMAND_SHOW_HIDE_HEATMAP)
);
builder.addLine();
builder.addCaptionLine("Hausdorff distance:");
builder.addLine();
builder.addOptionText("Average");
builder.addGap();
avgHD = builder.addLabelLine("");
builder.addGap();
builder.addLine();
builder.addOptionText("Maximum");
builder.addGap();
maxHD = builder.addLabelLine("");
builder.addGap();
builder.addLine();
builder.addOptionText("Minimum");
builder.addGap();
minHD = builder.addLabelLine("");
builder.addGap();
builder.addLine();
builder.addVerticalStrut();
}
......@@ -168,4 +191,10 @@ public class DistancePanel extends ControlPanel {
return new ImageIcon(SymmetryPanel.class.getClassLoader().getResource("/" + ICON));
}
public void updateHausdorffDistanceStats(double averageDist, double maxDist, double minDist) {
avgHD.setText(Double.toString(averageDist));
maxHD.setText(Double.toString(maxDist));
minHD.setText(Double.toString(minDist));
}
}
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