From cfbb94908f5b2d247b763e2663f180058efda7aa Mon Sep 17 00:00:00 2001 From: Mateusz Warowny Date: Thu, 6 Jul 2023 15:23:55 +0200 Subject: [PATCH] Implement getLastGraphGroup in for AnnotatedCollectionI --- src/jalview/datamodel/AnnotatedCollectionI.java | 18 +++++++++++++++++- 1 file changed, 17 insertions(+), 1 deletion(-) diff --git a/src/jalview/datamodel/AnnotatedCollectionI.java b/src/jalview/datamodel/AnnotatedCollectionI.java index 878f22a..755333c 100644 --- a/src/jalview/datamodel/AnnotatedCollectionI.java +++ b/src/jalview/datamodel/AnnotatedCollectionI.java @@ -62,5 +62,21 @@ public interface AnnotatedCollectionI extends SequenceCollectionI */ AnnotatedCollectionI getContext(); - + /** + * Returns the number of the highest annotation graph group attached to this + * alignment. + */ + default int getLastGraphGroup() + { + var annots = getAlignmentAnnotation(); + if (annots == null) + return 1; + int graphGroup = 1; + for (AlignmentAnnotation ala : annots) + { + graphGroup = Math.max(graphGroup, ala.graphGroup); + } + return graphGroup; + } + } -- 1.7.10.2