From: amwaterhouse Date: Wed, 9 Aug 2006 08:50:36 +0000 (+0000) Subject: Save links and scores and keyValues for features X-Git-Tag: Release_2_1~140 X-Git-Url: http://source.jalview.org/gitweb/?a=commitdiff_plain;h=73b285377601705bd5f500fee0ae6b5a06b1f2c4;p=jalview.git Save links and scores and keyValues for features --- diff --git a/schemas/jalview.xsd b/schemas/jalview.xsd index 6c1e65f..5ebae84 100755 --- a/schemas/jalview.xsd +++ b/schemas/jalview.xsd @@ -1,7 +1,7 @@ - - + + @@ -133,12 +133,21 @@ + + + + + + + + + diff --git a/src/jalview/datamodel/SequenceFeature.java b/src/jalview/datamodel/SequenceFeature.java index ef391eb..b50c50d 100755 --- a/src/jalview/datamodel/SequenceFeature.java +++ b/src/jalview/datamodel/SequenceFeature.java @@ -33,7 +33,7 @@ public class SequenceFeature public float score; public String type; public String description; - Hashtable otherDetails; + public Hashtable otherDetails; public java.util.Vector links; // Feature group can be set from a features file diff --git a/src/jalview/gui/Jalview2XML.java b/src/jalview/gui/Jalview2XML.java index 95912fe..f1f8bb7 100755 --- a/src/jalview/gui/Jalview2XML.java +++ b/src/jalview/gui/Jalview2XML.java @@ -253,6 +253,32 @@ public class Jalview2XML features.setDescription(sf[index].getDescription()); features.setType(sf[index].getType()); features.setFeatureGroup(sf[index].getFeatureGroup()); + features.setScore(sf[index].getScore()); + if(sf[index].links!=null) + { + for(int l=0; l _otherDataList.size())) { + throw new IndexOutOfBoundsException(); + } + + return (jalview.schemabinding.version2.OtherData) _otherDataList.elementAt(index); + } //-- jalview.schemabinding.version2.OtherData getOtherData(int) + + /** + * Method getOtherData + * + * + * + * @return OtherData + */ + public jalview.schemabinding.version2.OtherData[] getOtherData() + { + int size = _otherDataList.size(); + jalview.schemabinding.version2.OtherData[] mArray = new jalview.schemabinding.version2.OtherData[size]; + for (int index = 0; index < size; index++) { + mArray[index] = (jalview.schemabinding.version2.OtherData) _otherDataList.elementAt(index); + } + return mArray; + } //-- jalview.schemabinding.version2.OtherData[] getOtherData() + + /** + * Method getOtherDataCount + * + * + * + * @return int + */ + public int getOtherDataCount() + { + return _otherDataList.size(); + } //-- int getOtherDataCount() + + /** + * Returns the value of field 'score'. + * + * @return float + * @return the value of field 'score'. + */ + public float getScore() + { + return this._score; + } //-- float getScore() + + /** * Returns the value of field 'status'. * * @return String @@ -196,6 +321,18 @@ public class Feature implements java.io.Serializable { } //-- boolean hasEnd() /** + * Method hasScore + * + * + * + * @return boolean + */ + public boolean hasScore() + { + return this._has_score; + } //-- boolean hasScore() + + /** * Method isValid * * @@ -242,6 +379,30 @@ public class Feature implements java.io.Serializable { } //-- void marshal(org.xml.sax.ContentHandler) /** + * Method removeAllOtherData + * + */ + public void removeAllOtherData() + { + _otherDataList.removeAllElements(); + } //-- void removeAllOtherData() + + /** + * Method removeOtherData + * + * + * + * @param index + * @return OtherData + */ + public jalview.schemabinding.version2.OtherData removeOtherData(int index) + { + java.lang.Object obj = _otherDataList.elementAt(index); + _otherDataList.removeElementAt(index); + return (jalview.schemabinding.version2.OtherData) obj; + } //-- jalview.schemabinding.version2.OtherData removeOtherData(int) + + /** * Sets the value of field 'begin'. * * @param begin the value of field 'begin'. @@ -284,6 +445,51 @@ public class Feature implements java.io.Serializable { } //-- void setFeatureGroup(java.lang.String) /** + * Method setOtherData + * + * + * + * @param index + * @param vOtherData + */ + public void setOtherData(int index, jalview.schemabinding.version2.OtherData vOtherData) + throws java.lang.IndexOutOfBoundsException + { + //-- check bounds for index + if ((index < 0) || (index > _otherDataList.size())) { + throw new IndexOutOfBoundsException(); + } + _otherDataList.setElementAt(vOtherData, index); + } //-- void setOtherData(int, jalview.schemabinding.version2.OtherData) + + /** + * Method setOtherData + * + * + * + * @param otherDataArray + */ + public void setOtherData(jalview.schemabinding.version2.OtherData[] otherDataArray) + { + //-- copy array + _otherDataList.removeAllElements(); + for (int i = 0; i < otherDataArray.length; i++) { + _otherDataList.addElement(otherDataArray[i]); + } + } //-- void setOtherData(jalview.schemabinding.version2.OtherData) + + /** + * Sets the value of field 'score'. + * + * @param score the value of field 'score'. + */ + public void setScore(float score) + { + this._score = score; + this._has_score = true; + } //-- void setScore(float) + + /** * Sets the value of field 'status'. * * @param status the value of field 'status'. diff --git a/src/jalview/schemabinding/version2/FeatureDescriptor.java b/src/jalview/schemabinding/version2/FeatureDescriptor.java index ac172e8..d0b9372 100755 --- a/src/jalview/schemabinding/version2/FeatureDescriptor.java +++ b/src/jalview/schemabinding/version2/FeatureDescriptor.java @@ -57,6 +57,9 @@ public class FeatureDescriptor extends org.exolab.castor.xml.util.XMLClassDescri super(); nsURI = "www.jalview.org"; xmlName = "feature"; + + //-- set grouping compositor + setCompositorAsSequence(); org.exolab.castor.xml.util.XMLFieldDescriptorImpl desc = null; org.exolab.castor.xml.XMLFieldHandler handler = null; org.exolab.castor.xml.FieldValidator fieldValidator = null; @@ -290,8 +293,84 @@ public class FeatureDescriptor extends org.exolab.castor.xml.util.XMLClassDescri fieldValidator.setValidator(typeValidator); } desc.setValidator(fieldValidator); + //-- _score + desc = new org.exolab.castor.xml.util.XMLFieldDescriptorImpl(float.class, "_score", "score", org.exolab.castor.xml.NodeType.Attribute); + handler = (new org.exolab.castor.xml.XMLFieldHandler() { + public java.lang.Object getValue( java.lang.Object object ) + throws IllegalStateException + { + Feature target = (Feature) object; + if(!target.hasScore()) + return null; + return new java.lang.Float(target.getScore()); + } + public void setValue( java.lang.Object object, java.lang.Object value) + throws IllegalStateException, IllegalArgumentException + { + try { + Feature target = (Feature) object; + // if null, use delete method for optional primitives + if (value == null) { + target.deleteScore(); + return; + } + target.setScore( ((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); + addFieldDescriptor(desc); + + //-- validation code for: _score + fieldValidator = new org.exolab.castor.xml.FieldValidator(); + { //-- local scope + FloatValidator typeValidator = new FloatValidator(); + fieldValidator.setValidator(typeValidator); + } + desc.setValidator(fieldValidator); //-- initialize element descriptors + //-- _otherDataList + desc = new org.exolab.castor.xml.util.XMLFieldDescriptorImpl(jalview.schemabinding.version2.OtherData.class, "_otherDataList", "otherData", org.exolab.castor.xml.NodeType.Element); + handler = (new org.exolab.castor.xml.XMLFieldHandler() { + public java.lang.Object getValue( java.lang.Object object ) + throws IllegalStateException + { + Feature target = (Feature) object; + return target.getOtherData(); + } + public void setValue( java.lang.Object object, java.lang.Object value) + throws IllegalStateException, IllegalArgumentException + { + try { + Feature target = (Feature) object; + target.addOtherData( (jalview.schemabinding.version2.OtherData) value); + } + catch (java.lang.Exception ex) { + throw new IllegalStateException(ex.toString()); + } + } + public java.lang.Object newInstance( java.lang.Object parent ) { + return new jalview.schemabinding.version2.OtherData(); + } + } ); + desc.setHandler(handler); + desc.setNameSpaceURI("www.jalview.org"); + desc.setMultivalued(true); + addFieldDescriptor(desc); + + //-- validation code for: _otherDataList + fieldValidator = new org.exolab.castor.xml.FieldValidator(); + fieldValidator.setMinOccurs(0); + { //-- local scope + } + desc.setValidator(fieldValidator); } //-- jalview.schemabinding.version2.FeatureDescriptor()