From: amwaterhouse Date: Tue, 16 May 2006 13:04:56 +0000 (+0000) Subject: Save annotation colours, hideConsevation etc, graphGroups X-Git-Tag: Release_2_1~404 X-Git-Url: http://source.jalview.org/gitweb/?a=commitdiff_plain;h=501657b3f11ab8e83271b6500375d8ae80b66c84;p=jalview.git Save annotation colours, hideConsevation etc, graphGroups --- diff --git a/src/jalview/gui/Jalview2XML.java b/src/jalview/gui/Jalview2XML.java index 227cb49..f34a764 100755 --- a/src/jalview/gui/Jalview2XML.java +++ b/src/jalview/gui/Jalview2XML.java @@ -307,14 +307,19 @@ public class Jalview2XML for (int i = 0; i < aa.length; i++) { + Annotation an = new Annotation(); + if (aa[i].label.equals("Quality") || aa[i].label.equals("Conservation") || aa[i].label.equals("Consensus")) { + an.setLabel(aa[i].label); + an.setGraph(true); + vamsasSet.addAnnotation(an); continue; } - Annotation an = new Annotation(); + an.setDescription(aa[i].description); if(aa[i].sequenceRef!=null) @@ -326,6 +331,7 @@ public class Jalview2XML { an.setGraph(true); an.setGraphType(aa[i].graph); + an.setGraphGroup(aa[i].graphGroup); if(aa[i].getThreshold()!=null) { ThresholdLine line = new ThresholdLine(); @@ -356,6 +362,10 @@ public class Jalview2XML ae.setPosition(a); ae.setSecondaryStructure(aa[i].annotations[a].secondaryStructure + ""); + + if(aa[i].annotations[a].colour!=java.awt.Color.black) + ae.setColour(aa[i].annotations[a].colour.getRGB()); + an.addAnnotationElement(ae); } @@ -777,15 +787,36 @@ public class Jalview2XML } } + ///////////////////////////////// ////////////////////////////////// //LOAD ANNOTATIONS + boolean hideQuality = true, + hideConservation = true, + hideConsensus = true; + if (vamsasSet.getAnnotation() != null) { Annotation[] an = vamsasSet.getAnnotation(); for (int i = 0; i < an.length; i++) { + if (an[i].getLabel().equals("Quality")) + { + hideQuality = false; + continue; + } + else if(an[i].getLabel().equals("Conservation")) + { + hideConservation = false; + continue; + } + else if(an[i].getLabel().equals("Consensus")) + { + hideConsensus = false; + continue; + } + AnnotationElement[] ae = an[i].getAnnotationElement(); jalview.datamodel.Annotation[] anot = new jalview.datamodel.Annotation[al.getWidth()]; @@ -795,6 +826,7 @@ public class Jalview2XML ae[aa].getDescription(), ae[aa].getSecondaryStructure().length()==0?' ':ae[aa].getSecondaryStructure().charAt(0), ae[aa].getValue()); + anot[ae[aa].getPosition()].colour = new java.awt.Color( ae[aa].getColour() ); } jalview.datamodel.AlignmentAnnotation jaa = null; @@ -805,6 +837,8 @@ public class Jalview2XML an[i].getDescription(), anot, 0, 0, an[i].getGraphType()); + jaa.graphGroup = an[i].getGraphGroup(); + if (an[i].getThresholdLine() != null) { jaa.setThreshold(new jalview.datamodel.GraphLine( @@ -835,14 +869,6 @@ public class Jalview2XML } - ///////////////////////////////// - // LOAD VIEWPORT - Viewport[] views = jms.getViewport(); - Viewport view = views[0]; // DEAL WITH MULTIPLE VIEWPORTS LATER - - AlignFrame af = new AlignFrame(al); - - // af.changeColour() ); ///////////////////////// //LOAD GROUPS @@ -902,6 +928,29 @@ public class Jalview2XML } + ///////////////////////////////// + // LOAD VIEWPORT + Viewport[] views = jms.getViewport(); + Viewport view = views[0]; // DEAL WITH MULTIPLE VIEWPORTS LATER + + AlignFrame af = new AlignFrame(al); + int hSize = al.getAlignmentAnnotation().length; + for (int h = 0; h < hSize; h++) + { + if ( + (hideConsensus && + al.getAlignmentAnnotation()[h].label.equals("Consensus")) + || + (hideQuality && al.getAlignmentAnnotation()[h].label.equals("Quality")) + || + (hideConservation && + al.getAlignmentAnnotation()[h].label.equals("Conservation"))) + { + al.deleteAnnotation(al.getAlignmentAnnotation()[h]); + hSize --; + h--; + } + } af.setBounds(view.getXpos(), view.getYpos(), view.getWidth(), view.getHeight()); diff --git a/src/jalview/schemabinding/version2/Annotation.java b/src/jalview/schemabinding/version2/Annotation.java index e6c8e5a..ec9b84c 100755 --- a/src/jalview/schemabinding/version2/Annotation.java +++ b/src/jalview/schemabinding/version2/Annotation.java @@ -61,6 +61,26 @@ public class Annotation implements java.io.Serializable { private java.lang.String _sequenceRef; /** + * Field _graphColour + */ + private int _graphColour; + + /** + * keeps track of state for field: _graphColour + */ + private boolean _has_graphColour; + + /** + * Field _graphGroup + */ + private int _graphGroup; + + /** + * keeps track of state for field: _graphGroup + */ + private boolean _has_graphGroup; + + /** * Field _annotationElementList */ private java.util.Vector _annotationElementList; @@ -132,6 +152,24 @@ public class Annotation implements java.io.Serializable { } //-- void deleteGraph() /** + * Method deleteGraphColour + * + */ + public void deleteGraphColour() + { + this._has_graphColour= false; + } //-- void deleteGraphColour() + + /** + * Method deleteGraphGroup + * + */ + public void deleteGraphGroup() + { + this._has_graphGroup= false; + } //-- void deleteGraphGroup() + + /** * Method deleteGraphType * */ @@ -223,6 +261,28 @@ public class Annotation implements java.io.Serializable { } //-- boolean getGraph() /** + * Returns the value of field 'graphColour'. + * + * @return int + * @return the value of field 'graphColour'. + */ + public int getGraphColour() + { + return this._graphColour; + } //-- int getGraphColour() + + /** + * Returns the value of field 'graphGroup'. + * + * @return int + * @return the value of field 'graphGroup'. + */ + public int getGraphGroup() + { + return this._graphGroup; + } //-- int getGraphGroup() + + /** * Returns the value of field 'graphType'. * * @return int @@ -279,6 +339,30 @@ public class Annotation implements java.io.Serializable { } //-- boolean hasGraph() /** + * Method hasGraphColour + * + * + * + * @return boolean + */ + public boolean hasGraphColour() + { + return this._has_graphColour; + } //-- boolean hasGraphColour() + + /** + * Method hasGraphGroup + * + * + * + * @return boolean + */ + public boolean hasGraphGroup() + { + return this._has_graphGroup; + } //-- boolean hasGraphGroup() + + /** * Method hasGraphType * * @@ -416,6 +500,28 @@ public class Annotation implements java.io.Serializable { } //-- void setGraph(boolean) /** + * Sets the value of field 'graphColour'. + * + * @param graphColour the value of field 'graphColour'. + */ + public void setGraphColour(int graphColour) + { + this._graphColour = graphColour; + this._has_graphColour = true; + } //-- void setGraphColour(int) + + /** + * Sets the value of field 'graphGroup'. + * + * @param graphGroup the value of field 'graphGroup'. + */ + public void setGraphGroup(int graphGroup) + { + this._graphGroup = graphGroup; + this._has_graphGroup = true; + } //-- void setGraphGroup(int) + + /** * Sets the value of field 'graphType'. * * @param graphType the value of field 'graphType'. diff --git a/src/jalview/schemabinding/version2/AnnotationDescriptor.java b/src/jalview/schemabinding/version2/AnnotationDescriptor.java index b3125c3..b2290fe 100755 --- a/src/jalview/schemabinding/version2/AnnotationDescriptor.java +++ b/src/jalview/schemabinding/version2/AnnotationDescriptor.java @@ -183,6 +183,88 @@ public class AnnotationDescriptor extends org.exolab.castor.xml.util.XMLClassDes fieldValidator.setValidator(typeValidator); } desc.setValidator(fieldValidator); + //-- _graphColour + desc = new org.exolab.castor.xml.util.XMLFieldDescriptorImpl(java.lang.Integer.TYPE, "_graphColour", "graphColour", org.exolab.castor.xml.NodeType.Attribute); + handler = (new org.exolab.castor.xml.XMLFieldHandler() { + public java.lang.Object getValue( java.lang.Object object ) + throws IllegalStateException + { + Annotation target = (Annotation) object; + if(!target.hasGraphColour()) + return null; + return new java.lang.Integer(target.getGraphColour()); + } + public void setValue( java.lang.Object object, java.lang.Object value) + throws IllegalStateException, IllegalArgumentException + { + try { + Annotation target = (Annotation) object; + // if null, use delete method for optional primitives + if (value == null) { + target.deleteGraphColour(); + return; + } + target.setGraphColour( ((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); + addFieldDescriptor(desc); + + //-- validation code for: _graphColour + fieldValidator = new org.exolab.castor.xml.FieldValidator(); + { //-- local scope + IntegerValidator typeValidator= new IntegerValidator(); + fieldValidator.setValidator(typeValidator); + } + desc.setValidator(fieldValidator); + //-- _graphGroup + desc = new org.exolab.castor.xml.util.XMLFieldDescriptorImpl(java.lang.Integer.TYPE, "_graphGroup", "graphGroup", org.exolab.castor.xml.NodeType.Attribute); + handler = (new org.exolab.castor.xml.XMLFieldHandler() { + public java.lang.Object getValue( java.lang.Object object ) + throws IllegalStateException + { + Annotation target = (Annotation) object; + if(!target.hasGraphGroup()) + return null; + return new java.lang.Integer(target.getGraphGroup()); + } + public void setValue( java.lang.Object object, java.lang.Object value) + throws IllegalStateException, IllegalArgumentException + { + try { + Annotation target = (Annotation) object; + // if null, use delete method for optional primitives + if (value == null) { + target.deleteGraphGroup(); + return; + } + target.setGraphGroup( ((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); + addFieldDescriptor(desc); + + //-- validation code for: _graphGroup + fieldValidator = new org.exolab.castor.xml.FieldValidator(); + { //-- local scope + IntegerValidator typeValidator= new IntegerValidator(); + fieldValidator.setValidator(typeValidator); + } + desc.setValidator(fieldValidator); //-- initialize element descriptors //-- _annotationElementList @@ -211,13 +293,12 @@ public class AnnotationDescriptor extends org.exolab.castor.xml.util.XMLClassDes } ); desc.setHandler(handler); desc.setNameSpaceURI("www.vamsas.ac.uk/jalview/version2"); - desc.setRequired(true); desc.setMultivalued(true); addFieldDescriptor(desc); //-- validation code for: _annotationElementList fieldValidator = new org.exolab.castor.xml.FieldValidator(); - fieldValidator.setMinOccurs(1); + fieldValidator.setMinOccurs(0); { //-- local scope } desc.setValidator(fieldValidator); @@ -288,13 +369,11 @@ public class AnnotationDescriptor extends org.exolab.castor.xml.util.XMLClassDes } ); desc.setHandler(handler); desc.setNameSpaceURI("www.vamsas.ac.uk/jalview/version2"); - desc.setRequired(true); desc.setMultivalued(false); addFieldDescriptor(desc); //-- validation code for: _description fieldValidator = new org.exolab.castor.xml.FieldValidator(); - fieldValidator.setMinOccurs(1); { //-- local scope StringValidator typeValidator = new StringValidator(); typeValidator.setWhiteSpace("preserve"); diff --git a/src/jalview/schemabinding/version2/AnnotationElement.java b/src/jalview/schemabinding/version2/AnnotationElement.java index 8c91439..2507197 100755 --- a/src/jalview/schemabinding/version2/AnnotationElement.java +++ b/src/jalview/schemabinding/version2/AnnotationElement.java @@ -44,6 +44,16 @@ public class AnnotationElement implements java.io.Serializable { private boolean _has_position; /** + * Field _colour + */ + private int _colour; + + /** + * keeps track of state for field: _colour + */ + private boolean _has_colour; + + /** * Field _displayCharacter */ private java.lang.String _displayCharacter; @@ -83,6 +93,15 @@ public class AnnotationElement implements java.io.Serializable { //-----------/ /** + * Method deleteColour + * + */ + public void deleteColour() + { + this._has_colour= false; + } //-- void deleteColour() + + /** * Method deletePosition * */ @@ -101,6 +120,17 @@ public class AnnotationElement implements java.io.Serializable { } //-- void deleteValue() /** + * Returns the value of field 'colour'. + * + * @return int + * @return the value of field 'colour'. + */ + public int getColour() + { + return this._colour; + } //-- int getColour() + + /** * Returns the value of field 'description'. * * @return String @@ -156,6 +186,18 @@ public class AnnotationElement implements java.io.Serializable { } //-- float getValue() /** + * Method hasColour + * + * + * + * @return boolean + */ + public boolean hasColour() + { + return this._has_colour; + } //-- boolean hasColour() + + /** * Method hasPosition * * @@ -226,6 +268,17 @@ public class AnnotationElement implements java.io.Serializable { } //-- void marshal(org.xml.sax.ContentHandler) /** + * Sets the value of field 'colour'. + * + * @param colour the value of field 'colour'. + */ + public void setColour(int colour) + { + this._colour = colour; + this._has_colour = true; + } //-- void setColour(int) + + /** * Sets the value of field 'description'. * * @param description the value of field 'description'. diff --git a/src/jalview/schemabinding/version2/AnnotationElementDescriptor.java b/src/jalview/schemabinding/version2/AnnotationElementDescriptor.java index 4034755..0eab95b 100755 --- a/src/jalview/schemabinding/version2/AnnotationElementDescriptor.java +++ b/src/jalview/schemabinding/version2/AnnotationElementDescriptor.java @@ -106,6 +106,47 @@ public class AnnotationElementDescriptor extends org.exolab.castor.xml.util.XMLC fieldValidator.setValidator(typeValidator); } desc.setValidator(fieldValidator); + //-- _colour + desc = new org.exolab.castor.xml.util.XMLFieldDescriptorImpl(java.lang.Integer.TYPE, "_colour", "colour", org.exolab.castor.xml.NodeType.Attribute); + handler = (new org.exolab.castor.xml.XMLFieldHandler() { + public java.lang.Object getValue( java.lang.Object object ) + throws IllegalStateException + { + AnnotationElement target = (AnnotationElement) object; + if(!target.hasColour()) + return null; + return new java.lang.Integer(target.getColour()); + } + public void setValue( java.lang.Object object, java.lang.Object value) + throws IllegalStateException, IllegalArgumentException + { + try { + AnnotationElement target = (AnnotationElement) object; + // if null, use delete method for optional primitives + if (value == null) { + target.deleteColour(); + return; + } + target.setColour( ((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); + addFieldDescriptor(desc); + + //-- validation code for: _colour + fieldValidator = new org.exolab.castor.xml.FieldValidator(); + { //-- local scope + IntegerValidator typeValidator= new IntegerValidator(); + fieldValidator.setValidator(typeValidator); + } + desc.setValidator(fieldValidator); //-- initialize element descriptors //-- _displayCharacter @@ -135,13 +176,11 @@ public class AnnotationElementDescriptor extends org.exolab.castor.xml.util.XMLC } ); desc.setHandler(handler); desc.setNameSpaceURI("www.vamsas.ac.uk/jalview/version2"); - desc.setRequired(true); desc.setMultivalued(false); addFieldDescriptor(desc); //-- validation code for: _displayCharacter fieldValidator = new org.exolab.castor.xml.FieldValidator(); - fieldValidator.setMinOccurs(1); { //-- local scope StringValidator typeValidator = new StringValidator(); typeValidator.setWhiteSpace("preserve"); @@ -175,13 +214,11 @@ public class AnnotationElementDescriptor extends org.exolab.castor.xml.util.XMLC } ); desc.setHandler(handler); desc.setNameSpaceURI("www.vamsas.ac.uk/jalview/version2"); - desc.setRequired(true); desc.setMultivalued(false); addFieldDescriptor(desc); //-- validation code for: _description fieldValidator = new org.exolab.castor.xml.FieldValidator(); - fieldValidator.setMinOccurs(1); { //-- local scope StringValidator typeValidator = new StringValidator(); typeValidator.setWhiteSpace("preserve"); @@ -215,13 +252,11 @@ public class AnnotationElementDescriptor extends org.exolab.castor.xml.util.XMLC } ); desc.setHandler(handler); desc.setNameSpaceURI("www.vamsas.ac.uk/jalview/version2"); - desc.setRequired(true); desc.setMultivalued(false); addFieldDescriptor(desc); //-- validation code for: _secondaryStructure fieldValidator = new org.exolab.castor.xml.FieldValidator(); - fieldValidator.setMinOccurs(1); { //-- local scope StringValidator typeValidator = new StringValidator(); typeValidator.setLength(1); @@ -245,9 +280,11 @@ public class AnnotationElementDescriptor extends org.exolab.castor.xml.util.XMLC { try { AnnotationElement target = (AnnotationElement) object; - // ignore null values for non optional primitives - if (value == null) return; - + // if null, use delete method for optional primitives + if (value == null) { + target.deleteValue(); + return; + } target.setValue( ((java.lang.Float)value).floatValue()); } catch (java.lang.Exception ex) { @@ -260,13 +297,11 @@ public class AnnotationElementDescriptor extends org.exolab.castor.xml.util.XMLC } ); desc.setHandler(handler); desc.setNameSpaceURI("www.vamsas.ac.uk/jalview/version2"); - desc.setRequired(true); desc.setMultivalued(false); addFieldDescriptor(desc); //-- validation code for: _value fieldValidator = new org.exolab.castor.xml.FieldValidator(); - fieldValidator.setMinOccurs(1); { //-- local scope FloatValidator typeValidator = new FloatValidator(); fieldValidator.setValidator(typeValidator);