* @author JimP
*
*/
-public class Alignment implements AlignmentI
+public class Alignment implements AlignmentI, AutoCloseable
{
private Alignment dataset;
{
synchronized (sequences)
{
+
if (i > -1 && i < sequences.size())
{
return sequences.get(i);
}
@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();
}
/**
int i = 0;
SequenceI sq = null;
String sqname = null;
+ int nseq = sequences.size();
if (startAfter != null)
{
// try to find the sequence in the alignment
boolean matched = false;
- while (i < sequences.size())
+ while (i < nseq)
{
if (getSequenceAt(i++) == startAfter)
{
i = 0;
}
}
- while (i < sequences.size())
+ while (i < nseq)
{
sq = getSequenceAt(i);
sqname = sq.getName();
public int getWidth()
{
int maxLength = -1;
-
+
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!
int maxLength = -1;
SequenceI current;
- for (int i = 0; i < sequences.size(); i++)
+ int nseq = sequences.size();
+ for (int i = 0; i < nseq; i++)
{
current = getSequenceAt(i);
for (int j = current.getLength(); j > maxLength; j--)
maxLength++;
int cLength;
- for (int i = 0; i < sequences.size(); i++)
+ for (int i = 0; i < nseq; i++)
{
current = getSequenceAt(i);
cLength = current.getLength();