JAL-3594 Default values for channel properties defined in code as fallback
authorBen Soares <b.soares@dundee.ac.uk>
Sat, 5 Dec 2020 21:17:33 +0000 (21:17 +0000)
committerBen Soares <b.soares@dundee.ac.uk>
Sat, 5 Dec 2020 21:17:33 +0000 (21:17 +0000)
14 files changed:
resources/default_images/UoD_banner.png [new file with mode: 0644]
resources/default_images/jalview_banner.png [new file with mode: 0644]
resources/default_images/jalview_logo-128.png [new file with mode: 0644]
resources/default_images/jalview_logo-16.png [new file with mode: 0644]
resources/default_images/jalview_logo-256.png [new file with mode: 0644]
resources/default_images/jalview_logo-32.png [new file with mode: 0644]
resources/default_images/jalview_logo-38.png [new file with mode: 0644]
resources/default_images/jalview_logo-48.png [new file with mode: 0644]
resources/default_images/jalview_logo-512.png [new file with mode: 0644]
resources/default_images/jalview_logo-64.png [new file with mode: 0644]
resources/default_images/rotatable_jalview_logo-38.png [new file with mode: 0644]
src/jalview/util/ChannelProperties.java
utils/channels/develop/resources/channel_properties
utils/channels/release/resources/channel_properties

diff --git a/resources/default_images/UoD_banner.png b/resources/default_images/UoD_banner.png
new file mode 100644 (file)
index 0000000..2aff7e2
Binary files /dev/null and b/resources/default_images/UoD_banner.png differ
diff --git a/resources/default_images/jalview_banner.png b/resources/default_images/jalview_banner.png
new file mode 100644 (file)
index 0000000..a381b83
Binary files /dev/null and b/resources/default_images/jalview_banner.png differ
diff --git a/resources/default_images/jalview_logo-128.png b/resources/default_images/jalview_logo-128.png
new file mode 100644 (file)
index 0000000..63fa253
Binary files /dev/null and b/resources/default_images/jalview_logo-128.png differ
diff --git a/resources/default_images/jalview_logo-16.png b/resources/default_images/jalview_logo-16.png
new file mode 100644 (file)
index 0000000..9a1adfb
Binary files /dev/null and b/resources/default_images/jalview_logo-16.png differ
diff --git a/resources/default_images/jalview_logo-256.png b/resources/default_images/jalview_logo-256.png
new file mode 100644 (file)
index 0000000..6963612
Binary files /dev/null and b/resources/default_images/jalview_logo-256.png differ
diff --git a/resources/default_images/jalview_logo-32.png b/resources/default_images/jalview_logo-32.png
new file mode 100644 (file)
index 0000000..7af5791
Binary files /dev/null and b/resources/default_images/jalview_logo-32.png differ
diff --git a/resources/default_images/jalview_logo-38.png b/resources/default_images/jalview_logo-38.png
new file mode 100644 (file)
index 0000000..0b60196
Binary files /dev/null and b/resources/default_images/jalview_logo-38.png differ
diff --git a/resources/default_images/jalview_logo-48.png b/resources/default_images/jalview_logo-48.png
new file mode 100644 (file)
index 0000000..297e6cc
Binary files /dev/null and b/resources/default_images/jalview_logo-48.png differ
diff --git a/resources/default_images/jalview_logo-512.png b/resources/default_images/jalview_logo-512.png
new file mode 100644 (file)
index 0000000..340f8e5
Binary files /dev/null and b/resources/default_images/jalview_logo-512.png differ
diff --git a/resources/default_images/jalview_logo-64.png b/resources/default_images/jalview_logo-64.png
new file mode 100644 (file)
index 0000000..2505ae9
Binary files /dev/null and b/resources/default_images/jalview_logo-64.png differ
diff --git a/resources/default_images/rotatable_jalview_logo-38.png b/resources/default_images/rotatable_jalview_logo-38.png
new file mode 100644 (file)
index 0000000..e584298
Binary files /dev/null and b/resources/default_images/rotatable_jalview_logo-38.png differ
index 5d7f795..6a99b0f 100644 (file)
@@ -19,12 +19,36 @@ public class ChannelProperties
 
   private Properties channelProps = new Properties();
 
