Merge branch 'Release_2_8_1_Branch' into Release_2_8_1_Branch_i18n
authorJim Procter <jprocter@dundee.ac.uk>
Fri, 2 May 2014 09:44:52 +0000 (10:44 +0100)
committerJim Procter <jprocter@dundee.ac.uk>
Fri, 2 May 2014 09:44:52 +0000 (10:44 +0100)
33 files changed:
schemas/jalview.xsd
src/jalview/analysis/AAFrequency.java
src/jalview/api/AlignViewportI.java
src/jalview/appletgui/AlignFrame.java
src/jalview/appletgui/AlignViewport.java
src/jalview/appletgui/RedundancyPanel.java
src/jalview/appletgui/SliderPanel.java
src/jalview/datamodel/Alignment.java
src/jalview/datamodel/AnnotatedCollectionI.java
src/jalview/datamodel/SequenceGroup.java
src/jalview/gui/AlignFrame.java
src/jalview/gui/Jalview2XML.java
src/jalview/gui/RedundancyPanel.java
src/jalview/gui/SliderPanel.java
src/jalview/gui/TreeCanvas.java
src/jalview/schemabinding/version2/.castor.cdr
src/jalview/schemabinding/version2/AnnotationColourScheme.java [new file with mode: 0644]
src/jalview/schemabinding/version2/AnnotationColours.java
src/jalview/schemabinding/version2/JGroup.java
src/jalview/schemabinding/version2/descriptors/AnnotationColourSchemeDescriptor.java [new file with mode: 0644]
src/jalview/schemabinding/version2/descriptors/AnnotationColoursDescriptor.java
src/jalview/schemabinding/version2/descriptors/JGroupDescriptor.java
src/jalview/schemes/AnnotationColourGradient.java
src/jalview/schemes/Blosum62ColourScheme.java
src/jalview/schemes/ClustalxColourScheme.java
src/jalview/schemes/ColourSchemeI.java
src/jalview/schemes/FollowerColourScheme.java [new file with mode: 0644]
src/jalview/schemes/ResidueColourScheme.java
src/jalview/schemes/TCoffeeColourScheme.java
src/jalview/schemes/UserColourScheme.java
src/jalview/viewmodel/AlignmentViewport.java
src/jalview/workers/ConservationThread.java
test/jalview/io/Jalview2xmlTests.java

index eb10ae1..ab893bd 100755 (executable)
                                <xs:element name="JGroup" minOccurs="0"
                                        maxOccurs="unbounded">
                                        <xs:complexType>
-                                               <xs:sequence>
-                                                       <xs:element name="seq" type="xs:string"
-                                                               maxOccurs="unbounded" />
+            <xs:sequence>
+                                                       <xs:element name="seq" type="xs:string" maxOccurs="unbounded" />
+                                                       <xs:element name="annotationColours" type="jv:AnnotationColourScheme"
+                                                               minOccurs="0" maxOccurs="1" />
                                                </xs:sequence>
                                                <xs:attribute name="start" type="xs:int" />
                                                <xs:attribute name="end" type="xs:int" />
                                <xs:element name="Viewport" maxOccurs="unbounded" minOccurs="0">
                                        <xs:complexType>
                                                <xs:sequence>
-                                                       <xs:element name="AnnotationColours"
-                                                               minOccurs="0">
-                                                               <xs:complexType>
-                                                                       <xs:attribute name="aboveThreshold"
-                                                                               type="xs:int" />
-                                                                       <xs:attribute name="annotation"
-                                                                               type="xs:string" />
-                                                                       <xs:attribute name="minColour"
-                                                                               type="xs:int" />
-                                                                       <xs:attribute name="maxColour"
-                                                                               type="xs:int" />
-                                                                       <xs:attribute name="colourScheme"
-                                                                               type="xs:string" />
-                                                                       <xs:attribute name="threshold"
-                                                                               type="xs:float" />
-                       <xs:attribute name="perSequence" 
-                       type="xs:boolean" 
-                       use="optional" />
-                       <xs:attribute name="predefinedColours" 
-                  type="xs:boolean" 
-                  use="optional" />
-                                                               </xs:complexType>
+                                                       <xs:element name="AnnotationColours" type="jv:AnnotationColourScheme" 
+                                                               minOccurs="0" maxOccurs="1">
                                                        </xs:element>
                                                        <xs:element name="hiddenColumns"
                                                                minOccurs="0" maxOccurs="unbounded">
       <xs:attribute name="xpos" type="xs:int"/>
       <xs:attribute name="ypos" type="xs:int"/>
     </xs:attributeGroup>
+  <xs:complexType name="AnnotationColourScheme">
+       <xs:attribute name="aboveThreshold" type="xs:int" />
+       <xs:attribute name="annotation" type="xs:string" />
+       <xs:attribute name="minColour" type="xs:int" />
+       <xs:attribute name="maxColour" type="xs:int" />
+       <xs:attribute name="colourScheme" type="xs:string" />
+       <xs:attribute name="threshold" type="xs:float" />
+       <xs:attribute name="perSequence" type="xs:boolean" use="optional" />
+       <xs:attribute name="predefinedColours" type="xs:boolean"
+               use="optional" />
+  </xs:complexType>
+  
 </xs:schema>
index ca4e71c..75a777f 100755 (executable)
@@ -183,9 +183,11 @@ public class AAFrequency
       residueHash.put(PID_GAPS, new Float(percentage));
 
       if (nongap>0) {
+        // calculate for non-gapped too
         percentage = ((float) maxCount * 100) / nongap;
-        residueHash.put(PID_NOGAPS, new Float(percentage));
       }
+      residueHash.put(PID_NOGAPS, new Float(percentage));
+      
       result[i] = residueHash;
     }
   }
index 4f78145..44fef0e 100644 (file)
@@ -22,6 +22,7 @@ import java.awt.Color;
 import java.util.Hashtable;
 import java.util.Map;
 
+import jalview.analysis.Conservation;
 import jalview.datamodel.AlignmentAnnotation;
 import jalview.datamodel.AlignmentI;
 import jalview.datamodel.AlignmentView;
@@ -186,5 +187,7 @@ public interface AlignViewportI
 
   void setColumnSelection(ColumnSelection cs);
 
+  void setConservation(Conservation cons);
+
 
 }
index 5e6df04..40999c6 100644 (file)
@@ -158,7 +158,8 @@ public class AlignFrame extends EmbmenuFrame implements ActionListener,
     showConsensusHistogram.setState(viewport.isShowConsensusHistogram());
     showSequenceLogo.setState(viewport.isShowSequenceLogo());
     normSequenceLogo.setState(viewport.isNormaliseSequenceLogo());
-
+    applyToAllGroups.setState(viewport.getColourAppliesToAllGroups());
+    
     seqLimits.setState(viewport.showJVSuffix);
 
     if (applet != null)
@@ -2327,42 +2328,20 @@ public class AlignFrame extends EmbmenuFrame implements ActionListener,
     {
       if (viewport.getAbovePIDThreshold())
       {
-        threshold = SliderPanel.setPIDSliderSource(alignPanel, cs,
-                "Background");
-
-        cs.setThreshold(threshold, viewport.getIgnoreGapsConsensus());
-
-        viewport.setGlobalColourScheme(cs);
-      }
-      else
-      {
-        cs.setThreshold(0, viewport.getIgnoreGapsConsensus());
-      }
+        viewport.setThreshold(SliderPanel.setPIDSliderSource(alignPanel, cs,
+                "Background"));
+      } 
 
       if (viewport.getConservationSelected())
       {
-
-        Alignment al = (Alignment) viewport.getAlignment();
-        Conservation c = new Conservation("All",
-                ResidueProperties.propHash, 3, al.getSequences(), 0,
-                al.getWidth() - 1);
-
-        c.calculate();
-        c.verdict(false, viewport.getConsPercGaps());
-
-        cs.setConservation(c);
-
-        cs.setConservationInc(SliderPanel.setConservationSlider(alignPanel,
+        cs.setConservationApplied(true);
+        viewport.setIncrement(SliderPanel.setConservationSlider(alignPanel,
                 cs, "Background"));
-
       }
       else
       {
-        cs.setConservation(null);
+        cs.setConservationApplied(false);
       }
-
-      cs.setConsensus(viewport.getSequenceConsensusHash());
-
     }
     viewport.setGlobalColourScheme(cs);
 
index 7e9cbf1..2ced8da 100644 (file)
@@ -484,26 +484,6 @@ public class AlignViewport extends AlignmentViewport implements
     }
   }
 
-  public void setThreshold(int thresh)
-  {
-    threshold = thresh;
-  }
-
-  public int getThreshold()
-  {
-    return threshold;
-  }
-
-  public void setIncrement(int inc)
-  {
-    increment = inc;
-  }
-
-  public int getIncrement()
-  {
-    return increment;
-  }
-
   public void resetSeqLimits(int height)
   {
     setEndSeq(height / getCharHeight());
index 345c906..b5f507f 100644 (file)
@@ -19,7 +19,7 @@
 package jalview.appletgui;
 
 import java.util.*;
-
+import java.util.List;
 import java.awt.*;
 import java.awt.event.*;
 
@@ -131,6 +131,7 @@ public class RedundancyPanel extends SliderPanel implements Runnable,
     valueField.setVisible(true);
 
     validate();
+    sliderValueChanged();
     // System.out.println("blob done "+ (System.currentTimeMillis()-start));
   }
 
@@ -143,19 +144,16 @@ public class RedundancyPanel extends SliderPanel implements Runnable,
 
     float value = slider.getValue();
 
+    List<SequenceI> redundantSequences = new ArrayList<SequenceI>();
     for (int i = 0; i < redundancy.length; i++)
     {
-      if (value > redundancy[i])
-      {
-        redundantSeqs.removeElement(originalSequences[i]);
-      }
-      else if (!redundantSeqs.contains(originalSequences[i]))
+      if (value <= redundancy[i])
       {
-        redundantSeqs.addElement(originalSequences[i]);
+        redundantSequences.add(originalSequences[i]);
       }
     }
 
-    ap.idPanel.idCanvas.setHighlighted(redundantSeqs);
+    ap.idPanel.idCanvas.setHighlighted(redundantSequences);
     PaintRefresher.Refresh(this, ap.av.getSequenceSetId(), true, true);
 
   }
index 340bb64..1bd5fd8 100644 (file)
@@ -196,25 +196,16 @@ public class SliderPanel extends Panel implements ActionListener,
       return;
     }
 
-    ColourSchemeI toChange = null;
+    ColourSchemeI toChange = cs;
     Iterator<SequenceGroup> allGroups = null;
 
     if (allGroupsCheck.getState())
     {
       allGroups = ap.av.getAlignment().getGroups().listIterator();
     }
-    else
-    {
-      toChange = cs;
-    }
 
-    do
+    while (toChange != null)
     {
-      if (allGroups != null)
-      {
-        toChange = allGroups.next().cs;
-      }
-
       if (forConservation)
       {
         toChange.setConservationInc(i);
@@ -223,8 +214,17 @@ public class SliderPanel extends Panel implements ActionListener,
       {
         toChange.setThreshold(i, ap.av.getIgnoreGapsConsensus());
       }
-
-    } while (allGroups != null && allGroups.hasNext());
+      if (allGroups != null && allGroups.hasNext())
+      {
+        while ((toChange = allGroups.next().cs) == null
+                && allGroups.hasNext())
+          ;
+      }
+      else
+      {
+        toChange = null;
+      }
+    }
 
     ap.seqPanel.seqCanvas.repaint();
 
@@ -315,8 +315,9 @@ public class SliderPanel extends Panel implements ActionListener,
     slider.setFont(new java.awt.Font("Verdana", 0, 11));
     slider.setOrientation(0);
     valueField.setFont(new java.awt.Font("Verdana", 0, 11));
-    valueField.setText("      ");
-    valueField.addActionListener(this);
+    valueField.setText("   ");
+    valueField.addActionListener(this); 
+    valueField.setColumns(3);
     label.setFont(new java.awt.Font("Verdana", 0, 11));
     label.setText(MessageManager.getString("label.set_this_label_text"));
     jPanel1.setLayout(borderLayout1);
index ed65dd5..35efe4f 100755 (executable)
@@ -371,7 +371,7 @@ public class Alignment implements AlignmentI
             return;
           }
         }
-
+        sg.setContext(this);
         groups.add(sg);
       }
     }
@@ -446,6 +446,9 @@ public class Alignment implements AlignmentI
       {
         removeAnnotationForGroup(null);
       }
+      for (SequenceGroup sg:groups) {
+        sg.setContext(null);
+      }
       groups.clear();
     }
   }
@@ -460,6 +463,7 @@ public class Alignment implements AlignmentI
       {
         removeAnnotationForGroup(g);
         groups.remove(g);
+        g.setContext(null);
       }
     }
   }
@@ -1498,4 +1502,14 @@ public int getStartRes()
 {
   return 0;
 }
+
+/* In the case of AlignmentI - returns the dataset for the alignment, if set
+ * (non-Javadoc)
+ * @see jalview.datamodel.AnnotatedCollectionI#getContext()
+ */
+@Override
+public AnnotatedCollectionI getContext()
+{
+  return dataset;
+}
 }
index 510437a..0f856ee 100644 (file)
@@ -31,4 +31,9 @@ public interface AnnotatedCollectionI extends SequenceCollectionI
 
   Iterable<AlignmentAnnotation> findAnnotation(String calcId);
 
+  /**
+   * context for this annotated collection
+   * @return null or the collection upon which this collection is defined (e.g. alignment, parent group).
+   */
+  AnnotatedCollectionI getContext();
 }
index 5d0841e..a8b0ace 100755 (executable)
@@ -470,12 +470,28 @@ public class SequenceGroup implements AnnotatedCollectionI
   }
 
   /**
-   * Max Gaps Threshold for performing a conservation calculation TODO: make
-   * this a configurable property - or global to an alignment view
+   * Max Gaps Threshold (percent) for performing a conservation calculation 
    */
   private int consPercGaps = 25;
 
   /**
+   * @return Max Gaps Threshold for performing a conservation calculation
+   */
+  public int getConsPercGaps()
+  {
+    return consPercGaps;
+  }
+
+  /**
+   * set Max Gaps Threshold (percent) for performing a conservation calculation
+   * @param consPercGaps 
+   */
+  public void setConsPercGaps(int consPercGaps)
+  {
+    this.consPercGaps = consPercGaps;
+  }
+
+  /**
    * calculate residue conservation for group - but only if necessary.
    */
   public void recalcConservation()
@@ -484,10 +500,6 @@ public class SequenceGroup implements AnnotatedCollectionI
     {
       return;
     }
