X-Git-Url: http://source.jalview.org/gitweb/?a=blobdiff_plain;f=src%2Fjalview%2Fviewmodel%2FOverviewDimensions.java;h=d7f2e61b641b1853a5dec85ffa270a83ffa11985;hb=c526a787880d475c11bbc9124052fd5b7d120405;hp=36b5e0f414171c077cdfb0dea49f096526ebca73;hpb=964c4a6836f02a8b58c5eac7c6722e60c90d72d0;p=jalview.git diff --git a/src/jalview/viewmodel/OverviewDimensions.java b/src/jalview/viewmodel/OverviewDimensions.java index 36b5e0f..d7f2e61 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 * @@ -192,6 +196,44 @@ public abstract class OverviewDimensions HiddenSequences hiddenSeqs, HiddenColumns hiddenCols); /** + * Update the viewport location from a mouse drag within the overview's box + * + * @param mousex + * x location of mouse + * @param mousey + * y location of mouse + * @param hiddenSeqs + * the alignment's hidden sequences + * @param hiddenCols + * the alignment's hidden columns + */ + public abstract void adjustViewportFromMouse(int mousex, int mousey, + HiddenSequences hiddenSeqs, HiddenColumns hiddenCols); + + /** + * Initialise dragging from the mouse - must be called on initial mouse click + * before using adjustViewportFromMouse in drag operations + * + * @param mousex + * x location of mouse + * @param mousey + * y location of mouse + * @param hiddenSeqs + * the alignment's hidden sequences + * @param hiddenCols + * the alignment's hidden columns + */ + public abstract void setDragPoint(int x, int y, + HiddenSequences hiddenSeqs, HiddenColumns hiddenCols); + + /* + * Move the viewport so that the top left corner of the overview's box + * is at the mouse position (leftx, topy) + */ + protected abstract void updateViewportFromTopLeft(int leftx, int topy, + HiddenSequences hiddenSeqs, HiddenColumns hiddenCols); + + /** * Set the overview panel's box position to match the viewport * * @param hiddenSeqs @@ -225,13 +267,17 @@ public abstract class OverviewDimensions */ protected abstract void resetAlignmentDims(); + /* + * Given the box coordinates in residues and sequences, set the box dimensions in the overview window + */ protected void setBoxPosition(int startRes, int startSeq, int vpwidth, int vpheight) { resetAlignmentDims(); // boxX, boxY is the x,y location equivalent to startRes, startSeq - boxX = Math.round((float) startRes * width / alwidth); + int xPos = Math.min(startRes, alwidth - vpwidth + 1); + boxX = Math.round((float) xPos * width / alwidth); boxY = Math.round((float) startSeq * sequencesHeight / alheight); // boxWidth is the width in residues translated to pixels @@ -252,12 +298,20 @@ public abstract class OverviewDimensions */ public boolean isPositionInBox(int x, int y) { - return (x > boxX && y > boxY && boxX + x < boxWidth - && boxY + y < boxHeight); + return (x > boxX && y > boxY && x < boxX + boxWidth + && y < boxY + boxHeight); } - public void setMousePosition(int x, int y) - { + /* + * Given the centre x position, calculate the box's left x position + */ + protected abstract int getLeftXFromCentreX(int mousex, + HiddenColumns hidden); + + /* + * Given the centre y position, calculate the box's top y position + */ + protected abstract int getTopYFromCentreY(int mousey, + HiddenSequences hidden); - } } \ No newline at end of file