X-Git-Url: http://source.jalview.org/gitweb/?a=blobdiff_plain;f=src%2Fjalview%2Fbin%2FCache.java;h=48c1ee9b0757fb863e806964f5d80e96c635ed86;hb=refs%2Fheads%2Ffeatures%2FJAL-653_JAL-1766_htslib_refseqsupport;hp=6764430447e8e51547331df5c08c645ad9626772;hpb=2d18ff6c5ccbd11297b80f70591dc0cb2f6aace6;p=jalview.git diff --git a/src/jalview/bin/Cache.java b/src/jalview/bin/Cache.java index 6764430..48c1ee9 100755 --- a/src/jalview/bin/Cache.java +++ b/src/jalview/bin/Cache.java @@ -21,8 +21,12 @@ package jalview.bin; import jalview.datamodel.PDBEntry; +import jalview.gui.UserDefinedColours; +import jalview.schemes.ColourSchemes; +import jalview.schemes.UserColourScheme; import jalview.structure.StructureImportSettings; import jalview.urls.IdOrgSettings; +import jalview.util.ColorUtils; import jalview.ws.dbsources.das.api.DasSourceRegistryI; import jalview.ws.dbsources.das.datamodel.DasSourceRegistry; import jalview.ws.sifts.SiftsSettings; @@ -41,6 +45,7 @@ import java.util.Date; import java.util.Enumeration; import java.util.Locale; import java.util.Properties; +import java.util.StringTokenizer; import java.util.TreeSet; import org.apache.log4j.ConsoleAppender; @@ -184,6 +189,8 @@ import org.apache.log4j.SimpleLayout; *
  • STRUCTURE_DISPLAY choose from JMOL (default) or CHIMERA for 3D structure * display
  • *
  • CHIMERA_PATH specify full path to Chimera program (if non-standard)
  • + *
  • ID_ORG_HOSTURL location of jalview service providing identifiers.org urls + *
  • * * * Deprecated settings: @@ -241,9 +248,7 @@ public class Cache * Identifiers.org download settings */ private static final String ID_ORG_FILE = System.getProperty("user.home") - + File.separatorChar + ".jalview_identifiers"; - - private static final String ID_ORG_URL = "http://identifiers.org/rest/collections/"; + + File.separatorChar + ".identifiers.org.ids.json"; /** * Allowed values are PDB or mmCIF @@ -456,7 +461,8 @@ public class Cache "sifts_cache_threshold_in_days", DEFAULT_CACHE_THRESHOLD_IN_DAYS)); - IdOrgSettings.setUrl(ID_ORG_URL); + IdOrgSettings.setUrl(getDefault("ID_ORG_HOSTURL", + "http://www.jalview.org/services/identifiers")); IdOrgSettings.setDownloadLocation(ID_ORG_FILE); System.out @@ -545,7 +551,7 @@ public class Cache setProperty("VERSION", codeVersion); // LOAD USERDEFINED COLOURS - jalview.gui.UserDefinedColours + jalview.bin.Cache .initUserColourSchemes(getProperty("USER_DEFINED_COLOURS")); jalview.io.PIRFile.useModellerOutput = Cache.getDefault("PIR_MODELLER", false); @@ -887,19 +893,11 @@ public class Cache { return defcolour; } - Color col = jalview.schemes.ColourSchemeProperty - .getAWTColorFromName(colprop); + Color col = ColorUtils.parseColourString(colprop); if (col == null) { - try - { - col = new jalview.schemes.UserColourScheme(colprop).findColour('A'); - } catch (Exception ex) - { - log.warn("Couldn't parse '" + colprop + "' as a colour for " - + property); - col = null; - } + log.warn("Couldn't parse '" + colprop + "' as a colour for " + + property); } return (col == null) ? defcolour : col; } @@ -1016,4 +1014,54 @@ public class Cache Cache.applicationProperties.setProperty(propName, value); } } + + /** + * Loads in user colour schemes from files. + * + * @param files + * a '|'-delimited list of file paths + */ + public static void initUserColourSchemes(String files) + { + 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(); + StringTokenizer st = new StringTokenizer(files, "|"); + while (st.hasMoreElements()) + { + String file = st.nextToken(); + try + { + UserColourScheme ucs = ColourSchemes.loadColourScheme(file); + if (ucs != null) + { + if (coloursFound.length() > 0) + { + coloursFound.append("|"); + } + coloursFound.append(file); + ColourSchemes.getInstance().registerColourScheme(ucs); + } + } catch (Exception ex) + { + System.out.println("Error loading User ColourFile\n" + ex); + } + } + if (!files.equals(coloursFound.toString())) + { + if (coloursFound.toString().length() > 1) + { + setProperty(UserDefinedColours.USER_DEFINED_COLOURS, coloursFound.toString()); + } + else + { + applicationProperties.remove(UserDefinedColours.USER_DEFINED_COLOURS); + } + } + } }