-    if (cs != null)
-    {
-      cs.alignmentChanged(this, null);
-    }
     try
     {
       Hashtable cnsns[] = AAFrequency.calculate(sequences, startRes,
@@ -499,7 +511,6 @@ public class SequenceGroup implements AnnotatedCollectionI
       if (cs != null)
       {
         cs.setConsensus(cnsns);
-        cs.alignmentChanged(this, null);
       }
 
       if ((conservation != null)
@@ -519,10 +530,13 @@ public class SequenceGroup implements AnnotatedCollectionI
           if (cs.conservationApplied())
           {
             cs.setConservation(c);
-            cs.alignmentChanged(this, null);
           }
         }
       }
+      if (cs != null)
+      {
+        cs.alignmentChanged(context!=null ? context : this, null);
+      }
     } catch (java.lang.OutOfMemoryError err)
     {
       // TODO: catch OOM
@@ -1195,11 +1209,15 @@ public class SequenceGroup implements AnnotatedCollectionI
     ArrayList<AlignmentAnnotation> annot = new ArrayList<AlignmentAnnotation>();
     for (SequenceI seq : (Vector<SequenceI>) sequences)
     {
-      for (AlignmentAnnotation al : seq.getAnnotation())
+      AlignmentAnnotation[] aa = seq.getAnnotation();
+      if (aa != null)
       {
-        if (al.groupRef == this)
+        for (AlignmentAnnotation al : aa)
         {
-          annot.add(al);
+          if (al.groupRef == this)
+          {
+            annot.add(al);
+          }
         }
       }
     }
@@ -1232,4 +1250,21 @@ public class SequenceGroup implements AnnotatedCollectionI
   {
     sequences.clear();
   }
+  private AnnotatedCollectionI context;
+  /**
+   * set the alignment or group context for this group
+   * @param context
+   */
+  public void setContext(AnnotatedCollectionI context)
+  {
+    this.context = context; 
+  }
+  /* (non-Javadoc)
+   * @see jalview.datamodel.AnnotatedCollectionI#getContext()
+   */
+  @Override
+  public AnnotatedCollectionI getContext()
+  {
+    return context;
+  }
 }
index 353a139..d475c91 100644 (file)
@@ -3235,10 +3235,7 @@ public class AlignFrame extends GAlignFrame implements DropTargetListener,
       {
         threshold = SliderPanel.setPIDSliderSource(alignPanel, cs,
                 "Background");
-
         cs.setThreshold(threshold, viewport.getIgnoreGapsConsensus());
-
-        viewport.setGlobalColourScheme(cs);
       }
       else
       {
index 3bca941..a1a009d 100644 (file)
@@ -279,7 +279,7 @@ public class Jalview2XML
       return;
     }
 
-    Hashtable<String,AlignFrame> dsses = new Hashtable<String,AlignFrame>();
+    Hashtable<String, AlignFrame> dsses = new Hashtable<String, AlignFrame>();
 
     try
     {
@@ -348,7 +348,8 @@ public class Jalview2XML
 
             SaveState(apanel, fileName, jout);
 
-            String dssid = getDatasetIdRef(af.getViewport().getAlignment().getDataset());
+            String dssid = getDatasetIdRef(af.getViewport().getAlignment()
+                    .getDataset());
             if (!dsses.containsKey(dssid))
             {
               dsses.put(dssid, af);
@@ -358,8 +359,9 @@ public class Jalview2XML
         }
       }
 
-      writeDatasetFor(dsses, ""+jout.hashCode()+" "+uniqueSetSuffix, jout);
-      
+      writeDatasetFor(dsses, "" + jout.hashCode() + " " + uniqueSetSuffix,
+              jout);
+
       try
       {
         jout.flush();
@@ -389,7 +391,7 @@ public class Jalview2XML
       int ap, apSize = af.alignPanels.size();
       FileOutputStream fos = new FileOutputStream(jarFile);
       JarOutputStream jout = new JarOutputStream(fos);
-      Hashtable<String,AlignFrame> dsses = new Hashtable<String,AlignFrame>();
+      Hashtable<String, AlignFrame> dsses = new Hashtable<String, AlignFrame>();
       for (ap = 0; ap < apSize; ap++)
       {
         AlignmentPanel apanel = (AlignmentPanel) af.alignPanels
@@ -400,7 +402,8 @@ public class Jalview2XML
           jfileName = jfileName + ".xml";
         }
         SaveState(apanel, jfileName, jout);
-        String dssid = getDatasetIdRef(af.getViewport().getAlignment().getDataset());
+        String dssid = getDatasetIdRef(af.getViewport().getAlignment()
+                .getDataset());
         if (!dsses.containsKey(dssid))
         {
           dsses.put(dssid, af);
@@ -428,10 +431,10 @@ public class Jalview2XML
           String fileName, JarOutputStream jout)
   {
 
-    for (String dssids:dsses.keySet())
+    for (String dssids : dsses.keySet())
     {
       AlignFrame _af = dsses.get(dssids);
-      String jfileName = fileName + " Dataset for "+ _af.getTitle();
+      String jfileName = fileName + " Dataset for " + _af.getTitle();
       if (!jfileName.endsWith(".xml"))
       {
         jfileName = jfileName + ".xml";
@@ -456,25 +459,27 @@ public class Jalview2XML
   public JalviewModel SaveState(AlignmentPanel ap, String fileName,
           JarOutputStream jout)
   {
-    return SaveState(ap, fileName, false,jout);
+    return SaveState(ap, fileName, false, jout);
   }
+
   /**
-  * create a JalviewModel from an algnment view and marshall it to a
-  * JarOutputStream
-  * 
-  * @param ap
-  *          panel to create jalview model for
-  * @param fileName
-  *          name of alignment panel written to output stream
-  * @param storeDS
-  *          when true, only write the dataset for the alignment, not the data associated with the view.
-  * @param jout
-  *          jar output stream
-  * @param out
-  *          jar entry name
-  */
-  public JalviewModel SaveState(AlignmentPanel ap, String fileName, boolean storeDS,
-          JarOutputStream jout)
+   * create a JalviewModel from an algnment view and marshall it to a
+   * JarOutputStream
+   * 
+   * @param ap
+   *          panel to create jalview model for
+   * @param fileName
+   *          name of alignment panel written to output stream
+   * @param storeDS
+   *          when true, only write the dataset for the alignment, not the data
+   *          associated with the view.
+   * @param jout
+   *          jar output stream
+   * @param out
+   *          jar entry name
+   */
+  public JalviewModel SaveState(AlignmentPanel ap, String fileName,
+          boolean storeDS, JarOutputStream jout)
   {
     initSeqRefs();
     Vector jmolViewIds = new Vector(); //
@@ -486,7 +491,8 @@ public class Jalview2XML
     object.setVamsasModel(new jalview.schemabinding.version2.VamsasModel());
 
     object.setCreationDate(new java.util.Date(System.currentTimeMillis()));
-    object.setVersion(jalview.bin.Cache.getDefault("VERSION","Development Build"));
+    object.setVersion(jalview.bin.Cache.getDefault("VERSION",
+            "Development Build"));
 
     jalview.datamodel.AlignmentI jal = av.getAlignment();
 
@@ -529,11 +535,12 @@ public class Jalview2XML
 
     // SAVE SEQUENCES
     String id = "";
-    jalview.datamodel.SequenceI jds,jdatasq;
+    jalview.datamodel.SequenceI jds, jdatasq;
     for (int i = 0; i < jal.getHeight(); i++)
     {
       jds = jal.getSequenceAt(i);
-      jdatasq=jds.getDatasetSequence() == null ? jds : jds.getDatasetSequence();
+      jdatasq = jds.getDatasetSequence() == null ? jds : jds
+              .getDatasetSequence();
       id = seqHash(jds);
 
       if (seqRefIds.get(id) != null)
@@ -877,17 +884,19 @@ public class Jalview2XML
     IdentityHashMap groupRefs = new IdentityHashMap();
     if (storeDS)
     {
-        for (SequenceI sq:jal.getSequences())
+      for (SequenceI sq : jal.getSequences())
+      {
+        // Store annotation on dataset sequences only
+        jalview.datamodel.AlignmentAnnotation[] aa = sq.getAnnotation();
+        if (aa != null && aa.length > 0)
         {
-       // Store annotation on dataset sequences only
-          jalview.datamodel.AlignmentAnnotation[] aa = sq.getAnnotation();
-          if (aa!=null && aa.length>0)
-          {
-            storeAlignmentAnnotation(aa, groupRefs, av, calcIdSet, storeDS,
-                    vamsasSet);
-          }
+          storeAlignmentAnnotation(aa, groupRefs, av, calcIdSet, storeDS,
+                  vamsasSet);
         }
-    } else {
+      }
+    }
+    else
+    {
       if (jal.getAlignmentAnnotation() != null)
       {
         // Store the annotation shown on the alignment.
@@ -933,10 +942,10 @@ public class Jalview2XML
           }
           else if (sg.cs instanceof jalview.schemes.AnnotationColourGradient)
           {
-            groups[i]
-                    .setColour(ColourSchemeProperty
-                            .getColourName(((jalview.schemes.AnnotationColourGradient) sg.cs)
-                                    .getBaseColour()));
+            groups[i].setColour("AnnotationColourGradient");
+            groups[i].setAnnotationColours(constructAnnotationColours(
+                    (jalview.schemes.AnnotationColourGradient) sg.cs,
+                    userColours, jms));
           }
           else if (sg.cs instanceof jalview.schemes.UserColourScheme)
           {
@@ -1009,28 +1018,11 @@ public class Jalview2XML
       }
       else if (av.getGlobalColourScheme() instanceof jalview.schemes.AnnotationColourGradient)
       {
-        jalview.schemes.AnnotationColourGradient acg = (jalview.schemes.AnnotationColourGradient) av
-                .getGlobalColourScheme();
+        AnnotationColours ac = constructAnnotationColours(
+                (jalview.schemes.AnnotationColourGradient) av
+                        .getGlobalColourScheme(),
+                userColours, jms);
 
-        AnnotationColours ac = new AnnotationColours();
-        ac.setAboveThreshold(acg.getAboveThreshold());
-        ac.setThreshold(acg.getAnnotationThreshold());
-        ac.setAnnotation(acg.getAnnotation());
-        if (acg.getBaseColour() instanceof jalview.schemes.UserColourScheme)
-        {
-          ac.setColourScheme(SetUserColourScheme(acg.getBaseColour(),
-                  userColours, jms));
-        }
-        else
-        {
-          ac.setColourScheme(ColourSchemeProperty.getColourName(acg
-                  .getBaseColour()));
-        }
-
-        ac.setMaxColour(acg.getMaxColour().getRGB());
-        ac.setMinColour(acg.getMinColour().getRGB());
-        ac.setPerSequence(acg.isSeqAssociated());
-        ac.setPredefinedColours(acg.isPredefinedColours());
         view.setAnnotationColours(ac);
         view.setBgColour("AnnotationColourGradient");
       }
@@ -1250,7 +1242,35 @@ public class Jalview2XML
     return object;
   }
 
-  private void storeAlignmentAnnotation(AlignmentAnnotation[] aa, IdentityHashMap groupRefs, AlignmentViewport av, Set<String> calcIdSet, boolean storeDS, SequenceSet vamsasSet)
+  private AnnotationColours constructAnnotationColours(
+          AnnotationColourGradient acg, Vector userColours,
+          JalviewModelSequence jms)
+  {
+    AnnotationColours ac = new AnnotationColours();
+    ac.setAboveThreshold(acg.getAboveThreshold());
+    ac.setThreshold(acg.getAnnotationThreshold());
+    ac.setAnnotation(acg.getAnnotation());
+    if (acg.getBaseColour() instanceof jalview.schemes.UserColourScheme)
+    {
+      ac.setColourScheme(SetUserColourScheme(acg.getBaseColour(),
+              userColours, jms));
+    }
+    else
+    {
+      ac.setColourScheme(ColourSchemeProperty.getColourName(acg
+              .getBaseColour()));
+    }
+
+    ac.setMaxColour(acg.getMaxColour().getRGB());
+    ac.setMinColour(acg.getMinColour().getRGB());
+    ac.setPerSequence(acg.isSeqAssociated());
+    ac.setPredefinedColours(acg.isPredefinedColours());
+    return ac;
+  }
+
+  private void storeAlignmentAnnotation(AlignmentAnnotation[] aa,
+          IdentityHashMap groupRefs, AlignmentViewport av,
+          Set<String> calcIdSet, boolean storeDS, SequenceSet vamsasSet)
   {
 
     for (int i = 0; i < aa.length; i++)
@@ -1382,11 +1402,12 @@ public class Jalview2XML
       }
       if (!storeDS || (storeDS && !aa[i].autoCalculated))
       {
-        // skip autocalculated annotation - these are only provided for alignments
+        // skip autocalculated annotation - these are only provided for
+        // alignments
         vamsasSet.addAnnotation(an);
       }
     }
-    
+
   }
 
   private CalcIdParam createCalcIdParam(String calcId, AlignViewport av)
@@ -1772,7 +1793,7 @@ public class Jalview2XML
     try
     {
       // create list to store references for any new Jmol viewers created
-      newStructureViewers=new Vector<AppJmol>();
+      newStructureViewers = new Vector<AppJmol>();
       // UNMARSHALLER SEEMS TO CLOSE JARINPUTSTREAM, MOST ANNOYING
       // Workaround is to make sure caller implements the JarInputStreamProvider
       // interface
@@ -1780,13 +1801,13 @@ public class Jalview2XML
 
       jarInputStreamProvider jprovider = createjarInputStreamProvider(file);
       af = LoadJalviewAlign(jprovider);
-      
+
     } catch (MalformedURLException e)
     {
       errorMessage = "Invalid URL format for '" + file + "'";
       reportErrors();
-    }
-    finally {
+    } finally
+    {
       try
       {
         SwingUtilities.invokeAndWait(new Runnable()
@@ -1872,7 +1893,7 @@ public class Jalview2XML
       frefedSequence = new Vector();
     }
 
-    jalview.gui.AlignFrame af= null,_af = null;
+    jalview.gui.AlignFrame af = null, _af = null;
     Hashtable gatherToThisFrame = new Hashtable();
     final String file = jprovider.getFilename();
     try
@@ -2130,8 +2151,9 @@ public class Jalview2XML
 
     JalviewModelSequence jms = object.getJalviewModelSequence();
 
-    Viewport view = (jms.getViewportCount()>0) ? jms.getViewport(0) : null;
-    
+    Viewport view = (jms.getViewportCount() > 0) ? jms.getViewport(0)
+            : null;
+
     // ////////////////////////////////
     // LOAD SEQUENCES
 
@@ -2537,14 +2559,13 @@ public class Jalview2XML
         }
       }
     }
-
     // ///////////////////////
     // LOAD GROUPS
     // Create alignment markup and styles for this view
     if (jms.getJGroupCount() > 0)
     {
       JGroup[] groups = jms.getJGroup();
-
+      boolean addAnnotSchemeGroup = false;
       for (int i = 0; i < groups.length; i++)
       {
         ColourSchemeI cs = null;
@@ -2555,6 +2576,12 @@ public class Jalview2XML
           {
             cs = GetUserColourScheme(jms, groups[i].getColour());
           }
+          else if (groups[i].getColour().equals("AnnotationColourGradient")
+                  && groups[i].getAnnotationColours() != null)
+          {
+            addAnnotSchemeGroup = true;
+            cs = null;
+          }
           else
           {
             cs = ColourSchemeProperty.getColour(al, groups[i].getColour());
@@ -2653,10 +2680,15 @@ public class Jalview2XML
           }
         }
         al.addGroup(sg);
-
+        if (addAnnotSchemeGroup)
+        {
+          // reconstruct the annotation colourscheme
+          sg.cs = constructAnnotationColour(
+                  groups[i].getAnnotationColours(), null, al, jms, false);
+        }
       }
     }
-    if (view==null)
+    if (view == null)
     {
       // only dataset in this model, so just return.
       return null;
@@ -2704,6 +2736,13 @@ public class Jalview2XML
 
       }
     }
+    /**
+     * indicate that annotation colours are applied across all groups (pre
+     * Jalview 2.8.1 behaviour)
+     */
+    boolean doGroupAnnColour = isVersionStringLaterThan("2.8.1",
+            object.getVersion());
+
     AlignmentPanel ap = null;
     boolean isnewview = true;
     if (viewId != null)
@@ -3168,25 +3207,81 @@ public class Jalview2XML
     // and finally return.
     return af;
   }
