JAL-3210 Improvements to eclipse detection. New src tree and SwingJS updated from...
[jalview.git] / src / jalview / bin / Cache.java
index 4dac4df..b15c317 100755 (executable)
@@ -33,6 +33,7 @@ import jalview.util.Platform;
 import jalview.ws.sifts.SiftsSettings;
 
 import java.awt.Color;
+import java.awt.Dimension;
 import java.io.BufferedReader;
 import java.io.File;
 import java.io.FileInputStream;
@@ -661,6 +662,40 @@ public class Cache implements ApplicationSingletonI
   }
 
   /**
+   * retrieve a dimension, such as for Jmol
+   * 
+   * @param property
+   * @param def
+   * @return
+   */
+  public static Dimension getDefaultDim(String property, Dimension def)
+  {
+    String s = getProperty(property);
+    if (s != null)
+    {
+      if (s.indexOf(',') < 0)
+      {
+        s = s.trim().replace(' ', ',');
+        if (s.indexOf(',') < 0)
+        {
+          s += "," + s;
+        }
+      }
+      try
+      {
+        int pt = s.indexOf(",");
+        return new Dimension(Integer.parseInt(s.substring(0, pt)),
+                Integer.parseInt(s.substring(pt + 1)));
+      } catch (NumberFormatException e)
+      {
+        System.out.println("Error parsing Dimension property '" + property
+                + "' with value '" + s + "'");
+      }
+    }
+    return def;
+  }
+
+  /**
    * Answers the value of the given property, or the supplied default value if
    * the property is not set
    */