1 package jalview.datamodel;
4 * An immutable object representing one or more residue and corresponding
5 * alignment column positions for a sequence
7 public class SequenceCursor
10 * the aligned sequence this cursor applies to
12 public final SequenceI sequence;
15 * residue position in sequence (start...), 0 if undefined
17 public final int residuePosition;
20 * column position (1...) corresponding to residuePosition, or 0 if undefined
22 public final int columnPosition;
25 * a token which may be used to check whether this cursor is still valid for
26 * its sequence (allowing it to be ignored if the sequence has changed)
28 public final int token;
34 * sequence this cursor applies to
36 * residue position in sequence (start..)
38 * column position in alignment (1..)
40 * a token that may be validated by the sequence to check the cursor
43 public SequenceCursor(SequenceI seq, int resPos, int column, int tok)
46 residuePosition = resPos;
47 columnPosition = column;
54 int hash = 31 * residuePosition;
55 hash = 31 * hash + columnPosition;
56 hash = 31 * hash + token;
59 hash += sequence.hashCode();
65 * Two cursors are equal if they refer to the same sequence object and have
66 * the same residue position, column position and token value
69 public boolean equals(Object obj)
71 if (!(obj instanceof SequenceCursor))
75 SequenceCursor sc = (SequenceCursor) obj;
76 return sequence == sc.sequence && residuePosition == sc.residuePosition
77 && columnPosition == sc.columnPosition && token == sc.token;
81 public String toString()
83 return (sequence == null ? "" : sequence.getName()) + ":Pos"
84 + residuePosition + ":Col" + columnPosition + ":tok" + token;