-  Vector<AppJmol> newStructureViewers=null;
+
+  /**
+   * 
+   * @param supported - minimum version we are comparing against
+   * @param version - version of data being processsed.
+   * @return true if version is development/null or evaluates to the same or
+   *         later X.Y.Z (where X,Y,Z are like [0-9]+b?[0-9]*)
+   */
+  private boolean isVersionStringLaterThan(String supported, String version)
+  {
+    if (version == null || version.equalsIgnoreCase("DEVELOPMENT BUILD")
+            || version.equalsIgnoreCase("Test"))
+    {
+      System.err.println("Assuming project file with "
+              + (version == null ? "null" : version)
+              + " is compatible with Jalview version " + supported);
+      return true;
+    }
+    else
+    {
+      StringTokenizer currentV = new StringTokenizer(supported, "."), fileV = new StringTokenizer(
+              version, ".");
+      while (currentV.hasMoreTokens() && fileV.hasMoreTokens())
+      {
+        // convert b to decimal to catch bugfix releases within a series
+        String curT = currentV.nextToken().toLowerCase().replace('b', '.');
+        String fileT = fileV.nextToken().toLowerCase().replace('b', '.');
+        try
+        {
+          if (Float.valueOf(curT) > Float.valueOf(fileT))
+          {
+            // current version is newer than the version that wrote the file
+            return false;
+          }
+        } catch (NumberFormatException nfe)
+        {
+          System.err
+                  .println("** WARNING: Version comparison failed for tokens ("
+                          + curT
+                          + ") and ("
+                          + fileT
+                          + ")\n** Current: '"
+                          + supported + "' and Version: '" + version + "'");
+        }
+      }
+      if (currentV.hasMoreElements())
+      {
+        // fileV has no minor version but identical series to current
+        return false;
+      }
+    }
+    return true;
+  }
+
+  Vector<AppJmol> newStructureViewers = null;
+
   protected void addNewStructureViewer(AppJmol sview)
   {
-    if (newStructureViewers!=null)
+    if (newStructureViewers != null)
     {
       sview.jmb.setFinishedLoadingFromArchive(false);
       newStructureViewers.add(sview);
     }
   }
+
   protected void setLoadingFinishedForNewStructureViewers()
   {
-    if (newStructureViewers!=null)
+    if (newStructureViewers != null)
     {
-      for (AppJmol sview:newStructureViewers)
+      for (AppJmol sview : newStructureViewers)
       {
         sview.jmb.setFinishedLoadingFromArchive(true);
       }
       newStructureViewers.clear();
-      newStructureViewers=null;
+      newStructureViewers = null;
     }
   }
 
@@ -3303,111 +3398,11 @@ public class Jalview2XML
       }
       else if (view.getBgColour().startsWith("Annotation"))
       {
-        // int find annotation
-        if (af.viewport.getAlignment().getAlignmentAnnotation() != null)
-        {
-          for (int i = 0; i < af.viewport.getAlignment()
-                  .getAlignmentAnnotation().length; i++)
-          {
-            if (af.viewport.getAlignment().getAlignmentAnnotation()[i].label
-                    .equals(view.getAnnotationColours().getAnnotation()))
-            {
-              if (af.viewport.getAlignment().getAlignmentAnnotation()[i]
-                      .getThreshold() == null)
-              {
-                af.viewport.getAlignment().getAlignmentAnnotation()[i]
-                        .setThreshold(new jalview.datamodel.GraphLine(view
-                                .getAnnotationColours().getThreshold(),
-                                "Threshold", java.awt.Color.black)
-
-                        );
-              }
+        AnnotationColours viewAnnColour = view.getAnnotationColours();
+        cs = constructAnnotationColour(viewAnnColour, af, al, jms, true);
 
-              if (view.getAnnotationColours().getColourScheme()
-                      .equals("None"))
-              {
-                cs = new AnnotationColourGradient(af.viewport
-                        .getAlignment().getAlignmentAnnotation()[i],
-                        new java.awt.Color(view.getAnnotationColours()
-                                .getMinColour()), new java.awt.Color(view
-                                .getAnnotationColours().getMaxColour()),
-                        view.getAnnotationColours().getAboveThreshold());
-              }
-              else if (view.getAnnotationColours().getColourScheme()
-                      .startsWith("ucs"))
-              {
-                cs = new AnnotationColourGradient(af.viewport
-                        .getAlignment().getAlignmentAnnotation()[i],
-                        GetUserColourScheme(jms, view
-                                .getAnnotationColours().getColourScheme()),
-                        view.getAnnotationColours().getAboveThreshold());
-              }
-              else
-              {
-                cs = new AnnotationColourGradient(af.viewport
-                        .getAlignment().getAlignmentAnnotation()[i],
-                        ColourSchemeProperty.getColour(al, view
-                                .getAnnotationColours().getColourScheme()),
-                        view.getAnnotationColours().getAboveThreshold());
-              }
-              if (view.getAnnotationColours().hasPerSequence())
-              {
-                ((AnnotationColourGradient)cs).setSeqAssociated(view.getAnnotationColours().isPerSequence());
-              }
-              if (view.getAnnotationColours().hasPredefinedColours())
-              {
-                ((AnnotationColourGradient)cs).setPredefinedColours(view.getAnnotationColours().isPredefinedColours());
-              }
-              // Also use these settings for all the groups
-              if (al.getGroups() != null)
-              {
-                for (int g = 0; g < al.getGroups().size(); g++)
-                {
-                  jalview.datamodel.SequenceGroup sg = al.getGroups()
-                          .get(g);
-
-                  if (sg.cs == null)
-                  {
-                    continue;
-                  }
+        // annpos
 
-                  /*
-                   * if
-                   * (view.getAnnotationColours().getColourScheme().equals("None"
-                   * )) { sg.cs = new AnnotationColourGradient(
-                   * af.viewport.getAlignment().getAlignmentAnnotation()[i], new
-                   * java.awt.Color(view.getAnnotationColours().
-                   * getMinColour()), new
-                   * java.awt.Color(view.getAnnotationColours().
-                   * getMaxColour()),
-                   * view.getAnnotationColours().getAboveThreshold()); } else
-                   */
-                  {
-                    sg.cs = new AnnotationColourGradient(af.viewport
-                            .getAlignment().getAlignmentAnnotation()[i],
-                            sg.cs, view.getAnnotationColours()
-                                    .getAboveThreshold());
-                    if (cs instanceof AnnotationColourGradient) 
-                    {
-                      if (view.getAnnotationColours().hasPerSequence())
-                      { 
-                        ((AnnotationColourGradient)cs).setSeqAssociated(view.getAnnotationColours().isPerSequence());
-                      }
-                      if (view.getAnnotationColours().hasPredefinedColours())
-                      {
-                        ((AnnotationColourGradient)cs).setPredefinedColours(view.getAnnotationColours().isPredefinedColours());
-                      }
-                    }
-                  }
-
-                }
-              }
-
-              break;
-            }
-
-          }
-        }
       }
       else
       {
@@ -3601,6 +3596,131 @@ public class Jalview2XML
     return af;
   }
 
