From 08147bef2f987d715de9d4c617c7beb58a326d42 Mon Sep 17 00:00:00 2001 From: jprocter Date: Tue, 31 Mar 2009 16:39:56 +0000 Subject: [PATCH 1/1] prototype for store/restore of feature colour gradient settings --- schemas/jalview.xsd | 11 +- src/jalview/gui/Jalview2XML.java | 16 +- src/jalview/schemabinding/version2/.castor.cdr | 2 +- src/jalview/schemabinding/version2/Setting.java | 156 ++++++++++++++++++++ .../version2/descriptors/SettingDescriptor.java | 129 ++++++++++++++++ 5 files changed, 309 insertions(+), 5 deletions(-) diff --git a/schemas/jalview.xsd b/schemas/jalview.xsd index 72c1270..bcc0438 100755 --- a/schemas/jalview.xsd +++ b/schemas/jalview.xsd @@ -178,7 +178,16 @@ - + + Optional minimum colour for graduated feature colour + + + threshold value for graduated feature colour + + + threshold type for graduated feature colour + + diff --git a/src/jalview/gui/Jalview2XML.java b/src/jalview/gui/Jalview2XML.java index db53d00..b3cf1af 100755 --- a/src/jalview/gui/Jalview2XML.java +++ b/src/jalview/gui/Jalview2XML.java @@ -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( diff --git a/src/jalview/schemabinding/version2/.castor.cdr b/src/jalview/schemabinding/version2/.castor.cdr index 92a62c4..1114d86 100644 --- a/src/jalview/schemabinding/version2/.castor.cdr +++ b/src/jalview/schemabinding/version2/.castor.cdr @@ -1,4 +1,4 @@ -#Fri Feb 06 14:21:53 GMT 2009 +#Tue Mar 31 17:21:18 BST 2009 jalview.schemabinding.version2.ThresholdLine=jalview.schemabinding.version2.descriptors.ThresholdLineDescriptor jalview.schemabinding.version2.SequenceSetProperties=jalview.schemabinding.version2.descriptors.SequenceSetPropertiesDescriptor jalview.schemabinding.version2.StructureState=jalview.schemabinding.version2.descriptors.StructureStateDescriptor diff --git a/src/jalview/schemabinding/version2/Setting.java b/src/jalview/schemabinding/version2/Setting.java index 5cd78bd..e6f824f 100755 --- a/src/jalview/schemabinding/version2/Setting.java +++ b/src/jalview/schemabinding/version2/Setting.java @@ -61,6 +61,36 @@ public class Setting implements java.io.Serializable { */ private boolean _has_order; + /** + * Optional minimum colour for graduated feature colour + */ + private int _mincolour; + + /** + * keeps track of state for field: _mincolour + */ + private boolean _has_mincolour; + + /** + * threshold value for graduated feature colour + */ + private float _threshold; + + /** + * keeps track of state for field: _threshold + */ + private boolean _has_threshold; + + /** + * threshold type for graduated feature colour + */ + private int _threshstate; + + /** + * keeps track of state for field: _threshstate + */ + private boolean _has_threshstate; + //----------------/ //- Constructors -/ @@ -91,12 +121,33 @@ public class Setting implements java.io.Serializable { /** */ + public void deleteMincolour( + ) { + this._has_mincolour= false; + } + + /** + */ public void deleteOrder( ) { this._has_order= false; } /** + */ + public void deleteThreshold( + ) { + this._has_threshold= false; + } + + /** + */ + public void deleteThreshstate( + ) { + this._has_threshstate= false; + } + + /** * Returns the value of field 'colour'. * * @return the value of field 'Colour'. @@ -117,6 +168,18 @@ public class Setting implements java.io.Serializable { } /** + * Returns the value of field 'mincolour'. The field + * 'mincolour' has the following description: Optional minimum + * colour for graduated feature colour + * + * @return the value of field 'Mincolour'. + */ + public int getMincolour( + ) { + return this._mincolour; + } + + /** * Returns the value of field 'order'. * * @return the value of field 'Order'. @@ -127,6 +190,30 @@ public class Setting implements java.io.Serializable { } /** + * Returns the value of field 'threshold'. The field + * 'threshold' has the following description: threshold value + * for graduated feature colour + * + * @return the value of field 'Threshold'. + */ + public float getThreshold( + ) { + return this._threshold; + } + + /** + * Returns the value of field 'threshstate'. The field + * 'threshstate' has the following description: threshold type + * for graduated feature colour + * + * @return the value of field 'Threshstate'. + */ + public int getThreshstate( + ) { + return this._threshstate; + } + + /** * Returns the value of field 'type'. * * @return the value of field 'Type'. @@ -157,6 +244,16 @@ public class Setting implements java.io.Serializable { } /** + * Method hasMincolour. + * + * @return true if at least one Mincolour has been added + */ + public boolean hasMincolour( + ) { + return this._has_mincolour; + } + + /** * Method hasOrder. * * @return true if at least one Order has been added @@ -167,6 +264,26 @@ public class Setting implements java.io.Serializable { } /** + * Method hasThreshold. + * + * @return true if at least one Threshold has been added + */ + public boolean hasThreshold( + ) { + return this._has_threshold; + } + + /** + * Method hasThreshstate. + * + * @return true if at least one Threshstate has been added + */ + public boolean hasThreshstate( + ) { + return this._has_threshstate; + } + + /** * Returns the value of field 'display'. * * @return the value of field 'Display'. @@ -246,6 +363,19 @@ public class Setting implements java.io.Serializable { } /** + * Sets the value of field 'mincolour'. The field 'mincolour' + * has the following description: Optional minimum colour for + * graduated feature colour + * + * @param mincolour the value of field 'mincolour'. + */ + public void setMincolour( + final int mincolour) { + this._mincolour = mincolour; + this._has_mincolour = true; + } + + /** * Sets the value of field 'order'. * * @param order the value of field 'order'. @@ -257,6 +387,32 @@ public class Setting implements java.io.Serializable { } /** + * Sets the value of field 'threshold'. The field 'threshold' + * has the following description: threshold value for graduated + * feature colour + * + * @param threshold the value of field 'threshold'. + */ + public void setThreshold( + final float threshold) { + this._threshold = threshold; + this._has_threshold = true; + } + + /** + * Sets the value of field 'threshstate'. The field + * 'threshstate' has the following description: threshold type + * for graduated feature colour + * + * @param threshstate the value of field 'threshstate'. + */ + public void setThreshstate( + final int threshstate) { + this._threshstate = threshstate; + this._has_threshstate = true; + } + + /** * Sets the value of field 'type'. * * @param type the value of field 'type'. diff --git a/src/jalview/schemabinding/version2/descriptors/SettingDescriptor.java b/src/jalview/schemabinding/version2/descriptors/SettingDescriptor.java index 23783bb..8122411 100644 --- a/src/jalview/schemabinding/version2/descriptors/SettingDescriptor.java +++ b/src/jalview/schemabinding/version2/descriptors/SettingDescriptor.java @@ -226,6 +226,135 @@ public class SettingDescriptor extends org.exolab.castor.xml.util.XMLClassDescri typeValidator.setMaxInclusive((float) 3.4028235E38); } desc.setValidator(fieldValidator); + //-- _mincolour + desc = new org.exolab.castor.xml.util.XMLFieldDescriptorImpl(java.lang.Integer.TYPE, "_mincolour", "mincolour", org.exolab.castor.xml.NodeType.Attribute); + handler = new org.exolab.castor.xml.XMLFieldHandler() { + public java.lang.Object getValue( java.lang.Object object ) + throws IllegalStateException + { + Setting target = (Setting) object; + if (!target.hasMincolour()) { return null; } + return new java.lang.Integer(target.getMincolour()); + } + public void setValue( java.lang.Object object, java.lang.Object value) + throws IllegalStateException, IllegalArgumentException + { + try { + Setting target = (Setting) object; + // if null, use delete method for optional primitives + if (value == null) { + target.deleteMincolour(); + return; + } + target.setMincolour( ((java.lang.Integer) value).intValue()); + } catch (java.lang.Exception ex) { + throw new IllegalStateException(ex.toString()); + } + } + public java.lang.Object newInstance(java.lang.Object parent) { + return null; + } + }; + desc.setHandler(handler); + desc.setMultivalued(false); + addFieldDescriptor(desc); + + //-- validation code for: _mincolour + fieldValidator = new org.exolab.castor.xml.FieldValidator(); + { //-- local scope + org.exolab.castor.xml.validators.IntValidator typeValidator; + typeValidator = new org.exolab.castor.xml.validators.IntValidator(); + fieldValidator.setValidator(typeValidator); + typeValidator.setMinInclusive(-2147483648); + typeValidator.setMaxInclusive(2147483647); + } + desc.setValidator(fieldValidator); + //-- _threshold + desc = new org.exolab.castor.xml.util.XMLFieldDescriptorImpl(java.lang.Float.TYPE, "_threshold", "threshold", org.exolab.castor.xml.NodeType.Attribute); + handler = new org.exolab.castor.xml.XMLFieldHandler() { + public java.lang.Object getValue( java.lang.Object object ) + throws IllegalStateException + { + Setting target = (Setting) object; + if (!target.hasThreshold()) { return null; } + return new java.lang.Float(target.getThreshold()); + } + public void setValue( java.lang.Object object, java.lang.Object value) + throws IllegalStateException, IllegalArgumentException + { + try { + Setting target = (Setting) object; + // if null, use delete method for optional primitives + if (value == null) { + target.deleteThreshold(); + return; + } + target.setThreshold( ((java.lang.Float) value).floatValue()); + } catch (java.lang.Exception ex) { + throw new IllegalStateException(ex.toString()); + } + } + public java.lang.Object newInstance(java.lang.Object parent) { + return null; + } + }; + desc.setHandler(handler); + desc.setMultivalued(false); + addFieldDescriptor(desc); + + //-- validation code for: _threshold + fieldValidator = new org.exolab.castor.xml.FieldValidator(); + { //-- local scope + org.exolab.castor.xml.validators.FloatValidator typeValidator; + typeValidator = new org.exolab.castor.xml.validators.FloatValidator(); + fieldValidator.setValidator(typeValidator); + typeValidator.setMinInclusive((float) -3.4028235E38); + typeValidator.setMaxInclusive((float) 3.4028235E38); + } + desc.setValidator(fieldValidator); + //-- _threshstate + desc = new org.exolab.castor.xml.util.XMLFieldDescriptorImpl(java.lang.Integer.TYPE, "_threshstate", "threshstate", org.exolab.castor.xml.NodeType.Attribute); + handler = new org.exolab.castor.xml.XMLFieldHandler() { + public java.lang.Object getValue( java.lang.Object object ) + throws IllegalStateException + { + Setting target = (Setting) object; + if (!target.hasThreshstate()) { return null; } + return new java.lang.Integer(target.getThreshstate()); + } + public void setValue( java.lang.Object object, java.lang.Object value) + throws IllegalStateException, IllegalArgumentException + { + try { + Setting target = (Setting) object; + // if null, use delete method for optional primitives + if (value == null) { + target.deleteThreshstate(); + return; + } + target.setThreshstate( ((java.lang.Integer) value).intValue()); + } catch (java.lang.Exception ex) { + throw new IllegalStateException(ex.toString()); + } + } + public java.lang.Object newInstance(java.lang.Object parent) { + return null; + } + }; + desc.setHandler(handler); + desc.setMultivalued(false); + addFieldDescriptor(desc); + + //-- validation code for: _threshstate + fieldValidator = new org.exolab.castor.xml.FieldValidator(); + { //-- local scope + org.exolab.castor.xml.validators.IntValidator typeValidator; + typeValidator = new org.exolab.castor.xml.validators.IntValidator(); + fieldValidator.setValidator(typeValidator); + typeValidator.setMinInclusive(-2147483648); + typeValidator.setMaxInclusive(2147483647); + } + desc.setValidator(fieldValidator); //-- initialize element descriptors } -- 1.7.10.2