2 * Jalview - A Sequence Alignment Editor and Viewer ($$Version-Rel$$)
3 * Copyright (C) $$Year-Rel$$ The Jalview Authors
5 * This file is part of Jalview.
7 * Jalview is free software: you can redistribute it and/or
8 * modify it under the terms of the GNU General Public License
9 * as published by the Free Software Foundation, either version 3
10 * of the License, or (at your option) any later version.
12 * Jalview is distributed in the hope that it will be useful, but
13 * WITHOUT ANY WARRANTY; without even the implied warranty
14 * of MERCHANTABILITY or FITNESS FOR A PARTICULAR
15 * PURPOSE. See the GNU General Public License for more details.
17 * You should have received a copy of the GNU General Public License
18 * along with Jalview. If not, see <http://www.gnu.org/licenses/>.
19 * The Jalview Authors are detailed in the 'AUTHORS' file.
21 package jalview.datamodel;
23 import java.awt.Color;
25 import jalview.renderer.ContactGeometry.contactInterval;
28 * helper class to compute min/max/mean for a range on a contact list
33 public class ContactListImpl implements ContactListI
35 ContactListProviderI clist;
37 public static ContactListI newContactList(ContactListProviderI list)
39 return new ContactListImpl(list);
42 public ContactListImpl(ContactListProviderI list)
48 public int getPosition()
50 return clist.getPosition();
54 public double getContactAt(int column)
56 return clist.getContactAt(column);
60 public int getContactHeight()
62 return clist.getContactHeight();
66 public ContactRange getRangeFor(int from_column, int to_column)
68 // TODO: consider caching ContactRange for a particular call ?
69 if (clist instanceof ContactListI)
71 // clist may implement getRangeFor in a more efficient way, so use theirs
72 return ((ContactListI) clist).getRangeFor(from_column, to_column);
78 if (to_column >= getContactHeight())
80 to_column = getContactHeight() - 1;
82 ContactRange cr = new ContactRange();
83 cr.setFrom_column(from_column);
84 cr.setTo_column(to_column);
86 for (int i = from_column; i <= to_column; i++)
88 double contact = getContactAt(i);
99 if (cr.getMax() < contact)
104 if (cr.getMin() < contact)
111 if (tot > 0 && to_column > from_column)
113 cr.setMean(tot / (1 + to_column - from_column));
123 public int[] getMappedPositionsFor(int cStart, int cEnd)
125 return clist.getMappedPositionsFor(cStart, cEnd);
129 public Color getColourForGroup()
131 return clist.getColourForGroup();