From 5b977aa5b8443f3a5e1bfdc1ef84bf1c4b91631f Mon Sep 17 00:00:00 2001 From: "j.procter@dundee.ac.uk" Date: Fri, 12 Sep 2014 16:56:29 +0100 Subject: [PATCH] JAL-1486 JAL-535 refactor code for trimming alignment annotation according to selections from FormatAdapter to view model method --- src/jalview/api/AlignViewportI.java | 9 +++++++++ src/jalview/viewmodel/AlignmentViewport.java | 22 ++++++++++++++++++++++ 2 files changed, 31 insertions(+) diff --git a/src/jalview/api/AlignViewportI.java b/src/jalview/api/AlignViewportI.java index 567ae83..d8ba30d 100644 --- a/src/jalview/api/AlignViewportI.java +++ b/src/jalview/api/AlignViewportI.java @@ -22,6 +22,7 @@ package jalview.api; import java.awt.Color; import java.util.Hashtable; +import java.util.List; import java.util.Map; import jalview.analysis.Conservation; @@ -191,4 +192,12 @@ public interface AlignViewportI void setConservation(Conservation cons); + /** + * get a copy of the currently visible alignment annotation + * @param selectedOnly if true - trim to selected regions on the alignment + * @return an empty list or new alignment annotation objects shown only visible columns trimmed to selected region only + */ + List getVisibleAlignmentAnnotation( + boolean selectedOnly); + } diff --git a/src/jalview/viewmodel/AlignmentViewport.java b/src/jalview/viewmodel/AlignmentViewport.java index 0c8afaa..0fa4a3c 100644 --- a/src/jalview/viewmodel/AlignmentViewport.java +++ b/src/jalview/viewmodel/AlignmentViewport.java @@ -1243,6 +1243,28 @@ public abstract class AlignmentViewport implements AlignViewportI } + @Override + public List getVisibleAlignmentAnnotation(boolean selectedOnly) + { + ArrayList ala = new ArrayList(); + AlignmentAnnotation[] aa; + if ((aa=alignment.getAlignmentAnnotation())!=null) + { + for (AlignmentAnnotation annot:aa) + { + AlignmentAnnotation clone = new AlignmentAnnotation(annot); + if (selectedOnly && selectionGroup!=null) + { + colSel.makeVisibleAnnotation(selectionGroup.getStartRes(), selectionGroup.getEndRes(),clone); + } else { + colSel.makeVisibleAnnotation(clone); + } + ala.add(clone); + } + } + return ala; + } + /** * @return the padGaps */ -- 1.7.10.2