+++ /dev/null
-/*
- * 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 <http://www.gnu.org/licenses/>.
- * 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
-{
-
-}
@Override
public void run()
{
+ boolean annotationAdded = false;
try
{
calcMan.notifyStart(this);
{
try
{
- computeAnnotations();
+ annotationAdded = computeAnnotations();
} catch (IndexOutOfBoundsException x)
{
// probable race condition. just finish and return without any fuss.
if (ap != null)
{
- ap.adjustAnnotationHeight();
+ if (annotationAdded)
+ {
+ ap.adjustAnnotationHeight();
+ }
ap.paintAlignment(true);
}
/**
* 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
max[crow] = Math.max(count[crow], max[crow]);
}
}
+
+ boolean annotationAdded = false;
+
for (int anrow = 0; anrow < rows; anrow++)
{
Annotation[] anns = new Annotation[width];
* 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;
ourAnnots.add(ann);
}
}
+ return annotationAdded;
}
/**
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
* <ul>
* <li>the number of variant features at the position</li>
* <li>the number of Cath features of status 'True Positive'</li>
int[] count(String residue, List<SequenceFeature> features);
/**
- * Returns names for the annotation that this is counting, for use as the
+ * Returns names for the annotations that this is counting, for use as the
* displayed labels
*
* @return
String[] getNames();
/**
- * Returns descriptions for the annotation, for display as tooltips
+ * Returns descriptions for the annotations, for display as tooltips
*
* @return
*/