X-Git-Url: http://source.jalview.org/gitweb/?a=blobdiff_plain;f=src%2Fjalview%2Fworkers%2FAlignCalcWorker.java;h=16fc467e0bfdc1c0813497894f7ff8d2c712f7cc;hb=747167089ecf8d6afc70d417f5a20352e029bd95;hp=6bdf1c23ed827b20fac66cbd82a10ee49cdc4940;hpb=17e77c3f2949a0729322b4a8d907f3f34b6a9914;p=jalview.git diff --git a/src/jalview/workers/AlignCalcWorker.java b/src/jalview/workers/AlignCalcWorker.java index 6bdf1c2..16fc467 100644 --- a/src/jalview/workers/AlignCalcWorker.java +++ b/src/jalview/workers/AlignCalcWorker.java @@ -1,6 +1,6 @@ /* - * Jalview - A Sequence Alignment Editor and Viewer (Version 2.9) - * Copyright (C) 2015 The Jalview Authors + * Jalview - A Sequence Alignment Editor and Viewer ($$Version-Rel$$) + * Copyright (C) $$Year-Rel$$ The Jalview Authors * * This file is part of Jalview. * @@ -20,12 +20,13 @@ */ package jalview.workers; -import jalview.api.AlignCalcManagerI; +import jalview.api.AlignCalcManagerI2; import jalview.api.AlignCalcWorkerI; import jalview.api.AlignViewportI; import jalview.api.AlignmentViewPanel; import jalview.datamodel.AlignmentAnnotation; import jalview.datamodel.AlignmentI; +import jalview.datamodel.Annotation; import java.util.List; @@ -42,11 +43,11 @@ public abstract class AlignCalcWorker implements AlignCalcWorkerI */ protected AlignViewportI alignViewport; - protected AlignCalcManagerI calcMan; + protected AlignCalcManagerI2 calcMan; protected AlignmentViewPanel ap; - protected List ourAnnots = null; + protected List ourAnnots; public AlignCalcWorker(AlignViewportI alignViewport, AlignmentViewPanel alignPanel) @@ -60,7 +61,8 @@ public abstract class AlignCalcWorker implements AlignCalcWorkerI { if (calcMan != null) { - calcMan.workerComplete(this); + calcMan.cancelWorker(this); + calcMan.removeWorker(this); } alignViewport = null; calcMan = null; @@ -68,17 +70,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 +93,52 @@ 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; + } + } + + public AlignViewportI getAlignViewport() + { + return alignViewport; + } }