1 package jalview.datamodel;
3 import java.util.ArrayList;
6 public class ContactMatrix implements ContactMatrixI
9 * are contacts reflexive ?
11 boolean symmetric = true;
13 public ContactMatrix(boolean symmetric)
15 this.symmetric = symmetric;
18 List<List<Float>> contacts = null;
20 int width = 0, numcontacts = 0;
22 float min = 0f, max = 0f;
24 public void addContact(int left, int right, float strength)
26 if (left < 0 || right < 0)
28 throw new Error(new RuntimeException(
29 "Cannot have negative indices for contact left=" + left
30 + " right=" + right + " strength=" + strength));
44 // TODO: use sparse list for efficiency ?
45 contacts = new ArrayList<List<Float>>();
47 List<Float> clist = contacts.get(left);
50 clist = new ArrayList<Float>();
51 contacts.set(left, clist);
53 Float last = clist.set(right, strength);
54 // TODO: if last is non null, may need to recompute range
55 checkBounds(strength);
62 private void checkBounds(float strength)
75 public ContactListI getContactList(final int column)
77 if (column < 0 || column >= width)
82 return new ContactListImpl(new ContactListProviderI()
87 public int getPosition()
93 public int getContactHeight()
100 public double getContactAt(int column)
108 clist = contacts.get(p);
109 cl = clist.get(column);
113 clist = contacts.get(column);
119 clist = contacts.get(p);
120 cl = clist.get(column);
124 // return 0 not NaN ?
127 return cl.doubleValue();
133 public float getMin()
139 public float getMax()
145 public boolean hasReferenceSeq()
147 // TODO Auto-generated method stub
152 public SequenceI getReferenceSeq()
154 // TODO Auto-generated method stub