X-Git-Url: http://source.jalview.org/gitweb/?a=blobdiff_plain;f=src%2Fjalview%2Fgui%2FUserDefinedColours.java;h=79df106d8c7eb51c381b643641203fb6b29f8448;hb=e1124a62486322d2d28482529d2d6b850ce1719b;hp=e85a74cb7873bc5524cbe536b13787e07aa59c25;hpb=fd621a25427a759de0268471f753083bed5e1b53;p=jalview.git diff --git a/src/jalview/gui/UserDefinedColours.java b/src/jalview/gui/UserDefinedColours.java index e85a74c..79df106 100755 --- a/src/jalview/gui/UserDefinedColours.java +++ b/src/jalview/gui/UserDefinedColours.java @@ -68,7 +68,7 @@ public class UserDefinedColours extends GUserDefinedColours if (System.getProperty("os.name").startsWith("Mac")) { - frame.setSize(450, 560); + frame.setSize(760, 370); } if (sg != null) @@ -336,23 +336,28 @@ public class UserDefinedColours extends GUserDefinedColours */ public static UserColourScheme loadDefaultColours() { + UserColourScheme ret = null; + String colours = jalview.bin.Cache.getProperty("USER_DEFINED_COLOURS"); - if ( colours != null) + if ( colours != null ) { if(colours.indexOf("|")>-1) colours = colours.substring(0, colours.indexOf("|")); - return loadColours(colours); + ret = loadColours(colours); } - else + + if(ret == null) { Color[] newColours = new Color[24]; for (int i = 0; i < 24; i++) { newColours[i] = Color.white; } - return new UserColourScheme(newColours); + ret = new UserColourScheme(newColours); } + + return ret; } /** @@ -517,9 +522,10 @@ public class UserDefinedColours extends GUserDefinedColours { userColourSchemes = new Hashtable(); - if(files==null) + if(files==null || files.length()==0) return; + // In case colours can't be loaded, we'll remove them // from the default list here. StringBuffer coloursFound = new StringBuffer(); @@ -545,7 +551,50 @@ public class UserDefinedColours extends GUserDefinedColours } if (!files.equals(coloursFound.toString())) { - jalview.bin.Cache.setProperty("USER_DEFINED_COLOURS", coloursFound.toString()); + if (coloursFound.toString().length() > 1) + jalview.bin.Cache.setProperty("USER_DEFINED_COLOURS", + coloursFound.toString()); + else + jalview.bin.Cache.applicationProperties.remove("USER_DEFINED_COLOURS"); + } + } + + public static void removeColourFromDefaults(String target) + { + // The only way to find colours by name is to load them in + // In case colours can't be loaded, we'll remove them + // from the default list here. + + userColourSchemes = new Hashtable(); + + StringBuffer coloursFound = new StringBuffer(); + StringTokenizer st = new StringTokenizer( + jalview.bin.Cache.getProperty("USER_DEFINED_COLOURS"), "|"); + + while (st.hasMoreElements()) + { + String file = st.nextToken(); + try + { + UserColourScheme ucs = loadColours(file); + if (ucs != null && !ucs.getName().equals(target)) + { + if (coloursFound.length() > 0) + coloursFound.append("|"); + coloursFound.append(file); + userColourSchemes.put(ucs.getName(), ucs); + } + } + catch (Exception ex) + { + System.out.println("Error loading User ColourFile\n" + ex); + } } + + if (coloursFound.toString().length() > 1) + jalview.bin.Cache.setProperty("USER_DEFINED_COLOURS", coloursFound.toString()); + else + jalview.bin.Cache.applicationProperties.remove("USER_DEFINED_COLOURS"); + } }