Commit 9b0c8eb1 authored by Daniel Schramm's avatar Daniel Schramm
Browse files

Feature point weights displayed next to the FP-radius slider

parent c63de423
Loading
Loading
Loading
Loading
+11 −22
Original line number Diff line number Diff line
@@ -9,6 +9,7 @@ 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;
@@ -17,7 +18,6 @@ import javax.swing.JButton;
import javax.swing.JCheckBox;
import javax.swing.JLabel;
import javax.swing.JPanel;
import javax.swing.JScrollPane;
import javax.swing.JTextField;

/**
@@ -51,7 +51,7 @@ 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 JPanel featurePointsStats;
    private final Map<FeaturePointType, JLabel> featurePointStats;
    private final JLabel avgHD, maxHD, minHD;
    
    /**
@@ -94,6 +94,7 @@ public class DistancePanel extends ControlPanel {
        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);
            
@@ -114,6 +115,10 @@ public class DistancePanel extends ControlPanel {
            sliderInput.postActionEvent();
            fpSliderInputs.add(sliderInput);
            
            fpBuilder.addGap();
            featurePointStats.put(featurePoint.getFeaturePointType(), fpBuilder.addLabelLine(null));
            fpBuilder.addGap();
            
            fpBuilder.addLine();
        }
        builder.addScrollPane(featurePointsPanel)
@@ -180,15 +185,6 @@ public class DistancePanel extends ControlPanel {
        builder.addGap();
        builder.addLine();
        
        featurePointsStats = new JPanel();
        final JScrollPane fpStatsScrollPanel = builder.addScrollPane(featurePointsStats);
        fpStatsScrollPanel.setBorder(BorderFactory.createTitledBorder("Feature point weights"));
        fpStatsScrollPanel.setVisible(false);
        weightedDistChBx.addActionListener((ActionEvent ae) -> {
            fpStatsScrollPanel.setVisible(weightedDistChBx.isSelected());
        });
        builder.addLine();
        
        builder.addVerticalStrut();
    }
    
@@ -226,17 +222,10 @@ public class DistancePanel extends ControlPanel {
     * @param featurePointWeights Map of feature point types and their weights
     */
    public void updateFeaturePointWeights(Map<FeaturePointType, Double> featurePointWeights) {
        featurePointsStats.removeAll();
        
        final ControlPanelBuilder fpBuilder = new ControlPanelBuilder(featurePointsStats);
        for (final Map.Entry<FeaturePointType, Double> fpStats: featurePointWeights.entrySet()) {
            fpBuilder.addOptionText(fpStats.getKey().getName());
            fpBuilder.addGap();
            
            fpBuilder.addLabelLine(Double.toString(fpStats.getValue()));
            fpBuilder.addGap();
            fpBuilder.addLine();
        }
        featurePointStats.forEach((fpType, fpWeightLabel) -> {
            final Double fpWeight = featurePointWeights.get(fpType);
            fpWeightLabel.setText(fpWeight == null ? "" : Double.toString(fpWeight));
        });
    }

}