From 0fdb1b858c58883a08c0fa50c1540fd2a316687b Mon Sep 17 00:00:00 2001 From: gmungoc Date: Wed, 18 Jan 2017 16:24:41 +0000 Subject: [PATCH] JAL-2228 removed ColumnCounterI, finessed recalc of annotation height --- src/jalview/workers/ColumnCounterI.java | 33 ----------------------- src/jalview/workers/ColumnCounterSetWorker.java | 25 ++++++++++++----- src/jalview/workers/FeatureSetCounterI.java | 17 ++++++------ 3 files changed, 27 insertions(+), 48 deletions(-) delete mode 100644 src/jalview/workers/ColumnCounterI.java diff --git a/src/jalview/workers/ColumnCounterI.java b/src/jalview/workers/ColumnCounterI.java deleted file mode 100644 index 53f1b4b..0000000 --- a/src/jalview/workers/ColumnCounterI.java +++ /dev/null @@ -1,33 +0,0 @@ -/* - * Jalview - A Sequence Alignment Editor and Viewer ($$Version-Rel$$) - * Copyright (C) $$Year-Rel$$ The Jalview Authors - * - * This file is part of Jalview. - * - * Jalview is free software: you can redistribute it and/or - * modify it under the terms of the GNU General Public License - * as published by the Free Software Foundation, either version 3 - * of the License, or (at your option) any later version. - * - * Jalview is distributed in the hope that it will be useful, but - * WITHOUT ANY WARRANTY; without even the implied warranty - * of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with Jalview. If not, see . - * The Jalview Authors are detailed in the 'AUTHORS' file. - */ -package jalview.workers; - -/** - * interfaces that provide counting routines for the newCalculator - * AlignmentAnnotationFactory methods - * - * @author jprocter - * - */ -public interface ColumnCounterI -{ - -} diff --git a/src/jalview/workers/ColumnCounterSetWorker.java b/src/jalview/workers/ColumnCounterSetWorker.java index e1cbd2a..6c5707d 100644 --- a/src/jalview/workers/ColumnCounterSetWorker.java +++ b/src/jalview/workers/ColumnCounterSetWorker.java @@ -69,6 +69,7 @@ class ColumnCounterSetWorker extends AlignCalcWorker @Override public void run() { + boolean annotationAdded = false; try { calcMan.notifyStart(this); @@ -93,7 +94,7 @@ class ColumnCounterSetWorker extends AlignCalcWorker { try { - computeAnnotations(); + annotationAdded = computeAnnotations(); } catch (IndexOutOfBoundsException x) { // probable race condition. just finish and return without any fuss. @@ -111,7 +112,10 @@ class ColumnCounterSetWorker extends AlignCalcWorker if (ap != null) { - ap.adjustAnnotationHeight(); + if (annotationAdded) + { + ap.adjustAnnotationHeight(); + } ap.paintAlignment(true); } @@ -120,8 +124,10 @@ class ColumnCounterSetWorker extends AlignCalcWorker /** * Scan each column of the alignment to calculate a count by feature type. Set * the count as the value of the alignment annotation for that feature type. + * + * @return */ - void computeAnnotations() + boolean computeAnnotations() { FeatureRenderer fr = new FeatureRenderer(alignViewport); // TODO use the commented out code once JAL-2075 is fixed @@ -170,6 +176,9 @@ class ColumnCounterSetWorker extends AlignCalcWorker max[crow] = Math.max(count[crow], max[crow]); } } + + boolean annotationAdded = false; + for (int anrow = 0; anrow < rows; anrow++) { Annotation[] anns = new Annotation[width]; @@ -192,9 +201,12 @@ class ColumnCounterSetWorker extends AlignCalcWorker * construct or update the annotation */ String description = counter.getDescriptions()[anrow]; - AlignmentAnnotation ann = alignViewport.getAlignment() - .findOrCreateAnnotation(counter.getNames()[anrow], - description, false, null, null); + if (!alignment.findAnnotation(description).iterator().hasNext()) + { + annotationAdded = true; + } + AlignmentAnnotation ann = alignment.findOrCreateAnnotation( + counter.getNames()[anrow], description, false, null, null); ann.description = description; ann.showAllColLabels = true; ann.scaleColLabel = true; @@ -207,6 +219,7 @@ class ColumnCounterSetWorker extends AlignCalcWorker ourAnnots.add(ann); } } + return annotationAdded; } /** diff --git a/src/jalview/workers/FeatureSetCounterI.java b/src/jalview/workers/FeatureSetCounterI.java index 3bbf8ec..e14952f 100644 --- a/src/jalview/workers/FeatureSetCounterI.java +++ b/src/jalview/workers/FeatureSetCounterI.java @@ -26,17 +26,16 @@ import jalview.datamodel.SequenceFeature; import java.util.List; /** - * Like FeatureCounterI but returns a vector of counts for a set of features - * - * An interface for a type that returns counts of any value of interest at a - * sequence position that can be determined from the sequence character and any - * features present at that position + * An interface for a type that returns counts (per computed annotation type) of + * any value of interest at a sequence position that can be determined from the + * sequence character and any features present at that position * */ -public interface FeatureSetCounterI extends ColumnCounterI +public interface FeatureSetCounterI { /** - * Returns counts of some properties of interest, for example + * Returns counts (per annotation type) of some properties of interest, for + * example *