X-Git-Url: http://source.jalview.org/gitweb/?a=blobdiff_plain;f=src%2Fjalview%2Fworkers%2FAnnotationWorker.java;h=8f37f15e7377bba0153d42203846bee11bab188c;hb=da09a965dd227e2d03d0f8f3ead720bf4f918d9b;hp=65603d689af04d246aa9874c01e2d4ce2f7ffb10;hpb=0580d6486ec69ff7a9bc8b406cb3703afaca767c;p=jalview.git diff --git a/src/jalview/workers/AnnotationWorker.java b/src/jalview/workers/AnnotationWorker.java index 65603d6..8f37f15 100644 --- a/src/jalview/workers/AnnotationWorker.java +++ b/src/jalview/workers/AnnotationWorker.java @@ -47,11 +47,11 @@ class AnnotationWorker extends AlignCalcWorker * @param af * @param counter */ - public AnnotationWorker(AlignViewportI viewport, - AlignmentViewPanel panel, AnnotationProviderI counter) + public AnnotationWorker(AlignViewportI viewport, AlignmentViewPanel panel, + AnnotationProviderI counter) { super(viewport, panel); - ourAnnots = new ArrayList(); + ourAnnots = new ArrayList<>(); this.counter = counter; calcMan.registerWorker(this); } @@ -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) { @@ -112,7 +121,10 @@ class AnnotationWorker extends AlignCalcWorker if (ap != null) { ap.adjustAnnotationHeight(); - ap.paintAlignment(true); + // TODO: only need to update colour and geometry if panel height changes + // and view is coloured by annotation, and the annotation is actually + // changed! + ap.paintAlignment(true, true); } }