*/
package jalview.bin;
-import jalview.datamodel.DBRefSource;
+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;
import java.util.Collections;
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;
* <li>SORT_ALIGNMENT (No sort|Id|Pairwise Identity)</li>
* <li>SEQUENCE_LINKS list of name|URL pairs for opening a url with
* $SEQUENCE_ID$</li>
+ * <li>STORED_LINKS list of name|url pairs which user has entered but are not
+ * currently used
+ * <li>DEFAULT_LINK name of single url to be used when user double clicks a
+ * sequence id (must be in SEQUENCE_LINKS or STORED_LINKS)
* <li>GROUP_LINKS list of name|URL[|<separator>] tuples - see
* jalview.utils.GroupURLLink for more info</li>
* <li>DAS_REGISTRY_URL the registry to query</li>
* <li>STRUCTURE_DISPLAY choose from JMOL (default) or CHIMERA for 3D structure
* display</li>
* <li>CHIMERA_PATH specify full path to Chimera program (if non-standard)</li>
+ * <li>ID_ORG_HOSTURL location of jalview service providing identifiers.org urls
+ * </li>
*
* </ul>
* Deprecated settings:
public static final String DAS_ACTIVE_SOURCE = "DAS_ACTIVE_SOURCE";
+ /**
+ * Sifts settings
+ */
public static final String DEFAULT_SIFTS_DOWNLOAD_DIR = System
.getProperty("user.home")
+ File.separatorChar
private final static String DEFAULT_FAIL_SAFE_PID_THRESHOLD = "30";
- private final static String DEFAULT_STRUCTURE_FORMAT = DBRefSource.PDB;
+ /**
+ * Identifiers.org download settings
+ */
+ private static final String ID_ORG_FILE = System.getProperty("user.home")
+ + File.separatorChar + ".identifiers.org.ids.json";
+
+ /**
+ * Allowed values are PDB or mmCIF
+ */
+ private final static String PDB_DOWNLOAD_FORMAT = PDBEntry.Type.MMCIF
+ .toString();
+
+ private final static String DEFAULT_PDB_FILE_PARSER = StructureImportSettings.StructureParser.JMOL_PARSER
+ .toString();
+
+ /*
+ * a date formatter using a fixed (rather than the user's) locale;
+ * this ensures that date properties can be written and re-read successfully
+ * even if the user changes their locale setting
+ */
+ private static final DateFormat date_format = SimpleDateFormat
+ .getDateTimeInstance(SimpleDateFormat.MEDIUM,
+ SimpleDateFormat.MEDIUM, Locale.UK);
/**
* Initialises the Jalview Application Log
"sifts_cache_threshold_in_days",
DEFAULT_CACHE_THRESHOLD_IN_DAYS));
+ IdOrgSettings.setUrl(getDefault("ID_ORG_HOSTURL",
+ "http://www.jalview.org/services/identifiers"));
+ IdOrgSettings.setDownloadLocation(ID_ORG_FILE);
+
System.out
.println("Jalview Version: " + codeVersion + codeInstallation);
- StructureImportSettings.setCurrentDefaultFormat(jalview.bin.Cache
- .getDefault(
- "DEFAULT_STRUCTURE_FORMAT", DEFAULT_STRUCTURE_FORMAT));
-
- StructureImportSettings.setProcessHETATMs(jalview.bin.Cache.getDefault(
- "PROCESS_HETATM", false));
+ StructureImportSettings.setDefaultStructureFileFormat(jalview.bin.Cache
+ .getDefault("PDB_DOWNLOAD_FORMAT", PDB_DOWNLOAD_FORMAT));
+ StructureImportSettings
+ .setDefaultPDBFileParser(DEFAULT_PDB_FILE_PARSER);
+ // StructureImportSettings
+ // .setDefaultPDBFileParser(jalview.bin.Cache.getDefault(
+ // "DEFAULT_PDB_FILE_PARSER", DEFAULT_PDB_FILE_PARSER));
// jnlpVersion will be null if we're using InstallAnywhere
// Dont do this check if running in headless mode
if (jnlpVersion == null
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);
{
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;
}
setProperty(property, jalview.util.Format.getHexString(colour));
}
- public static final DateFormat date_format = SimpleDateFormat
- .getDateTimeInstance();
-
/**
- * store a date in a jalview property
+ * Stores a formatted date in a jalview property, using a fixed locale.
*
- * @param string
- * @param time
+ * @param propertyName
+ * @param date
+ * @return the formatted date string
*/
- public static void setDateProperty(String property, Date time)
+ public static String setDateProperty(String propertyName, Date date)
{
- setProperty(property, date_format.format(time));
+ String formatted = date_format.format(date);
+ setProperty(propertyName, formatted);
+ return formatted;
}
/**
- * read a date stored in a jalview property
+ * Reads a date stored in a Jalview property, parses it (using a fixed locale
+ * format) and returns as a Date, or null if parsing fails
*
- * @param property
- * @return valid date as stored by setDateProperty, or null
+ * @param propertyName
+ * @return
*
*/
- public static Date getDateProperty(String property)
+ public static Date getDateProperty(String propertyName)
{
- String val = getProperty(property);
+ String val = getProperty(propertyName);
if (val != null)
{
try
} catch (Exception ex)
{
System.err.println("Invalid or corrupt date in property '"
- + property + "' : value was '" + val + "'");
+ + propertyName + "' : value was '" + val + "'");
}
}
return null;
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);
+ }
+ }
+ }
}