+  private static final Properties defaultProps;
+
   private Map<String, Image> imageMap = new HashMap<String, Image>();
 
   private static ChannelProperties instance;
 
   private boolean initDone = false;
 
+  static
+  {
+    defaultProps = new Properties();
+    // these should be kept up to date, but in real life they should never
+    // actually be used anyway.
+    defaultProps.put("app_name", "Jalview");
+    defaultProps.put("banner", "/default_images/jalview_banner.png");
+    defaultProps.put("logo.16", "/default_images/jalview_logo-16.png");
+    defaultProps.put("logo.32", "/default_images/jalview_logo-32.png");
+    defaultProps.put("logo.38", "/default_images/jalview_logo-38.png");
+    defaultProps.put("logo.48", "/default_images/jalview_logo-48.png");
+    defaultProps.put("logo.64", "/default_images/jalview_logo-64.png");
+    defaultProps.put("logo.128", "/default_images/jalview_logo-128.png");
+    defaultProps.put("logo.256", "/default_images/jalview_logo-256.png");
+    defaultProps.put("logo.512", "/default_images/jalview_logo-512.png");
+    defaultProps.put("rotatable_logo.48",
+            "/default_images/rotatable_jalview_logo-38.png");
+    defaultProps.put("uod_banner", "/default_images/UoD_banner.png");
+    defaultProps.put("default_appbase",
+            "https://www.jalview.org/getdown/release/1.8");
+  }
+
   private boolean init()
   {
     if (initDone)
@@ -37,8 +61,9 @@ public class ChannelProperties
     if (channelPropsURL == null)
     {
       // fallback
-      System.err.println(
-              "Failed to find '" + CHANNEL_PROPERTIES_FILENAME + "' file");
+      System.err.println("Failed to find '" + CHANNEL_PROPERTIES_FILENAME
+              + "' filem using defaults");
+      channelProps = defaultProps;
       return false;
     }
     else
@@ -72,11 +97,6 @@ public class ChannelProperties
     return instance;
   }
 
-  public static String getProperty(String key)
-  {
-    return getProperty(key, null);
-  }
-
   private static Properties channelProps()
   {
     return getChannelProperties().channelProps;
@@ -87,14 +107,34 @@ public class ChannelProperties
     return getChannelProperties().imageMap;
   }
 
+  /*
+   * getProperty(key) will get property value from channel_properties for key.
+   * If no property for key is found, it will fall back to using the defaultProps defined for this class.
+   */
+  public static String getProperty(String key)
+  {
+    return getProperty(key, null, true);
+  }
+
+  /*
+   * getProperty(key, defaultVal) will get property value from channel_properties for key.
+   * If no property for key is found, it will return defaultVal and NOT fall back to the class defaultProps.
+   */
   public static String getProperty(String key, String defaultVal)
   {
+    return getProperty(key, defaultVal, false);
+  }
+
+  private static String getProperty(String key, String defaultVal,
+          boolean useClassDefaultProps)
+  {
     if (channelProps() != null)
     {
       if (channelProps().containsKey(key))
       {
-        String val = channelProps().getProperty(key, "NOTFOUND");
-        return channelProps().getProperty(key, defaultVal);
+        return channelProps().getProperty(key,
+                useClassDefaultProps ? defaultProps.getProperty(key)
+                        : defaultVal);
       }
       else
       {
index 487c3e8..9af7f1f 100644 (file)
@@ -9,4 +9,5 @@ logo.128=/images/jalview_develop_logo-128.png
 logo.256=/images/jalview_develop_logo-256.png
 logo.512=/images/jalview_develop_logo-512.png
 rotatable_logo.48=/images/rotatable_jalview_develop_logo-38.png
+uod_banner=/images/UoD_banner.png
 default_appbase=https://www.jalview.org/getdown/develop/11
index 3170933..a00392f 100644 (file)
@@ -9,4 +9,5 @@ logo.128=/images/jalview_logo-128.png
 logo.256=/images/jalview_logo-256.png
 logo.512=/images/jalview_logo-512.png
 rotatable_logo.48=/images/rotatable_jalview_logo-38.png
+uod_banner=/images/UoD_banner.png
 default_appbase=https://www.jalview.org/getdown/release/1.8