X-Git-Url: https://gitweb.fperrin.net/?a=blobdiff_plain;f=tim%2Fprune%2FGpsPruner.java;h=29f7eb592681131438714de9122b7c7caea0a601;hb=112bb0c9b46894adca9a33ed8c99ea712b253185;hp=8a95f7f69e3f950eae3ec45cfe539f68cca1ad4b;hpb=da0b1f449260a0b4a94318006382a9039726ef3e;p=GpsPrune.git diff --git a/tim/prune/GpsPruner.java b/tim/prune/GpsPruner.java index 8a95f7f..29f7eb5 100644 --- a/tim/prune/GpsPruner.java +++ b/tim/prune/GpsPruner.java @@ -1,30 +1,38 @@ package tim.prune; -import java.awt.BorderLayout; import java.awt.event.WindowAdapter; +import java.awt.BorderLayout; import java.awt.event.WindowEvent; +import java.io.File; +import java.io.FileNotFoundException; import java.util.Locale; - +import java.util.ArrayList; import javax.swing.JFrame; import javax.swing.JSplitPane; import javax.swing.JToolBar; import javax.swing.WindowConstants; import tim.prune.gui.DetailsDisplay; -import tim.prune.gui.MapChart; +import tim.prune.gui.IconManager; import tim.prune.gui.MenuManager; import tim.prune.gui.ProfileChart; import tim.prune.gui.SelectorDisplay; +import tim.prune.gui.StatusBar; +import tim.prune.gui.Viewport; +import tim.prune.gui.map.MapCanvas; /** - * Tool to visualize, edit and prune GPS data + * Tool to visualize, edit, convert and prune GPS data * Please see the included readme.txt or http://activityworkshop.net + * This software is copyright activityworkshop.net and made available through the Gnu GPL */ public class GpsPruner { - // Final release of version 4 - public static final String VERSION_NUMBER = "4"; - public static final String BUILD_NUMBER = "089"; + /** Version number of application, used in about screen and for version check */ + public static final String VERSION_NUMBER = "8"; + /** Build number, just used for about screen */ + public static final String BUILD_NUMBER = "155"; + /** Static reference to App object */ private static App APP = null; @@ -35,24 +43,90 @@ public class GpsPruner public static void main(String[] args) { Locale locale = null; - if (args.length == 1) + String localeCode = null; + String langFilename = null; + String configFilename = null; + ArrayList dataFiles = new ArrayList(); + boolean showUsage = false; + for (int i=0; i used to specify a configuration file" + + "\n --lang= or --locale= used to specify language" + + "\n --langfile= used to specify an alternative language file\n"); + } + // Initialise configuration if selected + try + { + if (configFilename != null) { + Config.loadFile(new File(configFilename)); + } + else { + Config.loadDefaultFile(); + } + } + catch (ConfigException ce) { + System.err.println("Failed to load config file: " + configFilename); + } + if (locale != null) { + // Make sure Config holds chosen language + Config.setConfigString(Config.KEY_LANGUAGE_CODE, localeCode); + } + else { + // Set locale according to Config's language property + String configLang = Config.getConfigString(Config.KEY_LANGUAGE_CODE); + if (configLang != null) { + Locale configLocale = getLanguage(configLang); + if (configLocale != null) {locale = configLocale;} } } I18nManager.init(locale); - launch(); + if (langFilename != null) { + try { + I18nManager.addLanguageFile(langFilename); + } + catch (FileNotFoundException fnfe) { + System.err.println("Failed to load language file: " + langFilename); + } + } + // Set up the window and go + launch(dataFiles); } @@ -79,31 +153,37 @@ public class GpsPruner /** * Launch the main application + * @param inDataFiles list of data files to load on startup */ - private static void launch() + private static void launch(ArrayList inDataFiles) { JFrame frame = new JFrame("Prune"); - UpdateMessageBroker broker = new UpdateMessageBroker(); - APP = new App(frame, broker); + APP = new App(frame); // make menu - MenuManager menuManager = new MenuManager(frame, APP, APP.getTrackInfo()); + MenuManager menuManager = new MenuManager(APP, APP.getTrackInfo()); frame.setJMenuBar(menuManager.createMenuBar()); APP.setMenuManager(menuManager); - broker.addSubscriber(menuManager); + UpdateMessageBroker.addSubscriber(menuManager); // Make toolbar for buttons JToolBar toolbar = menuManager.createToolBar(); - // Make three GUI components and add as listeners + // Make main GUI components and add as listeners SelectorDisplay leftPanel = new SelectorDisplay(APP.getTrackInfo()); - broker.addSubscriber(leftPanel); + UpdateMessageBroker.addSubscriber(leftPanel); DetailsDisplay rightPanel = new DetailsDisplay(APP.getTrackInfo()); - broker.addSubscriber(rightPanel); - MapChart mapDisp = new MapChart(APP, APP.getTrackInfo()); - broker.addSubscriber(mapDisp); + UpdateMessageBroker.addSubscriber(rightPanel); + MapCanvas mapDisp = new MapCanvas(APP, APP.getTrackInfo()); + UpdateMessageBroker.addSubscriber(mapDisp); + Viewport viewport = new Viewport(mapDisp); + APP.setViewport(viewport); ProfileChart profileDisp = new ProfileChart(APP.getTrackInfo()); - broker.addSubscriber(profileDisp); + UpdateMessageBroker.addSubscriber(profileDisp); + StatusBar statusBar = new StatusBar(); + UpdateMessageBroker.addSubscriber(statusBar); + UpdateMessageBroker.informSubscribers("Prune v" + VERSION_NUMBER); + // Arrange in the frame using split panes JSplitPane midPane = new JSplitPane(JSplitPane.VERTICAL_SPLIT, mapDisp, profileDisp); midPane.setResizeWeight(1.0); // allocate as much space as poss to map JSplitPane triplePane = new JSplitPane(JSplitPane.HORIZONTAL_SPLIT, midPane, rightPanel); @@ -113,6 +193,8 @@ public class GpsPruner frame.getContentPane().add(toolbar, BorderLayout.NORTH); frame.getContentPane().add(new JSplitPane(JSplitPane.HORIZONTAL_SPLIT, leftPanel, triplePane), BorderLayout.CENTER); + frame.getContentPane().add(statusBar, BorderLayout.SOUTH); + // add closing listener frame.addWindowListener(new WindowAdapter() { public void windowClosing(WindowEvent e) { @@ -122,9 +204,20 @@ public class GpsPruner // Avoid automatically shutting down if window closed frame.setDefaultCloseOperation(WindowConstants.DO_NOTHING_ON_CLOSE); + // set icon + try { + frame.setIconImage(IconManager.getImageIcon(IconManager.WINDOW_ICON).getImage()); + } + catch (Exception e) {} // ignore + // finish off and display frame frame.pack(); frame.setSize(650, 450); - frame.show(); + frame.setVisible(true); + // Set position of map/profile splitter + midPane.setDividerLocation(0.75); + + // Finally, give the files to load to the App + APP.loadDataFiles(inDataFiles); } }