From f8efe615d1c7d5c23fd838c1abcd77be542b154c Mon Sep 17 00:00:00 2001 From: jprocter Date: Mon, 25 Apr 2011 16:21:40 +0000 Subject: [PATCH] JAL-824 - patch to schema to allow jmol colouring state to be stored --- schemas/jalview.xsd | 7 +- src/jalview/gui/Jalview2XML.java | 11 +-- src/jalview/schemabinding/version2/.castor.cdr | 2 +- .../schemabinding/version2/StructureState.java | 74 +++++++++++++++++++- .../descriptors/StructureStateDescriptor.java | 41 +++++++++++ 5 files changed, 127 insertions(+), 8 deletions(-) diff --git a/schemas/jalview.xsd b/schemas/jalview.xsd index 8ba8b4b..7780c06 100755 --- a/schemas/jalview.xsd +++ b/schemas/jalview.xsd @@ -59,14 +59,17 @@ - + Flag set if the alignment panel containing this JSeq should be included in those used to colour its associated sequences in this structureState(since Jalview 2.7). - + + + Flag set if the structure display is coloured by the Jmol state, rather than by one or more linked alignment views. + diff --git a/src/jalview/gui/Jalview2XML.java b/src/jalview/gui/Jalview2XML.java index 2df51b1..5a13723 100755 --- a/src/jalview/gui/Jalview2XML.java +++ b/src/jalview/gui/Jalview2XML.java @@ -624,6 +624,7 @@ public class Jalview2XML state.setAlignwithAlignPanel(jmol.isUsedforaligment(ap)); state.setColourwithAlignPanel(jmol .isUsedforcolourby(ap)); + state.setColourByJmol(jmol.isColouredByJmol()); if (!jmolViewIds.contains(state.getViewId())) { // Make sure we only store a Jmol state once in each XML @@ -2573,7 +2574,7 @@ public class Jalview2XML { new int[] { x, y, width, height }, "", new Hashtable(), new boolean[] - { false, false } }); + { false, false, true } }); // Legacy pre-2.7 conversion JAL-823 : // do not assume any view has to be linked for colour by sequence } @@ -2591,6 +2592,8 @@ public class Jalview2XML .hasColourwithAlignPanel() ? ids[p] .getStructureState(s).getColourwithAlignPanel() : false; + // default for pre-2.7 projects is that Jmol colouring is enabled + ((boolean[])jmoldat[3])[2] &=ids[p].getStructureState(s).hasColourByJmol() ? ids[p].getStructureState(s).getColourByJmol() : true; if (((String) jmoldat[1]).length() < ids[p] .getStructureState(s).getContent().length()) @@ -2630,7 +2633,7 @@ public class Jalview2XML int[] geom = (int[]) svattrib[0]; String state = (String) svattrib[1]; Hashtable oldFiles = (Hashtable) svattrib[2]; - final boolean useinJmolsuperpos = ((boolean[]) svattrib[3])[0], usetoColourbyseq = ((boolean[]) svattrib[3])[1]; + final boolean useinJmolsuperpos = ((boolean[]) svattrib[3])[0], usetoColourbyseq = ((boolean[]) svattrib[3])[1], jmolColouring=((boolean[])svattrib[3])[2]; int x = geom[0], y = geom[1], width = geom[2], height = geom[3]; // collate the pdbfile -> sequence mappings from this view Vector pdbfilenames = new Vector(); @@ -2786,7 +2789,7 @@ public class Jalview2XML try { sview = new AppJmol(pdbf, id, sq, alf.alignPanel, - useinJmolsuperpos, usetoColourbyseq, fileloc, + useinJmolsuperpos, usetoColourbyseq, jmolColouring, fileloc, rect, vid); } catch (OutOfMemoryError ex) { @@ -2845,7 +2848,7 @@ public class Jalview2XML } if (usetoColourbyseq) { - ((AppJmol) comp).useAlignmentPanelForColourbyseq(ap); + ((AppJmol) comp).useAlignmentPanelForColourbyseq(ap, !jmolColouring); } else { diff --git a/src/jalview/schemabinding/version2/.castor.cdr b/src/jalview/schemabinding/version2/.castor.cdr index 4577127..49d113a 100644 --- a/src/jalview/schemabinding/version2/.castor.cdr +++ b/src/jalview/schemabinding/version2/.castor.cdr @@ -1,4 +1,4 @@ -#Tue Apr 19 14:59:20 BST 2011 +#Mon Apr 25 14:07:25 BST 2011 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/StructureState.java b/src/jalview/schemabinding/version2/StructureState.java index 4432971..c269dce 100644 --- a/src/jalview/schemabinding/version2/StructureState.java +++ b/src/jalview/schemabinding/version2/StructureState.java @@ -112,13 +112,25 @@ public class StructureState implements java.io.Serializable { * in this structureState(since Jalview 2.7). * */ - private boolean _colourwithAlignPanel = true; + private boolean _colourwithAlignPanel = false; /** * keeps track of state for field: _colourwithAlignPanel */ private boolean _has_colourwithAlignPanel; + /** + * Flag set if the structure display is coloured by the Jmol + * state, rather than by one or more linked alignment views. + * + */ + private boolean _colourByJmol = true; + + /** + * keeps track of state for field: _colourByJmol + */ + private boolean _has_colourByJmol; + //----------------/ //- Constructors -/ @@ -143,6 +155,13 @@ public class StructureState implements java.io.Serializable { /** */ + public void deleteColourByJmol( + ) { + this._has_colourByJmol= false; + } + + /** + */ public void deleteColourwithAlignPanel( ) { this._has_colourwithAlignPanel= false; @@ -199,6 +218,20 @@ public class StructureState implements java.io.Serializable { } /** + * Returns the value of field 'colourByJmol'. The field + * 'colourByJmol' has the following description: Flag set if + * the structure display is coloured by the Jmol state, rather + * than by one or more linked alignment views. + * + * + * @return the value of field 'ColourByJmol'. + */ + public boolean getColourByJmol( + ) { + return this._colourByJmol; + } + + /** * Returns the value of field 'colourwithAlignPanel'. The field * 'colourwithAlignPanel' has the following description: Flag * set if the alignment panel containing this JSeq should be @@ -305,6 +338,16 @@ public class StructureState implements java.io.Serializable { } /** + * Method hasColourByJmol. + * + * @return true if at least one ColourByJmol has been added + */ + public boolean hasColourByJmol( + ) { + return this._has_colourByJmol; + } + + /** * Method hasColourwithAlignPanel. * * @return true if at least one ColourwithAlignPanel has been @@ -381,6 +424,20 @@ public class StructureState implements java.io.Serializable { } /** + * Returns the value of field 'colourByJmol'. The field + * 'colourByJmol' has the following description: Flag set if + * the structure display is coloured by the Jmol state, rather + * than by one or more linked alignment views. + * + * + * @return the value of field 'ColourByJmol'. + */ + public boolean isColourByJmol( + ) { + return this._colourByJmol; + } + + /** * Returns the value of field 'colourwithAlignPanel'. The field * 'colourwithAlignPanel' has the following description: Flag * set if the alignment panel containing this JSeq should be @@ -470,6 +527,21 @@ public class StructureState implements java.io.Serializable { } /** + * Sets the value of field 'colourByJmol'. The field + * 'colourByJmol' has the following description: Flag set if + * the structure display is coloured by the Jmol state, rather + * than by one or more linked alignment views. + * + * + * @param colourByJmol the value of field 'colourByJmol'. + */ + public void setColourByJmol( + final boolean colourByJmol) { + this._colourByJmol = colourByJmol; + this._has_colourByJmol = true; + } + + /** * Sets the value of field 'colourwithAlignPanel'. The field * 'colourwithAlignPanel' has the following description: Flag * set if the alignment panel containing this JSeq should be diff --git a/src/jalview/schemabinding/version2/descriptors/StructureStateDescriptor.java b/src/jalview/schemabinding/version2/descriptors/StructureStateDescriptor.java index 5330dfd..4729515 100644 --- a/src/jalview/schemabinding/version2/descriptors/StructureStateDescriptor.java +++ b/src/jalview/schemabinding/version2/descriptors/StructureStateDescriptor.java @@ -428,6 +428,47 @@ public class StructureStateDescriptor extends org.exolab.castor.xml.util.XMLClas fieldValidator.setValidator(typeValidator); } desc.setValidator(fieldValidator); + //-- _colourByJmol + desc = new org.exolab.castor.xml.util.XMLFieldDescriptorImpl(java.lang.Boolean.TYPE, "_colourByJmol", "colourByJmol", org.exolab.castor.xml.NodeType.Attribute); + handler = new org.exolab.castor.xml.XMLFieldHandler() { + public java.lang.Object getValue( java.lang.Object object ) + throws IllegalStateException + { + StructureState target = (StructureState) object; + if (!target.hasColourByJmol()) { return null; } + return (target.getColourByJmol() ? java.lang.Boolean.TRUE : java.lang.Boolean.FALSE); + } + public void setValue( java.lang.Object object, java.lang.Object value) + throws IllegalStateException, IllegalArgumentException + { + try { + StructureState target = (StructureState) object; + // if null, use delete method for optional primitives + if (value == null) { + target.deleteColourByJmol(); + return; + } + target.setColourByJmol( ((java.lang.Boolean) value).booleanValue()); + } 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: _colourByJmol + fieldValidator = new org.exolab.castor.xml.FieldValidator(); + { //-- local scope + org.exolab.castor.xml.validators.BooleanValidator typeValidator; + typeValidator = new org.exolab.castor.xml.validators.BooleanValidator(); + fieldValidator.setValidator(typeValidator); + } + desc.setValidator(fieldValidator); //-- initialize element descriptors } -- 1.7.10.2