X-Git-Url: http://source.jalview.org/gitweb/?a=blobdiff_plain;f=src%2Fjalview%2Fworkers%2FAnnotationWorker.java;h=8f37f15e7377bba0153d42203846bee11bab188c;hb=6e5d144752feac881f35390fffcebe8f4233d68d;hp=901b6fc3535da2cb13c51d936405b0ed26ed7da6;hpb=25551bf7f81cd62e7b427f5787f2879eab2afed7;p=jalview.git diff --git a/src/jalview/workers/AnnotationWorker.java b/src/jalview/workers/AnnotationWorker.java index 901b6fc..8f37f15 100644 --- a/src/jalview/workers/AnnotationWorker.java +++ b/src/jalview/workers/AnnotationWorker.java @@ -20,11 +20,11 @@ */ package jalview.workers; +import jalview.api.AlignViewportI; +import jalview.api.AlignmentViewPanel; import jalview.datamodel.AlignmentAnnotation; import jalview.datamodel.AlignmentI; -import jalview.gui.AlignFrame; -import jalview.gui.AlignmentPanel; -import jalview.gui.FeatureRenderer; +import jalview.renderer.seqfeatures.FeatureRenderer; import java.util.ArrayList; import java.util.List; @@ -47,10 +47,11 @@ class AnnotationWorker extends AlignCalcWorker * @param af * @param counter */ - public AnnotationWorker(AlignFrame af, AnnotationProviderI counter) + public AnnotationWorker(AlignViewportI viewport, AlignmentViewPanel panel, + AnnotationProviderI counter) { - super(af.getViewport(), af.alignPanel); - ourAnnots = new ArrayList(); + super(viewport, panel); + ourAnnots = new ArrayList<>(); this.counter = counter; calcMan.registerWorker(this); } @@ -78,20 +79,29 @@ class AnnotationWorker extends AlignCalcWorker return; } - removeAnnotations(); + // removeAnnotation(); AlignmentI alignment = alignViewport.getAlignment(); if (alignment != null) { try { List anns = counter.calculateAnnotation( - alignment, new FeatureRenderer((AlignmentPanel) ap)); + 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) { @@ -111,21 +121,11 @@ 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); } - - } - - /** - * Remove all our annotations before re-calculating them - */ - void removeAnnotations() - { - for (AlignmentAnnotation ann : ourAnnots) - { - alignViewport.getAlignment().deleteAnnotation(ann); - } - ourAnnots.clear(); } @Override