package jalview.datamodel;
import jalview.analysis.AlignmentUtils;
-import jalview.datamodel.AlignedCodonFrame.SequenceToSequenceMapping;
import jalview.io.FastaFile;
import jalview.util.Comparison;
import jalview.util.LinkedIdentityHashSet;
* @author JimP
*
*/
-public class Alignment implements AlignmentI
+public class Alignment implements AlignmentI, AutoCloseable
{
private Alignment dataset;
}
@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();
}
/**
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<SequenceI>()
+ 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!
// verify all mappings are in dataset
for (AlignedCodonFrame cf : codonFrameList)
{
- for (SequenceToSequenceMapping ssm : cf.getMappings())
+ for (SequenceMapping ssm : cf.getMappings())
{
if (!seqs.contains(ssm.getFromSeq()))
{
}
@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