X-Git-Url: https://gitweb.fperrin.net/?p=GpsPrune.git;a=blobdiff_plain;f=tim%2Fprune%2FGpsPruner.java;h=2511cf7981dcba09eafe474290a314edfff8a6f7;hp=7e9476cf5b2b62c56604d83a91eb36a821765371;hb=5625a1abadb5f2ca5f017fe7dbda1d5141cb637b;hpb=23959e65a6a0d581e657b07186d18b7a1ac5afeb diff --git a/tim/prune/GpsPruner.java b/tim/prune/GpsPruner.java index 7e9476c..2511cf7 100644 --- a/tim/prune/GpsPruner.java +++ b/tim/prune/GpsPruner.java @@ -1,26 +1,29 @@ package tim.prune; +import java.awt.BorderLayout; import java.awt.event.WindowAdapter; import java.awt.event.WindowEvent; import java.util.Locale; 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.MenuManager; import tim.prune.gui.ProfileChart; +import tim.prune.gui.SelectorDisplay; /** * Tool to visualize, edit and prune GPS data */ public class GpsPruner { - // Version 2, released 29 March 2007, 1 April 2007 - public static final String VERSION_NUMBER = "2"; - public static final String BUILD_NUMBER = "056"; + // Final release of version 3 + public static final String VERSION_NUMBER = "3"; + public static final String BUILD_NUMBER = "074"; private static App APP = null; @@ -35,23 +38,44 @@ public class GpsPruner { if (args[0].startsWith("--locale=")) { - if (args[0].length() == 11) - locale = new Locale(args[0].substring(9)); - else if (args[0].length() == 14) - locale = new Locale(args[0].substring(9, 11), args[0].substring(12)); - else - System.out.println("Unrecognised locale '" + args[0].substring(9) - + "' - locale should be eg 'DE' or 'DE_ch'"); + locale = getLanguage(args[0].substring(9)); + } + else if (args[0].startsWith("--lang=")) + { + locale = getLanguage(args[0].substring(7)); } else + { System.out.println("Unknown parameter '" + args[0] + - "'. Possible parameters:\n --locale= used for overriding locale settings\n"); + "'. Possible parameters:\n --locale= or --lang= used for overriding language settings\n"); + } } I18nManager.init(locale); launch(); } + /** + * Choose a locale based on the given code + * @param inString code for locale + * @return Locale object if available, otherwise null + */ + private static Locale getLanguage(String inString) + { + if (inString.length() == 2) + { + return new Locale(inString); + } + else if (inString.length() == 5) + { + return new Locale(inString.substring(0, 2), inString.substring(3)); + } + System.out.println("Unrecognised locale '" + inString + + "' - value should be eg 'DE' or 'DE_ch'"); + return null; + } + + /** * Launch the main application */ @@ -66,19 +90,28 @@ public class GpsPruner frame.setJMenuBar(menuManager.createMenuBar()); APP.setMenuManager(menuManager); broker.addSubscriber(menuManager); + // Make toolbar for buttons + JToolBar toolbar = menuManager.createToolBar(); // Make three GUI components and add as listeners - DetailsDisplay leftPanel = new DetailsDisplay(APP, APP.getTrackInfo()); + SelectorDisplay leftPanel = new SelectorDisplay(APP.getTrackInfo()); broker.addSubscriber(leftPanel); + DetailsDisplay rightPanel = new DetailsDisplay(APP.getTrackInfo()); + broker.addSubscriber(rightPanel); MapChart mapDisp = new MapChart(APP, APP.getTrackInfo()); broker.addSubscriber(mapDisp); ProfileChart profileDisp = new ProfileChart(APP.getTrackInfo()); broker.addSubscriber(profileDisp); - JSplitPane rightPane = new JSplitPane(JSplitPane.VERTICAL_SPLIT, mapDisp, profileDisp); - rightPane.setResizeWeight(1.0); // allocate as much space as poss to map + 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); + triplePane.setResizeWeight(1.0); // allocate as much space as poss to map + + frame.getContentPane().setLayout(new BorderLayout()); + frame.getContentPane().add(toolbar, BorderLayout.NORTH); frame.getContentPane().add(new JSplitPane(JSplitPane.HORIZONTAL_SPLIT, leftPanel, - rightPane)); + triplePane), BorderLayout.CENTER); // add closing listener frame.addWindowListener(new WindowAdapter() { public void windowClosing(WindowEvent e) { @@ -90,7 +123,7 @@ public class GpsPruner // finish off and display frame frame.pack(); - frame.setSize(600, 450); + frame.setSize(650, 450); frame.show(); } }