X-Git-Url: http://source.jalview.org/gitweb/?a=blobdiff_plain;f=src%2Fjalview%2Fviewmodel%2FOverviewDimensions.java;h=12512074a4f9e121ee9ae4a8807faea51d402e46;hb=aa08cfe91eda60027de76aafb0bcdbfc6481a1d9;hp=d7f2e61b641b1853a5dec85ffa270a83ffa11985;hpb=c526a787880d475c11bbc9124052fd5b7d120405;p=jalview.git diff --git a/src/jalview/viewmodel/OverviewDimensions.java b/src/jalview/viewmodel/OverviewDimensions.java index d7f2e61..1251207 100644 --- a/src/jalview/viewmodel/OverviewDimensions.java +++ b/src/jalview/viewmodel/OverviewDimensions.java @@ -20,14 +20,14 @@ */ package jalview.viewmodel; +import java.awt.Graphics; + import jalview.api.AlignmentColsCollectionI; import jalview.api.AlignmentRowsCollectionI; import jalview.datamodel.AlignmentI; import jalview.datamodel.HiddenColumns; import jalview.datamodel.HiddenSequences; -import java.awt.Graphics; - public abstract class OverviewDimensions { protected static final int MAX_WIDTH = 400; @@ -161,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; + width = w < 1 ? 1 : w; + widthRatio = (float) alwidth / width; } public void setHeight(int h) { - sequencesHeight = h - graphHeight; + sequencesHeight = (h < 1 ? 1 : h) - graphHeight; + heightRatio = (float) alheight / sequencesHeight; } /** @@ -277,14 +279,14 @@ public abstract class OverviewDimensions // boxX, boxY is the x,y location equivalent to startRes, startSeq int xPos = Math.min(startRes, alwidth - vpwidth + 1); - boxX = Math.round((float) xPos * width / alwidth); - boxY = Math.round((float) startSeq * sequencesHeight / alheight); + 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); } /**