From eccc204bba7aab9101c16df03cc5f740241d9184 Mon Sep 17 00:00:00 2001 From: gmungoc Date: Mon, 9 Dec 2019 14:31:37 +0000 Subject: [PATCH] JAL-3490 pull up getViewAsVisibleContigs to base class and interface --- src/jalview/api/AlignViewportI.java | 13 +++++++++++++ src/jalview/gui/AlignViewport.java | 26 -------------------------- src/jalview/viewmodel/AlignmentViewport.java | 18 ++++++++++++++++++ 3 files changed, 31 insertions(+), 26 deletions(-) diff --git a/src/jalview/api/AlignViewportI.java b/src/jalview/api/AlignViewportI.java index 785dd14..56d25d5 100644 --- a/src/jalview/api/AlignViewportI.java +++ b/src/jalview/api/AlignViewportI.java @@ -38,6 +38,7 @@ import jalview.viewmodel.ViewportRanges; import java.awt.Color; import java.awt.Font; import java.util.Hashtable; +import java.util.Iterator; import java.util.List; import java.util.Map; @@ -528,4 +529,16 @@ public interface AlignViewportI extends ViewStyleI * - a group defined on sequences in the alignment held by the view */ void addSequenceGroup(SequenceGroup sequenceGroup); + + /** + * Returns an interator over the [start, end] column positions of the visible + * regions of the alignment + * + * @param selectedRegionOnly + * if true, and the view has a selection region, + * then only the intersection of visible columns + * with the selection region is returned + * @return + */ + Iterator getViewAsVisibleContigs(boolean selectedRegionOnly); } diff --git a/src/jalview/gui/AlignViewport.java b/src/jalview/gui/AlignViewport.java index 61b0d1b..34146dd 100644 --- a/src/jalview/gui/AlignViewport.java +++ b/src/jalview/gui/AlignViewport.java @@ -59,7 +59,6 @@ import java.awt.FontMetrics; import java.awt.Rectangle; import java.util.ArrayList; import java.util.Hashtable; -import java.util.Iterator; import java.util.List; import javax.swing.JInternalFrame; @@ -446,31 +445,6 @@ public class AlignViewport extends AlignmentViewport } /** - * returns the visible column regions of the alignment - * - * @param selectedRegionOnly - * true to just return the contigs intersecting with the selected - * area - * @return - */ - public Iterator getViewAsVisibleContigs(boolean selectedRegionOnly) - { - int start = 0; - int end = 0; - if (selectedRegionOnly && selectionGroup != null) - { - start = selectionGroup.getStartRes(); - end = selectionGroup.getEndRes() + 1; - } - else - { - end = alignment.getWidth(); - } - return (alignment.getHiddenColumns().getVisContigsIterator(start, end, - false)); - } - - /** * get hash of undo and redo list for the alignment * * @return long[] { historyList.hashCode, redoList.hashCode }; diff --git a/src/jalview/viewmodel/AlignmentViewport.java b/src/jalview/viewmodel/AlignmentViewport.java index 8dcd1b3..2c430db 100644 --- a/src/jalview/viewmodel/AlignmentViewport.java +++ b/src/jalview/viewmodel/AlignmentViewport.java @@ -3044,4 +3044,22 @@ public abstract class AlignmentViewport codingComplement.setUpdateStructures(needToUpdateStructureViews); } } + + @Override + public Iterator getViewAsVisibleContigs(boolean selectedRegionOnly) + { + int start = 0; + int end = 0; + if (selectedRegionOnly && selectionGroup != null) + { + start = selectionGroup.getStartRes(); + end = selectionGroup.getEndRes() + 1; + } + else + { + end = alignment.getWidth(); + } + return (alignment.getHiddenColumns().getVisContigsIterator(start, end, + false)); + } } -- 1.7.10.2