+  private ColourSchemeI constructAnnotationColour(
+          AnnotationColours viewAnnColour, AlignFrame af, Alignment al,
+          JalviewModelSequence jms, boolean checkGroupAnnColour)
+  {
+    boolean propagateAnnColour = false;
+    ColourSchemeI cs = null;
+    AlignmentI annAlignment = af != null ? af.viewport.getAlignment() : al;
+    if (checkGroupAnnColour && al.getGroups() != null
+            && al.getGroups().size() > 0)
+    {
+      // pre 2.8.1 behaviour
+      // check to see if we should transfer annotation colours
+      propagateAnnColour = true;
+      for (jalview.datamodel.SequenceGroup sg : al.getGroups())
+      {
+        if (sg.cs instanceof AnnotationColourGradient)
+        {
+          propagateAnnColour = false;
+        }
+      }
+    }
+    // int find annotation
+    if (annAlignment.getAlignmentAnnotation() != null)
+    {
+      for (int i = 0; i < annAlignment.getAlignmentAnnotation().length; i++)
+      {
+        if (annAlignment.getAlignmentAnnotation()[i].label
+                .equals(viewAnnColour.getAnnotation()))
+        {
+          if (annAlignment.getAlignmentAnnotation()[i].getThreshold() == null)
+          {
+            annAlignment.getAlignmentAnnotation()[i]
+                    .setThreshold(new jalview.datamodel.GraphLine(
+                            viewAnnColour.getThreshold(), "Threshold",
+                            java.awt.Color.black)
+
+                    );
+          }
+
+          if (viewAnnColour.getColourScheme().equals("None"))
+          {
+            cs = new AnnotationColourGradient(
+                    annAlignment.getAlignmentAnnotation()[i],
+                    new java.awt.Color(viewAnnColour.getMinColour()),
+                    new java.awt.Color(viewAnnColour.getMaxColour()),
+                    viewAnnColour.getAboveThreshold());
+          }
+          else if (viewAnnColour.getColourScheme().startsWith("ucs"))
+          {
+            cs = new AnnotationColourGradient(
+                    annAlignment.getAlignmentAnnotation()[i],
+                    GetUserColourScheme(jms,
+                            viewAnnColour.getColourScheme()),
+                    viewAnnColour.getAboveThreshold());
+          }
+          else
+          {
+            cs = new AnnotationColourGradient(
+                    annAlignment.getAlignmentAnnotation()[i],
+                    ColourSchemeProperty.getColour(al,
+                            viewAnnColour.getColourScheme()),
+                    viewAnnColour.getAboveThreshold());
+          }
+          if (viewAnnColour.hasPerSequence())
+          {
+            ((AnnotationColourGradient) cs).setSeqAssociated(viewAnnColour
+                    .isPerSequence());
+          }
+          if (viewAnnColour.hasPredefinedColours())
+          {
+            ((AnnotationColourGradient) cs)
+                    .setPredefinedColours(viewAnnColour
+                            .isPredefinedColours());
+          }
+          if (propagateAnnColour && al.getGroups() != null)
+          {
+            // Also use these settings for all the groups
+            for (int g = 0; g < al.getGroups().size(); g++)
+            {
+              jalview.datamodel.SequenceGroup sg = al.getGroups().get(g);
+
+              if (sg.cs == null)
+              {
+                continue;
+              }
+
+              /*
+               * if (viewAnnColour.getColourScheme().equals("None" )) { sg.cs =
+               * new AnnotationColourGradient(
+               * annAlignment.getAlignmentAnnotation()[i], new
+               * java.awt.Color(viewAnnColour. getMinColour()), new
+               * java.awt.Color(viewAnnColour. getMaxColour()),
+               * viewAnnColour.getAboveThreshold()); } else
+               */
+              {
+                sg.cs = new AnnotationColourGradient(
+                        annAlignment.getAlignmentAnnotation()[i], sg.cs,
+                        viewAnnColour.getAboveThreshold());
+                if (cs instanceof AnnotationColourGradient)
+                {
+                  if (viewAnnColour.hasPerSequence())
+                  {
+                    ((AnnotationColourGradient) cs)
+                            .setSeqAssociated(viewAnnColour.isPerSequence());
+                  }
+                  if (viewAnnColour.hasPredefinedColours())
+                  {
+                    ((AnnotationColourGradient) cs)
+                            .setPredefinedColours(viewAnnColour
+                                    .isPredefinedColours());
+                  }
+                }
+              }
+
+            }
+          }
+
+          break;
+        }
+
+      }
+    }
+    return cs;
+  }
+
   private void reorderAutoannotation(AlignFrame af, Alignment al,
           ArrayList<JvAnnotRow> autoAlan)
   {
@@ -3847,14 +3967,18 @@ public class Jalview2XML
         { // make this dataset sequence sq's dataset sequence
           sq.setDatasetSequence(dsq);
           // and update the current dataset alignment
-          if (ds==null) {
-            if (dseqs!=null) {
+          if (ds == null)
+          {
+            if (dseqs != null)
+            {
               if (!dseqs.contains(dsq))
               {
                 dseqs.add(dsq);
               }
-            } else {
-              if (ds.findIndex(dsq)<0)
+            }
+            else
+            {
+              if (ds.findIndex(dsq) < 0)
               {
                 ds.addSequence(dsq);
               }
@@ -3890,7 +4014,8 @@ public class Jalview2XML
         }
         // TODO: merges will never happen if we 'know' we have the real dataset
         // sequence - this should be detected when id==dssid
-        System.err.println("DEBUG Notice:  Merged dataset sequence (if you see this often, post at http://issues.jalview.org/browse/JAL-1474)"); // ("
+        System.err
+                .println("DEBUG Notice:  Merged dataset sequence (if you see this often, post at http://issues.jalview.org/browse/JAL-1474)"); // ("
         // + (pre ? "prepended" : "") + " "
         // + (post ? "appended" : ""));
       }
index 3ff0ca3..7b489a7 100755 (executable)
@@ -162,6 +162,7 @@ public class RedundancyPanel extends GSliderPanel implements Runnable
     valueField.setVisible(true);
 
     validate();
+    sliderValueChanged();
     // System.out.println((System.currentTimeMillis()-start));
   }
 
@@ -173,21 +174,15 @@ public class RedundancyPanel extends GSliderPanel implements Runnable
     }
 
     float value = slider.getValue();
-
+    List<SequenceI> redundantSequences = new ArrayList<SequenceI>();
     for (int i = 0; i < redundancy.length; i++)
     {
-      if (value > redundancy[i])
-      {
-        redundantSeqs.remove(originalSequences[i]);
-      }
-      else if (!redundantSeqs.contains(originalSequences[i]))
+      if (value <= redundancy[i])
       {
-        redundantSeqs.add(originalSequences[i]);
+        redundantSequences.add(originalSequences[i]);
       }
-
     }
-
-    ap.idPanel.idCanvas.setHighlighted(redundantSeqs);
+    ap.idPanel.idCanvas.setHighlighted(redundantSequences);
   }
 
   /**
index 3eff177..f53204e 100755 (executable)
@@ -267,47 +267,34 @@ public class SliderPanel extends GSliderPanel
       return;
     }
 
-    ColourSchemeI toChange = null;
-    List<SequenceGroup> allGroups = null;
-    int groupIndex = 0;
+    ColourSchemeI toChange = cs;
+    Iterator<SequenceGroup> allGroups = null;
 
     if (allGroupsCheck.isSelected())
     {
-      allGroups = ap.av.getAlignment().getGroups();
-      groupIndex = allGroups.size() - 1;
-    }
-    else
-    {
-      toChange = cs;
+      allGroups = ap.av.getAlignment().getGroups().listIterator();
     }
 
-    while (groupIndex > -1)
+    while (toChange != null)
     {
-      if (allGroups != null)
-      {
-        toChange = ((SequenceGroup) allGroups.get(groupIndex)).cs;
-
-        if (toChange == null)
-        {
-          groupIndex--;
-
-          continue;
-        }
-      }
-
       if (forConservation)
       {
-        if (toChange.conservationApplied())
-        {
-          toChange.setConservationInc(i);
-        }
+        toChange.setConservationInc(i);
       }
       else
       {
         toChange.setThreshold(i, ap.av.getIgnoreGapsConsensus());
       }
-
-      groupIndex--;
+      if (allGroups != null && allGroups.hasNext())
+      {
+        while ((toChange = allGroups.next().cs) == null
+                && allGroups.hasNext())
+          ;
+      }
+      else
+      {
+        toChange = null;
+      }
     }
 
     ap.seqPanel.seqCanvas.repaint();
index 9e2e582..97cca4b 100755 (executable)
@@ -667,9 +667,12 @@ public class TreeCanvas extends JPanel implements MouseListener, Runnable,
             RenderingHints.VALUE_ANTIALIAS_ON);
     g2.setColor(Color.white);
     g2.fillRect(0, 0, width, height);
-
     g2.setFont(font);
 
+    if (longestName==null || tree ==null)
+    {
+      g2.drawString("Calculating tree.",20,20);
+    }
     offy = font.getSize() + 10;
 
     fm = g2.getFontMetrics(font);
index f307b15..425a30a 100644 (file)
@@ -1,4 +1,4 @@
-#Fri Apr 25 13:56:18 BST 2014
+#Thu May 01 17:34:18 BST 2014
 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
@@ -25,6 +25,7 @@ jalview.schemabinding.version2.WebServiceParameterSet=jalview.schemabinding.vers
 jalview.schemabinding.version2.Alcodon=jalview.schemabinding.version2.descriptors.AlcodonDescriptor
 jalview.schemabinding.version2.AnnotationColours=jalview.schemabinding.version2.descriptors.AnnotationColoursDescriptor
 jalview.schemabinding.version2.Pdbids=jalview.schemabinding.version2.descriptors.PdbidsDescriptor
+jalview.schemabinding.version2.AnnotationColourScheme=jalview.schemabinding.version2.descriptors.AnnotationColourSchemeDescriptor
 jalview.schemabinding.version2.Mapping=jalview.schemabinding.version2.descriptors.MappingDescriptor
 jalview.schemabinding.version2.MappingChoice=jalview.schemabinding.version2.descriptors.MappingChoiceDescriptor
 jalview.schemabinding.version2.Group=jalview.schemabinding.version2.descriptors.GroupDescriptor
diff --git a/src/jalview/schemabinding/version2/AnnotationColourScheme.java b/src/jalview/schemabinding/version2/AnnotationColourScheme.java
new file mode 100644 (file)
index 0000000..8bf97d5
--- /dev/null
@@ -0,0 +1,516 @@
+/*******************************************************************************
+ * Jalview - A Sequence Alignment Editor and Viewer (Version 2.8.0b1)
+ * Copyright (C) 2014 The Jalview Authors
+ * 
+ * This file is part of Jalview.
+ * 
+ * Jalview 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 3 of the License, or (at your option) any later version.
+ *  
+ * Jalview 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 Jalview.  
+ * If not, see <http://www.gnu.org/licenses/>.
+ * The Jalview Authors are detailed in the 'AUTHORS' file.
+ ******************************************************************************/
+/*
+ * This class was automatically generated with 
+ * <a href="http://www.castor.org">Castor 1.1</a>, using an XML
+ * Schema.
+ * $Id$
+ */
+
+package jalview.schemabinding.version2;
+
+//---------------------------------/
+//- Imported classes and packages -/
+//---------------------------------/
+
+import org.exolab.castor.xml.Marshaller;
+import org.exolab.castor.xml.Unmarshaller;
+
+/**
+ * Class AnnotationColourScheme.
+ * 
+ * @version $Revision$ $Date$
+ */
+public class AnnotationColourScheme implements java.io.Serializable
+{
+
+  // --------------------------/
+  // - Class/Member Variables -/
+  // --------------------------/
+
+  /**
+   * Field _aboveThreshold.
+   */
+  private int _aboveThreshold;
+
+  /**
+   * keeps track of state for field: _aboveThreshold
+   */
+  private boolean _has_aboveThreshold;
+
+  /**
+   * Field _annotation.
+   */
+  private java.lang.String _annotation;
+
+  /**
+   * Field _minColour.
+   */
+  private int _minColour;
+
+  /**
+   * keeps track of state for field: _minColour
+   */
+  private boolean _has_minColour;
+
+  /**
+   * Field _maxColour.
+   */
+  private int _maxColour;
+
+  /**
+   * keeps track of state for field: _maxColour
+   */
+  private boolean _has_maxColour;
+
+  /**
+   * Field _colourScheme.
+   */
+  private java.lang.String _colourScheme;
+
+  /**
+   * Field _threshold.
+   */
+  private float _threshold;
+
+  /**
+   * keeps track of state for field: _threshold
+   */
+  private boolean _has_threshold;
+
+  /**
+   * Field _perSequence.
+   */
+  private boolean _perSequence;
+
+  /**
+   * keeps track of state for field: _perSequence
+   */
+  private boolean _has_perSequence;
+
+  /**
+   * Field _predefinedColours.
+   */
+  private boolean _predefinedColours;
+
+  /**
+   * keeps track of state for field: _predefinedColours
+   */
+  private boolean _has_predefinedColours;
+
+  // ----------------/
+  // - Constructors -/
+  // ----------------/
+
+  public AnnotationColourScheme()
+  {
+    super();
+  }
+
+  // -----------/
+  // - Methods -/
+  // -----------/
+
+  /**
+     */
+  public void deleteAboveThreshold()
+  {
+    this._has_aboveThreshold = false;
+  }
+
+  /**
+     */
+  public void deleteMaxColour()
+  {
+    this._has_maxColour = false;
+  }
+
+  /**
+     */
+  public void deleteMinColour()
+  {
+    this._has_minColour = false;
+  }
+
+  /**
+     */
+  public void deletePerSequence()
+  {
+    this._has_perSequence = false;
+  }
+
+  /**
+     */
+  public void deletePredefinedColours()
+  {
+    this._has_predefinedColours = false;
+  }
+
+  /**
+     */
+  public void deleteThreshold()
+  {
+    this._has_threshold = false;
+  }
+
+  /**
+   * Returns the value of field 'aboveThreshold'.
+   * 
+   * @return the value of field 'AboveThreshold'.
+   */
+  public int getAboveThreshold()
+  {
+    return this._aboveThreshold;
+  }
+
+  /**
+   * Returns the value of field 'annotation'.
+   * 
+   * @return the value of field 'Annotation'.
+   */
+  public java.lang.String getAnnotation()
+  {
+    return this._annotation;
+  }
+
+  /**
+   * Returns the value of field 'colourScheme'.
+   * 
+   * @return the value of field 'ColourScheme'.
+   */
+  public java.lang.String getColourScheme()
+  {
+    return this._colourScheme;
+  }
+
+  /**
+   * Returns the value of field 'maxColour'.
+   * 
+   * @return the value of field 'MaxColour'.
+   */
+  public int getMaxColour()
+  {
+    return this._maxColour;
+  }
+
+  /**
+   * Returns the value of field 'minColour'.
+   * 
+   * @return the value of field 'MinColour'.
+   */
+  public int getMinColour()
+  {
+    return this._minColour;
+  }
+
+  /**
+   * Returns the value of field 'perSequence'.
+   * 
+   * @return the value of field 'PerSequence'.
+   */
+  public boolean getPerSequence()
+  {
+    return this._perSequence;
+  }
+
+  /**
+   * Returns the value of field 'predefinedColours'.
+   * 
+   * @return the value of field 'PredefinedColours'.
+   */
+  public boolean getPredefinedColours()
+  {
+    return this._predefinedColours;
+  }
+
+  /**
+   * Returns the value of field 'threshold'.
+   * 
+   * @return the value of field 'Threshold'.
+   */
+  public float getThreshold()
+  {
+    return this._threshold;
+  }
+
+  /**
+   * Method hasAboveThreshold.
+   * 
+   * @return true if at least one AboveThreshold has been added
+   */
+  public boolean hasAboveThreshold()
+  {
+    return this._has_aboveThreshold;
+  }
+
+  /**
+   * Method hasMaxColour.
+   * 
+   * @return true if at least one MaxColour has been added
+   */
+  public boolean hasMaxColour()
+  {
+    return this._has_maxColour;
+  }
+
+  /**
+   * Method hasMinColour.
+   * 
+   * @return true if at least one MinColour has been added
+   */
+  public boolean hasMinColour()
+  {
+    return this._has_minColour;
+  }
+
+  /**
+   * Method hasPerSequence.
+   * 
+   * @return true if at least one PerSequence has been added
+   */
+  public boolean hasPerSequence()
+  {
+    return this._has_perSequence;
+  }
+
+  /**
+   * Method hasPredefinedColours.
+   * 
+   * @return true if at least one PredefinedColours has been added
+   */
+  public boolean hasPredefinedColours()
+  {
+    return this._has_predefinedColours;
+  }
+
+  /**
+   * Method hasThreshold.
+   * 
+   * @return true if at least one Threshold has been added
+   */
+  public boolean hasThreshold()
+  {
+    return this._has_threshold;
+  }
+
+  /**
+   * Returns the value of field 'perSequence'.
+   * 
+   * @return the value of field 'PerSequence'.
+   */
+  public boolean isPerSequence()
+  {
+    return this._perSequence;
+  }
+
+  /**
+   * Returns the value of field 'predefinedColours'.
+   * 
+   * @return the value of field 'PredefinedColours'.
+   */
+  public boolean isPredefinedColours()
+  {
+    return this._predefinedColours;
+  }
+
+  /**
+   * Method isValid.
+   * 
+   * @return true if this object is valid according to the schema
+   */
+  public boolean isValid()
+  {
+    try
+    {
+      validate();
+    } catch (org.exolab.castor.xml.ValidationException vex)
+    {
+      return false;
+    }
+    return true;
+  }
+
+  /**
+   * 
+   * 
+   * @param out
+   * @throws org.exolab.castor.xml.MarshalException
+   *           if object is null or if any SAXException is thrown during
+   *           marshaling
+   * @throws org.exolab.castor.xml.ValidationException
+   *           if this object is an invalid instance according to the schema
+   */
+  public void marshal(final java.io.Writer out)
+          throws org.exolab.castor.xml.MarshalException,
+          org.exolab.castor.xml.ValidationException
+  {
+    Marshaller.marshal(this, out);
+  }
+
+  /**
+   * 
+   * 
+   * @param handler
+   * @throws java.io.IOException
+   *           if an IOException occurs during marshaling
+   * @throws org.exolab.castor.xml.ValidationException
+   *           if this object is an invalid instance according to the schema
+   * @throws org.exolab.castor.xml.MarshalException
+   *           if object is null or if any SAXException is thrown during
+   *           marshaling
+   */
+  public void marshal(final org.xml.sax.ContentHandler handler)
+          throws java.io.IOException,
+          org.exolab.castor.xml.MarshalException,
+          org.exolab.castor.xml.ValidationException
+  {
+    Marshaller.marshal(this, handler);
+  }
+
+  /**
+   * Sets the value of field 'aboveThreshold'.
+   * 
+   * @param aboveThreshold
+   *          the value of field 'aboveThreshold'.
+   */
+  public void setAboveThreshold(final int aboveThreshold)
+  {
+    this._aboveThreshold = aboveThreshold;
+    this._has_aboveThreshold = true;
+  }
+
+  /**
+   * Sets the value of field 'annotation'.
+   * 
+   * @param annotation
+   *          the value of field 'annotation'.
+   */
+  public void setAnnotation(final java.lang.String annotation)
+  {
+    this._annotation = annotation;
+  }
+
+  /**
+   * Sets the value of field 'colourScheme'.
+   * 
+   * @param colourScheme
+   *          the value of field 'colourScheme'.
+   */
+  public void setColourScheme(final java.lang.String colourScheme)
+  {
+    this._colourScheme = colourScheme;
+  }
+
+  /**
+   * Sets the value of field 'maxColour'.
+   * 
+   * @param maxColour
+   *          the value of field 'maxColour'.
+   */
+  public void setMaxColour(final int maxColour)
+  {
+    this._maxColour = maxColour;
+    this._has_maxColour = true;
+  }
+
+  /**
+   * Sets the value of field 'minColour'.
+   * 
+   * @param minColour
+   *          the value of field 'minColour'.
+   */
+  public void setMinColour(final int minColour)
+  {
+    this._minColour = minColour;
+    this._has_minColour = true;
+  }
+
+  /**
+   * Sets the value of field 'perSequence'.
+   * 
+   * @param perSequence
+   *          the value of field 'perSequence'.
+   */
+  public void setPerSequence(final boolean perSequence)
+  {
+    this._perSequence = perSequence;
+    this._has_perSequence = true;
+  }
+
+  /**
+   * Sets the value of field 'predefinedColours'.
+   * 
+   * @param predefinedColours
+   *          the value of field 'predefinedColours'.
+   */
+  public void setPredefinedColours(final boolean predefinedColours)
+  {
+    this._predefinedColours = predefinedColours;
+    this._has_predefinedColours = true;
+  }
+
+  /**
+   * Sets the value of field 'threshold'.
+   * 
+   * @param threshold
+   *          the value of field 'threshold'.
+   */
+  public void setThreshold(final float threshold)
+  {
+    this._threshold = threshold;
+    this._has_threshold = true;
+  }
+
+  /**
+   * Method unmarshal.
+   * 
+   * @param reader
+   * @throws org.exolab.castor.xml.MarshalException
+   *           if object is null or if any SAXException is thrown during
+   *           marshaling
+   * @throws org.exolab.castor.xml.ValidationException
+   *           if this object is an invalid instance according to the schema
+   * @return the unmarshaled
+   *         jalview.schemabinding.version2.AnnotationColourScheme
+   */
+  public static jalview.schemabinding.version2.AnnotationColourScheme unmarshal(
+          final java.io.Reader reader)
+          throws org.exolab.castor.xml.MarshalException,
+          org.exolab.castor.xml.ValidationException
+  {
+    return (jalview.schemabinding.version2.AnnotationColourScheme) Unmarshaller
+            .unmarshal(
+                    jalview.schemabinding.version2.AnnotationColourScheme.class,
+                    reader);
+  }
+
+  /**
+   * 
+   * 
+   * @throws org.exolab.castor.xml.ValidationException
+   *           if this object is an invalid instance according to the schema
+   */
+  public void validate() throws org.exolab.castor.xml.ValidationException
+  {
+    org.exolab.castor.xml.Validator validator = new org.exolab.castor.xml.Validator();
+    validator.validate(this);
+  }
+
+}
index e20bbc4..cbda218 100644 (file)
@@ -38,83 +38,10 @@ import org.exolab.castor.xml.Unmarshaller;
  * 
  * @version $Revision$ $Date$
  */
-public class AnnotationColours implements java.io.Serializable
+public class AnnotationColours extends AnnotationColourScheme implements
+        java.io.Serializable
 {
 
-  // --------------------------/
-  // - Class/Member Variables -/
-  // --------------------------/
-
-  /**
-   * Field _aboveThreshold.
-   */
-  private int _aboveThreshold;
-
-  /**
-   * keeps track of state for field: _aboveThreshold
-   */
-  private boolean _has_aboveThreshold;
-
-  /**
-   * Field _annotation.
-   */
-  private java.lang.String _annotation;
-
-  /**
-   * Field _minColour.
-   */
-  private int _minColour;
-
-  /**
-   * keeps track of state for field: _minColour
-   */
-  private boolean _has_minColour;
-
-  /**
-   * Field _maxColour.
-   */
-  private int _maxColour;
-
-  /**
-   * keeps track of state for field: _maxColour
-   */
-  private boolean _has_maxColour;
-
-  /**
-   * Field _colourScheme.
-   */
-  private java.lang.String _colourScheme;
-
-  /**
-   * Field _threshold.
-   */
-  private float _threshold;
-
-  /**
-   * keeps track of state for field: _threshold
-   */
-  private boolean _has_threshold;
-
-  /**
-   * Field _perSequence.
-   */
-  private boolean _perSequence;
-
-  /**
-   * keeps track of state for field: _perSequence
-   */
-  private boolean _has_perSequence;
-
-  /**
-   * Field _predefinedColours.
-   */
-  private boolean _predefinedColours;
-
-  /**
-   * keeps track of state for field: _predefinedColours
-   */
-  private boolean _has_predefinedColours;
-
   // ----------------/
   // - Constructors -/
   // ----------------/
@@ -129,208 +56,6 @@ public class AnnotationColours implements java.io.Serializable
   // -----------/
 
   /**
-     */
-  public void deleteAboveThreshold()
-  {
-    this._has_aboveThreshold = false;
-  }
-
-  /**
-     */
-  public void deleteMaxColour()
-  {
-    this._has_maxColour = false;
-  }
-
-  /**
-     */
-  public void deleteMinColour()
-  {
-    this._has_minColour = false;
-  }
-
-  /**
-     */
-  public void deletePerSequence()
-  {
-    this._has_perSequence = false;
-  }
-
-  /**
-     */
-  public void deletePredefinedColours()
-  {
-    this._has_predefinedColours = false;
-  }
-
-  /**
-     */
-  public void deleteThreshold()
-  {
-    this._has_threshold = false;
-  }
-
-  /**
-   * Returns the value of field 'aboveThreshold'.
-   * 
-   * @return the value of field 'AboveThreshold'.
-   */
-  public int getAboveThreshold()
-  {
-    return this._aboveThreshold;
-  }
-
-  /**
-   * Returns the value of field 'annotation'.
-   * 
-   * @return the value of field 'Annotation'.
-   */
-  public java.lang.String getAnnotation()
-  {
-    return this._annotation;
-  }
-
-  /**
-   * Returns the value of field 'colourScheme'.
-   * 
-   * @return the value of field 'ColourScheme'.
-   */
-  public java.lang.String getColourScheme()
-  {
-    return this._colourScheme;
-  }
-
-  /**
-   * Returns the value of field 'maxColour'.
-   * 
-   * @return the value of field 'MaxColour'.
-   */
-  public int getMaxColour()
-  {
-    return this._maxColour;
-  }
-
-  /**
-   * Returns the value of field 'minColour'.
-   * 
-   * @return the value of field 'MinColour'.
-   */
-  public int getMinColour()
-  {
-    return this._minColour;
-  }
-
-  /**
-   * Returns the value of field 'perSequence'.
-   * 
-   * @return the value of field 'PerSequence'.
-   */
-  public boolean getPerSequence()
-  {
-    return this._perSequence;
-  }
-
-  /**
-   * Returns the value of field 'predefinedColours'.
-   * 
-   * @return the value of field 'PredefinedColours'.
-   */
-  public boolean getPredefinedColours()
-  {
-    return this._predefinedColours;
-  }
-
-  /**
-   * Returns the value of field 'threshold'.
-   * 
-   * @return the value of field 'Threshold'.
-   */
-  public float getThreshold()
-  {
-    return this._threshold;
-  }
-
-  /**
-   * Method hasAboveThreshold.
-   * 
-   * @return true if at least one AboveThreshold has been added
-   */
-  public boolean hasAboveThreshold()
-  {
-    return this._has_aboveThreshold;
-  }
-
-  /**
-   * Method hasMaxColour.
-   * 
-   * @return true if at least one MaxColour has been added
-   */
-  public boolean hasMaxColour()
-  {
-    return this._has_maxColour;
-  }
-
-  /**
-   * Method hasMinColour.
-   * 
-   * @return true if at least one MinColour has been added
-   */
-  public boolean hasMinColour()
-  {
-    return this._has_minColour;
-  }
-
-  /**
-   * Method hasPerSequence.
-   * 
-   * @return true if at least one PerSequence has been added
-   */
-  public boolean hasPerSequence()
-  {
-    return this._has_perSequence;
-  }
-
-  /**
-   * Method hasPredefinedColours.
-   * 
-   * @return true if at least one PredefinedColours has been added
-   */
-  public boolean hasPredefinedColours()
-  {
-    return this._has_predefinedColours;
-  }
-
-  /**
-   * Method hasThreshold.
-   * 
-   * @return true if at least one Threshold has been added
-   */
-  public boolean hasThreshold()
-  {
-    return this._has_threshold;
-  }
-
-  /**
-   * Returns the value of field 'perSequence'.
-   * 
-   * @return the value of field 'PerSequence'.
-   */
-  public boolean isPerSequence()
-  {
-    return this._perSequence;
-  }
-
-  /**
-   * Returns the value of field 'predefinedColours'.
-   * 
-   * @return the value of field 'PredefinedColours'.
-   */
-  public boolean isPredefinedColours()
-  {
-    return this._predefinedColours;
-  }
-
-  /**
    * Method isValid.
    * 
    * @return true if this object is valid according to the schema
@@ -385,100 +110,6 @@ public class AnnotationColours implements java.io.Serializable
   }
 
   /**
-   * Sets the value of field 'aboveThreshold'.
-   * 
-   * @param aboveThreshold
-   *          the value of field 'aboveThreshold'.
-   */
-  public void setAboveThreshold(final int aboveThreshold)
-  {
-    this._aboveThreshold = aboveThreshold;
-    this._has_aboveThreshold = true;
-  }
-
-  /**
-   * Sets the value of field 'annotation'.
-   * 
-   * @param annotation
-   *          the value of field 'annotation'.
-   */
-  public void setAnnotation(final java.lang.String annotation)
-  {
-    this._annotation = annotation;
-  }
-
-  /**
-   * Sets the value of field 'colourScheme'.
-   * 
-   * @param colourScheme
-   *          the value of field 'colourScheme'.
-   */
-  public void setColourScheme(final java.lang.String colourScheme)
-  {
-    this._colourScheme = colourScheme;
-  }
-
-  /**
-   * Sets the value of field 'maxColour'.
-   * 
-   * @param maxColour
-   *          the value of field 'maxColour'.
-   */
-  public void setMaxColour(final int maxColour)
-  {
-    this._maxColour = maxColour;
-    this._has_maxColour = true;
-  }
-
-  /**
-   * Sets the value of field 'minColour'.
-   * 
-   * @param minColour
-   *          the value of field 'minColour'.
-   */
-  public void setMinColour(final int minColour)
-  {
-    this._minColour = minColour;
-    this._has_minColour = true;
-  }
-
-  /**
-   * Sets the value of field 'perSequence'.
-   * 
-   * @param perSequence
-   *          the value of field 'perSequence'.
-   */
-  public void setPerSequence(final boolean perSequence)
-  {
-    this._perSequence = perSequence;
-    this._has_perSequence = true;
-  }
-
-  /**
-   * Sets the value of field 'predefinedColours'.
-   * 
-   * @param predefinedColours
-   *          the value of field 'predefinedColours'.
-   */
-  public void setPredefinedColours(final boolean predefinedColours)
-  {
-    this._predefinedColours = predefinedColours;
-    this._has_predefinedColours = true;
-  }
-
-  /**
-   * Sets the value of field 'threshold'.
-   * 
-   * @param threshold
-   *          the value of field 'threshold'.
-   */
-  public void setThreshold(final float threshold)
-  {
-    this._threshold = threshold;
-    this._has_threshold = true;
-  }
-
-  /**
    * Method unmarshal.
    * 
    * @param reader
@@ -487,14 +118,15 @@ public class AnnotationColours implements java.io.Serializable
    *           marshaling
    * @throws org.exolab.castor.xml.ValidationException
    *           if this object is an invalid instance according to the schema
-   * @return the unmarshaled jalview.schemabinding.version2.AnnotationColours
+   * @return the unmarshaled
+   *         jalview.schemabinding.version2.AnnotationColourScheme
    */
-  public static jalview.schemabinding.version2.AnnotationColours unmarshal(
+  public static jalview.schemabinding.version2.AnnotationColourScheme unmarshal(
           final java.io.Reader reader)
           throws org.exolab.castor.xml.MarshalException,
           org.exolab.castor.xml.ValidationException
   {
-    return (jalview.schemabinding.version2.AnnotationColours) Unmarshaller
+    return (jalview.schemabinding.version2.AnnotationColourScheme) Unmarshaller
             .unmarshal(
                     jalview.schemabinding.version2.AnnotationColours.class,
                     reader);
index 56e43b7..44e8739 100644 (file)
@@ -226,6 +226,11 @@ public class JGroup implements java.io.Serializable
    */
   private java.util.Vector _seqList;
 
+  /**
+   * Field _annotationColours.
+   */
+  private jalview.schemabinding.version2.AnnotationColours _annotationColours;
+
   // ----------------/
   // - Constructors -/
   // ----------------/
@@ -390,6 +395,16 @@ public class JGroup implements java.io.Serializable
   }
 
   /**
+   * Returns the value of field 'annotationColours'.
+   * 
+   * @return the value of field 'AnnotationColours'.
+   */
+  public jalview.schemabinding.version2.AnnotationColours getAnnotationColours()
+  {
+    return this._annotationColours;
+  }
+
+  /**
    * Returns the value of field 'colour'.
    * 
    * @return the value of field 'Colour'.
@@ -954,6 +969,18 @@ public class JGroup implements java.io.Serializable
   }
 
   /**
+   * Sets the value of field 'annotationColours'.
+   * 
+   * @param annotationColours
+   *          the value of field 'annotationColours'.
+   */
+  public void setAnnotationColours(
+          final jalview.schemabinding.version2.AnnotationColours annotationColours)
+  {
+    this._annotationColours = annotationColours;
+  }
+
+  /**
    * Sets the value of field 'colour'.
    * 
    * @param colour
diff --git a/src/jalview/schemabinding/version2/descriptors/AnnotationColourSchemeDescriptor.java b/src/jalview/schemabinding/version2/descriptors/AnnotationColourSchemeDescriptor.java
new file mode 100644 (file)
index 0000000..98f2855
--- /dev/null
@@ -0,0 +1,592 @@
+/*******************************************************************************
+ * Jalview - A Sequence Alignment Editor and Viewer (Version 2.8.0b1)
+ * Copyright (C) 2014 The Jalview Authors
+ * 
+ * This file is part of Jalview.
+ * 
+ * Jalview 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 3 of the License, or (at your option) any later version.
+ *  
+ * Jalview 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 Jalview.  
+ * If not, see <http://www.gnu.org/licenses/>.
+ * The Jalview Authors are detailed in the 'AUTHORS' file.
+ ******************************************************************************/
+/*
+ * This class was automatically generated with 
+ * <a href="http://www.castor.org">Castor 1.1</a>, using an XML
+ * Schema.
+ * $Id$
+ */
+
+package jalview.schemabinding.version2.descriptors;
+
+//---------------------------------/
+//- Imported classes and packages -/
+//---------------------------------/
+
+import jalview.schemabinding.version2.AnnotationColourScheme;
+
+/**
+ * Class AnnotationColourSchemeDescriptor.
+ * 
+ * @version $Revision$ $Date$
+ */
+public class AnnotationColourSchemeDescriptor extends
+        org.exolab.castor.xml.util.XMLClassDescriptorImpl
+{
+
+  // --------------------------/
+  // - Class/Member Variables -/
+  // --------------------------/
+
+  /**
+   * Field _elementDefinition.
+   */
+  private boolean _elementDefinition;
+
+  /**
+   * Field _nsPrefix.
+   */
+  private java.lang.String _nsPrefix;
+
+  /**
+   * Field _nsURI.
+   */
+  private java.lang.String _nsURI;
+
+  /**
+   * Field _xmlName.
+   */
+  private java.lang.String _xmlName;
+
+  // ----------------/
+  // - Constructors -/
+  // ----------------/
+
+  public AnnotationColourSchemeDescriptor()
+  {
+    super();
+    _nsURI = "www.jalview.org";
+    _xmlName = "AnnotationColourScheme";
+    _elementDefinition = false;
+    org.exolab.castor.xml.util.XMLFieldDescriptorImpl desc = null;
+    org.exolab.castor.mapping.FieldHandler handler = null;
+    org.exolab.castor.xml.FieldValidator fieldValidator = null;
+    // -- initialize attribute descriptors
+
+    // -- _aboveThreshold
+    desc = new org.exolab.castor.xml.util.XMLFieldDescriptorImpl(
+            java.lang.Integer.TYPE, "_aboveThreshold", "aboveThreshold",
+            org.exolab.castor.xml.NodeType.Attribute);
+    handler = new org.exolab.castor.xml.XMLFieldHandler()
+    {
+      public java.lang.Object getValue(java.lang.Object object)
+              throws IllegalStateException
+      {
+        AnnotationColourScheme target = (AnnotationColourScheme) object;
+        if (!target.hasAboveThreshold())
+        {
+          return null;
+        }
+        return new java.lang.Integer(target.getAboveThreshold());
+      }
+
+      public void setValue(java.lang.Object object, java.lang.Object value)
+              throws IllegalStateException, IllegalArgumentException
+      {
+        try
+        {
+          AnnotationColourScheme target = (AnnotationColourScheme) object;
+          // if null, use delete method for optional primitives
+          if (value == null)
+          {
+            target.deleteAboveThreshold();
+            return;
+          }
+          target.setAboveThreshold(((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);
+    desc.setMultivalued(false);
+    addFieldDescriptor(desc);
+
+    // -- validation code for: _aboveThreshold
+    fieldValidator = new org.exolab.castor.xml.FieldValidator();
+    { // -- local scope
+      org.exolab.castor.xml.validators.IntValidator typeValidator;
+      typeValidator = new org.exolab.castor.xml.validators.IntValidator();
+      fieldValidator.setValidator(typeValidator);
+      typeValidator.setMinInclusive(-2147483648);
+      typeValidator.setMaxInclusive(2147483647);
+    }
+    desc.setValidator(fieldValidator);
+    // -- _annotation
+    desc = new org.exolab.castor.xml.util.XMLFieldDescriptorImpl(
+            java.lang.String.class, "_annotation", "annotation",
+            org.exolab.castor.xml.NodeType.Attribute);
+    desc.setImmutable(true);
+    handler = new org.exolab.castor.xml.XMLFieldHandler()
+    {
+      public java.lang.Object getValue(java.lang.Object object)
+              throws IllegalStateException
+      {
+        AnnotationColourScheme target = (AnnotationColourScheme) object;
+        return target.getAnnotation();
+      }
+
+      public void setValue(java.lang.Object object, java.lang.Object value)
+              throws IllegalStateException, IllegalArgumentException
+      {
+        try
+        {
+          AnnotationColourScheme target = (AnnotationColourScheme) object;
+          target.setAnnotation((java.lang.String) value);
+        } 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: _annotation
+    fieldValidator = new org.exolab.castor.xml.FieldValidator();
+    { // -- local scope
+      org.exolab.castor.xml.validators.StringValidator typeValidator;
+      typeValidator = new org.exolab.castor.xml.validators.StringValidator();
+      fieldValidator.setValidator(typeValidator);
+      typeValidator.setWhiteSpace("preserve");
+    }
+    desc.setValidator(fieldValidator);
+    // -- _minColour
+    desc = new org.exolab.castor.xml.util.XMLFieldDescriptorImpl(
+            java.lang.Integer.TYPE, "_minColour", "minColour",
+            org.exolab.castor.xml.NodeType.Attribute);
+    handler = new org.exolab.castor.xml.XMLFieldHandler()
+    {
+      public java.lang.Object getValue(java.lang.Object object)
+              throws IllegalStateException
+      {
+        AnnotationColourScheme target = (AnnotationColourScheme) object;
+        if (!target.hasMinColour())
+        {
+          return null;
+        }
+        return new java.lang.Integer(target.getMinColour());
+      }
+
+      public void setValue(java.lang.Object object, java.lang.Object value)
+              throws IllegalStateException, IllegalArgumentException
+      {
+        try
+        {
+          AnnotationColourScheme target = (AnnotationColourScheme) object;
+          // if null, use delete method for optional primitives
+          if (value == null)
+          {
+            target.deleteMinColour();
+            return;
+          }
+          target.setMinColour(((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);
+    desc.setMultivalued(false);
+    addFieldDescriptor(desc);
+
+    // -- validation code for: _minColour
+    fieldValidator = new org.exolab.castor.xml.FieldValidator();
+    { // -- local scope
+      org.exolab.castor.xml.validators.IntValidator typeValidator;
+      typeValidator = new org.exolab.castor.xml.validators.IntValidator();
+      fieldValidator.setValidator(typeValidator);
+      typeValidator.setMinInclusive(-2147483648);
+      typeValidator.setMaxInclusive(2147483647);
+    }
+    desc.setValidator(fieldValidator);
+    // -- _maxColour
+    desc = new org.exolab.castor.xml.util.XMLFieldDescriptorImpl(
+            java.lang.Integer.TYPE, "_maxColour", "maxColour",
+            org.exolab.castor.xml.NodeType.Attribute);
+    handler = new org.exolab.castor.xml.XMLFieldHandler()
+    {
+      public java.lang.Object getValue(java.lang.Object object)
+              throws IllegalStateException
+      {
+        AnnotationColourScheme target = (AnnotationColourScheme) object;
+        if (!target.hasMaxColour())
+        {
+          return null;
+        }
+        return new java.lang.Integer(target.getMaxColour());
+      }
+
+      public void setValue(java.lang.Object object, java.lang.Object value)
+              throws IllegalStateException, IllegalArgumentException
+      {
+        try
+        {
+          AnnotationColourScheme target = (AnnotationColourScheme) object;
+          // if null, use delete method for optional primitives
+          if (value == null)
+          {
+            target.deleteMaxColour();
+            return;
+          }
+          target.setMaxColour(((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);
+    desc.setMultivalued(false);
+    addFieldDescriptor(desc);
+
+    // -- validation code for: _maxColour
+    fieldValidator = new org.exolab.castor.xml.FieldValidator();
+    { // -- local scope
+      org.exolab.castor.xml.validators.IntValidator typeValidator;
+      typeValidator = new org.exolab.castor.xml.validators.IntValidator();
+      fieldValidator.setValidator(typeValidator);
+      typeValidator.setMinInclusive(-2147483648);
+      typeValidator.setMaxInclusive(2147483647);
+    }
+    desc.setValidator(fieldValidator);
+    // -- _colourScheme
+    desc = new org.exolab.castor.xml.util.XMLFieldDescriptorImpl(
+            java.lang.String.class, "_colourScheme", "colourScheme",
+            org.exolab.castor.xml.NodeType.Attribute);
+    desc.setImmutable(true);
+    handler = new org.exolab.castor.xml.XMLFieldHandler()
+    {
+      public java.lang.Object getValue(java.lang.Object object)
+              throws IllegalStateException
+      {
+        AnnotationColourScheme target = (AnnotationColourScheme) object;
+        return target.getColourScheme();
+      }
+
+      public void setValue(java.lang.Object object, java.lang.Object value)
+              throws IllegalStateException, IllegalArgumentException
+      {
+        try
+        {
+          AnnotationColourScheme target = (AnnotationColourScheme) object;
+          target.setColourScheme((java.lang.String) value);
+        } 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: _colourScheme
+    fieldValidator = new org.exolab.castor.xml.FieldValidator();
+    { // -- local scope
+      org.exolab.castor.xml.validators.StringValidator typeValidator;
+      typeValidator = new org.exolab.castor.xml.validators.StringValidator();
+      fieldValidator.setValidator(typeValidator);
+      typeValidator.setWhiteSpace("preserve");
+    }
+    desc.setValidator(fieldValidator);
+    // -- _threshold
+    desc = new org.exolab.castor.xml.util.XMLFieldDescriptorImpl(
+            java.lang.Float.TYPE, "_threshold", "threshold",
+            org.exolab.castor.xml.NodeType.Attribute);
+    handler = new org.exolab.castor.xml.XMLFieldHandler()
+    {
+      public java.lang.Object getValue(java.lang.Object object)
+              throws IllegalStateException
+      {
+        AnnotationColourScheme target = (AnnotationColourScheme) object;
+        if (!target.hasThreshold())
+        {
+          return null;
+        }
+        return new java.lang.Float(target.getThreshold());
+      }
+
+      public void setValue(java.lang.Object object, java.lang.Object value)
+              throws IllegalStateException, IllegalArgumentException
+      {
+        try
+        {
+          AnnotationColourScheme target = (AnnotationColourScheme) object;
+          // if null, use delete method for optional primitives
+          if (value == null)
+          {
+            target.deleteThreshold();
+            return;
+          }
+          target.setThreshold(((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);
+    desc.setMultivalued(false);
+    addFieldDescriptor(desc);
+
+    // -- validation code for: _threshold
+    fieldValidator = new org.exolab.castor.xml.FieldValidator();
+    { // -- local scope
+      org.exolab.castor.xml.validators.FloatValidator typeValidator;
+      typeValidator = new org.exolab.castor.xml.validators.FloatValidator();
+      fieldValidator.setValidator(typeValidator);
+      typeValidator.setMinInclusive((float) -3.4028235E38);
+      typeValidator.setMaxInclusive((float) 3.4028235E38);
+    }
+    desc.setValidator(fieldValidator);
+    // -- _perSequence
+    desc = new org.exolab.castor.xml.util.XMLFieldDescriptorImpl(
+            java.lang.Boolean.TYPE, "_perSequence", "perSequence",
+            org.exolab.castor.xml.NodeType.Attribute);
+    handler = new org.exolab.castor.xml.XMLFieldHandler()
+    {
+      public java.lang.Object getValue(java.lang.Object object)
+              throws IllegalStateException
+      {
+        AnnotationColourScheme target = (AnnotationColourScheme) object;
+        if (!target.hasPerSequence())
+        {
+          return null;
+        }
+        return (target.getPerSequence() ? java.lang.Boolean.TRUE
+                : java.lang.Boolean.FALSE);
+      }
+
+      public void setValue(java.lang.Object object, java.lang.Object value)
+              throws IllegalStateException, IllegalArgumentException
+      {
+        try
+        {
+          AnnotationColourScheme target = (AnnotationColourScheme) object;
+          // if null, use delete method for optional primitives
+          if (value == null)
+          {
+            target.deletePerSequence();
+            return;
+          }
+          target.setPerSequence(((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: _perSequence
+    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);
+    // -- _predefinedColours
+    desc = new org.exolab.castor.xml.util.XMLFieldDescriptorImpl(
+            java.lang.Boolean.TYPE, "_predefinedColours",
+            "predefinedColours", org.exolab.castor.xml.NodeType.Attribute);
+    handler = new org.exolab.castor.xml.XMLFieldHandler()
+    {
+      public java.lang.Object getValue(java.lang.Object object)
+              throws IllegalStateException
+      {
+        AnnotationColourScheme target = (AnnotationColourScheme) object;
+        if (!target.hasPredefinedColours())
+        {
+          return null;
+        }
+        return (target.getPredefinedColours() ? java.lang.Boolean.TRUE
+                : java.lang.Boolean.FALSE);
+      }
+
+      public void setValue(java.lang.Object object, java.lang.Object value)
+              throws IllegalStateException, IllegalArgumentException
+      {
+        try
+        {
+          AnnotationColourScheme target = (AnnotationColourScheme) object;
+          // if null, use delete method for optional primitives
+          if (value == null)
+          {
+            target.deletePredefinedColours();
+            return;
+          }
+          target.setPredefinedColours(((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: _predefinedColours
+    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
+
+  }
+
+  // -----------/
+  // - Methods -/
+  // -----------/
+
+  /**
+   * Method getAccessMode.
+   * 
+   * @return the access mode specified for this class.
+   */
+  public org.exolab.castor.mapping.AccessMode getAccessMode()
+  {
+    return null;
+  }
+
+  /**
+   * Method getIdentity.
+   * 
+   * @return the identity field, null if this class has no identity.
+   */
+  public org.exolab.castor.mapping.FieldDescriptor getIdentity()
+  {
+    return super.getIdentity();
+  }
+
+  /**
+   * Method getJavaClass.
+   * 
+   * @return the Java class represented by this descriptor.
+   */
+  public java.lang.Class getJavaClass()
+  {
+    return jalview.schemabinding.version2.AnnotationColourScheme.class;
+  }
+
+  /**
+   * Method getNameSpacePrefix.
+   * 
+   * @return the namespace prefix to use when marshaling as XML.
+   */
+  public java.lang.String getNameSpacePrefix()
+  {
+    return _nsPrefix;
+  }
+
+  /**
+   * Method getNameSpaceURI.
+   * 
+   * @return the namespace URI used when marshaling and unmarshaling as XML.
+   */
+  public java.lang.String getNameSpaceURI()
+  {
+    return _nsURI;
+  }
+
+  /**
+   * Method getValidator.
+   * 
+   * @return a specific validator for the class described by this
+   *         ClassDescriptor.
+   */
+  public org.exolab.castor.xml.TypeValidator getValidator()
+  {
+    return this;
+  }
+
+  /**
+   * Method getXMLName.
+   * 
+   * @return the XML Name for the Class being described.
+   */
+  public java.lang.String getXMLName()
+  {
+    return _xmlName;
+  }
+
+  /**
+   * Method isElementDefinition.
+   * 
+   * @return true if XML schema definition of this Class is that of a global
+   *         element or element with anonymous type definition.
+   */
+  public boolean isElementDefinition()
+  {
+    return _elementDefinition;
+  }
+
+}
index 954e3e5..5eb3939 100644 (file)
@@ -37,8 +37,9 @@ import jalview.schemabinding.version2.AnnotationColours;
  * 
  * @version $Revision$ $Date$
  */
-public class AnnotationColoursDescriptor extends
-        org.exolab.castor.xml.util.XMLClassDescriptorImpl
+public class AnnotationColoursDescriptor
+        extends
+        jalview.schemabinding.version2.descriptors.AnnotationColourSchemeDescriptor
 {
 
   // --------------------------/
@@ -72,435 +73,10 @@ public class AnnotationColoursDescriptor extends
   public AnnotationColoursDescriptor()
   {
     super();
+    setExtendsWithoutFlatten(new jalview.schemabinding.version2.descriptors.AnnotationColourSchemeDescriptor());
     _nsURI = "www.jalview.org";
     _xmlName = "AnnotationColours";
     _elementDefinition = true;
-    org.exolab.castor.xml.util.XMLFieldDescriptorImpl desc = null;
-    org.exolab.castor.mapping.FieldHandler handler = null;
-    org.exolab.castor.xml.FieldValidator fieldValidator = null;
-    // -- initialize attribute descriptors
-
-    // -- _aboveThreshold
-    desc = new org.exolab.castor.xml.util.XMLFieldDescriptorImpl(
-            java.lang.Integer.TYPE, "_aboveThreshold", "aboveThreshold",
-            org.exolab.castor.xml.NodeType.Attribute);
-    handler = new org.exolab.castor.xml.XMLFieldHandler()
-    {
-      public java.lang.Object getValue(java.lang.Object object)
-              throws IllegalStateException
-      {
-        AnnotationColours target = (AnnotationColours) object;
-        if (!target.hasAboveThreshold())
-        {
-          return null;
-        }
-        return new java.lang.Integer(target.getAboveThreshold());
-      }
-
-      public void setValue(java.lang.Object object, java.lang.Object value)
-              throws IllegalStateException, IllegalArgumentException
-      {
-        try
-        {
-          AnnotationColours target = (AnnotationColours) object;
-          // if null, use delete method for optional primitives
-          if (value == null)
-          {
-            target.deleteAboveThreshold();
-            return;
-          }
-          target.setAboveThreshold(((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);
-    desc.setMultivalued(false);
-    addFieldDescriptor(desc);
-
-    // -- validation code for: _aboveThreshold
-    fieldValidator = new org.exolab.castor.xml.FieldValidator();
-    { // -- local scope
-      org.exolab.castor.xml.validators.IntValidator typeValidator;
-      typeValidator = new org.exolab.castor.xml.validators.IntValidator();
-      fieldValidator.setValidator(typeValidator);
-      typeValidator.setMinInclusive(-2147483648);
-      typeValidator.setMaxInclusive(2147483647);
-    }
-    desc.setValidator(fieldValidator);
-    // -- _annotation
-    desc = new org.exolab.castor.xml.util.XMLFieldDescriptorImpl(
-            java.lang.String.class, "_annotation", "annotation",
-            org.exolab.castor.xml.NodeType.Attribute);
-    desc.setImmutable(true);
-    handler = new org.exolab.castor.xml.XMLFieldHandler()
-    {
-      public java.lang.Object getValue(java.lang.Object object)
-              throws IllegalStateException
-      {
-        AnnotationColours target = (AnnotationColours) object;
-        return target.getAnnotation();
-      }
-
-      public void setValue(java.lang.Object object, java.lang.Object value)
-              throws IllegalStateException, IllegalArgumentException
-      {
-        try
-        {
-          AnnotationColours target = (AnnotationColours) object;
-          target.setAnnotation((java.lang.String) value);
-        } 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: _annotation
-    fieldValidator = new org.exolab.castor.xml.FieldValidator();
-    { // -- local scope
-      org.exolab.castor.xml.validators.StringValidator typeValidator;
-      typeValidator = new org.exolab.castor.xml.validators.StringValidator();
-      fieldValidator.setValidator(typeValidator);
-      typeValidator.setWhiteSpace("preserve");
-    }
-    desc.setValidator(fieldValidator);
-    // -- _minColour
-    desc = new org.exolab.castor.xml.util.XMLFieldDescriptorImpl(
-            java.lang.Integer.TYPE, "_minColour", "minColour",
-            org.exolab.castor.xml.NodeType.Attribute);
-    handler = new org.exolab.castor.xml.XMLFieldHandler()
-    {
-      public java.lang.Object getValue(java.lang.Object object)
-              throws IllegalStateException
-      {
-        AnnotationColours target = (AnnotationColours) object;
-        if (!target.hasMinColour())
-        {
-          return null;
-        }
-        return new java.lang.Integer(target.getMinColour());
-      }
-
-      public void setValue(java.lang.Object object, java.lang.Object value)
-              throws IllegalStateException, IllegalArgumentException
-      {
-        try
-        {
-          AnnotationColours target = (AnnotationColours) object;
-          // if null, use delete method for optional primitives
-          if (value == null)
-          {
-            target.deleteMinColour();
-            return;
-          }
-          target.setMinColour(((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);
-    desc.setMultivalued(false);
-    addFieldDescriptor(desc);
-
-    // -- validation code for: _minColour
-    fieldValidator = new org.exolab.castor.xml.FieldValidator();
-    { // -- local scope
-      org.exolab.castor.xml.validators.IntValidator typeValidator;
-      typeValidator = new org.exolab.castor.xml.validators.IntValidator();
-      fieldValidator.setValidator(typeValidator);
-      typeValidator.setMinInclusive(-2147483648);
-      typeValidator.setMaxInclusive(2147483647);
-    }
-    desc.setValidator(fieldValidator);
-    // -- _maxColour
-    desc = new org.exolab.castor.xml.util.XMLFieldDescriptorImpl(
-            java.lang.Integer.TYPE, "_maxColour", "maxColour",
-            org.exolab.castor.xml.NodeType.Attribute);
-    handler = new org.exolab.castor.xml.XMLFieldHandler()
-    {
-      public java.lang.Object getValue(java.lang.Object object)
-              throws IllegalStateException
-      {
-        AnnotationColours target = (AnnotationColours) object;
-        if (!target.hasMaxColour())
-        {
-          return null;
-        }
-        return new java.lang.Integer(target.getMaxColour());
-      }
-
-      public void setValue(java.lang.Object object, java.lang.Object value)
-              throws IllegalStateException, IllegalArgumentException
-      {
-        try
-        {
-          AnnotationColours target = (AnnotationColours) object;
-          // if null, use delete method for optional primitives
-          if (value == null)
-          {
-            target.deleteMaxColour();
-            return;
-          }
-          target.setMaxColour(((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);
-    desc.setMultivalued(false);
-    addFieldDescriptor(desc);
-
-    // -- validation code for: _maxColour
-    fieldValidator = new org.exolab.castor.xml.FieldValidator();
-    { // -- local scope
-      org.exolab.castor.xml.validators.IntValidator typeValidator;
-      typeValidator = new org.exolab.castor.xml.validators.IntValidator();
-      fieldValidator.setValidator(typeValidator);
-      typeValidator.setMinInclusive(-2147483648);
-      typeValidator.setMaxInclusive(2147483647);
-    }
-    desc.setValidator(fieldValidator);
-    // -- _colourScheme
-    desc = new org.exolab.castor.xml.util.XMLFieldDescriptorImpl(
-            java.lang.String.class, "_colourScheme", "colourScheme",
-            org.exolab.castor.xml.NodeType.Attribute);
-    desc.setImmutable(true);
-    handler = new org.exolab.castor.xml.XMLFieldHandler()
-    {
-      public java.lang.Object getValue(java.lang.Object object)
-              throws IllegalStateException
-      {
-        AnnotationColours target = (AnnotationColours) object;
-        return target.getColourScheme();
-      }
-
-      public void setValue(java.lang.Object object, java.lang.Object value)
-              throws IllegalStateException, IllegalArgumentException
-      {
-        try
-        {
-          AnnotationColours target = (AnnotationColours) object;
-          target.setColourScheme((java.lang.String) value);
-        } 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: _colourScheme
-    fieldValidator = new org.exolab.castor.xml.FieldValidator();
-    { // -- local scope
-      org.exolab.castor.xml.validators.StringValidator typeValidator;
-      typeValidator = new org.exolab.castor.xml.validators.StringValidator();
-      fieldValidator.setValidator(typeValidator);
-      typeValidator.setWhiteSpace("preserve");
-    }
-    desc.setValidator(fieldValidator);
-    // -- _threshold
-    desc = new org.exolab.castor.xml.util.XMLFieldDescriptorImpl(
-            java.lang.Float.TYPE, "_threshold", "threshold",
-            org.exolab.castor.xml.NodeType.Attribute);
-    handler = new org.exolab.castor.xml.XMLFieldHandler()
-    {
-      public java.lang.Object getValue(java.lang.Object object)
-              throws IllegalStateException
-      {
-        AnnotationColours target = (AnnotationColours) object;
-        if (!target.hasThreshold())
-        {
-          return null;
-        }
-        return new java.lang.Float(target.getThreshold());
-      }
-
-      public void setValue(java.lang.Object object, java.lang.Object value)
-              throws IllegalStateException, IllegalArgumentException
-      {
-        try
-        {
-          AnnotationColours target = (AnnotationColours) object;
-          // if null, use delete method for optional primitives
-          if (value == null)
-          {
-            target.deleteThreshold();
-            return;
-          }
-          target.setThreshold(((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);
-    desc.setMultivalued(false);
-    addFieldDescriptor(desc);
-
-    // -- validation code for: _threshold
-    fieldValidator = new org.exolab.castor.xml.FieldValidator();
-    { // -- local scope
-      org.exolab.castor.xml.validators.FloatValidator typeValidator;
-      typeValidator = new org.exolab.castor.xml.validators.FloatValidator();
-      fieldValidator.setValidator(typeValidator);
-      typeValidator.setMinInclusive((float) -3.4028235E38);
-      typeValidator.setMaxInclusive((float) 3.4028235E38);
-    }
-    desc.setValidator(fieldValidator);
-    // -- _perSequence
-    desc = new org.exolab.castor.xml.util.XMLFieldDescriptorImpl(
-            java.lang.Boolean.TYPE, "_perSequence", "perSequence",
-            org.exolab.castor.xml.NodeType.Attribute);
-    handler = new org.exolab.castor.xml.XMLFieldHandler()
-    {
-      public java.lang.Object getValue(java.lang.Object object)
-              throws IllegalStateException
-      {
-        AnnotationColours target = (AnnotationColours) object;
-        if (!target.hasPerSequence())
-        {
-          return null;
-        }
-        return (target.getPerSequence() ? java.lang.Boolean.TRUE
-                : java.lang.Boolean.FALSE);
-      }
-
-      public void setValue(java.lang.Object object, java.lang.Object value)
-              throws IllegalStateException, IllegalArgumentException
-      {
-        try
-        {
-          AnnotationColours target = (AnnotationColours) object;
-          // if null, use delete method for optional primitives
-          if (value == null)
-          {
-            target.deletePerSequence();
-            return;
-          }
-          target.setPerSequence(((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: _perSequence
-    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);
-    // -- _predefinedColours
-    desc = new org.exolab.castor.xml.util.XMLFieldDescriptorImpl(
-            java.lang.Boolean.TYPE, "_predefinedColours",
-            "predefinedColours", org.exolab.castor.xml.NodeType.Attribute);
-    handler = new org.exolab.castor.xml.XMLFieldHandler()
-    {
-      public java.lang.Object getValue(java.lang.Object object)
-              throws IllegalStateException
-      {
-        AnnotationColours target = (AnnotationColours) object;
-        if (!target.hasPredefinedColours())
-        {
-          return null;
-        }
-        return (target.getPredefinedColours() ? java.lang.Boolean.TRUE
-                : java.lang.Boolean.FALSE);
-      }
-
-      public void setValue(java.lang.Object object, java.lang.Object value)
-              throws IllegalStateException, IllegalArgumentException
-      {
-        try
-        {
-          AnnotationColours target = (AnnotationColours) object;
-          // if null, use delete method for optional primitives
-          if (value == null)
-          {
-            target.deletePredefinedColours();
-            return;
-          }
-          target.setPredefinedColours(((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: _predefinedColours
-    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
-
   }
 
   // -----------/
index 4082f2c..aec96ef 100644 (file)
@@ -1161,6 +1161,48 @@ public class JGroupDescriptor extends
       typeValidator.setWhiteSpace("preserve");
     }
     desc.setValidator(fieldValidator);
+    // -- _annotationColours
+    desc = new org.exolab.castor.xml.util.XMLFieldDescriptorImpl(
+            jalview.schemabinding.version2.AnnotationColours.class,
+            "_annotationColours", "annotationColours",
+            org.exolab.castor.xml.NodeType.Element);
+    handler = new org.exolab.castor.xml.XMLFieldHandler()
+    {
+      public java.lang.Object getValue(java.lang.Object object)
+              throws IllegalStateException
+      {
+        JGroup target = (JGroup) object;
+        return target.getAnnotationColours();
+      }
+
+      public void setValue(java.lang.Object object, java.lang.Object value)
+              throws IllegalStateException, IllegalArgumentException
+      {
+        try
+        {
+          JGroup target = (JGroup) object;
+          target.setAnnotationColours((jalview.schemabinding.version2.AnnotationColours) 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.AnnotationColours();
+      }
+    };
+    desc.setHandler(handler);
+    desc.setNameSpaceURI("www.jalview.org");
+    desc.setMultivalued(false);
+    addFieldDescriptor(desc);
+
+    // -- validation code for: _annotationColours
+    fieldValidator = new org.exolab.castor.xml.FieldValidator();
+    { // -- local scope
+    }
+    desc.setValidator(fieldValidator);
   }
 
   // -----------/
index 1b23d13..8f0626f 100755 (executable)
  */
 package jalview.schemes;
 
-import jalview.analysis.Conservation;
 import jalview.datamodel.AlignmentAnnotation;
+import jalview.datamodel.AlignmentI;
 import jalview.datamodel.AnnotatedCollectionI;
 import jalview.datamodel.GraphLine;
 import jalview.datamodel.SequenceCollectionI;
 import jalview.datamodel.SequenceI;
 
 import java.awt.Color;
-import java.util.Hashtable;
 import java.util.IdentityHashMap;
 import java.util.Map;
 
-public class AnnotationColourGradient extends ResidueColourScheme
+public class AnnotationColourGradient extends FollowerColourScheme
 {
   public static final int NO_THRESHOLD = -1;
 
@@ -48,14 +47,32 @@ public class AnnotationColourGradient extends ResidueColourScheme
 
   float r1, g1, b1, rr, gg, bb, dr, dg, db;
 
-  ColourSchemeI colourScheme;
-
   private boolean predefinedColours = false;
 
   private boolean seqAssociated = false;
 
   IdentityHashMap<SequenceI, AlignmentAnnotation> seqannot = null;
-
+  @Override
+  public ColourSchemeI applyTo(AnnotatedCollectionI sg,
+          Map<SequenceI, SequenceCollectionI> hiddenRepSequences)
+  {
+    AnnotationColourGradient acg = new AnnotationColourGradient(annotation, colourScheme, aboveAnnotationThreshold);
+    acg.thresholdIsMinMax = thresholdIsMinMax;
+    acg.annotationThreshold = (annotationThreshold==null) ? null : new GraphLine(annotationThreshold);
+    acg.r1 = r1;
+    acg.g1 = g1;
+    acg.b1 = b1;
+    acg.rr = rr;
+    acg.gg = gg;
+    acg.bb = bb;
+    acg.dr = dr;
+    acg.dg = dg;
+    acg.db = db;
+    acg.predefinedColours = predefinedColours;
+    acg.seqAssociated = seqAssociated;
+    
+    return acg;
+  }
   /**
    * Creates a new AnnotationColourGradient object.
    */
@@ -109,7 +126,6 @@ public class AnnotationColourGradient extends ResidueColourScheme
   public void alignmentChanged(AnnotatedCollectionI alignment,
           Map<SequenceI, SequenceCollectionI> hiddenReps)
   {
-    // TODO Auto-generated method stub
     super.alignmentChanged(alignment, hiddenReps);
 
     if (seqAssociated && annotation.getCalcId() != null)
@@ -122,7 +138,9 @@ public class AnnotationColourGradient extends ResidueColourScheme
       {
         seqannot = new IdentityHashMap<SequenceI, AlignmentAnnotation>();
       }
-      for (AlignmentAnnotation alan : alignment.findAnnotation(annotation
+      // resolve the context containing all the annotation for the sequence
+      AnnotatedCollectionI alcontext = alignment instanceof AlignmentI ? alignment : alignment.getContext();
+      for (AlignmentAnnotation alan : alcontext.findAnnotation(annotation
               .getCalcId()))
       {
         if (alan.sequenceRef != null
@@ -157,11 +175,6 @@ public class AnnotationColourGradient extends ResidueColourScheme
     }
   }
 
-  public ColourSchemeI getBaseColour()
-  {
-    return colourScheme;
-  }
-
   public Color getMinColour()
   {
     return new Color((int) r1, (int) g1, (int) b1);
@@ -292,28 +305,4 @@ public class AnnotationColourGradient extends ResidueColourScheme
   {
     seqAssociated = sassoc;
   }
-  @Override
-  public void setConsensus(Hashtable[] consensus)
-  {
-    if (colourScheme!=null)
-    {
-      colourScheme.setConsensus(consensus);
-    }
-  }
-  @Override
-  public void setConservation(Conservation cons)
-  {
-    if (colourScheme!=null)
-    {
-      colourScheme.setConservation(cons);
-    }
-  }
-  @Override
-  public void setConservationInc(int i)
-  {
-    if (colourScheme!=null)
-    {
-      colourScheme.setConservationInc(i);
-    }
-  }
 }
index ad0e0c0..b43afec 100755 (executable)
@@ -21,6 +21,10 @@ package jalview.schemes;
 import jalview.analysis.AAFrequency;
 
 import java.awt.Color;
+import java.util.Map;
+
+import jalview.datamodel.AnnotatedCollectionI;
+import jalview.datamodel.SequenceCollectionI;
 import jalview.datamodel.SequenceI;
 
 public class Blosum62ColourScheme extends ResidueColourScheme
@@ -88,4 +92,11 @@ public class Blosum62ColourScheme extends ResidueColourScheme
 
     return currentColour;
   }
+  @Override
+  public ColourSchemeI applyTo(AnnotatedCollectionI sg,
+          Map<SequenceI, SequenceCollectionI> hiddenRepSequences)
+  { 
+    ColourSchemeI newcs = super.applyTo(sg, hiddenRepSequences);
+    return newcs;
+  }
 }
index 62c94d8..77d7e5b 100755 (executable)
@@ -327,6 +327,14 @@ public class ClustalxColourScheme extends ResidueColourScheme // implements
   {
     this.includeGaps = includeGaps;
   }
+  @Override
+  public ColourSchemeI applyTo(AnnotatedCollectionI sg,
+          Map<SequenceI, SequenceCollectionI> hiddenRepSequences)
+  {
+    ClustalxColourScheme css= new ClustalxColourScheme(sg, hiddenRepSequences);
+    css.includeGaps = includeGaps;
+    return css;
+  }
 }
 
 class ConsensusColour
index 7fc6981..536efe7 100755 (executable)
@@ -29,25 +29,84 @@ import jalview.datamodel.SequenceI;
 
 public interface ColourSchemeI
 {
+  /**
+   * 
+   * @param c
+   * @return the colour for the given character
+   */
   public Color findColour(char c);
 
+  /**
+   * 
+   * @param c - sequence symbol or gap
+   * @param j - position in seq
+   * @param seq - sequence being coloured
+   * @return context dependent colour for the given symbol at the position in the given sequence
+   */
   public Color findColour(char c, int j, SequenceI seq);
 
+  /**
+   * assign the given consensus profile for the colourscheme
+   */
   public void setConsensus(java.util.Hashtable[] h);
 
+  /**
+   * assign the given conservation to the colourscheme
+   * @param c
+   */
   public void setConservation(jalview.analysis.Conservation c);
 
+  /**
+   * enable or disable conservation shading for this colourscheme
+   * @param conservationApplied 
+   */
+  public void setConservationApplied(boolean conservationApplied);
+  /**
+   * 
+   * @return true if conservation shading is enabled for this colourscheme
+   */
   public boolean conservationApplied();
 
+  /**
+   * set scale factor for bleaching of colour in unconserved regions
+   * @param i
+   */
   public void setConservationInc(int i);
 
+  /**
+   * 
+   * @return scale factor for bleaching colour in unconserved regions 
+   */
   public int getConservationInc();
 
+  /**
+   * 
+   * @return percentage identity threshold for applying colourscheme
+   */
   public int getThreshold();
 
+  /**
+   * set percentage identity threshold and type of %age identity calculation for shading
+   * @param ct 0..100 percentage identity for applying this colourscheme
+   * @param ignoreGaps when true, calculate PID without including gapped positions
+   */
   public void setThreshold(int ct, boolean ignoreGaps);
 
+  /**
+   * recalculate dependent data using the given sequence collection, taking account of hidden rows
+   * @param alignment
+   * @param hiddenReps
+   */
   public void alignmentChanged(AnnotatedCollectionI alignment,
           Map<SequenceI, SequenceCollectionI> hiddenReps);
 
+  /**
+   * create a new instance of the colourscheme configured to colour the given connection
+   * @param sg
+   * @param hiddenRepSequences
+   * @return copy of current scheme with any inherited settings transfered
+   */
+  public ColourSchemeI applyTo(AnnotatedCollectionI sg,
+          Map<SequenceI, SequenceCollectionI> hiddenRepSequences);
+
 }
diff --git a/src/jalview/schemes/FollowerColourScheme.java b/src/jalview/schemes/FollowerColourScheme.java
new file mode 100644 (file)
index 0000000..32e9316
--- /dev/null
@@ -0,0 +1,49 @@
+package jalview.schemes;
+
+import jalview.analysis.Conservation;
+
+import java.util.Hashtable;
+
+/**
+ * Colourscheme that takes its colours from some other colourscheme
+ * @author jimp
+ *
+ */
+public class FollowerColourScheme extends ResidueColourScheme
+{
+
+  protected ColourSchemeI colourScheme;
+
+  public ColourSchemeI getBaseColour()
+  {
+    return colourScheme;
+  }
+
+  @Override
+  public void setConsensus(Hashtable[] consensus)
+  {
+    if (colourScheme!=null)
+    {
+      colourScheme.setConsensus(consensus);
+    }
+  }
+
+  @Override
+  public void setConservation(Conservation cons)
+  {
+    if (colourScheme!=null)
+    {
+      colourScheme.setConservation(cons);
+    }
+  }
+
+  @Override
+  public void setConservationInc(int i)
+  {
+    if (colourScheme!=null)
+    {
+      colourScheme.setConservationInc(i);
+    }
+  }
+
+}
index 943d2fa..8b3150b 100755 (executable)
@@ -194,6 +194,11 @@ public class ResidueColourScheme implements ColourSchemeI
   {
     return conservationColouring;
   }
+  @Override
+  public void setConservationApplied(boolean conservationApplied)
+  {
+    conservationColouring = conservationApplied;
+  }
 
   public void setConservationInc(int i)
   {
@@ -306,4 +311,16 @@ public class ResidueColourScheme implements ColourSchemeI
   {
   }
 
+  @Override
+  public ColourSchemeI applyTo(AnnotatedCollectionI sg,
+          Map<SequenceI, SequenceCollectionI> hiddenRepSequences)
+  {
+    try {
+      return getClass().newInstance();
+    }
+    catch (Exception q)
+    {
+      throw new Error("Serious implementation error: cannot duplicate colourscheme "+getClass().getName(), q);
+    }
+  }
 }
index 6eb48c2..1c8e469 100644 (file)
@@ -85,8 +85,9 @@ public class TCoffeeColourScheme extends ResidueColourScheme
     // Search alignment to get all tcoffee annotation and pick one set of
     // annotation to use to colour seqs.
     seqMap = new IdentityHashMap<SequenceI, Color[]>();
+    AnnotatedCollectionI alcontext = alignment instanceof AlignmentI ? alignment : alignment.getContext();
     int w = 0;
-    for (AlignmentAnnotation al : alignment
+    for (AlignmentAnnotation al : alcontext
             .findAnnotation(TCoffeeScoreFile.TCOFFEE_SCORE))
     {
       if (al.sequenceRef != null && !al.belowAlignment)
@@ -129,4 +130,11 @@ public class TCoffeeColourScheme extends ResidueColourScheme
     }
     return cols[j];
   }
+  
+  @Override
+  public ColourSchemeI applyTo(AnnotatedCollectionI sg,
+          Map<SequenceI, SequenceCollectionI> hiddenRepSequences)
+  {
+    return new TCoffeeColourScheme(sg);
+  }
 }
index 82a5871..eb9f7b1 100755 (executable)
 package jalview.schemes;
 
 import java.awt.Color;
+import java.util.Map;
 import java.util.StringTokenizer;
+
+import jalview.datamodel.AnnotatedCollectionI;
+import jalview.datamodel.SequenceCollectionI;
 import jalview.datamodel.SequenceI;
 
 public class UserColourScheme extends ResidueColourScheme
@@ -38,7 +42,18 @@ public class UserColourScheme extends ResidueColourScheme
     super(ResidueProperties.aaIndex);
     colors = newColors;
   }
-
+  @Override
+  public ColourSchemeI applyTo(AnnotatedCollectionI sg,
+          Map<SequenceI, SequenceCollectionI> hiddenRepSequences)
+  {
+    UserColourScheme usc = new UserColourScheme(colors);
+    if (lowerCaseColours!=null) {
+      usc.schemeName = new String(schemeName);
+      usc.lowerCaseColours = new Color[lowerCaseColours.length];
+      System.arraycopy(lowerCaseColours, 0, usc.lowerCaseColours, 0, lowerCaseColours.length);
+    }
+    return usc;
+  }
   public UserColourScheme(String colour)
   {
     super(ResidueProperties.aaIndex);
@@ -143,6 +158,7 @@ public class UserColourScheme extends ResidueColourScheme
 
   public void parseAppletParameter(String paramValue)
   {
+    // TODO: need a function to generate appletParameter colour string from a UCS
     StringTokenizer st = new StringTokenizer(paramValue, ";");
     StringTokenizer st2;
     String token = null, colour, residues;
index d49572d..44ecf76 100644 (file)
@@ -212,6 +212,24 @@ public abstract class AlignmentViewport implements AlignViewportI
     // calculation till later or to do all calculations in thread.
     // via changecolour
     globalColourScheme = cs;
+    boolean recalc=false;
+    if (cs!=null)
+    {
+      cs.setConservationApplied(recalc = getConservationSelected());
+      if (getAbovePIDThreshold() || cs instanceof PIDColourScheme || cs instanceof Blosum62ColourScheme)
+      {
+        recalc = true;
+        cs.setThreshold(threshold, ignoreGapsInConsensusCalculation);
+      } else {
+        cs.setThreshold(0, ignoreGapsInConsensusCalculation);
+      }
+      if (recalc)
+      {
+        cs.setConsensus(hconsensus);
+        cs.setConservation(hconservation);
+      }
+      cs.alignmentChanged(alignment, hiddenRepSequences);
+    }
     if (getColourAppliesToAllGroups())
     {
       for (SequenceGroup sg : getAlignment().getGroups())
@@ -221,29 +239,13 @@ public abstract class AlignmentViewport implements AlignViewportI
           sg.cs = null;
           continue;
         }
-        if (cs instanceof ClustalxColourScheme)
-        {
-          sg.cs = new ClustalxColourScheme(sg, getHiddenRepSequences());
-        }
-        else
-        {
-          try
-          {
-            sg.cs = cs.getClass().newInstance();
-          } catch (Exception ex)
-          {
-            ex.printStackTrace();
-            sg.cs = cs;
-          }
-        }
-
+        sg.cs = cs.applyTo(sg, getHiddenRepSequences());
+        sg.setConsPercGaps(ConsPercGaps);
         if (getAbovePIDThreshold() || cs instanceof PIDColourScheme
                 || cs instanceof Blosum62ColourScheme)
         {
           sg.cs.setThreshold(threshold, getIgnoreGapsConsensus());
-          sg.cs.setConsensus(AAFrequency.calculate(
-                  sg.getSequences(getHiddenRepSequences()), 0,
-                  sg.getWidth()));
+          recalc=true;
         }
         else
         {
@@ -252,20 +254,19 @@ public abstract class AlignmentViewport implements AlignViewportI
 
         if (getConservationSelected())
         {
-          Conservation c = new Conservation("Group",
-                  ResidueProperties.propHash, 3,
-                  sg.getSequences(getHiddenRepSequences()), 0,
-                  getAlignment().getWidth() - 1);
-          c.calculate();
-          c.verdict(false, getConsPercGaps());
-          sg.cs.setConservation(c);
+          sg.cs.setConservationApplied(true);
+          recalc=true;
         }
         else
         {
           sg.cs.setConservation(null);
-          sg.cs.setThreshold(0, getIgnoreGapsConsensus());
+          // sg.cs.setThreshold(0, getIgnoreGapsConsensus());
+        }
+        if (recalc) {
+          sg.recalcConservation();
+        } else {
+          sg.cs.alignmentChanged(sg, hiddenRepSequences);
         }
-
       }
     }
 
@@ -299,7 +300,13 @@ public abstract class AlignmentViewport implements AlignViewportI
    * view
    */
   protected Hashtable[] hStrucConsensus = null;
-
+  
+  protected Conservation hconservation = null;
+  @Override
+  public void setConservation(Conservation cons)
+  {
+    hconservation = cons;
+  }
   /**
    * percentage gaps allowed in a column before all amino acid properties should
    * be considered unconserved
@@ -1300,7 +1307,7 @@ public abstract class AlignmentViewport implements AlignViewportI
     ColourSchemeI cs = globalColourScheme;
     if (cs != null)
     {
-      cs.alignmentChanged(alignment, null);
+      cs.alignmentChanged(alignment, hiddenRepSequences);
 
       cs.setConsensus(hconsensus);
       if (cs.conservationApplied())
index b6186d4..a8bc268 100644 (file)
@@ -80,7 +80,7 @@ public class ConservationThread extends AlignCalcWorker implements
       ourAnnot.add(conservation);
       ourAnnot.add(quality);
       ourAnnots = ourAnnot;
-
+      ConsPercGaps = alignViewport.getConsPercGaps();
       // AlignViewport.UPDATING_CONSERVATION = true;
 
       if (alignment == null || (alWidth = alignment.getWidth()) < 0)
@@ -125,7 +125,10 @@ public class ConservationThread extends AlignCalcWorker implements
   {
     if (b || !calcMan.isWorking(this) && cons != null
             && conservation != null && quality != null)
+    {
+      alignViewport.setConservation(cons);
       cons.completeAnnotations(conservation, quality, 0, alWidth);
+    }
   }
 
   @Override
index 3a69595..e294616 100644 (file)
@@ -2,8 +2,11 @@ package jalview.io;
 
 import static org.junit.Assert.*;
 import jalview.datamodel.AlignmentAnnotation;
+import jalview.datamodel.SequenceGroup;
 import jalview.datamodel.SequenceI;
 import jalview.gui.AlignFrame;
+import jalview.schemes.AnnotationColourGradient;
+import jalview.schemes.ColourSchemeI;
 
 import java.io.File;
 
@@ -29,7 +32,8 @@ public class Jalview2xmlTests
   @AfterClass
   public static void tearDownAfterClass() throws Exception
   {
-    jalview.gui.Desktop.instance.quit();
+    jalview.gui.Desktop.instance.closeAll_actionPerformed(null);
+    
   }
   public int countDsAnn(jalview.viewmodel.AlignmentViewport avp)
   {
@@ -96,4 +100,70 @@ public class Jalview2xmlTests
     assertTrue("Didn't set T-coffee colourscheme for imported project.",af.getViewport().getGlobalColourScheme().getClass().equals(jalview.schemes.TCoffeeColourScheme.class));
     System.out.println("T-Coffee score shading successfully recovered from project.");
   }
+  @Test
+  public void testColourByAnnotScores() throws Exception
+  {
+    String inFile = "examples/uniref50.fa",inAnnot="examples/testdata/uniref50_iupred.jva";
+    String tfile = File.createTempFile("JalviewTest", ".jvp").getAbsolutePath();
+    AlignFrame af = new jalview.io.FileLoader().LoadFileWaitTillLoaded(inFile, FormatAdapter.FILE);
+    assertTrue("Didn't read input file "+inFile, af!=null);
+    af.loadJalviewDataFile(inAnnot, FormatAdapter.FILE, null,null);
+    AlignmentAnnotation[] aa = af.getViewport().getAlignment().getSequenceAt(0).getAnnotation("IUPredWS (Short)");
+    assertTrue("Didn't find any IUPred annotation to use to shade alignment.",aa!=null && aa.length>0);
+    AnnotationColourGradient cs = new jalview.schemes.AnnotationColourGradient(aa[0], null, AnnotationColourGradient.ABOVE_THRESHOLD);
+    AnnotationColourGradient gcs = new jalview.schemes.AnnotationColourGradient(aa[0], null, AnnotationColourGradient.BELOW_THRESHOLD);
+    cs.setSeqAssociated(true);
+    gcs.setSeqAssociated(true);
+    af.changeColour(cs);
+    SequenceGroup sg = new SequenceGroup();
+    sg.setStartRes(57);
+    sg.setEndRes(92);
+    sg.cs = gcs;
+    af.getViewport().getAlignment().addGroup(sg);
+    sg.addSequence(af.getViewport().getAlignment().getSequenceAt(1), false);
+    sg.addSequence(af.getViewport().getAlignment().getSequenceAt(2), true);
+    af.alignPanel.alignmentChanged();
+    assertTrue("Failed to store as a project.",af.saveAlignment(tfile, "Jalview"));
+    af.closeMenuItem_actionPerformed(true);
+    af=null;
+    af = new jalview.io.FileLoader().LoadFileWaitTillLoaded(tfile, FormatAdapter.FILE);
+    assertTrue("Failed to import new project", af!=null);
+    
+    // check for group and alignment colourschemes
+    
+    ColourSchemeI _rcs=af.getViewport().getGlobalColourScheme();
+    ColourSchemeI _rgcs=af.getViewport().getAlignment().getGroups().get(0).cs;
+    assertTrue("Didn't recover global colourscheme",_rcs!=null); 
+    assertTrue("Didn't recover annotation colour global scheme",_rcs instanceof AnnotationColourGradient);
+    AnnotationColourGradient __rcs = (AnnotationColourGradient) _rcs;
+    assertTrue("Annotation colourscheme wasn't sequence associated",__rcs.isSeqAssociated());
+
+    
+    boolean diffseqcols=false,diffgseqcols=false;
+    SequenceI[] sqs=af.getViewport().getAlignment().getSequencesArray();
+    for (int p=0,pSize=af.getViewport().getAlignment().getWidth();p<pSize && (!diffseqcols || !diffgseqcols);p++)
+    {
+      if (_rcs.findColour(sqs[0].getCharAt(p), p, sqs[0])!=_rcs.findColour(sqs[5].getCharAt(p), p, sqs[5]))
+      {
+        diffseqcols = true;
+      }
+    }
+    assertTrue("Got Different sequence colours", diffseqcols);
+    System.out.println("Per sequence colourscheme (Background) successfully applied and recovered.");
+    
+    assertTrue("Didn't recover group colourscheme",_rgcs!=null); 
+    assertTrue("Didn't recover annotation colour group colourscheme",_rgcs instanceof AnnotationColourGradient);
+    __rcs = (AnnotationColourGradient) _rgcs;
+    assertTrue("Group Annotation colourscheme wasn't sequence associated",__rcs.isSeqAssociated());
+    
+    for (int p=0,pSize=af.getViewport().getAlignment().getWidth();p<pSize && (!diffseqcols || !diffgseqcols);p++)
+    {
+    if (_rgcs.findColour(sqs[1].getCharAt(p), p, sqs[1])!=_rgcs.findColour(sqs[2].getCharAt(p), p, sqs[2]))
+      {
+        diffgseqcols = true;
+      }
+    }
+    assertTrue("Got Different group sequence colours", diffgseqcols);
+    System.out.println("Per sequence (Group) colourscheme successfully applied and recovered.");
+  }
 }