Loading GUI/src/main/java/cz/fidentis/analyst/distance/DistanceAction.java +61 −9 Original line number Diff line number Diff line Loading @@ -43,11 +43,14 @@ public class DistanceAction extends ControlPanelAction { private boolean weightedFPsShow = true; private Map<MeshFacet, List<Double>> weightedHausdorffDistance = null; private FeaturePointType hoveredFeaturePoint = null; private final DistancePanel controlPanel; private final DrawableFeaturePoints weightedFeaturePoints; private static final Color WEIGHTED_FEATURE_POINT_DEFAULT_COLOR = Color.WHITE; private static final Color FEATURE_POINT_HIGHLIGHT_COLOR = Color.MAGENTA; private static final Color FEATURE_POINT_HOVER_COLOR = Color.CYAN; /** * Constructor. Loading Loading @@ -89,7 +92,7 @@ public class DistanceAction extends ControlPanelAction { // Add weighted feature points to the scene this.weightedFeaturePoints = new DrawableFeaturePoints(getSecondaryFeaturePoints().getFeaturePoints()); weightedFeaturePoints.setRenderMode(GL2.GL_LINE); weightedFeaturePoints.setColor(Color.WHITE); weightedFeaturePoints.setColor(WEIGHTED_FEATURE_POINT_DEFAULT_COLOR); getCanvas().getScene().addOtherDrawable(weightedFeaturePoints); // Place control panel to the topControlPanel Loading @@ -113,8 +116,7 @@ public class DistanceAction extends ControlPanelAction { // Highlight feature point if selected if (featurePointTypes.containsKey(faceFP.getFeaturePointType())) { getSecondaryFeaturePoints().setColor(i, FEATURE_POINT_HIGHLIGHT_COLOR); weightedFeaturePoints.setColor(i, FEATURE_POINT_HIGHLIGHT_COLOR); colorSecondaryFaceFeaturePoint(i, FEATURE_POINT_HIGHLIGHT_COLOR); } if (!faceFP.getPosition().equals(weightedFP.getPosition())) { secondaryFaceMoved = true; Loading Loading @@ -178,6 +180,12 @@ public class DistanceAction extends ControlPanelAction { case DistancePanel.ACTION_COMMAND_FEATURE_POINT_HIGHLIGHT: highlightFeaturePoint((LoadedActionEvent) ae); break; case DistancePanel.ACTION_COMMAND_FEATURE_POINT_HOVER_IN: hoverFeaturePoint((LoadedActionEvent) ae, true); break; case DistancePanel.ACTION_COMMAND_FEATURE_POINT_HOVER_OUT: hoverFeaturePoint((LoadedActionEvent) ae, false); break; case DistancePanel.ACTION_COMMAND_FEATURE_POINT_RESIZE: resizeFeaturePoint((LoadedActionEvent) ae); break; Loading Loading @@ -311,7 +319,9 @@ public class DistanceAction extends ControlPanelAction { } /** * Changes the colour of the secondary face's feature point at the given index. * Changes the color of the secondary face's feature point at the given index * and of its weighted representation when the feature point is (de)selected * for the computation of the weighted Hausdorff distance. * The index is received as the data payload of {@code actionEvent}. * * @param actionEvent Action event with the index of the feature point as its payload data Loading @@ -319,19 +329,61 @@ public class DistanceAction extends ControlPanelAction { private void highlightFeaturePoint(LoadedActionEvent actionEvent) { final int index = (int) actionEvent.getData(); final FeaturePointType fpType = getTypeOfFeaturePoint(index); final DrawableFeaturePoints secondaryFeaturePoints = getSecondaryFeaturePoints(); if (((JToggleButton) actionEvent.getSource()).isSelected()) { secondaryFeaturePoints.setColor(index, FEATURE_POINT_HIGHLIGHT_COLOR); weightedFeaturePoints.setColor(index, FEATURE_POINT_HIGHLIGHT_COLOR); colorSecondaryFaceFeaturePoint(index, FEATURE_POINT_HIGHLIGHT_COLOR); featurePointTypes.put(fpType, weightedFeaturePoints.getSize(index)); } else { secondaryFeaturePoints.resetColorToDefault(index); weightedFeaturePoints.resetColorToDefault(index); resetSecondaryFaceFeaturePointColor(index); featurePointTypes.remove(fpType); } } /** * Changes the color of the secondary face's feature point at the given index * and of its weighted representation when the cursor hovers over the feature point's name. * The index is received as the data payload of {@code actionEvent}. * * @param actionEvent Action event with the index of the feature point as its payload data * @param entered {@code true} if the cursor entered the feature point, * {@code false} if the cursor left the feature point */ private void hoverFeaturePoint(LoadedActionEvent actionEvent, boolean entered) { final int index = (int) actionEvent.getData(); if (entered) { // entering a feature point colorSecondaryFaceFeaturePoint(index, FEATURE_POINT_HOVER_COLOR); hoveredFeaturePoint = getTypeOfFeaturePoint(index); } else if (featurePointTypes.containsKey(hoveredFeaturePoint)) { // leaving highlighted FP colorSecondaryFaceFeaturePoint(index, FEATURE_POINT_HIGHLIGHT_COLOR); } else { // leaving ordinary FP resetSecondaryFaceFeaturePointColor(index); } } /** * Sets the color of the secondary face's feature point at the given index * and of its weighted representation. * * @param index Index of the feature point * @param color New color of the feature point */ private void colorSecondaryFaceFeaturePoint(int index, Color color) { getSecondaryFeaturePoints().setColor(index, color); weightedFeaturePoints.setColor(index, color); } /** * Resets to default the color of the secondary face's feature point at the given index * and of its weighted representation. * * @param index Index of the feature point */ private void resetSecondaryFaceFeaturePointColor(final int index) { getSecondaryFeaturePoints().resetColorToDefault(index); weightedFeaturePoints.resetColorToDefault(index); } /** * Changes the size of the secondary face's feature point at the given index. * The index is received as the data payload of {@code actionEvent}. Loading GUI/src/main/java/cz/fidentis/analyst/distance/DistancePanel.java +25 −0 Original line number Diff line number Diff line Loading @@ -2,12 +2,15 @@ package cz.fidentis.analyst.distance; import cz.fidentis.analyst.core.ControlPanel; import cz.fidentis.analyst.core.ControlPanelBuilder; import cz.fidentis.analyst.core.LoadedActionEvent; 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.awt.event.MouseAdapter; import java.awt.event.MouseEvent; import java.util.DoubleSummaryStatistics; import java.util.HashMap; import java.util.List; Loading Loading @@ -42,6 +45,8 @@ public class DistancePanel extends ControlPanel { public static final String ACTION_COMMAND_SET_DISTANCE_STRATEGY = "set strategy"; public static final String ACTION_COMMAND_RELATIVE_ABSOLUTE_DIST = "switch abosulte-relative distance"; public static final String ACTION_COMMAND_WEIGHTED_DISTANCE = "switch weighted distance on/off"; public static final String ACTION_COMMAND_FEATURE_POINT_HOVER_IN = "highlight hovered FP"; public static final String ACTION_COMMAND_FEATURE_POINT_HOVER_OUT = "set default color of hovered FP"; 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_DISTANCE_RECOMPUTE = "recompute the Hausdorff distance"; Loading Loading @@ -102,6 +107,26 @@ public class DistancePanel extends ControlPanel { ); checkBox.setText(featurePointType.getName()); checkBox.addActionListener(createListener(action, ACTION_COMMAND_FEATURE_POINT_HIGHLIGHT, i)); final int index = i; checkBox.addMouseListener(new MouseAdapter() { @Override public void mouseEntered(MouseEvent e) { action.actionPerformed(new LoadedActionEvent( e.getSource(), ActionEvent.ACTION_PERFORMED, ACTION_COMMAND_FEATURE_POINT_HOVER_IN, index)); } @Override public void mouseExited(MouseEvent e) { action.actionPerformed(new LoadedActionEvent( e.getSource(), ActionEvent.ACTION_PERFORMED, ACTION_COMMAND_FEATURE_POINT_HOVER_OUT, index)); } }); final JTextField sliderInput = fpBuilder.addSliderOptionLine(null, null, 100, null); sliderInput.setText(ControlPanelBuilder.doubleToStringLocale(DrawableFeaturePoints.DEFAULT_SIZE)); Loading Loading
GUI/src/main/java/cz/fidentis/analyst/distance/DistanceAction.java +61 −9 Original line number Diff line number Diff line Loading @@ -43,11 +43,14 @@ public class DistanceAction extends ControlPanelAction { private boolean weightedFPsShow = true; private Map<MeshFacet, List<Double>> weightedHausdorffDistance = null; private FeaturePointType hoveredFeaturePoint = null; private final DistancePanel controlPanel; private final DrawableFeaturePoints weightedFeaturePoints; private static final Color WEIGHTED_FEATURE_POINT_DEFAULT_COLOR = Color.WHITE; private static final Color FEATURE_POINT_HIGHLIGHT_COLOR = Color.MAGENTA; private static final Color FEATURE_POINT_HOVER_COLOR = Color.CYAN; /** * Constructor. Loading Loading @@ -89,7 +92,7 @@ public class DistanceAction extends ControlPanelAction { // Add weighted feature points to the scene this.weightedFeaturePoints = new DrawableFeaturePoints(getSecondaryFeaturePoints().getFeaturePoints()); weightedFeaturePoints.setRenderMode(GL2.GL_LINE); weightedFeaturePoints.setColor(Color.WHITE); weightedFeaturePoints.setColor(WEIGHTED_FEATURE_POINT_DEFAULT_COLOR); getCanvas().getScene().addOtherDrawable(weightedFeaturePoints); // Place control panel to the topControlPanel Loading @@ -113,8 +116,7 @@ public class DistanceAction extends ControlPanelAction { // Highlight feature point if selected if (featurePointTypes.containsKey(faceFP.getFeaturePointType())) { getSecondaryFeaturePoints().setColor(i, FEATURE_POINT_HIGHLIGHT_COLOR); weightedFeaturePoints.setColor(i, FEATURE_POINT_HIGHLIGHT_COLOR); colorSecondaryFaceFeaturePoint(i, FEATURE_POINT_HIGHLIGHT_COLOR); } if (!faceFP.getPosition().equals(weightedFP.getPosition())) { secondaryFaceMoved = true; Loading Loading @@ -178,6 +180,12 @@ public class DistanceAction extends ControlPanelAction { case DistancePanel.ACTION_COMMAND_FEATURE_POINT_HIGHLIGHT: highlightFeaturePoint((LoadedActionEvent) ae); break; case DistancePanel.ACTION_COMMAND_FEATURE_POINT_HOVER_IN: hoverFeaturePoint((LoadedActionEvent) ae, true); break; case DistancePanel.ACTION_COMMAND_FEATURE_POINT_HOVER_OUT: hoverFeaturePoint((LoadedActionEvent) ae, false); break; case DistancePanel.ACTION_COMMAND_FEATURE_POINT_RESIZE: resizeFeaturePoint((LoadedActionEvent) ae); break; Loading Loading @@ -311,7 +319,9 @@ public class DistanceAction extends ControlPanelAction { } /** * Changes the colour of the secondary face's feature point at the given index. * Changes the color of the secondary face's feature point at the given index * and of its weighted representation when the feature point is (de)selected * for the computation of the weighted Hausdorff distance. * The index is received as the data payload of {@code actionEvent}. * * @param actionEvent Action event with the index of the feature point as its payload data Loading @@ -319,19 +329,61 @@ public class DistanceAction extends ControlPanelAction { private void highlightFeaturePoint(LoadedActionEvent actionEvent) { final int index = (int) actionEvent.getData(); final FeaturePointType fpType = getTypeOfFeaturePoint(index); final DrawableFeaturePoints secondaryFeaturePoints = getSecondaryFeaturePoints(); if (((JToggleButton) actionEvent.getSource()).isSelected()) { secondaryFeaturePoints.setColor(index, FEATURE_POINT_HIGHLIGHT_COLOR); weightedFeaturePoints.setColor(index, FEATURE_POINT_HIGHLIGHT_COLOR); colorSecondaryFaceFeaturePoint(index, FEATURE_POINT_HIGHLIGHT_COLOR); featurePointTypes.put(fpType, weightedFeaturePoints.getSize(index)); } else { secondaryFeaturePoints.resetColorToDefault(index); weightedFeaturePoints.resetColorToDefault(index); resetSecondaryFaceFeaturePointColor(index); featurePointTypes.remove(fpType); } } /** * Changes the color of the secondary face's feature point at the given index * and of its weighted representation when the cursor hovers over the feature point's name. * The index is received as the data payload of {@code actionEvent}. * * @param actionEvent Action event with the index of the feature point as its payload data * @param entered {@code true} if the cursor entered the feature point, * {@code false} if the cursor left the feature point */ private void hoverFeaturePoint(LoadedActionEvent actionEvent, boolean entered) { final int index = (int) actionEvent.getData(); if (entered) { // entering a feature point colorSecondaryFaceFeaturePoint(index, FEATURE_POINT_HOVER_COLOR); hoveredFeaturePoint = getTypeOfFeaturePoint(index); } else if (featurePointTypes.containsKey(hoveredFeaturePoint)) { // leaving highlighted FP colorSecondaryFaceFeaturePoint(index, FEATURE_POINT_HIGHLIGHT_COLOR); } else { // leaving ordinary FP resetSecondaryFaceFeaturePointColor(index); } } /** * Sets the color of the secondary face's feature point at the given index * and of its weighted representation. * * @param index Index of the feature point * @param color New color of the feature point */ private void colorSecondaryFaceFeaturePoint(int index, Color color) { getSecondaryFeaturePoints().setColor(index, color); weightedFeaturePoints.setColor(index, color); } /** * Resets to default the color of the secondary face's feature point at the given index * and of its weighted representation. * * @param index Index of the feature point */ private void resetSecondaryFaceFeaturePointColor(final int index) { getSecondaryFeaturePoints().resetColorToDefault(index); weightedFeaturePoints.resetColorToDefault(index); } /** * Changes the size of the secondary face's feature point at the given index. * The index is received as the data payload of {@code actionEvent}. Loading
GUI/src/main/java/cz/fidentis/analyst/distance/DistancePanel.java +25 −0 Original line number Diff line number Diff line Loading @@ -2,12 +2,15 @@ package cz.fidentis.analyst.distance; import cz.fidentis.analyst.core.ControlPanel; import cz.fidentis.analyst.core.ControlPanelBuilder; import cz.fidentis.analyst.core.LoadedActionEvent; 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.awt.event.MouseAdapter; import java.awt.event.MouseEvent; import java.util.DoubleSummaryStatistics; import java.util.HashMap; import java.util.List; Loading Loading @@ -42,6 +45,8 @@ public class DistancePanel extends ControlPanel { public static final String ACTION_COMMAND_SET_DISTANCE_STRATEGY = "set strategy"; public static final String ACTION_COMMAND_RELATIVE_ABSOLUTE_DIST = "switch abosulte-relative distance"; public static final String ACTION_COMMAND_WEIGHTED_DISTANCE = "switch weighted distance on/off"; public static final String ACTION_COMMAND_FEATURE_POINT_HOVER_IN = "highlight hovered FP"; public static final String ACTION_COMMAND_FEATURE_POINT_HOVER_OUT = "set default color of hovered FP"; 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_DISTANCE_RECOMPUTE = "recompute the Hausdorff distance"; Loading Loading @@ -102,6 +107,26 @@ public class DistancePanel extends ControlPanel { ); checkBox.setText(featurePointType.getName()); checkBox.addActionListener(createListener(action, ACTION_COMMAND_FEATURE_POINT_HIGHLIGHT, i)); final int index = i; checkBox.addMouseListener(new MouseAdapter() { @Override public void mouseEntered(MouseEvent e) { action.actionPerformed(new LoadedActionEvent( e.getSource(), ActionEvent.ACTION_PERFORMED, ACTION_COMMAND_FEATURE_POINT_HOVER_IN, index)); } @Override public void mouseExited(MouseEvent e) { action.actionPerformed(new LoadedActionEvent( e.getSource(), ActionEvent.ACTION_PERFORMED, ACTION_COMMAND_FEATURE_POINT_HOVER_OUT, index)); } }); final JTextField sliderInput = fpBuilder.addSliderOptionLine(null, null, 100, null); sliderInput.setText(ControlPanelBuilder.doubleToStringLocale(DrawableFeaturePoints.DEFAULT_SIZE)); Loading