import jalview.util.MessageManager;
import java.util.ArrayList;
+import java.util.Arrays;
import java.util.BitSet;
import java.util.Collections;
import java.util.Enumeration;
+import java.util.HashMap;
import java.util.HashSet;
import java.util.Hashtable;
import java.util.Iterator;
{
private Alignment dataset;
- protected List<SequenceI> sequences;
+ private List<SequenceI> sequences;
protected List<SequenceGroup> groups;
return sequences.get(i);
}
}
+
return null;
}
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 getVisibleWidth()
+ {
+ int w = getWidth();
+ if (hiddenCols != null)
+ {
+ w -= hiddenCols.getSize();
+ }
+ return w;
+ }
+
/**
* DOCUMENT ME!
*
AlignmentAnnotation annot = new AlignmentAnnotation(name, name,
new Annotation[1], 0f, 0f, AlignmentAnnotation.BAR_GRAPH);
annot.hasText = false;
- annot.setCalcId(new String(calcId));
+ if (calcId != null)
+ {
+ annot.setCalcId(new String(calcId));
+ }
annot.autoCalculated = autoCalc;
if (seqRef != null)
{
@Override
public Iterable<AlignmentAnnotation> findAnnotation(String calcId)
{
- List<AlignmentAnnotation> aa = new ArrayList<>();
AlignmentAnnotation[] alignmentAnnotation = getAlignmentAnnotation();
if (alignmentAnnotation != null)
{
- for (AlignmentAnnotation a : alignmentAnnotation)
- {
- if (a.getCalcId() == calcId || (a.getCalcId() != null
- && calcId != null && a.getCalcId().equals(calcId)))
- {
- aa.add(a);
- }
- }
+ return AlignmentAnnotation.findAnnotation(
+ Arrays.asList(getAlignmentAnnotation()), calcId);
}
- return aa;
+ return Arrays.asList(new AlignmentAnnotation[] {});
}
@Override
public Iterable<AlignmentAnnotation> findAnnotations(SequenceI seq,
String calcId, String label)
{
- ArrayList<AlignmentAnnotation> aa = new ArrayList<>();
- for (AlignmentAnnotation ann : getAlignmentAnnotation())
- {
- if ((calcId == null || (ann.getCalcId() != null
- && ann.getCalcId().equals(calcId)))
- && (seq == null || (ann.sequenceRef != null
- && ann.sequenceRef == seq))
- && (label == null
- || (ann.label != null && ann.label.equals(label))))
- {
- aa.add(ann);
- }
- }
- return aa;
+ return AlignmentAnnotation.findAnnotations(
+ Arrays.asList(getAlignmentAnnotation()), seq, calcId, label);
}
@Override
}
@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
}
}
+ /**
+ * Returns a map from sequence to position (0, 1,...) in the alignment
+ */
+ @Override
+ public Map<SequenceI, Integer> getSequencePositions()
+ {
+ Map<SequenceI, Integer> map = new HashMap<>();
+
+ synchronized (sequences)
+ {
+ int i = sequences.size();
+ for (int j = 0; j < i; j++)
+ {
+ map.put(sequences.get(j), Integer.valueOf(j));
+ }
+ }
+ return map;
+ }
+
}