X-Git-Url: http://source.jalview.org/gitweb/?a=blobdiff_plain;f=src%2Fjalview%2Fbinding%2FJalviewUserColours.java;h=8df0d448a22418171f6115b7470a7cba5e178a8f;hb=b8d09897dacc7b0ad203982b4578e2c1d8929142;hp=354dc2f36d832f478df9ff7da84d5aff57f231bd;hpb=99c58ee0ae2a848f982552e53feaf6d5cb9925e5;p=jalview.git diff --git a/src/jalview/binding/JalviewUserColours.java b/src/jalview/binding/JalviewUserColours.java index 354dc2f..8df0d44 100755 --- a/src/jalview/binding/JalviewUserColours.java +++ b/src/jalview/binding/JalviewUserColours.java @@ -4,54 +4,36 @@ * Schema. * $Id$ */ +package jalview.binding; -/* -* Jalview - A Sequence Alignment Editor and Viewer -* Copyright (C) 2005 AM Waterhouse, J Procter, G Barton, M Clamp, S Searle -* -* This program is free software; you can redistribute it and/or -* modify it under the terms of the GNU General Public License -* as published by the Free Software Foundation; either version 2 -* of the License, or (at your option) any later version. -* -* This program is distributed in the hope that it will be useful, -* but WITHOUT ANY WARRANTY; without even the implied warranty of -* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -* GNU General Public License for more details. -* -* You should have received a copy of the GNU General Public License -* along with this program; if not, write to the Free Software -* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA -*/ +import org.exolab.castor.xml.MarshalException; +import org.exolab.castor.xml.Marshaller; +import org.exolab.castor.xml.Unmarshaller; +import org.exolab.castor.xml.ValidationException; -package jalview.binding; +import org.xml.sax.ContentHandler; - //---------------------------------/ - //- Imported classes and packages -/ //---------------------------------/ - +//- Imported classes and packages -/ +//---------------------------------/ import java.io.IOException; import java.io.Reader; import java.io.Serializable; import java.io.Writer; + import java.util.Enumeration; import java.util.Vector; -import org.exolab.castor.xml.MarshalException; -import org.exolab.castor.xml.Marshaller; -import org.exolab.castor.xml.Unmarshaller; -import org.exolab.castor.xml.ValidationException; -import org.xml.sax.ContentHandler; + /** * Class JalviewUserColours. * * @version $Revision$ $Date$ */ -public class JalviewUserColours implements java.io.Serializable { - - - //--------------------------/ - //- Class/Member Variables -/ +public class JalviewUserColours implements java.io.Serializable +{ + //--------------------------/ + //- Class/Member Variables -/ //--------------------------/ /** @@ -59,33 +41,32 @@ public class JalviewUserColours implements java.io.Serializable { */ private java.util.Vector _colourList; - - //----------------/ - //- Constructors -/ //----------------/ - - public JalviewUserColours() { + //- Constructors -/ + //----------------/ + public JalviewUserColours() + { super(); _colourList = new Vector(); - } //-- jalview.binding.JalviewUserColours() - + } - //-----------/ - //- Methods -/ + //-- jalview.binding.JalviewUserColours() //-----------/ /** - * Method addColour - * + * DOCUMENT ME! * + * @param vColour DOCUMENT ME! * - * @param vColour + * @throws java.lang.IndexOutOfBoundsException DOCUMENT ME! */ public void addColour(jalview.binding.Colour vColour) throws java.lang.IndexOutOfBoundsException { _colourList.addElement(vColour); - } //-- void addColour(jalview.binding.Colour) + } + + //-- void addColour(jalview.binding.Colour) /** * Method addColour @@ -99,7 +80,9 @@ public class JalviewUserColours implements java.io.Serializable { throws java.lang.IndexOutOfBoundsException { _colourList.insertElementAt(vColour, index); - } //-- void addColour(int, jalview.binding.Colour) + } + + //-- void addColour(int, jalview.binding.Colour) /** * Method enumerateColour @@ -111,7 +94,9 @@ public class JalviewUserColours implements java.io.Serializable { public java.util.Enumeration enumerateColour() { return _colourList.elements(); - } //-- java.util.Enumeration enumerateColour() + } + + //-- java.util.Enumeration enumerateColour() /** * Method getColour @@ -125,12 +110,15 @@ public class JalviewUserColours implements java.io.Serializable { throws java.lang.IndexOutOfBoundsException { //-- check bounds for index - if ((index < 0) || (index > _colourList.size())) { + if ((index < 0) || (index > _colourList.size())) + { throw new IndexOutOfBoundsException(); } return (jalview.binding.Colour) _colourList.elementAt(index); - } //-- jalview.binding.Colour getColour(int) + } + + //-- jalview.binding.Colour getColour(int) /** * Method getColour @@ -143,11 +131,16 @@ public class JalviewUserColours implements java.io.Serializable { { int size = _colourList.size(); jalview.binding.Colour[] mArray = new jalview.binding.Colour[size]; - for (int index = 0; index < size; index++) { + + for (int index = 0; index < size; index++) + { mArray[index] = (jalview.binding.Colour) _colourList.elementAt(index); } + return mArray; - } //-- jalview.binding.Colour[] getColour() + } + + //-- jalview.binding.Colour[] getColour() /** * Method getColourCount @@ -159,7 +152,9 @@ public class JalviewUserColours implements java.io.Serializable { public int getColourCount() { return _colourList.size(); - } //-- int getColourCount() + } + + //-- int getColourCount() /** * Method isValid @@ -170,14 +165,19 @@ public class JalviewUserColours implements java.io.Serializable { */ public boolean isValid() { - try { + try + { validate(); } - catch (org.exolab.castor.xml.ValidationException vex) { + catch (org.exolab.castor.xml.ValidationException vex) + { return false; } + return true; - } //-- boolean isValid() + } + + //-- boolean isValid() /** * Method marshal @@ -187,11 +187,13 @@ public class JalviewUserColours implements java.io.Serializable { * @param out */ public void marshal(java.io.Writer out) - throws org.exolab.castor.xml.MarshalException, org.exolab.castor.xml.ValidationException + throws org.exolab.castor.xml.MarshalException, + org.exolab.castor.xml.ValidationException { - Marshaller.marshal(this, out); - } //-- void marshal(java.io.Writer) + } + + //-- void marshal(java.io.Writer) /** * Method marshal @@ -201,11 +203,13 @@ public class JalviewUserColours implements java.io.Serializable { * @param handler */ public void marshal(org.xml.sax.ContentHandler handler) - throws java.io.IOException, org.exolab.castor.xml.MarshalException, org.exolab.castor.xml.ValidationException + throws java.io.IOException, org.exolab.castor.xml.MarshalException, + org.exolab.castor.xml.ValidationException { - Marshaller.marshal(this, handler); - } //-- void marshal(org.xml.sax.ContentHandler) + } + + //-- void marshal(org.xml.sax.ContentHandler) /** * Method removeAllColour @@ -214,7 +218,9 @@ public class JalviewUserColours implements java.io.Serializable { public void removeAllColour() { _colourList.removeAllElements(); - } //-- void removeAllColour() + } + + //-- void removeAllColour() /** * Method removeColour @@ -228,8 +234,11 @@ public class JalviewUserColours implements java.io.Serializable { { java.lang.Object obj = _colourList.elementAt(index); _colourList.removeElementAt(index); + return (jalview.binding.Colour) obj; - } //-- jalview.binding.Colour removeColour(int) + } + + //-- jalview.binding.Colour removeColour(int) /** * Method setColour @@ -243,11 +252,15 @@ public class JalviewUserColours implements java.io.Serializable { throws java.lang.IndexOutOfBoundsException { //-- check bounds for index - if ((index < 0) || (index > _colourList.size())) { + if ((index < 0) || (index > _colourList.size())) + { throw new IndexOutOfBoundsException(); } + _colourList.setElementAt(vColour, index); - } //-- void setColour(int, jalview.binding.Colour) + } + + //-- void setColour(int, jalview.binding.Colour) /** * Method setColour @@ -260,10 +273,14 @@ public class JalviewUserColours implements java.io.Serializable { { //-- copy array _colourList.removeAllElements(); - for (int i = 0; i < colourArray.length; i++) { + + for (int i = 0; i < colourArray.length; i++) + { _colourList.addElement(colourArray[i]); } - } //-- void setColour(jalview.binding.Colour) + } + + //-- void setColour(jalview.binding.Colour) /** * Method unmarshal @@ -274,20 +291,24 @@ public class JalviewUserColours implements java.io.Serializable { * @return Object */ public static java.lang.Object unmarshal(java.io.Reader reader) - throws org.exolab.castor.xml.MarshalException, org.exolab.castor.xml.ValidationException + throws org.exolab.castor.xml.MarshalException, + org.exolab.castor.xml.ValidationException { - return (jalview.binding.JalviewUserColours) Unmarshaller.unmarshal(jalview.binding.JalviewUserColours.class, reader); - } //-- java.lang.Object unmarshal(java.io.Reader) + return (jalview.binding.JalviewUserColours) Unmarshaller.unmarshal(jalview.binding.JalviewUserColours.class, + reader); + } + + //-- java.lang.Object unmarshal(java.io.Reader) /** * Method validate * */ - public void validate() - throws org.exolab.castor.xml.ValidationException + public void validate() throws org.exolab.castor.xml.ValidationException { org.exolab.castor.xml.Validator validator = new org.exolab.castor.xml.Validator(); validator.validate(this); - } //-- void validate() + } + //-- void validate() }