]> gitweb.fperrin.net Git - GpsPrune.git/blobdiff - tim/prune/config/Config.java
Version 9, February 2010
[GpsPrune.git] / tim / prune / config / Config.java
similarity index 82%
rename from tim/prune/Config.java
rename to tim/prune/config/Config.java
index befbaccc1b4819216576f8d6a3c653ad7baca9dd..a822b6e34ebef38da13b798f6afa7460c288f0eb 100644 (file)
@@ -1,9 +1,10 @@
-package tim.prune;
+package tim.prune.config;
 
 import java.io.File;
 import java.io.FileInputStream;
 import java.util.Properties;
 
+
 /**
  * Abstract class to hold application-wide configuration
  */
@@ -14,6 +15,8 @@ public abstract class Config
 
        /** Hashtable containing all config values */
        private static Properties _configValues = new Properties();
+       /** Colour scheme object is also part of config */
+       private static ColourScheme _colourScheme = new ColourScheme();
 
        /** Default config file */
        private static final File DEFAULT_CONFIG_FILE = new File(".pruneconfig");
@@ -24,6 +27,8 @@ public abstract class Config
        public static final String KEY_PHOTO_DIR = "prune.photodirectory";
        /** Key for language code */
        public static final String KEY_LANGUAGE_CODE = "prune.languagecode";
+       /** Key for language file */
+       public static final String KEY_LANGUAGE_FILE = "prune.languagefile";
        /** Key for GPS device */
        public static final String KEY_GPS_DEVICE = "prune.gpsdevice";
        /** Key for GPS format */
@@ -36,8 +41,8 @@ public abstract class Config
        public static final String KEY_MAPSERVERINDEX = "prune.mapserverindex";
        /** Key for map server url */
        public static final String KEY_MAPSERVERURL = "prune.mapserverurl";
-       /** Key for show pace flag */
-       public static final String KEY_SHOW_PACE = "prune.showpace";
+       /** Key for show map flag */
+       public static final String KEY_SHOW_MAP = "prune.showmap";
        /** Key for width of thumbnails in kmz */
        public static final String KEY_KMZ_IMAGE_WIDTH = "prune.kmzimagewidth";
        /** Key for height of thumbnails in kmz */
@@ -48,6 +53,10 @@ public abstract class Config
        public static final String KEY_GNUPLOT_PATH = "prune.gnuplotpath";
        /** Key for exiftool path */
        public static final String KEY_EXIFTOOL_PATH = "prune.exiftoolpath";
+       /** Key for colour scheme */
+       public static final String KEY_COLOUR_SCHEME = "prune.colourscheme";
+       /** Key for kml track colour */
+       public static final String KEY_KML_TRACK_COLOUR = "prune.kmltrackcolour";
 
 
        /**
@@ -91,6 +100,7 @@ public abstract class Config
                }
                // Save all properties from file
                _configValues.putAll(props);
+               _colourScheme.loadFromHex(_configValues.getProperty(KEY_COLOUR_SCHEME));
                if (loadFailed) {
                        throw new ConfigException();
                }
@@ -108,12 +118,12 @@ public abstract class Config
                props.put(KEY_GPS_DEVICE, "usb:");
                props.put(KEY_GPS_FORMAT, "garmin");
                props.put(KEY_POVRAY_FONT, "crystal.ttf"); // alternative: DejaVuSans-Bold.ttf
-               props.put(KEY_SHOW_PACE, "0"); // hide by default
+               props.put(KEY_SHOW_MAP, "0"); // hide by default
                props.put(KEY_EXIFTOOL_PATH, "exiftool");
                props.put(KEY_GNUPLOT_PATH, "gnuplot");
                props.put(KEY_GPSBABEL_PATH, "gpsbabel");
                props.put(KEY_KMZ_IMAGE_WIDTH, "240");
-               props.put(KEY_KMZ_IMAGE_HEIGHT, "180");
+               props.put(KEY_KMZ_IMAGE_HEIGHT, "240");
                return props;
        }
 
@@ -145,6 +155,14 @@ public abstract class Config
                return _configValues;
        }
 
+       /**
+        * @return the current colour scheme
+        */
+       public static ColourScheme getColourScheme()
+       {
+               return _colourScheme;
+       }
+
        /**
         * Store the given configuration setting
         * @param inKey key (from constants)
@@ -152,8 +170,10 @@ public abstract class Config
         */
        public static void setConfigString(String inKey, String inValue)
        {
-               if (inKey != null && !inKey.equals(""))
-               {
+               if (inValue == null || inValue.equals("")) {
+                       _configValues.remove(inKey);
+               }
+               else {
                        _configValues.put(inKey, inValue);
                }
        }
@@ -223,6 +243,15 @@ public abstract class Config
        public static boolean isKeyBoolean(String inKey)
        {
                // Only two boolean keys so far
-               return inKey != null && (inKey.equals(KEY_METRIC_UNITS) || inKey.equals(KEY_SHOW_PACE));
+               return inKey != null && (
+                       inKey.equals(KEY_METRIC_UNITS) || inKey.equals(KEY_SHOW_MAP));
+       }
+
+       /**
+        * Update the colour scheme property from the current settings
+        */
+       public static void updateColourScheme()
+       {
+               setConfigString(KEY_COLOUR_SCHEME, _colourScheme.toString());
        }
 }