*/
package jalview.workers;
+import jalview.api.AlignViewportI;
+import jalview.api.AlignmentViewPanel;
import jalview.datamodel.AlignmentAnnotation;
import jalview.datamodel.AlignmentI;
import jalview.datamodel.Annotation;
import jalview.datamodel.SequenceFeature;
import jalview.datamodel.SequenceI;
-import jalview.gui.AlignFrame;
-import jalview.gui.AlignmentPanel;
-import jalview.gui.FeatureRenderer;
+import jalview.renderer.seqfeatures.FeatureRenderer;
import jalview.util.ColorUtils;
import jalview.util.Comparison;
* @param af
* @param counter
*/
- public ColumnCounterWorker(AlignFrame af, FeatureCounterI counter)
+ public ColumnCounterWorker(AlignViewportI viewport,
+ AlignmentViewPanel panel, FeatureCounterI counter)
{
- super(af.getViewport(), af.alignPanel);
+ super(viewport, panel);
ourAnnots = new ArrayList<AlignmentAnnotation>();
this.counter = counter;
calcMan.registerWorker(this);
return;
}
- removeAnnotation();
if (alignViewport.getAlignment() != null)
{
try
} catch (OutOfMemoryError error)
{
ap.raiseOOMWarning("calculating feature counts", error);
- calcMan.workerCannotRun(this);
+ calcMan.disableWorker(this);
} finally
{
calcMan.workerComplete(this);
*/
void computeAnnotations()
{
- FeatureRenderer fr = new FeatureRenderer((AlignmentPanel) ap);
+ FeatureRenderer fr = new FeatureRenderer(alignViewport);
// TODO use the commented out code once JAL-2075 is fixed
// to get adequate performance on genomic length sequence
AlignmentI alignment = alignViewport.getAlignment();
{
Color color = ColorUtils.getGraduatedColour(count, 0, Color.cyan,
max, Color.blue);
- anns[i] = new Annotation(String.valueOf(count),
- String.valueOf(count), '0', count, color);
+ String str = String.valueOf(count);
+ anns[i] = new Annotation(str, str, '0', count, color);
}
}
/*
- * construct the annotation, save it and add it to the displayed alignment
+ * construct or update the annotation
*/
- AlignmentAnnotation ann = new AlignmentAnnotation(counter.getName(),
- counter.getDescription(), anns);
+ AlignmentAnnotation ann = alignViewport.getAlignment()
+ .findOrCreateAnnotation(counter.getName(),
+ counter.getDescription(), false, null,
+ null);
+ ann.description = counter.getDescription();
ann.showAllColLabels = true;
+ ann.scaleColLabel = true;
ann.graph = AlignmentAnnotation.BAR_GRAPH;
- ourAnnots.add(ann);
- alignViewport.getAlignment().addAnnotation(ann);
+ ann.annotations = anns;
+ setGraphMinMax(ann, anns);
+ ann.validateRangeAndDisplay();
+ if (!ourAnnots.contains(ann))
+ {
+ ourAnnots.add(ann);
+ }
}
/**
{
// do nothing
}
+
+ /**
+ * Answers true to indicate that if this worker's annotation is deleted from
+ * the display, the worker should also be removed. This prevents it running
+ * and recreating the annotation when the alignment changes.
+ */
+ @Override
+ public boolean isDeletable()
+ {
+ return true;
+ }
}