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