Merge branch 'develop' of https://source.jalview.org/git/jalview.git into menard
authorAnne Menard <menard.annec@gmail.com>
Mon, 16 Jul 2012 08:24:38 +0000 (10:24 +0200)
committerAnne Menard <menard.annec@gmail.com>
Mon, 16 Jul 2012 08:24:38 +0000 (10:24 +0200)
26 files changed:
lib/groovy-all-1.8.2.jar [new file with mode: 0644]
src/jalview/appletgui/AnnotationPanel.java
src/jalview/datamodel/Alignment.java
src/jalview/datamodel/AlignmentI.java
src/jalview/gui/AlignmentPanel.java
src/jalview/gui/AnnotationPanel.java
src/jalview/gui/AppJmolBinding.java
src/jalview/gui/FeatureRenderer.java
src/jalview/gui/FeatureSettings.java
src/jalview/gui/Jalview2XML.java
src/jalview/io/FeaturesFile.java
src/jalview/io/TCoffeeScoreFile.java
src/jalview/schemes/BuriedColourScheme.java
src/jalview/schemes/HelixColourScheme.java
src/jalview/schemes/HydrophobicColourScheme.java
src/jalview/schemes/NucleotideColourScheme.java
src/jalview/schemes/PurinePyrimidineColourScheme.java
src/jalview/schemes/RNAHelicesColour.java
src/jalview/schemes/ResidueColourScheme.java
src/jalview/schemes/ScoreColourScheme.java
src/jalview/schemes/StrandColourScheme.java
src/jalview/schemes/TaylorColourScheme.java
src/jalview/schemes/TurnColourScheme.java
src/jalview/schemes/ZappoColourScheme.java
src/jalview/ws/jws2/AAConsClient.java
src/jalview/ws/jws2/AADisorderClient.java

diff --git a/lib/groovy-all-1.8.2.jar b/lib/groovy-all-1.8.2.jar
new file mode 100644 (file)
index 0000000..85af249
Binary files /dev/null and b/lib/groovy-all-1.8.2.jar differ
index 7e6e3a1..492683d 100755 (executable)
@@ -255,6 +255,7 @@ public class AnnotationPanel extends Panel implements AwtRenderPanelI, Adjustmen
     aa[activeRow].validateRangeAndDisplay();
 
     adjustPanelHeight();
+    ap.alignmentChanged();
     repaint();
 
     return;
