prototype for store/restore of feature colour gradient settings
authorjprocter <Jim Procter>
Tue, 31 Mar 2009 16:39:56 +0000 (16:39 +0000)
committerjprocter <Jim Procter>
Tue, 31 Mar 2009 16:39:56 +0000 (16:39 +0000)
schemas/jalview.xsd
src/jalview/gui/Jalview2XML.java
src/jalview/schemabinding/version2/.castor.cdr
src/jalview/schemabinding/version2/Setting.java
src/jalview/schemabinding/version2/descriptors/SettingDescriptor.java

index 72c1270..bcc0438 100755 (executable)
                                                                        <xs:attribute name="colour" type="xs:int" use="required"/>
                                                                        <xs:attribute name="display" type="xs:boolean" use="required"/>
                                                                        <xs:attribute name="order" type="xs:float" use="optional"/>
-                                                               </xs:complexType>
+                                                                       <xs:attribute name="mincolour" type="xs:int" use="optional">
+                                                                       <xs:annotation><xs:documentation>Optional minimum colour for graduated feature colour</xs:documentation>
+                                                                       </xs:annotation></xs:attribute>
+                                                                       <xs:attribute name="threshold" type="xs:float" use="optional">
+                                                                       <xs:annotation><xs:documentation>threshold value for graduated feature colour</xs:documentation>
+                                                                       </xs:annotation></xs:attribute>
+                                                                       <xs:attribute name="threshstate" type="xs:int" use="optional">
+                                                                       <xs:annotation><xs:documentation>threshold type for graduated feature colour</xs:documentation>
+                                                                       </xs:annotation></xs:attribute>
+                                                       </xs:complexType>
                                                        </xs:element>
                                                        <xs:element name="group" minOccurs="0" maxOccurs="unbounded">
                                                                <xs:complexType>
