import jalview.api.AlignmentViewPanel;
import jalview.datamodel.AlignmentAnnotation;
import jalview.datamodel.AlignmentI;
+import jalview.datamodel.Annotation;
import java.util.List;
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;
+ }
+ }
+
}
return;
}
- removeAnnotation();
+ // removeAnnotation();
AlignmentI alignment = alignViewport.getAlignment();
if (alignment != null)
{
alignment, new FeatureRenderer(alignViewport));
for (AlignmentAnnotation ann : anns)
{
- ann.showAllColLabels = true;
- ann.graph = AlignmentAnnotation.BAR_GRAPH;
- ourAnnots.add(ann);
- alignment.addAnnotation(ann);
+ AlignmentAnnotation theAnn = alignment.findOrCreateAnnotation(
+ ann.label, ann.description, false, null, null);
+ theAnn.showAllColLabels = true;
+ theAnn.graph = AlignmentAnnotation.BAR_GRAPH;
+ theAnn.scaleColLabel = true;
+ theAnn.annotations = ann.annotations;
+ setGraphMinMax(theAnn, theAnn.annotations);
+ theAnn.validateRangeAndDisplay();
+ if (!ourAnnots.contains(theAnn))
+ {
+ ourAnnots.add(theAnn);
+ }
+ // alignment.addAnnotation(ann);
}
} catch (IndexOutOfBoundsException x)
{
}
/**
- * 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
- */
- private 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;
- }
- }
-
- /**
* Returns a count of any feature types present at the specified position of
* the alignment
*