X-Git-Url: http://source.jalview.org/gitweb/?a=blobdiff_plain;f=src%2Fjalview%2Fworkers%2FAlignCalcWorker.java;h=570ddd1793d3e5a8a78ce14c56f06e52a4971f40;hb=db93a1adcbe0a4eaaf06e0a70ade0d6c5c1961c3;hp=5dd656a188d259c8cef54bf925b13eccafcdf478;hpb=a90e2fe3cc3b779521a81cf8de410936f3a777c1;p=jalview.git diff --git a/src/jalview/workers/AlignCalcWorker.java b/src/jalview/workers/AlignCalcWorker.java index 5dd656a..570ddd1 100644 --- a/src/jalview/workers/AlignCalcWorker.java +++ b/src/jalview/workers/AlignCalcWorker.java @@ -26,6 +26,7 @@ import jalview.api.AlignViewportI; import jalview.api.AlignmentViewPanel; import jalview.datamodel.AlignmentAnnotation; import jalview.datamodel.AlignmentI; +import jalview.datamodel.Annotation; import java.util.List; @@ -46,7 +47,7 @@ public abstract class AlignCalcWorker implements AlignCalcWorkerI protected AlignmentViewPanel ap; - protected List ourAnnots = null; + protected List ourAnnots; public AlignCalcWorker(AlignViewportI alignViewport, AlignmentViewPanel alignPanel) @@ -68,17 +69,18 @@ public abstract class AlignCalcWorker implements AlignCalcWorkerI } + @Override public boolean involves(AlignmentAnnotation i) { return ourAnnots != null && ourAnnots.contains(i); } /** - * permanently remove from the alignment all annotation rows managed by this + * Permanently removes from the alignment all annotation rows managed by this * worker */ @Override - public void removeOurAnnotation() + public void removeAnnotation() { if (ourAnnots != null && alignViewport != null) { @@ -90,9 +92,48 @@ public abstract class AlignCalcWorker implements AlignCalcWorkerI alignment.deleteAnnotation(aa, true); } } + ourAnnots.clear(); } } + // TODO: allow GUI to query workers associated with annotation to add items to // annotation label panel popup menu + @Override + public boolean isDeletable() + { + return false; + } + + /** + * Calculate min and max values of annotations and set as graphMin, graphMax + * on the AlignmentAnnotation. This is needed because otherwise, well, bad + * things happen. + * + * @param ann + * @param anns + */ + protected void setGraphMinMax(AlignmentAnnotation ann, Annotation[] anns) + { + // TODO feels like this belongs inside AlignmentAnnotation! + float max = Float.MIN_VALUE; + float min = Float.MAX_VALUE; + boolean set = false; + for (Annotation a : anns) + { + if (a != null) + { + set = true; + float val = a.value; + max = Math.max(max, val); + min = Math.min(min, val); + } + } + if (set) + { + ann.graphMin = min; + ann.graphMax = max; + } + } + }