X-Git-Url: http://source.jalview.org/gitweb/?a=blobdiff_plain;f=src%2Fjalview%2Frenderer%2FContactGeometry.java;h=4aef1d81ae9bdd95fa86234cedf12025ad323020;hb=e70614203293e8f04d7640729851725a763ae130;hp=52581fb10eeb9e62396185faeff6909b49e793fd;hpb=3380595c6eb44d914e9a25958bc09c4e292e1c32;p=jalview.git diff --git a/src/jalview/renderer/ContactGeometry.java b/src/jalview/renderer/ContactGeometry.java index 52581fb..4aef1d8 100644 --- a/src/jalview/renderer/ContactGeometry.java +++ b/src/jalview/renderer/ContactGeometry.java @@ -12,8 +12,11 @@ public class ContactGeometry final int contact_height; + final int graphHeight; + public ContactGeometry(ContactListI contacts, int graphHeight) { + this.graphHeight = graphHeight; contact_height = contacts.getContactHeight(); // fractional number of contacts covering each pixel contacts_per_pixel = (graphHeight < 1) ? contact_height @@ -71,6 +74,25 @@ public class ContactGeometry return ci; } + /** + * return the cell containing given pixel + * + * @param pCentre + * @return range for pCEntre + */ + public contactInterval mapFor(int pCentre) + { + int pStart = Math.max(pCentre - pixels_step, 0); + int pEnd = Math.min(pStart + pixels_step, graphHeight); + int cStart = (int) Math.floor(pStart * contacts_per_pixel); + contactInterval ci = new contactInterval(cStart, + (int) Math.min(contact_height, + Math.ceil(cStart + (pixels_step) * contacts_per_pixel)), + pStart, pEnd); + + return ci; + } + public Iterator iterateOverContactIntervals( int graphHeight) {