X-Git-Url: http://source.jalview.org/gitweb/?a=blobdiff_plain;f=src%2Fjalview%2Fdatamodel%2FAlignment.java;h=5ad8be174a72419900d92d864eb6737368059658;hb=ca8504cf9d10874dce9f07cf7a9d933853fe0dd0;hp=fd4e10ca6b79d4b198ed9cf252e7f0f98f29c0f0;hpb=775e7bc104584e88dddcea73fbf02c66f5200c16;p=jalview.git diff --git a/src/jalview/datamodel/Alignment.java b/src/jalview/datamodel/Alignment.java index fd4e10c..5ad8be1 100755 --- a/src/jalview/datamodel/Alignment.java +++ b/src/jalview/datamodel/Alignment.java @@ -46,7 +46,7 @@ import java.util.Vector; * @author JimP * */ -public class Alignment implements AlignmentI +public class Alignment implements AlignmentI, AutoCloseable { private Alignment dataset; @@ -301,15 +301,20 @@ public class Alignment implements AlignmentI } @Override - public void finalize() throws Throwable + public void close() { if (getDataset() != null) { - getDataset().removeAlignmentRef(); + try + { + getDataset().removeAlignmentRef(); + } catch (Throwable e) + { + e.printStackTrace(); + } } nullReferences(); - super.finalize(); } /** @@ -711,39 +716,21 @@ public class Alignment implements AlignmentI for (int i = 0; i < sequences.size(); i++) { - if (getSequenceAt(i).getLength() > maxLength) - { - maxLength = getSequenceAt(i).getLength(); - } + maxLength = Math.max(maxLength, getSequenceAt(i).getLength()); } - 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! @@ -1921,9 +1908,12 @@ public class Alignment implements AlignmentI } @Override - public void setHiddenColumns(HiddenColumns cols) + public boolean setHiddenColumns(HiddenColumns cols) { + boolean changed = cols == null ? hiddenCols != null + : !cols.equals(hiddenCols); hiddenCols = cols; + return changed; } @Override