+ /**
+ * get the user's default colour if available
+ * @param property
+ * @param defcolour
+ * @return
+ */
+ public static Color getDefaultColour(String property, Color defcolour)
+ {
+ String colprop = getProperty(property);
+ if (colprop==null) {
+ return defcolour;
+ }
+ Color col = jalview.schemes.ColourSchemeProperty.getAWTColorFromName(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;
+ }
+ }
+ return (col==null) ? defcolour: col;
+ }
+
+ /**
+ * store a colour as a Jalview user default property
+ * @param property
+ * @param colour
+ */
+ public static void setColourProperty(String property, Color colour)
+ {
+ setProperty(property, jalview.util.Format
+ .getHexString(colour));
+ }
+
+ public static final DateFormat date_format = SimpleDateFormat.getDateTimeInstance();
+
+ /**
+ * store a date in a jalview property
+ * @param string
+ * @param time
+ */
+ public static void setDateProperty(String property, Date time)
+ {
+ setProperty(property, date_format.format(time));
+ }
+ /**
+ * read a date stored in a jalview property
+ * @param property
+ * @return valid date as stored by setDateProperty, or null
+ *
+ */
+ public static Date getDateProperty(String property)
+ {
+ String val = getProperty(property);
+ if (val!=null)
+ {
+ try {
+ return date_format.parse(val);
+ } catch (Exception ex)
+ {
+ System.err.println("Invalid or corrupt date in property '"+property+"' : value was '"+val+"'");
+ }
+ }
+ return null;
+ }