JAL-961 allow calcId to be specified independently of alignment annotation row label
[jalview.git] / src / jalview / datamodel / Alignment.java
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)
     {