X-Git-Url: http://source.jalview.org/gitweb/?a=blobdiff_plain;f=src%2Fjalview%2Fviewmodel%2FOverviewDimensions.java;h=0235081052825fe532e44d247638d702b63e8ec9;hb=7a0d503181fe41452120a8a02ca63476392aa08c;hp=ee3b511d85ad4019c3c9d1ad11e0c8c7f01e6491;hpb=58fb14c48ecb086be7422f92addf14f930656523;p=jalview.git diff --git a/src/jalview/viewmodel/OverviewDimensions.java b/src/jalview/viewmodel/OverviewDimensions.java index ee3b511..0235081 100644 --- a/src/jalview/viewmodel/OverviewDimensions.java +++ b/src/jalview/viewmodel/OverviewDimensions.java @@ -58,6 +58,10 @@ public abstract class OverviewDimensions protected int alheight; + protected float widthRatio; + + protected float heightRatio; + /** * Create an OverviewDimensions object * @@ -157,23 +161,25 @@ public abstract class OverviewDimensions public float getPixelsPerCol() { resetAlignmentDims(); - return (float) width / alwidth; + return 1 / widthRatio; } public float getPixelsPerSeq() { resetAlignmentDims(); - return (float) sequencesHeight / alheight; + return 1 / heightRatio; } public void setWidth(int w) { width = w; + widthRatio = (float) alwidth / width; } public void setHeight(int h) { sequencesHeight = h - graphHeight; + heightRatio = (float) alheight / sequencesHeight; } /** @@ -272,14 +278,15 @@ public abstract class OverviewDimensions resetAlignmentDims(); // boxX, boxY is the x,y location equivalent to startRes, startSeq - boxX = Math.round((float) startRes * width / alwidth); - boxY = Math.round((float) startSeq * sequencesHeight / alheight); + int xPos = Math.min(startRes, alwidth - vpwidth + 1); + boxX = Math.round(xPos / widthRatio); + boxY = Math.round(startSeq / heightRatio); // boxWidth is the width in residues translated to pixels - boxWidth = Math.round((float) vpwidth * width / alwidth); + boxWidth = Math.round(vpwidth / widthRatio); // boxHeight is the height in sequences translated to pixels - boxHeight = Math.round((float) vpheight * sequencesHeight / alheight); + boxHeight = Math.round(vpheight / heightRatio); } /** @@ -300,7 +307,8 @@ public abstract class OverviewDimensions /* * Given the centre x position, calculate the box's left x position */ - protected abstract int getLeftXFromCentreX(int mousex, HiddenColumns hidden); + protected abstract int getLeftXFromCentreX(int mousex, + HiddenColumns hidden); /* * Given the centre y position, calculate the box's top y position