From 552a05df8deb46017d3e1931cfc9a196553f2a45 Mon Sep 17 00:00:00 2001 From: gmungoc Date: Mon, 10 Sep 2018 13:45:57 +0100 Subject: [PATCH] JAL-3099 new method AlignmentI.getVisibleWidth() --- src/jalview/datamodel/Alignment.java | 28 +++++++--------------------- src/jalview/datamodel/AlignmentI.java | 20 +++++++++++++++++--- 2 files changed, 24 insertions(+), 24 deletions(-) diff --git a/src/jalview/datamodel/Alignment.java b/src/jalview/datamodel/Alignment.java index 3ba35b6..11d28a0 100755 --- a/src/jalview/datamodel/Alignment.java +++ b/src/jalview/datamodel/Alignment.java @@ -720,31 +720,17 @@ public class Alignment implements AlignmentI return maxLength; } - /* + @Override - public int getWidth() + public int getVisibleWidth() { - final Wrapper temp = new Wrapper(); - - forEachSequence(new Consumer() + int w = getWidth(); + if (hiddenCols != null) { - @Override - public void accept(SequenceI s) - { - if (s.getLength() > temp.inner) - { - temp.inner = s.getLength(); - } - } - }, 0, sequences.size() - 1); - - return temp.inner; + w -= hiddenCols.getSize(); + } + return w; } - - public static class Wrapper - { - public int inner; - }*/ /** * DOCUMENT ME! diff --git a/src/jalview/datamodel/AlignmentI.java b/src/jalview/datamodel/AlignmentI.java index 5fb16d6..f129a4c 100755 --- a/src/jalview/datamodel/AlignmentI.java +++ b/src/jalview/datamodel/AlignmentI.java @@ -48,15 +48,29 @@ public interface AlignmentI extends AnnotatedCollectionI /** * - * Calculates the maximum width of the alignment, including gaps. + * Answers the width of the alignment, including gaps, that is, the length of + * the longest sequence, or -1 if there are no sequences. Avoid calling this + * method repeatedly where possible, as it has to perform a calculation. Note + * that this width includes any hidden columns. * - * @return Greatest sequence length within alignment, or -1 if no sequences - * present + * @return + * @see AlignmentI#getVisibleWidth() */ @Override int getWidth(); /** + * + * Answers the visible width of the alignment, including gaps, that is, the + * length of the longest sequence, excluding any hidden columns. Answers -1 if + * there are no sequences. Avoid calling this method repeatedly where + * possible, as it has to perform a calculation. + * + * @return + */ + int getVisibleWidth(); + + /** * Calculates if this set of sequences (visible and invisible) are all the * same length * -- 1.7.10.2