1 package tim.prune.function;
3 import javax.swing.JOptionPane;
6 import tim.prune.GenericFunction;
7 import tim.prune.I18nManager;
8 import tim.prune.data.Track;
9 import tim.prune.undo.UndoRearrangeWaypoints;
12 * Class to provide the function for rearranging waypoints
14 public class RearrangeWaypointsFunction extends GenericFunction
17 /** Enumeration for rearrange commands */
20 /** Rearrange all waypoints to start */
22 /** Rearrange all waypoints to end */
24 /** Rearrange each waypoint to nearest track point */
30 * @param inApp app object
32 public RearrangeWaypointsFunction(App inApp)
37 /** Begin the rearrange (not needed) */
41 /** Get the name key (not needed) */
42 public String getNameKey() {
47 * Rearrange the waypoints into track order
48 * @param inFunction nearest point, all to end or all to start
50 public void rearrangeWaypoints(Rearrange inFunction)
52 Track track = _app.getTrackInfo().getTrack();
53 UndoRearrangeWaypoints undo = new UndoRearrangeWaypoints(track);
54 boolean success = false;
55 if (inFunction == Rearrange.TO_START || inFunction == Rearrange.TO_END)
57 // Collect the waypoints to the start or end of the track
58 success = track.collectWaypoints(inFunction == Rearrange.TO_START);
62 // Interleave the waypoints into track order
63 success = track.interleaveWaypoints();
67 _app.completeFunction(undo, I18nManager.getText("confirm.rearrangewaypoints"));
71 JOptionPane.showMessageDialog(_parentFrame, I18nManager.getText("error.rearrange.noop"),
72 I18nManager.getText("error.function.noop.title"), JOptionPane.WARNING_MESSAGE);