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 = ((double) contact_height) / ((double) graphHeight);
21 if (contacts_per_pixel >= 1)
23 // many contacts rendered per pixel
28 // pixel height for each contact
29 pixels_step = (int) Math
30 .ceil(((double) graphHeight) / (double) contact_height);
34 public class contactInterval
36 public contactInterval(int cStart, int cEnd, int pStart, int pEnd)
44 // range on contact list
45 public final int cStart;
47 public final int cEnd;
50 public final int pStart;
52 public final int pEnd;
61 public contactInterval mapFor(int pStart, int pEnd)
63 int cStart = (int) Math.floor(pStart * contacts_per_pixel);
64 contactInterval ci = new contactInterval(cStart,
65 (int) Math.min(contact_height,
67 cStart + (pEnd - pStart) * contacts_per_pixel)),
73 public Iterator<contactInterval> iterateOverContactIntervals(
76 // NOT YET IMPLEMENTED
78 // int cstart = 0, cend;
81 // eht = y2 - graphHeight; ht >= eht; ht -= pixels_step)
83 // cstart = (int) Math.floor(((double) y2 - ht) * contacts_per_pixel);
84 // cend = (int) Math.min(contact_height,
85 // Math.ceil(cstart + contacts_per_pixel * pixels_step));
87 // return new Iterator<contactIntervals>() {
90 // public boolean hasNext()
92 // // TODO Auto-generated method stub
97 // public contactIntervals next()
99 // // TODO Auto-generated method stub