diff --git a/GUI/src/main/java/cz/fidentis/analyst/distance/DistanceAction.java b/GUI/src/main/java/cz/fidentis/analyst/distance/DistanceAction.java index 1498dc4c0d32a5b5a4ed12d1d4f0342e9bf19326..b94b2702bbfce165d9f1c02779b160d13fd63177 100644 --- a/GUI/src/main/java/cz/fidentis/analyst/distance/DistanceAction.java +++ b/GUI/src/main/java/cz/fidentis/analyst/distance/DistanceAction.java @@ -91,7 +91,7 @@ public class DistanceAction extends ControlPanelAction { this.hausdorffDistance = null; // recompute only priorities calculateHausdorffDistance(); break; - case DistancePanel.ACTION_COMMAND_WEIGHTED_DIST_RECOMPUTE: + case DistancePanel.ACTION_COMMAND_DISTANCE_RECOMPUTE: this.visitor = null; // recompute calculateHausdorffDistance(); break; diff --git a/GUI/src/main/java/cz/fidentis/analyst/distance/DistancePanel.java b/GUI/src/main/java/cz/fidentis/analyst/distance/DistancePanel.java index 2f0c1c05fed8bbf98ebc963056b52565975ba670..0fc7ce2de409801686fdf0471ab6a408a48340bd 100644 --- a/GUI/src/main/java/cz/fidentis/analyst/distance/DistancePanel.java +++ b/GUI/src/main/java/cz/fidentis/analyst/distance/DistancePanel.java @@ -6,15 +6,12 @@ import cz.fidentis.analyst.feature.FeaturePoint; import cz.fidentis.analyst.feature.FeaturePointType; import cz.fidentis.analyst.scene.DrawableFeaturePoints; import cz.fidentis.analyst.symmetry.SymmetryPanel; -import java.awt.event.ActionEvent; import java.awt.event.ActionListener; -import java.util.ArrayList; import java.util.HashMap; import java.util.List; import java.util.Map; import javax.swing.BorderFactory; import javax.swing.ImageIcon; -import javax.swing.JButton; import javax.swing.JCheckBox; import javax.swing.JLabel; import javax.swing.JPanel; @@ -43,7 +40,7 @@ public class DistancePanel extends ControlPanel { public static final String ACTION_COMMAND_WEIGHTED_DISTANCE = "switch weighted distance on/off"; public static final String ACTION_COMMAND_FEATURE_POINT_HIGHLIGHT = "highlight feature point with color"; public static final String ACTION_COMMAND_FEATURE_POINT_RESIZE = "set size of feature point"; - public static final String ACTION_COMMAND_WEIGHTED_DIST_RECOMPUTE = "recompute weighted distance"; + public static final String ACTION_COMMAND_DISTANCE_RECOMPUTE = "recompute the Hausdorff distance"; /* * Configuration of panel-specific GUI elements @@ -82,7 +79,7 @@ public class DistancePanel extends ControlPanel { builder.addGap(); builder.addLine(); - final JCheckBox weightedDistChBx = builder.addCheckBoxOptionLine( + builder.addCheckBoxOptionLine( null, "Weighted Hausdorff distance", false, @@ -92,28 +89,22 @@ public class DistancePanel extends ControlPanel { final JPanel featurePointsPanel = new JPanel(); final ControlPanelBuilder fpBuilder = new ControlPanelBuilder(featurePointsPanel); - final List<JCheckBox> fpCheckBoxes = new ArrayList<>(featurePoints.size()); - final List<JTextField> fpSliderInputs = new ArrayList<>(featurePoints.size()); featurePointStats = new HashMap<>(featurePoints.size()); for (int i = 0; i < featurePoints.size(); i++) { final FeaturePoint featurePoint = featurePoints.get(i); final JCheckBox checkBox = fpBuilder.addCheckBox( false, - createListener(action, ACTION_COMMAND_FEATURE_POINT_HIGHLIGHT, i) + createListener(action, ACTION_COMMAND_DISTANCE_RECOMPUTE) ); checkBox.setText(featurePoint.getFeaturePointType().getName()); - fpCheckBoxes.add(checkBox); + checkBox.addActionListener(createListener(action, ACTION_COMMAND_FEATURE_POINT_HIGHLIGHT, i)); - final JTextField sliderInput = fpBuilder.addSliderOptionLine( - null, - null, - 100, - createListener(action, ACTION_COMMAND_FEATURE_POINT_RESIZE, i) - ); + final JTextField sliderInput = fpBuilder.addSliderOptionLine(null, null, 100, null); sliderInput.setText(ControlPanelBuilder.doubleToStringLocale(DrawableFeaturePoints.DEFAULT_SIZE)); - sliderInput.postActionEvent(); - fpSliderInputs.add(sliderInput); + sliderInput.postActionEvent(); // Set correct position of slider + sliderInput.addActionListener(createListener(action, ACTION_COMMAND_DISTANCE_RECOMPUTE)); + sliderInput.addActionListener(createListener(action, ACTION_COMMAND_FEATURE_POINT_RESIZE, i)); fpBuilder.addGap(); featurePointStats.put(featurePoint.getFeaturePointType(), fpBuilder.addLabelLine(null)); @@ -125,37 +116,6 @@ public class DistancePanel extends ControlPanel { .setBorder(BorderFactory.createTitledBorder("Feature points")); builder.addLine(); - final JButton recomputeButton = builder.addButton( - "Recompute", - createListener(action, ACTION_COMMAND_WEIGHTED_DIST_RECOMPUTE) - ); - recomputeButton.setEnabled(false); - recomputeButton.addActionListener((ActionEvent ae) -> - recomputeButton.setEnabled(false) - ); - weightedDistChBx.addActionListener((ActionEvent ae) -> { - if (!weightedDistChBx.isSelected()) { - recomputeButton.setEnabled(false); - } - }); - for (final JCheckBox checkBox: fpCheckBoxes) { - checkBox.addActionListener((ActionEvent ae) -> { - if (weightedDistChBx.isSelected()) { - recomputeButton.setEnabled(true); - } - }); - } - for (int i = 0; i < fpSliderInputs.size(); i++) { - final JTextField sliderInput = fpSliderInputs.get(i); - final JCheckBox sliderCheckBox = fpCheckBoxes.get(i); - sliderInput.addActionListener((ActionEvent ae) -> { - if (weightedDistChBx.isSelected() && sliderCheckBox.isSelected()) { - recomputeButton.setEnabled(true); - } - }); - } - builder.addLine(); - builder.addCaptionLine("Visualization options:"); builder.addLine(); builder.addCheckBoxOptionLine(