]> gitweb.fperrin.net Git - GpsPrune.git/blob - tim/prune/GpsPruner.java
7e9476cf5b2b62c56604d83a91eb36a821765371
[GpsPrune.git] / tim / prune / GpsPruner.java
1 package tim.prune;
2
3 import java.awt.event.WindowAdapter;
4 import java.awt.event.WindowEvent;
5 import java.util.Locale;
6
7 import javax.swing.JFrame;
8 import javax.swing.JSplitPane;
9 import javax.swing.WindowConstants;
10
11 import tim.prune.gui.DetailsDisplay;
12 import tim.prune.gui.MapChart;
13 import tim.prune.gui.MenuManager;
14 import tim.prune.gui.ProfileChart;
15
16 /**
17  * Tool to visualize, edit and prune GPS data
18  */
19 public class GpsPruner
20 {
21         // Version 2, released 29 March 2007, 1 April 2007
22         public static final String VERSION_NUMBER = "2";
23         public static final String BUILD_NUMBER = "056";
24         private static App APP = null;
25
26
27         /**
28          * Main method
29          * @param args command line arguments
30          */
31         public static void main(String[] args)
32         {
33                 Locale locale = null;
34                 if (args.length == 1)
35                 {
36                         if (args[0].startsWith("--locale="))
37                         {
38                                 if (args[0].length() == 11)
39                                         locale = new Locale(args[0].substring(9));
40                                 else if (args[0].length() == 14)
41                                         locale = new Locale(args[0].substring(9, 11), args[0].substring(12));
42                                 else
43                                         System.out.println("Unrecognised locale '" + args[0].substring(9)
44                                                 + "' - locale should be eg 'DE' or 'DE_ch'");
45                         }
46                         else
47                                 System.out.println("Unknown parameter '" + args[0] +
48                                         "'. Possible parameters:\n   --locale=  used for overriding locale settings\n");
49                 }
50                 I18nManager.init(locale);
51                 launch();
52         }
53
54
55         /**
56          * Launch the main application
57          */
58         private static void launch()
59         {
60                 JFrame frame = new JFrame("Prune");
61                 UpdateMessageBroker broker = new UpdateMessageBroker();
62                 APP = new App(frame, broker);
63
64                 // make menu
65                 MenuManager menuManager = new MenuManager(frame, APP, APP.getTrackInfo());
66                 frame.setJMenuBar(menuManager.createMenuBar());
67                 APP.setMenuManager(menuManager);
68                 broker.addSubscriber(menuManager);
69
70                 // Make three GUI components and add as listeners
71                 DetailsDisplay leftPanel = new DetailsDisplay(APP, APP.getTrackInfo());
72                 broker.addSubscriber(leftPanel);
73                 MapChart mapDisp = new MapChart(APP, APP.getTrackInfo());
74                 broker.addSubscriber(mapDisp);
75                 ProfileChart profileDisp = new ProfileChart(APP.getTrackInfo());
76                 broker.addSubscriber(profileDisp);
77
78                 JSplitPane rightPane = new JSplitPane(JSplitPane.VERTICAL_SPLIT, mapDisp, profileDisp);
79                 rightPane.setResizeWeight(1.0); // allocate as much space as poss to map
80                 frame.getContentPane().add(new JSplitPane(JSplitPane.HORIZONTAL_SPLIT, leftPanel,
81                                 rightPane));
82                 // add closing listener
83                 frame.addWindowListener(new WindowAdapter() {
84                         public void windowClosing(WindowEvent e) {
85                                 APP.exit();
86                         }
87                 });
88                 // Avoid automatically shutting down if window closed
89                 frame.setDefaultCloseOperation(WindowConstants.DO_NOTHING_ON_CLOSE);
90
91                 // finish off and display frame
92                 frame.pack();
93                 frame.setSize(600, 450);
94                 frame.show();
95         }
96 }