JAL-2068 AnnotationWorker create/update annotation, not delete / re-add
[jalview.git] / src / jalview / workers / AnnotationWorker.java
index 65603d6..4d81307 100644 (file)
@@ -79,7 +79,7 @@ class AnnotationWorker extends AlignCalcWorker
         return;
       }
 
-      removeAnnotation();
+      // removeAnnotation();
       AlignmentI alignment = alignViewport.getAlignment();
       if (alignment != null)
       {
@@ -89,10 +89,19 @@ class AnnotationWorker extends AlignCalcWorker
                   alignment, new FeatureRenderer(alignViewport));
           for (AlignmentAnnotation ann : anns)
           {
-            ann.showAllColLabels = true;
-            ann.graph = AlignmentAnnotation.BAR_GRAPH;
-            ourAnnots.add(ann);
-            alignment.addAnnotation(ann);
+            AlignmentAnnotation theAnn = alignment.findOrCreateAnnotation(
+                    ann.label, ann.description, false, null, null);
+            theAnn.showAllColLabels = true;
+            theAnn.graph = AlignmentAnnotation.BAR_GRAPH;
+            theAnn.scaleColLabel = true;
+            theAnn.annotations = ann.annotations;
+            setGraphMinMax(theAnn, theAnn.annotations);
+            theAnn.validateRangeAndDisplay();
+            if (!ourAnnots.contains(theAnn))
+            {
+              ourAnnots.add(theAnn);
+            }
+            // alignment.addAnnotation(ann);
           }
         } catch (IndexOutOfBoundsException x)
         {