JAL-4274 Use Cache BITMAP_* if no other image restrictions given
[jalview.git] / src / jalview / bin / Cache.java
index 038a5a0..9266d2a 100755 (executable)
@@ -141,7 +141,8 @@ import jalview.ws.sifts.SiftsSettings;
  * <li>WRAP_ALIGNMENT</li>
  * <li>EPS_RENDERING (Prompt each time|Lineart|Text) default for EPS rendering
  * style check</li>
- * <li>BITMAP_SCALE - scale factor for PNG export - default 0 - native resolution</li>
+ * <li>BITMAP_SCALE - scale factor for PNG export - default 0.0 - native
+ * resolution</li>
  * <li>BITMAP_HEIGHT - height bound for PNG export or 0 for unbound</li>
  * <li>BITMAP_WIDTH - width bound for PNG export or 0 for unbound</li>
  * <li>SORT_ALIGNMENT (No sort|Id|Pairwise Identity)</li>
@@ -641,8 +642,8 @@ public class Cache
         url = Cache.class.getResource(resourcePath).toString();
       } catch (Exception ex)
       {
-        jalview.bin.Console.errPrintln("Failed to resolve resource " + resourcePath
-                + ": " + ex.getMessage());
+        jalview.bin.Console.errPrintln("Failed to resolve resource "
+                + resourcePath + ": " + ex.getMessage());
       }
     }
     else
@@ -799,6 +800,25 @@ public class Cache
     return def;
   }
 
+  public static float getDefault(String property, float def)
+  {
+    String string = getProperty(property);
+    if (string != null)
+    {
+      try
+      {
+        def = Float.parseFloat(string);
+      } catch (NumberFormatException e)
+      {
+        if (!Jalview.quiet())
+          jalview.bin.Console.outPrintln("Error parsing float property '"
+                  + property + "' with value '" + string + "'");
+      }
+    }
+
+    return def;
+  }
+
   /**
    * Answers the value of the given property, or the supplied default value if
    * the property is not set
@@ -1064,8 +1084,9 @@ public class Cache
         return date_format.parse(val);
       } catch (Exception ex)
       {
-        jalview.bin.Console.errPrintln("Invalid or corrupt date in property '"
-                + propertyName + "' : value was '" + val + "'");
+        jalview.bin.Console
+                .errPrintln("Invalid or corrupt date in property '"
+                        + propertyName + "' : value was '" + val + "'");
       }
     }
     return null;
@@ -1088,8 +1109,8 @@ public class Cache
         return Integer.valueOf(val);
       } catch (NumberFormatException x)
       {
-        jalview.bin.Console.errPrintln("Invalid integer in property '" + property
-                + "' (value was '" + val + "')");
+        jalview.bin.Console.errPrintln("Invalid integer in property '"
+                + property + "' (value was '" + val + "')");
       }
     }
     return null;
@@ -1632,7 +1653,6 @@ public class Cache
   private static final Collection<String> bootstrapProperties = new ArrayList<>(
           Arrays.asList(JALVIEWLOGLEVEL, BOOTSTRAP_TEST));
 
-
   public static Properties bootstrapProperties(String filename)
   {
     Properties bootstrapProps = new Properties();
@@ -1661,8 +1681,9 @@ public class Cache
       return null;
     if (!file.exists())
     {
-      jalview.bin.Console.errPrintln("Could not load bootstrap preferences file '"
-              + filename + "'");
+      jalview.bin.Console
+              .errPrintln("Could not load bootstrap preferences file '"
+                      + filename + "'");
       return null;
     }
 
@@ -1678,8 +1699,9 @@ public class Cache
       }
     } catch (FileNotFoundException e)
     {
-      jalview.bin.Console.errPrintln("Could not find bootstrap preferences file '"
-              + file.getAbsolutePath() + "'");
+      jalview.bin.Console
+              .errPrintln("Could not find bootstrap preferences file '"
+                      + file.getAbsolutePath() + "'");
     } catch (IOException e)
     {
       jalview.bin.Console.errPrintln(