]> gitweb.fperrin.net Git - GpsPrune.git/blobdiff - tim/prune/function/compress/MarkPointsInRectangleFunction.java
Version 17, September 2014
[GpsPrune.git] / tim / prune / function / compress / MarkPointsInRectangleFunction.java
index 73c867f8c5b786944a2ee7c652a43be5ee4048b1..2ea0f8ca64c495486cec33d3a94d82598f5f2b5d 100644 (file)
@@ -1,17 +1,13 @@
 package tim.prune.function.compress;
 
-import javax.swing.JOptionPane;
-
 import tim.prune.App;
-import tim.prune.GenericFunction;
-import tim.prune.I18nManager;
 import tim.prune.UpdateMessageBroker;
 import tim.prune.data.DataPoint;
 
 /**
  * Function to mark all the points in the selected rectangle
  */
-public class MarkPointsInRectangleFunction extends GenericFunction
+public class MarkPointsInRectangleFunction extends MarkAndDeleteFunction
 {
        /** Minimum and maximum latitude values of rectangle */
        private double _minLat = 0.0, _maxLat = 0.0;
@@ -28,6 +24,11 @@ public class MarkPointsInRectangleFunction extends GenericFunction
                super(inApp);
        }
 
+       /** @return name key */
+       public String getNameKey() {
+               return "menu.track.markrectangle";
+       }
+
        /**
         * Set the coordinates of the rectangle
         * @param inLon1 first longitude value
@@ -79,7 +80,7 @@ public class MarkPointsInRectangleFunction extends GenericFunction
                        final double pointLat = point.getLatitude().getDouble();
                        final boolean insideRect = (pointLon >= _minLon && pointLon <= _maxLon
                                && pointLat >= _minLat && pointLat <= _maxLat);
-                       // If so, then mark it
+                       // Mark it accordingly (also resetting points outside the rect to false)
                        point.setMarkedForDeletion(insideRect);
                        if (insideRect) {
                                numMarked++;
@@ -89,15 +90,9 @@ public class MarkPointsInRectangleFunction extends GenericFunction
                // Inform subscribers to update display
                UpdateMessageBroker.informSubscribers();
                // Confirm message showing how many marked
-               if (numMarked > 0) {
-                       JOptionPane.showMessageDialog(_parentFrame, I18nManager.getText("dialog.compress.confirm1")
-                               + " " + numMarked + " " + I18nManager.getText("dialog.compress.confirm2"),
-                               I18nManager.getText(getNameKey()), JOptionPane.INFORMATION_MESSAGE);
+               if (numMarked > 0)
+               {
+                       optionallyDeleteMarkedPoints(numMarked);
                }
        }
-
-       /** @return name key */
-       public String getNameKey() {
-               return "menu.track.markrectangle";
-       }
 }