index 6c11936..271374f 100755 (executable)
@@ -1381,12 +1381,14 @@ public class Alignment implements AlignmentI
 
   @Override
   public AlignmentAnnotation findOrCreateAnnotation(String name,
-          boolean autoCalc, SequenceI seqRef, SequenceGroup groupRef)
+          String calcId, boolean autoCalc, SequenceI seqRef, SequenceGroup groupRef)
   {
+    assert(name!=null);
     for (AlignmentAnnotation annot : getAlignmentAnnotation())
     {
       if (annot.autoCalculated == autoCalc
-              && annot.getCalcId().equals(name)
+              && (name.equals(annot.label))
+              && (calcId==null || annot.getCalcId().equals(calcId))
               && annot.sequenceRef == seqRef && annot.groupRef == groupRef)
       {
         return annot;
@@ -1395,7 +1397,7 @@ public class Alignment implements AlignmentI
     AlignmentAnnotation annot = new AlignmentAnnotation(name, name,
             new Annotation[1], 0f, 0f, AlignmentAnnotation.BAR_GRAPH);
     annot.hasText = false;
-    annot.setCalcId(new String(name));
+    annot.setCalcId(new String(calcId));
     annot.autoCalculated = autoCalc;
     if (seqRef != null)
     {
index d09c41d..7e55e36 100755 (executable)
@@ -438,15 +438,17 @@ public interface AlignmentI extends AnnotatedCollectionI
 
   /**
    * search for or create a specific annotation row on the alignment
-   *
-   * @param method - CalcId for the annotation (must match)
+   * @param name name for annotation (must match)
+   * @param calcId calcId for the annotation (null or must match)
    * @param autoCalc - value of autocalc flag for the annotation
    * @param seqRef - null or specific sequence reference
    * @param groupRef - null or specific group reference
+   * @param method - CalcId for the annotation (must match)
+   *
    * @return existing annotation matching the given attributes
    */
-  public AlignmentAnnotation findOrCreateAnnotation(String name, boolean autoCalc,
-          SequenceI seqRef, SequenceGroup groupRef);
+  public AlignmentAnnotation findOrCreateAnnotation(String name, String calcId,
+          boolean autoCalc, SequenceI seqRef, SequenceGroup groupRef);
 
   /**
    * move the given group up or down in the alignment by the given number of rows.
index 330620c..8f2dd04 100644 (file)
@@ -20,7 +20,6 @@ package jalview.gui;
 import java.beans.*;
 import java.io.*;
 import java.util.Hashtable;
-import java.util.Vector;
 
 import java.awt.*;
 import java.awt.event.*;
@@ -921,10 +920,14 @@ public class AlignmentPanel extends GAlignmentPanel implements
 
     if (av.showAnnotation && (endSeq == av.getAlignment().getHeight()))
     {
+      // draw annotation - need to offset for current scroll position
+      int offset=-alabels.scrollOffset;
+      pg.translate(0, offset);
       pg.translate(-idWidth - 3, (endSeq - startSeq) * av.charHeight + 3);
       alabels.drawComponent((Graphics2D) pg, idWidth);
       pg.translate(idWidth + 3, 0);
       annotationPanel.renderer.drawComponent(annotationPanel, av, (Graphics2D) pg, -1, startRes, endRes + 1);
+      pg.translate(0, -offset);
     }
 
     return Printable.PAGE_EXISTS;
@@ -1072,6 +1075,11 @@ public class AlignmentPanel extends GAlignmentPanel implements
 
   void makeAlignmentImage(int type, File file)
   {
+    long progress=System.currentTimeMillis();
+    if (alignFrame!=null) {
+      alignFrame.setProgressBar("Saving "+(type == jalview.util.ImageMaker.PNG ? "PNG image":"EPS file") , progress);
+    }
+    try {
     int maxwidth = av.getAlignment().getWidth();
     if (av.hasHiddenColumns())
     {
@@ -1110,19 +1118,17 @@ public class AlignmentPanel extends GAlignmentPanel implements
     {
 
       jalview.util.ImageMaker im;
+      final String imageAction,imageTitle;
       if (type == jalview.util.ImageMaker.PNG)
       {
-        im = new jalview.util.ImageMaker(this, jalview.util.ImageMaker.PNG,
-                "Create PNG image from alignment", width, height, file,
-                null);
-      }
-      else
-      {
-        im = new jalview.util.ImageMaker(this, jalview.util.ImageMaker.EPS,
-                "Create EPS file from alignment", width, height, file,
-                alignFrame.getTitle());
+      imageAction="Create PNG image from alignment";
+      imageTitle=null;
+      } else {
+        imageAction="Create EPS file from alignment";
+        imageTitle=alignFrame.getTitle();
       }
-
+      im = new jalview.util.ImageMaker(this, type, imageAction, width, height, file,
+                imageTitle);
       if (av.getWrapAlignment())
       {
         if (im.getGraphics() != null)
@@ -1150,6 +1156,13 @@ public class AlignmentPanel extends GAlignmentPanel implements
     {
       ex.printStackTrace();
     }
+    }
+    finally {
+      if (alignFrame!=null)
+      {
+        alignFrame.setProgressBar("Export complete.", progress);
+      }
+    }
   }
 
   /**
@@ -1491,4 +1504,22 @@ public class AlignmentPanel extends GAlignmentPanel implements
   {
     new OOMWarning(string,  error, this);
   }
+
+  public FeatureRenderer cloneFeatureRenderer()
+  {
+    
+    return new FeatureRenderer(this);
+  }
+
+  public void updateFeatureRenderer(FeatureRenderer fr)
+  {
+    fr.transferSettings(seqPanel.seqCanvas.getFeatureRenderer());
+  }
+
+  public void updateFeatureRendererFrom(FeatureRenderer fr)
+  {
+    if (seqPanel.seqCanvas.getFeatureRenderer()!=null) {
+      seqPanel.seqCanvas.getFeatureRenderer().transferSettings(fr);
+    }
+  }
 }
index 03fbf28..c8784a5 100755 (executable)
@@ -363,6 +363,7 @@ public class AnnotationPanel extends JPanel implements AwtRenderPanelI,
     aa[activeRow].validateRangeAndDisplay();
 
     adjustPanelHeight();
+    ap.alignmentChanged();
     repaint();
 
     return;
index 63813a9..df62eab 100644 (file)
@@ -61,13 +61,12 @@ public class AppJmolBinding extends jalview.ext.jmol.JalviewJmolBinding
     AlignmentPanel ap = (alignment==null) ? appJmolWindow.ap : (AlignmentPanel) alignment;
     if (ap.av.showSequenceFeatures)
     {
-      if (fr == null)
+      if (fr==null)
       {
-        fr = new FeatureRenderer(ap);
+        fr=ap.cloneFeatureRenderer();
+      } else {
+        ap.updateFeatureRenderer(fr);
       }
-
-      fr.transferSettings(ap.
-              seqPanel.seqCanvas.getFeatureRenderer());
     }
 
     return fr;
index 2db75bf..4abc85a 100755 (executable)
@@ -18,6 +18,7 @@
 package jalview.gui;
 
 import java.util.*;
+import java.util.concurrent.ConcurrentHashMap;
 
 import java.awt.*;
 import java.awt.event.*;
@@ -52,12 +53,12 @@ public class FeatureRenderer implements jalview.api.FeatureRenderer
   FontMetrics fm;
 
   int charOffset;
-
-  Hashtable featureColours = new Hashtable();
+  Map featureColours = new ConcurrentHashMap();
 
   // A higher level for grouping features of a
   // particular type
-  Hashtable featureGroups = new Hashtable();
+  Map featureGroups = new ConcurrentHashMap();
 
   // This is actually an Integer held in the hashtable,
   // Retrieved using the key feature type
@@ -85,13 +86,13 @@ public class FeatureRenderer implements jalview.api.FeatureRenderer
   {
     String[] renderOrder;
 
-    Hashtable featureGroups;
+    Map featureGroups;
 
-    Hashtable featureColours;
+    Map featureColours;
 
     float transparency;
 
-    Hashtable featureOrder;
+    Map featureOrder;
 
     public FeatureRendererSettings(String[] renderOrder,
             Hashtable featureGroups, Hashtable featureColours,
@@ -113,27 +114,27 @@ public class FeatureRenderer implements jalview.api.FeatureRenderer
     public FeatureRendererSettings(FeatureRenderer fr)
     {
       renderOrder = null;
-      featureGroups = new Hashtable();
-      featureColours = new Hashtable();
-      featureOrder = new Hashtable();
+      featureGroups = new ConcurrentHashMap();
+      featureColours = new ConcurrentHashMap();
+      featureOrder = new ConcurrentHashMap();
       if (fr.renderOrder != null)
       {
         this.renderOrder = new String[fr.renderOrder.length];
         System.arraycopy(fr.renderOrder, 0, renderOrder, 0,
-                renderOrder.length);
+                fr.renderOrder.length);
       }
       if (fr.featureGroups != null)
       {
-        this.featureGroups = new Hashtable(fr.featureGroups);
+        this.featureGroups = new ConcurrentHashMap(fr.featureGroups);
       }
       if (fr.featureColours != null)
       {
-        this.featureColours = new Hashtable(fr.featureColours);
+        this.featureColours = new ConcurrentHashMap(fr.featureColours);
       }
-      Enumeration en = fr.featureColours.keys();
-      while (en.hasMoreElements())
+      Iterator en = fr.featureColours.keySet().iterator();
+      while (en.hasNext())
       {
-        Object next = en.nextElement();
+        Object next = en.next();
         Object val = featureColours.get(next);
         if (val instanceof GraduatedColor)
         {
@@ -144,7 +145,7 @@ public class FeatureRenderer implements jalview.api.FeatureRenderer
       this.transparency = fr.transparency;
       if (fr.featureOrder != null)
       {
-        this.featureOrder = new Hashtable(fr.featureOrder);
+        this.featureOrder = new ConcurrentHashMap(fr.featureOrder);
       }
     }
   }
@@ -1403,7 +1404,7 @@ public class FeatureRenderer implements jalview.api.FeatureRenderer
 
   }
 
-  Hashtable featureOrder = null;
+  Map featureOrder = null;
 
   /**
    * analogous to colour - store a normalized ordering for all feature types in
index 35690a9..1928382 100755 (executable)
@@ -714,13 +714,13 @@ public class FeatureSettings extends JPanel
         PrintWriter out = new PrintWriter(new OutputStreamWriter(
                 new FileOutputStream(choice), "UTF-8"));
 
-        Enumeration e = fr.featureColours.keys();
+        Iterator e = fr.featureColours.keySet().iterator();
         float[] sortOrder = new float[fr.featureColours.size()];
         String[] sortTypes = new String[fr.featureColours.size()];
         int i = 0;
-        while (e.hasMoreElements())
+        while (e.hasNext())
         {
-          sortTypes[i] = e.nextElement().toString();
+          sortTypes[i] = e.next().toString();
           sortOrder[i] = fr.getOrder(sortTypes[i]);
           i++;
         }
@@ -1134,13 +1134,13 @@ public class FeatureSettings extends JPanel
 
       if (fr.featureGroups != null)
       {
-        Enumeration en = fr.featureGroups.keys();
+        Iterator en = fr.featureGroups.keySet().iterator();
         gps = new String[fr.featureColours.size()];
         int g = 0;
         boolean valid = false;
-        while (en.hasMoreElements())
+        while (en.hasNext())
         {
-          String gp = (String) en.nextElement();
+          String gp = (String) en.next();
           Boolean on = (Boolean) fr.featureGroups.get(gp);
           if (on != null && on.booleanValue())
           {
index 14650a9..45bab7c 100644 (file)
@@ -1162,11 +1162,11 @@ public class Jalview2XML
       }
 
       // Make sure we save none displayed feature settings
-      Enumeration en = ap.seqPanel.seqCanvas.getFeatureRenderer().featureColours
-              .keys();
-      while (en.hasMoreElements())
+      Iterator en = ap.seqPanel.seqCanvas.getFeatureRenderer().featureColours
+              .keySet().iterator();
+      while (en.hasNext())
       {
-        String key = en.nextElement().toString();
+        String key = en.next().toString();
         if (settingsAdded.contains(key))
         {
           continue;
@@ -1187,11 +1187,11 @@ public class Jalview2XML
         fs.addSetting(setting);
         settingsAdded.addElement(key);
       }
-      en = ap.seqPanel.seqCanvas.getFeatureRenderer().featureGroups.keys();
+      en = ap.seqPanel.seqCanvas.getFeatureRenderer().featureGroups.keySet().iterator();
       Vector groupsAdded = new Vector();
-      while (en.hasMoreElements())
+      while (en.hasNext())
       {
-        String grp = en.nextElement().toString();
+        String grp = en.next().toString();
         if (groupsAdded.contains(grp))
         {
           continue;
index d072d3d..9fc04b4 100755 (executable)
@@ -106,7 +106,7 @@ public class FeaturesFile extends AlignFile
    * @return true if features were added\r
    */\r
   public boolean parse(AlignmentI align, \r
-          Hashtable colours, boolean removeHTML, boolean relaxedIdMatching)\r
+          Map colours, boolean removeHTML, boolean relaxedIdMatching)\r
   {\r
     return parse(align, colours, null, removeHTML, relaxedIdMatching);\r
   }\r
@@ -119,8 +119,8 @@ public class FeaturesFile extends AlignFile
    * @param removeHTML - process html strings into plain text\r
    * @return true if features were added\r
    */\r
-  public boolean parse(AlignmentI align, Hashtable colours,\r
-          Hashtable featureLink, boolean removeHTML)\r
+  public boolean parse(AlignmentI align, Map colours,\r
+          Map featureLink, boolean removeHTML)\r
   {\r
     return parse(align, colours, featureLink, removeHTML, false);\r
   }\r
@@ -136,7 +136,7 @@ public class FeaturesFile extends AlignFile
    * @return true if features were added\r
    */\r
   public boolean parse(AlignmentI align,\r
-          Hashtable colours, Hashtable featureLink, boolean removeHTML, boolean relaxedIdmatching)\r
+          Map colours, Map featureLink, boolean removeHTML, boolean relaxedIdmatching)\r
   {\r
 \r
     String line = null;\r
@@ -150,7 +150,7 @@ public class FeaturesFile extends AlignFile
       StringTokenizer st;\r
       SequenceFeature sf;\r
       String featureGroup = null, groupLink = null;\r
-      Hashtable typeLink = new Hashtable();\r
+      Map typeLink = new Hashtable();\r
       /**\r
        * when true, assume GFF style features rather than Jalview style.\r
        */\r
index 01d0939..45bfd43 100644 (file)
@@ -490,7 +490,7 @@ public class TCoffeeScoreFile extends AlignFile {
              }
            }
            // this will overwrite any existing t-coffee scores for the alignment
-           AlignmentAnnotation aa=al.findOrCreateAnnotation(TCOFFEE_SCORE,false,s,null);
+           AlignmentAnnotation aa=al.findOrCreateAnnotation(TCOFFEE_SCORE,TCOFFEE_SCORE,false,s, null);
            if (s!=null)
            {
              aa.label="T-COFFEE";
index 6ccdef5..7ac6546 100755 (executable)
@@ -32,7 +32,7 @@ public class BuriedColourScheme extends ScoreColourScheme
    */
   public BuriedColourScheme()
   {
-    super(ResidueProperties.buried, ResidueProperties.buriedmin,
+    super(ResidueProperties.aaIndex, ResidueProperties.buried, ResidueProperties.buriedmin,
             ResidueProperties.buriedmax);
   }
 
index ca2bb61..3683b80 100755 (executable)
@@ -23,7 +23,7 @@ public class HelixColourScheme extends ScoreColourScheme
 {
   public HelixColourScheme()
   {
-    super(ResidueProperties.helix, ResidueProperties.helixmin,
+    super(ResidueProperties.aaIndex, ResidueProperties.helix, ResidueProperties.helixmin,
             ResidueProperties.helixmax);
   }
 
index 4dd05c1..0cb365f 100755 (executable)
@@ -32,7 +32,7 @@ public class HydrophobicColourScheme extends ScoreColourScheme
    */
   public HydrophobicColourScheme()
   {
-    super(ResidueProperties.hyd, ResidueProperties.hydmin,
+    super(ResidueProperties.aaIndex, ResidueProperties.hyd, ResidueProperties.hydmin,
             ResidueProperties.hydmax);
   }
 
index 2c63ddb..78d34e2 100755 (executable)
@@ -34,7 +34,7 @@ public class NucleotideColourScheme extends ResidueColourScheme
    */
   public NucleotideColourScheme()
   {
-    super(ResidueProperties.nucleotide, 0);
+    super(ResidueProperties.nucleotideIndex, ResidueProperties.nucleotide, 0);
   }
 
   /**
index 0498536..7720220 100644 (file)
@@ -31,7 +31,7 @@ public class PurinePyrimidineColourScheme extends ResidueColourScheme
    */
   public PurinePyrimidineColourScheme()
   {
-    super(ResidueProperties.purinepyrimidine, 0);
+    super(ResidueProperties.purinepyrimidineIndex, ResidueProperties.purinepyrimidine, 0);
   }
 
   /**
index 16f822f..bfb760e 100644 (file)
@@ -21,6 +21,7 @@ import java.awt.*;
 import java.util.Hashtable;
 
 import jalview.datamodel.AlignmentAnnotation;
+import jalview.datamodel.SequenceI;
 
 /**
  * Looks at the information computed from an RNA Stockholm format file on the
@@ -56,6 +57,7 @@ public class RNAHelicesColour extends ResidueColourScheme
    */
   public RNAHelicesColour(AlignmentAnnotation annotation)
   {
+    super(ResidueProperties.nucleotideIndex);
     this.annotation = annotation;
     refresh();
   }
@@ -118,6 +120,7 @@ public class RNAHelicesColour extends ResidueColourScheme
    * 
    * @return color in RGB
    */
+  @Override
   public Color findColour(char c)
   {
     return ResidueProperties.purinepyrimidine[ResidueProperties.purinepyrimidineIndex[c]];
@@ -135,7 +138,8 @@ public class RNAHelicesColour extends ResidueColourScheme
    * 
    * @return Color in RGB
    */
-  public Color findColour(char c, int j)
+  @Override
+  public Color findColour(char c, int j, SequenceI seq)
   {
     refresh();
     Color currentColour = Color.white;
index bbba865..666834e 100755 (executable)
@@ -35,7 +35,7 @@ import java.util.Map;
  */
 public class ResidueColourScheme implements ColourSchemeI
 {
-
+  final int[] symbolIndex;
   boolean conservationColouring = false;
 
   Color[] colors = null;
@@ -58,23 +58,32 @@ public class ResidueColourScheme implements ColourSchemeI
 
   /**
    * Creates a new ResidueColourScheme object.
-   * 
+   * @param final int[] index table into colors (ResidueProperties.naIndex or ResidueProperties.aaIndex)
    * @param colors
-   *          DOCUMENT ME!
+   *          colours for symbols in sequences
    * @param threshold
-   *          DOCUMENT ME!
+   *          threshold for conservation shading
    */
-  public ResidueColourScheme(Color[] colours, int threshold)
+  public ResidueColourScheme(int[] aaOrnaIndex, Color[] colours, int threshold)
   {
+    symbolIndex = aaOrnaIndex;
     this.colors = colours;
     this.threshold = threshold;
   }
 
   /**
-   * Creates a new ResidueColourScheme object.
+   * Creates a new ResidueColourScheme object with a lookup table for indexing the colour map
+   */
+  public ResidueColourScheme(int[] aaOrNaIndex)
+  {
+    symbolIndex = aaOrNaIndex;
+  }
+  /**
+   * Creates a new ResidueColourScheme object - default constructor for non-sequence dependent colourschemes
    */
   public ResidueColourScheme()
   {
+    symbolIndex = null;
   }
 
   /**
@@ -83,7 +92,7 @@ public class ResidueColourScheme implements ColourSchemeI
   public Color findColour(char c)
   {
     return colors == null ? Color.white
-            : colors[ResidueProperties.aaIndex[c]];
+            : colors[symbolIndex[c]];
   }
 
   @Override
@@ -91,9 +100,9 @@ public class ResidueColourScheme implements ColourSchemeI
   {
     Color currentColour;
 
-    if ((threshold == 0) || aboveThreshold(c, j))
+    if (colors!=null && symbolIndex!=null && (threshold == 0) || aboveThreshold(c, j))
     {
-      currentColour = colors[ResidueProperties.aaIndex[c]];
+      currentColour = colors[symbolIndex[c]];
     }
     else
     {
index 116bbd8..d11a2e8 100755 (executable)
@@ -48,9 +48,9 @@ public class ScoreColourScheme extends ResidueColourScheme
    * @param max
    *          DOCUMENT ME!
    */
-  public ScoreColourScheme(double[] scores, double min, double max)
+  public ScoreColourScheme(int symbolIndex[], double[] scores, double min, double max)
   {
-    super();
+    super(symbolIndex);
 
     this.scores = scores;
     this.min = min;
index ef88c38..69c2f1c 100755 (executable)
@@ -32,7 +32,7 @@ public class StrandColourScheme extends ScoreColourScheme
    */
   public StrandColourScheme()
   {
-    super(ResidueProperties.strand, ResidueProperties.strandmin,
+    super(ResidueProperties.aaIndex, ResidueProperties.strand, ResidueProperties.strandmin,
             ResidueProperties.strandmax);
   }
 
index ceee169..316c828 100755 (executable)
@@ -21,6 +21,6 @@ public class TaylorColourScheme extends ResidueColourScheme
 {
   public TaylorColourScheme()
   {
-    super(ResidueProperties.taylor, 0);
+    super(ResidueProperties.aaIndex, ResidueProperties.taylor, 0);
   }
 }
index a2c1eda..cd5cd3f 100755 (executable)
@@ -32,7 +32,7 @@ public class TurnColourScheme extends ScoreColourScheme
    */
   public TurnColourScheme()
   {
-    super(ResidueProperties.turn, ResidueProperties.turnmin,
+    super(ResidueProperties.aaIndex,ResidueProperties.turn, ResidueProperties.turnmin,
             ResidueProperties.turnmax);
   }
 
index c6dffe5..c578fe3 100755 (executable)
@@ -30,6 +30,6 @@ public class ZappoColourScheme extends ResidueColourScheme
    */
   public ZappoColourScheme()
   {
-    super(ResidueProperties.zappo, 0);
+    super(ResidueProperties.aaIndex,  ResidueProperties.zappo, 0);
   }
 }
index c5aa7fa..b2c9d4d 100644 (file)
@@ -43,11 +43,9 @@ public class AAConsClient extends JabawsAlignCalcWorker
 
   public void updateResultAnnotation(boolean immediate)
   {
-
     if (immediate || !calcMan.isWorking(this) && scoremanager != null)
     {
       AlignmentAnnotation annotation;
-      ;
       Map<String, TreeSet<Score>> scoremap = scoremanager.asMap();
       int alWidth = alignViewport.getAlignment().getWidth();
       AlignmentI alignment;
@@ -74,7 +72,10 @@ public class AAConsClient extends JabawsAlignCalcWorker
           else
           {
             // simple annotation row
-            annotation = alignViewport.getAlignment().findOrCreateAnnotation(scr.getMethod(), true, null, null);
+            annotation = alignViewport.getAlignment()
+                    .findOrCreateAnnotation(scr.getMethod(), getCalcId(), true,
+                            null, null);
+
             Annotation[] elm = new Annotation[alWidth];
             if (alWidth == gapMap.length) // scr.getScores().size())
             {
index baec458..c5c7a13 100644 (file)
@@ -1,14 +1,19 @@
 package jalview.ws.jws2;
 
 import jalview.api.AlignCalcWorkerI;
+import jalview.bin.Cache;
 import jalview.datamodel.SequenceFeature;
 import jalview.datamodel.SequenceI;
 import jalview.gui.AlignFrame;
+import jalview.schemes.GraduatedColor;
 import jalview.ws.jws2.jabaws2.Jws2Instance;
 import jalview.ws.params.WsParamSetI;
 
+import java.awt.Color;
+import java.util.Hashtable;
 import java.util.Iterator;
 import java.util.List;
+import java.util.Map;
 
 import compbio.data.sequence.Range;
 import compbio.data.sequence.Score;
@@ -55,6 +60,7 @@ public class AADisorderClient extends JabawsAlignCalcWorker implements
     if (immediate || !calcMan.isWorking(this) && scoremanager != null)
     {
       boolean dispFeatures = false;
+      Map<String,Object> fc=new Hashtable<String, Object>();
       for (String seqId : seqNames.keySet())
       {
         SequenceI dseq, seq = seqNames.get(seqId);
@@ -65,7 +71,7 @@ public class AADisorderClient extends JabawsAlignCalcWorker implements
         }
         ;
         ScoreHolder scores = scoremanager.getAnnotationForSequence(seqId);
-
+        float last=Float.NaN,val=Float.NaN;
         for (Score scr : scores.scores)
         {
 
@@ -81,7 +87,7 @@ public class AADisorderClient extends JabawsAlignCalcWorker implements
               {
                 sf = new SequenceFeature(typeName + "(" + scr.getMethod()
                         + ")", "Disordered Region", base + rn.from, base
-                        + rn.to, vals.next().floatValue(), methodName);
+                        + rn.to, val=vals.next().floatValue(), methodName);
               }
               else
               {
@@ -90,6 +96,11 @@ public class AADisorderClient extends JabawsAlignCalcWorker implements
                         base + rn.to, methodName);
               }
               dseq.addSequenceFeature(sf);
+              if (last!=val && last!=Float.NaN)
+              {
+                fc.put(sf.getType(),sf);
+              }
+              last=val;
               dispFeatures = true;
             }
           }
@@ -100,7 +111,12 @@ public class AADisorderClient extends JabawsAlignCalcWorker implements
             {
               SequenceFeature sf = new SequenceFeature(typeName + "("
                       + scr.getMethod() + ")", "Disordered Region", start,
-                      start, vals.next().floatValue(), methodName);
+                      start, val=vals.next().floatValue(), methodName);
+              if (last!=val && last!=Float.NaN)
+              {
+                fc.put(sf.getType(),sf);
+              }
+              last=val;
               dseq.addSequenceFeature(sf);
               dispFeatures = true;
             }
@@ -110,15 +126,25 @@ public class AADisorderClient extends JabawsAlignCalcWorker implements
       {
         if (dispFeatures)
         {
+          jalview.gui.FeatureRenderer fr = ((jalview.gui.AlignmentPanel) ap).cloneFeatureRenderer();
           // TODO: configure feature display settings for added types if they don't already exist
-          
+          for (String ft:fc.keySet())
+          {
+            Cache.log.debug("Set graduated feature for new type:"+ft);
+            Object gc=fr.getFeatureStyle(ft);
+            if (gc instanceof Color)
+            {
+              // set graduated color as fading to white for minimum, and autoscaling to values on alignment
+              GraduatedColor ggc=new GraduatedColor(Color.white, (Color)gc,Float.MIN_VALUE, Float.MAX_VALUE);
+              ggc.setAutoScaled(true);
+              fr.setColour(ft, ggc);
+            }
+          }
+          af.alignPanel.updateFeatureRendererFrom(fr);
           af.alignPanel.av.setShowSequenceFeatures(true);
           ap.paintAlignment(true);
         }
       }
-      /*
-       * else { ap.paintAlignment(true); }
-       */
     }
   }