Merge branch 'develop' into bug/JAL-2541cutRelocateFeatures
[jalview.git] / src / jalview / binding / JalviewUserColours.java
index 6709487..67ee5a2 100644 (file)
@@ -42,6 +42,11 @@ public class JalviewUserColours implements java.io.Serializable
    */
   private java.util.Vector _colourList;
 
+  /**
+   * Field _filterList.
+   */
+  private java.util.Vector _filterList;
+
   // ----------------/
   // - Constructors -/
   // ----------------/
@@ -50,6 +55,7 @@ public class JalviewUserColours implements java.io.Serializable
   {
     super();
     this._colourList = new java.util.Vector();
+    this._filterList = new java.util.Vector();
   }
 
   // -----------/
@@ -84,6 +90,33 @@ public class JalviewUserColours implements java.io.Serializable
   }
 
   /**
+   * 
+   * 
+   * @param vFilter
+   * @throws java.lang.IndexOutOfBoundsException
+   *           if the index given is outside the bounds of the collection
+   */
+  public void addFilter(final Filter vFilter)
+          throws java.lang.IndexOutOfBoundsException
+  {
+    this._filterList.addElement(vFilter);
+  }
+
+  /**
+   * 
+   * 
+   * @param index
+   * @param vFilter
+   * @throws java.lang.IndexOutOfBoundsException
+   *           if the index given is outside the bounds of the collection
+   */
+  public void addFilter(final int index, final Filter vFilter)
+          throws java.lang.IndexOutOfBoundsException
+  {
+    this._filterList.add(index, vFilter);
+  }
+
+  /**
    * Method enumerateColour.
    * 
    * @return an Enumeration over all Colour elements
@@ -94,6 +127,16 @@ public class JalviewUserColours implements java.io.Serializable
   }
 
   /**
+   * Method enumerateFilter.
+   * 
+   * @return an Enumeration over all Filter elements
+   */
+  public java.util.Enumeration enumerateFilter()
+  {
+    return this._filterList.elements();
+  }
+
+  /**
    * Method getColour.
    * 
    * @param index
@@ -141,6 +184,53 @@ public class JalviewUserColours implements java.io.Serializable
   }
 
   /**
+   * Method getFilter.
+   * 
+   * @param index
+   * @throws java.lang.IndexOutOfBoundsException
+   *           if the index given is outside the bounds of the collection
+   * @return the value of the Filter at the given index
+   */
+  public Filter getFilter(final int index)
+          throws java.lang.IndexOutOfBoundsException
+  {
+    // check bounds for index
+    if (index < 0 || index >= this._filterList.size())
+    {
+      throw new IndexOutOfBoundsException(
+              "getFilter: Index value '" + index + "' not in range [0.."
+                      + (this._filterList.size() - 1) + "]");
+    }
+
+    return (Filter) _filterList.get(index);
+  }
+
+  /**
+   * Method getFilter.Returns the contents of the collection in an Array.
+   * <p>
+   * Note: Just in case the collection contents are changing in another thread,
+   * we pass a 0-length Array of the correct type into the API call. This way we
+   * <i>know</i> that the Array returned is of exactly the correct length.
+   * 
+   * @return this collection as an Array
+   */
+  public Filter[] getFilter()
+  {
+    Filter[] array = new Filter[0];
+    return (Filter[]) this._filterList.toArray(array);
+  }
+
+  /**
+   * Method getFilterCount.
+   * 
+   * @return the size of this collection
+   */
+  public int getFilterCount()
+  {
+    return this._filterList.size();
+  }
+
+  /**
    * Returns the value of field 'schemeName'.
    * 
    * @return the value of field 'SchemeName'.
@@ -217,13 +307,20 @@ public class JalviewUserColours implements java.io.Serializable
   }
 
   /**
-     */
+   */
   public void removeAllColour()
   {
     this._colourList.clear();
   }
 
   /**
+   */
+  public void removeAllFilter()
+  {
+    this._filterList.clear();
+  }
+
+  /**
    * Method removeColour.
    * 
    * @param vColour
@@ -248,6 +345,30 @@ public class JalviewUserColours implements java.io.Serializable
   }
 
   /**
+   * Method removeFilter.
+   * 
+   * @param vFilter
+   * @return true if the object was removed from the collection.
+   */
+  public boolean removeFilter(final Filter vFilter)
+  {
+    boolean removed = _filterList.remove(vFilter);
+    return removed;
+  }
+
+  /**
+   * Method removeFilterAt.
+   * 
+   * @param index
+   * @return the element removed from the collection
+   */
+  public Filter removeFilterAt(final int index)
+  {
+    java.lang.Object obj = this._filterList.remove(index);
+    return (Filter) obj;
+  }
+
+  /**
    * 
    * 
    * @param index
@@ -286,6 +407,44 @@ public class JalviewUserColours implements java.io.Serializable
   }
 
   /**
+   * 
+   * 
+   * @param index
+   * @param vFilter
+   * @throws java.lang.IndexOutOfBoundsException
+   *           if the index given is outside the bounds of the collection
+   */
+  public void setFilter(final int index, final Filter vFilter)
+          throws java.lang.IndexOutOfBoundsException
+  {
+    // check bounds for index
+    if (index < 0 || index >= this._filterList.size())
+    {
+      throw new IndexOutOfBoundsException(
+              "setFilter: Index value '" + index + "' not in range [0.."
+                      + (this._filterList.size() - 1) + "]");
+    }
+
+    this._filterList.set(index, vFilter);
+  }
+
+  /**
+   * 
+   * 
+   * @param vFilterArray
+   */
+  public void setFilter(final Filter[] vFilterArray)
+  {
+    // -- copy array
+    _filterList.clear();
+
+    for (int i = 0; i < vFilterArray.length; i++)
+    {
+      this._filterList.add(vFilterArray[i]);
+    }
+  }
+
+  /**
    * Sets the value of field 'schemeName'.
    * 
    * @param schemeName