index db53d00..b3cf1af 100755 (executable)
@@ -2666,9 +2666,19 @@ public class Jalview2XML
       for (int fs = 0; fs < jms.getFeatureSettings().getSettingCount(); fs++)
       {
         Setting setting = jms.getFeatureSettings().getSetting(fs);
-
-        af.alignPanel.seqPanel.seqCanvas.getFeatureRenderer().setColour(
-                setting.getType(), new java.awt.Color(setting.getColour()));
+        if (setting.hasMincolour())
+        {
+          // TODO: determine how to set data independent bounds for a graduated colour scheme's range.
+          GraduatedColor gc = new GraduatedColor(new java.awt.Color(setting.getMincolour()), new java.awt.Color(setting.getColour()),
+                  0,1);
+          if (setting.hasThreshold()) {
+            gc.setThresh(setting.getThreshold());
+            gc.setThreshType(setting.getThreshstate());
+          }
+        } else {
+          af.alignPanel.seqPanel.seqCanvas.getFeatureRenderer().setColour(
+                  setting.getType(), new java.awt.Color(setting.getColour()));
+        }
         renderOrder[fs] = setting.getType();
         if (setting.hasOrder())
           af.alignPanel.seqPanel.seqCanvas.getFeatureRenderer().setOrder(
index 92a62c4..1114d86 100644 (file)
@@ -1,4 +1,4 @@
-#Fri Feb 06 14:21:53 GMT 2009\r
+#Tue Mar 31 17:21:18 BST 2009\r
 jalview.schemabinding.version2.ThresholdLine=jalview.schemabinding.version2.descriptors.ThresholdLineDescriptor\r
 jalview.schemabinding.version2.SequenceSetProperties=jalview.schemabinding.version2.descriptors.SequenceSetPropertiesDescriptor\r
 jalview.schemabinding.version2.StructureState=jalview.schemabinding.version2.descriptors.StructureStateDescriptor\r
index 5cd78bd..e6f824f 100755 (executable)
@@ -61,6 +61,36 @@ public class Setting implements java.io.Serializable {
      */\r
     private boolean _has_order;\r
 \r
+    /**\r
+     * Optional minimum colour for graduated feature colour\r
+     */\r
+    private int _mincolour;\r
+\r
+    /**\r
+     * keeps track of state for field: _mincolour\r
+     */\r
+    private boolean _has_mincolour;\r
+\r
+    /**\r
+     * threshold value for graduated feature colour\r
+     */\r
+    private float _threshold;\r
+\r
+    /**\r
+     * keeps track of state for field: _threshold\r
+     */\r
+    private boolean _has_threshold;\r
+\r
+    /**\r
+     * threshold type for graduated feature colour\r
+     */\r
+    private int _threshstate;\r
+\r
+    /**\r
+     * keeps track of state for field: _threshstate\r
+     */\r
+    private boolean _has_threshstate;\r
+\r
 \r
       //----------------/\r
      //- Constructors -/\r
@@ -91,12 +121,33 @@ public class Setting implements java.io.Serializable {
 \r
     /**\r
      */\r
+    public void deleteMincolour(\r
+    ) {\r
+        this._has_mincolour= false;\r
+    }\r
+\r
+    /**\r
+     */\r
     public void deleteOrder(\r
     ) {\r
         this._has_order= false;\r
     }\r
 \r
     /**\r
+     */\r
+    public void deleteThreshold(\r
+    ) {\r
+        this._has_threshold= false;\r
+    }\r
+\r
+    /**\r
+     */\r
+    public void deleteThreshstate(\r
+    ) {\r
+        this._has_threshstate= false;\r
+    }\r
+\r
+    /**\r
      * Returns the value of field 'colour'.\r
      * \r
      * @return the value of field 'Colour'.\r
@@ -117,6 +168,18 @@ public class Setting implements java.io.Serializable {
     }\r
 \r
     /**\r
+     * Returns the value of field 'mincolour'. The field\r
+     * 'mincolour' has the following description: Optional minimum\r
+     * colour for graduated feature colour\r
+     * \r
+     * @return the value of field 'Mincolour'.\r
+     */\r
+    public int getMincolour(\r
+    ) {\r
+        return this._mincolour;\r
+    }\r
+\r
+    /**\r
      * Returns the value of field 'order'.\r
      * \r
      * @return the value of field 'Order'.\r
@@ -127,6 +190,30 @@ public class Setting implements java.io.Serializable {
     }\r
 \r
     /**\r
+     * Returns the value of field 'threshold'. The field\r
+     * 'threshold' has the following description: threshold value\r
+     * for graduated feature colour\r
+     * \r
+     * @return the value of field 'Threshold'.\r
+     */\r
+    public float getThreshold(\r
+    ) {\r
+        return this._threshold;\r
+    }\r
+\r
+    /**\r
+     * Returns the value of field 'threshstate'. The field\r
+     * 'threshstate' has the following description: threshold type\r
+     * for graduated feature colour\r
+     * \r
+     * @return the value of field 'Threshstate'.\r
+     */\r
+    public int getThreshstate(\r
+    ) {\r
+        return this._threshstate;\r
+    }\r
+\r
+    /**\r
      * Returns the value of field 'type'.\r
      * \r
      * @return the value of field 'Type'.\r
@@ -157,6 +244,16 @@ public class Setting implements java.io.Serializable {
     }\r
 \r
     /**\r
+     * Method hasMincolour.\r
+     * \r
+     * @return true if at least one Mincolour has been added\r
+     */\r
+    public boolean hasMincolour(\r
+    ) {\r
+        return this._has_mincolour;\r
+    }\r
+\r
+    /**\r
      * Method hasOrder.\r
      * \r
      * @return true if at least one Order has been added\r
@@ -167,6 +264,26 @@ public class Setting implements java.io.Serializable {
     }\r
 \r
     /**\r
+     * Method hasThreshold.\r
+     * \r
+     * @return true if at least one Threshold has been added\r
+     */\r
+    public boolean hasThreshold(\r
+    ) {\r
+        return this._has_threshold;\r
+    }\r
+\r
+    /**\r
+     * Method hasThreshstate.\r
+     * \r
+     * @return true if at least one Threshstate has been added\r
+     */\r
+    public boolean hasThreshstate(\r
+    ) {\r
+        return this._has_threshstate;\r
+    }\r
+\r
+    /**\r
      * Returns the value of field 'display'.\r
      * \r
      * @return the value of field 'Display'.\r
@@ -246,6 +363,19 @@ public class Setting implements java.io.Serializable {
     }\r
 \r
     /**\r
+     * Sets the value of field 'mincolour'. The field 'mincolour'\r
+     * has the following description: Optional minimum colour for\r
+     * graduated feature colour\r
+     * \r
+     * @param mincolour the value of field 'mincolour'.\r
+     */\r
+    public void setMincolour(\r
+            final int mincolour) {\r
+        this._mincolour = mincolour;\r
+        this._has_mincolour = true;\r
+    }\r
+\r
+    /**\r
      * Sets the value of field 'order'.\r
      * \r
      * @param order the value of field 'order'.\r
@@ -257,6 +387,32 @@ public class Setting implements java.io.Serializable {
     }\r
 \r
     /**\r
+     * Sets the value of field 'threshold'. The field 'threshold'\r
+     * has the following description: threshold value for graduated\r
+     * feature colour\r
+     * \r
+     * @param threshold the value of field 'threshold'.\r
+     */\r
+    public void setThreshold(\r
+            final float threshold) {\r
+        this._threshold = threshold;\r
+        this._has_threshold = true;\r
+    }\r
+\r
+    /**\r
+     * Sets the value of field 'threshstate'. The field\r
+     * 'threshstate' has the following description: threshold type\r
+     * for graduated feature colour\r
+     * \r
+     * @param threshstate the value of field 'threshstate'.\r
+     */\r
+    public void setThreshstate(\r
+            final int threshstate) {\r
+        this._threshstate = threshstate;\r
+        this._has_threshstate = true;\r
+    }\r
+\r
+    /**\r
      * Sets the value of field 'type'.\r
      * \r
      * @param type the value of field 'type'.\r
index 23783bb..8122411 100644 (file)
@@ -226,6 +226,135 @@ public class SettingDescriptor extends org.exolab.castor.xml.util.XMLClassDescri
             typeValidator.setMaxInclusive((float) 3.4028235E38);\r
         }\r
         desc.setValidator(fieldValidator);\r
+        //-- _mincolour\r
+        desc = new org.exolab.castor.xml.util.XMLFieldDescriptorImpl(java.lang.Integer.TYPE, "_mincolour", "mincolour", org.exolab.castor.xml.NodeType.Attribute);\r
+        handler = new org.exolab.castor.xml.XMLFieldHandler() {\r
+            public java.lang.Object getValue( java.lang.Object object ) \r
+                throws IllegalStateException\r
+            {\r
+                Setting target = (Setting) object;\r
+                if (!target.hasMincolour()) { return null; }\r
+                return new java.lang.Integer(target.getMincolour());\r
+            }\r
+            public void setValue( java.lang.Object object, java.lang.Object value) \r
+                throws IllegalStateException, IllegalArgumentException\r
+            {\r
+                try {\r
+                    Setting target = (Setting) object;\r
+                    // if null, use delete method for optional primitives \r
+                    if (value == null) {\r
+                        target.deleteMincolour();\r
+                        return;\r
+                    }\r
+                    target.setMincolour( ((java.lang.Integer) value).intValue());\r
+                } catch (java.lang.Exception ex) {\r
+                    throw new IllegalStateException(ex.toString());\r
+                }\r
+            }\r
+            public java.lang.Object newInstance(java.lang.Object parent) {\r
+                return null;\r
+            }\r
+        };\r
+        desc.setHandler(handler);\r
+        desc.setMultivalued(false);\r
+        addFieldDescriptor(desc);\r
+        \r
+        //-- validation code for: _mincolour\r
+        fieldValidator = new org.exolab.castor.xml.FieldValidator();\r
+        { //-- local scope\r
+            org.exolab.castor.xml.validators.IntValidator typeValidator;\r
+            typeValidator = new org.exolab.castor.xml.validators.IntValidator();\r
+            fieldValidator.setValidator(typeValidator);\r
+            typeValidator.setMinInclusive(-2147483648);\r
+            typeValidator.setMaxInclusive(2147483647);\r
+        }\r
+        desc.setValidator(fieldValidator);\r
+        //-- _threshold\r
+        desc = new org.exolab.castor.xml.util.XMLFieldDescriptorImpl(java.lang.Float.TYPE, "_threshold", "threshold", org.exolab.castor.xml.NodeType.Attribute);\r
+        handler = new org.exolab.castor.xml.XMLFieldHandler() {\r
+            public java.lang.Object getValue( java.lang.Object object ) \r
+                throws IllegalStateException\r
+            {\r
+                Setting target = (Setting) object;\r
+                if (!target.hasThreshold()) { return null; }\r
+                return new java.lang.Float(target.getThreshold());\r
+            }\r
+            public void setValue( java.lang.Object object, java.lang.Object value) \r
+                throws IllegalStateException, IllegalArgumentException\r
+            {\r
+                try {\r
+                    Setting target = (Setting) object;\r
+                    // if null, use delete method for optional primitives \r
+                    if (value == null) {\r
+                        target.deleteThreshold();\r
+                        return;\r
+                    }\r
+                    target.setThreshold( ((java.lang.Float) value).floatValue());\r
+                } catch (java.lang.Exception ex) {\r
+                    throw new IllegalStateException(ex.toString());\r
+                }\r
+            }\r
+            public java.lang.Object newInstance(java.lang.Object parent) {\r
+                return null;\r
+            }\r
+        };\r
+        desc.setHandler(handler);\r
+        desc.setMultivalued(false);\r
+        addFieldDescriptor(desc);\r
+        \r
+        //-- validation code for: _threshold\r
+        fieldValidator = new org.exolab.castor.xml.FieldValidator();\r
+        { //-- local scope\r
+            org.exolab.castor.xml.validators.FloatValidator typeValidator;\r
+            typeValidator = new org.exolab.castor.xml.validators.FloatValidator();\r
+            fieldValidator.setValidator(typeValidator);\r
+            typeValidator.setMinInclusive((float) -3.4028235E38);\r
+            typeValidator.setMaxInclusive((float) 3.4028235E38);\r
+        }\r
+        desc.setValidator(fieldValidator);\r
+        //-- _threshstate\r
+        desc = new org.exolab.castor.xml.util.XMLFieldDescriptorImpl(java.lang.Integer.TYPE, "_threshstate", "threshstate", org.exolab.castor.xml.NodeType.Attribute);\r
+        handler = new org.exolab.castor.xml.XMLFieldHandler() {\r
+            public java.lang.Object getValue( java.lang.Object object ) \r
+                throws IllegalStateException\r
+            {\r
+                Setting target = (Setting) object;\r
+                if (!target.hasThreshstate()) { return null; }\r
+                return new java.lang.Integer(target.getThreshstate());\r
+            }\r
+            public void setValue( java.lang.Object object, java.lang.Object value) \r
+                throws IllegalStateException, IllegalArgumentException\r
+            {\r
+                try {\r
+                    Setting target = (Setting) object;\r
+                    // if null, use delete method for optional primitives \r
+                    if (value == null) {\r
+                        target.deleteThreshstate();\r
+                        return;\r
+                    }\r
+                    target.setThreshstate( ((java.lang.Integer) value).intValue());\r
+                } catch (java.lang.Exception ex) {\r
+                    throw new IllegalStateException(ex.toString());\r
+                }\r
+            }\r
+            public java.lang.Object newInstance(java.lang.Object parent) {\r
+                return null;\r
+            }\r
+        };\r
+        desc.setHandler(handler);\r
+        desc.setMultivalued(false);\r
+        addFieldDescriptor(desc);\r
+        \r
+        //-- validation code for: _threshstate\r
+        fieldValidator = new org.exolab.castor.xml.FieldValidator();\r
+        { //-- local scope\r
+            org.exolab.castor.xml.validators.IntValidator typeValidator;\r
+            typeValidator = new org.exolab.castor.xml.validators.IntValidator();\r
+            fieldValidator.setValidator(typeValidator);\r
+            typeValidator.setMinInclusive(-2147483648);\r
+            typeValidator.setMaxInclusive(2147483647);\r
+        }\r
+        desc.setValidator(fieldValidator);\r
         //-- initialize element descriptors\r
         \r
     }\r