1 package jalview.renderer;
3 import java.util.Iterator;
5 import jalview.datamodel.ContactListI;
7 public class ContactGeometry
11 final double contacts_per_pixel;
13 final int contact_height;
15 public ContactGeometry(ContactListI contacts, int graphHeight)
17 contact_height = contacts.getContactHeight();
18 // fractional number of contacts covering each pixel
19 contacts_per_pixel = (graphHeight < 1) ? contact_height
20 : ((double) contact_height) / ((double) graphHeight);
22 if (contacts_per_pixel >= 1)
24 // many contacts rendered per pixel
29 // pixel height for each contact
30 pixels_step = (int) Math
31 .ceil(((double) graphHeight) / (double) contact_height);
35 public class contactInterval
37 public contactInterval(int cStart, int cEnd, int pStart, int pEnd)
45 // range on contact list
46 public final int cStart;
48 public final int cEnd;
51 public final int pStart;
53 public final int pEnd;
62 public contactInterval mapFor(int pStart, int pEnd)
64 int cStart = (int) Math.floor(pStart * contacts_per_pixel);
65 contactInterval ci = new contactInterval(cStart,
66 (int) Math.min(contact_height,
68 cStart + (pEnd - pStart) * contacts_per_pixel)),
74 public Iterator<contactInterval> iterateOverContactIntervals(
77 // NOT YET IMPLEMENTED
79 // int cstart = 0, cend;
82 // eht = y2 - graphHeight; ht >= eht; ht -= pixels_step)
84 // cstart = (int) Math.floor(((double) y2 - ht) * contacts_per_pixel);
85 // cend = (int) Math.min(contact_height,
86 // Math.ceil(cstart + contacts_per_pixel * pixels_step));
88 // return new Iterator<contactIntervals>() {
91 // public boolean hasNext()
93 // // TODO Auto-generated method stub
98 // public contactIntervals next()
100 // // TODO Auto-generated method stub