JAL-4298 Fixed initial log level to see .jalview_properties setting. Moved Java Conso...
[jalview.git] / src / jalview / bin / Cache.java
index 038a5a0..a44d474 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>
@@ -588,7 +589,7 @@ public class Cache
             {
               if (!Jalview.quiet())
               {
-                jalview.bin.Console.outPrintln(
+                jalview.bin.Console.errPrintln(
                         "Non-fatal exception when checking version at "
                                 + remoteBuildPropertiesUrl + ":");
                 jalview.bin.Console.printStackTrace(ex);
@@ -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
@@ -791,7 +792,26 @@ public class Cache
       } catch (NumberFormatException e)
       {
         if (!Jalview.quiet())
-          jalview.bin.Console.outPrintln("Error parsing int property '"
+          jalview.bin.Console.errPrintln("Error parsing int property '"
+                  + property + "' with value '" + string + "'");
+      }
+    }
+
+    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.errPrintln("Error parsing float property '"
                   + property + "' with value '" + string + "'");
       }
     }
@@ -842,7 +862,7 @@ public class Cache
     } catch (Exception ex)
     {
       if (!Jalview.quiet())
-        jalview.bin.Console.outPrintln(
+        jalview.bin.Console.errPrintln(
                 "Error setting property: " + key + " " + obj + "\n" + ex);
     }
     return oldValue;
@@ -874,7 +894,7 @@ public class Cache
       } catch (Exception ex)
       {
         if (!Jalview.quiet())
-          jalview.bin.Console.outPrintln("Error saving properties: " + ex);
+          jalview.bin.Console.errPrintln("Error saving properties: " + ex);
       }
     }
   }
@@ -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();
@@ -1643,26 +1663,36 @@ public class Cache
     }
     if (file == null || !file.exists())
     {
+      if (file != null)
+      {
+        jalview.bin.Console
+                .errPrintln("Could not load bootstrap preferences file '"
+                        + file.getPath() + "'");
+      }
       String channelPrefsFilename = ChannelProperties
               .getProperty("preferences.filename");
       String propertiesFilename = System.getProperty("user.home")
               + File.separatorChar + channelPrefsFilename;
+      jalview.bin.Console.errPrintln(
+              "Using default properties file '" + propertiesFilename + "'");
       file = new File(propertiesFilename);
     }
     if (file == null || !file.exists())
+
     {
       String releasePrefsFilename = fallbackPropertiesFile;
       String releasePropertiesFilename = System.getProperty("user.home")
               + File.separatorChar + releasePrefsFilename;
+      jalview.bin.Console.errPrintln("Falling back to properties file '"
+              + releasePropertiesFilename + "'");
       file = new File(releasePropertiesFilename);
     }
 
-    if (filename == null)
-      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 '"
+                      + file.getPath() + "'");
       return null;
     }
 
@@ -1678,8 +1708,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(