1 package jalview.datamodel;
5 import jalview.renderer.ContactGeometry.contactInterval;
8 * helper class to compute min/max/mean for a range on a contact list
13 public class ContactListImpl implements ContactListI
15 ContactListProviderI clist;
17 public static ContactListI newContactList(ContactListProviderI list)
19 return new ContactListImpl(list);
22 public ContactListImpl(ContactListProviderI list)
28 public int getPosition()
30 return clist.getPosition();
34 public double getContactAt(int column)
36 return clist.getContactAt(column);
40 public int getContactHeight()
42 return clist.getContactHeight();
46 public ContactRange getRangeFor(int from_column, int to_column)
48 // TODO: consider caching ContactRange for a particular call ?
49 if (clist instanceof ContactListI)
51 // clist may implement getRangeFor in a more efficient way, so use theirs
52 return ((ContactListI) clist).getRangeFor(from_column, to_column);
58 if (to_column >= getContactHeight())
60 to_column = getContactHeight()-1;
62 ContactRange cr = new ContactRange();
63 cr.setFrom_column(from_column);
64 cr.setTo_column(to_column);
66 for (int i = from_column; i <= to_column; i++)
68 double contact = getContactAt(i);
79 if (cr.getMax() < contact)
84 if (cr.getMin() < contact)
91 if (tot > 0 && to_column>from_column)
93 cr.setMean(tot / (1 + to_column - from_column));
103 public int[] getMappedPositionsFor(int cStart, int cEnd)
105 return clist.getMappedPositionsFor(cStart, cEnd);
109 public Color getColourForGroup()
111 return clist.getColourForGroup();