From: j.procter@dundee.ac.uk Date: Fri, 12 Sep 2014 15:56:29 +0000 (+0100) Subject: JAL-1486 JAL-535 refactor code for trimming alignment annotation according to selecti... X-Git-Tag: Jalview_2_9~175^2~4 X-Git-Url: http://source.jalview.org/gitweb/?a=commitdiff_plain;h=5b977aa5b8443f3a5e1bfdc1ef84bf1c4b91631f;p=jalview.git JAL-1486 JAL-535 refactor code for trimming alignment annotation according to selections from FormatAdapter to view model method --- 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 */