X-Git-Url: http://source.jalview.org/gitweb/?a=blobdiff_plain;f=src%2Fjalview%2Fviewmodel%2FOverviewDimensions.java;h=d2912d8996be680821b48c109f6e0193c4dd690e;hb=8e884069ac5b4f02f1cabf435e4a7506ae91f0e0;hp=6f4a4e01c74f44a117b4e11ff14355b1787ed57b;hpb=536a4a9c407a4c07b71e86e75135eaa2ba5e8850;p=jalview.git diff --git a/src/jalview/viewmodel/OverviewDimensions.java b/src/jalview/viewmodel/OverviewDimensions.java index 6f4a4e0..d2912d8 100644 --- a/src/jalview/viewmodel/OverviewDimensions.java +++ b/src/jalview/viewmodel/OverviewDimensions.java @@ -31,24 +31,41 @@ import java.awt.Graphics; public abstract class OverviewDimensions { protected static final int MAX_WIDTH = 400; + protected static final int MIN_WIDTH = 120; + protected static final int MIN_SEQ_HEIGHT = 40; + protected static final int MAX_SEQ_HEIGHT = 300; private static final int DEFAULT_GRAPH_HEIGHT = 20; protected int width; + protected int sequencesHeight; + protected int graphHeight = DEFAULT_GRAPH_HEIGHT; + protected int boxX = -1; + protected int boxY = -1; + protected int boxWidth = -1; + protected int boxHeight = -1; - protected int scrollCol = -1; - protected int scrollRow = -1; + protected int alwidth; + protected int alheight; + /** + * Create an OverviewDimensions object + * + * @param ranges + * positional properties of the viewport + * @param showAnnotationPanel + * true if the annotation panel is to be shown, false otherwise + */ public OverviewDimensions(ViewportRanges ranges, boolean showAnnotationPanel) { @@ -97,16 +114,6 @@ public abstract class OverviewDimensions g.drawRect(boxX + 1, boxY + 1, boxWidth - 2, boxHeight - 2); } - public int getScrollCol() - { - return scrollCol; - } - - public int getScrollRow() - { - return scrollRow; - } - public int getBoxX() { return boxX; @@ -149,11 +156,13 @@ public abstract class OverviewDimensions public float getPixelsPerCol() { + resetAlignmentDims(); return (float) width / alwidth; } public float getPixelsPerSeq() { + resetAlignmentDims(); return (float) sequencesHeight / alheight; } @@ -178,12 +187,9 @@ public abstract class OverviewDimensions * the alignment's hidden sequences * @param hiddenCols * the alignment's hidden columns - * @param ranges - * the alignment's width and height ranges */ public abstract void updateViewportFromMouse(int mousex, int mousey, - HiddenSequences hiddenSeqs, HiddenColumns hiddenCols, - ViewportRanges ranges); + HiddenSequences hiddenSeqs, HiddenColumns hiddenCols); /** * Set the overview panel's box position to match the viewport @@ -192,33 +198,46 @@ public abstract class OverviewDimensions * the alignment's hidden sequences * @param hiddenCols * the alignment's hidden columns - * @param ranges - * the alignment's width and height ranges */ public abstract void setBoxPosition(HiddenSequences hiddenSeqs, - HiddenColumns hiddenCols, ViewportRanges ranges); + HiddenColumns hiddenCols); /** * Get the collection of columns used by this overview dimensions object * - * @param ranges - * the alignment's width and height ranges * @param hiddenCols * the alignment's hidden columns * @return a column collection */ - public abstract AlignmentColsCollectionI getColumns( - ViewportRanges ranges, HiddenColumns hiddenCols); + public abstract AlignmentColsCollectionI getColumns(AlignmentI al); /** * Get the collection of rows used by this overview dimensions object * - * @param ranges - * the alignment's width and height ranges * @param al * the alignment * @return a row collection */ - public abstract AlignmentRowsCollectionI getRows( - ViewportRanges ranges, AlignmentI al); + public abstract AlignmentRowsCollectionI getRows(AlignmentI al); + + /** + * Updates overview dimensions to account for current alignment dimensions + */ + protected abstract void resetAlignmentDims(); + + 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); + boxY = Math.round((float) startSeq * sequencesHeight / alheight); + + // boxWidth is the width in residues translated to pixels + boxWidth = Math.round((float) vpwidth * width / alwidth); + + // boxHeight is the height in sequences translated to pixels + boxHeight = Math.round((float) vpheight * sequencesHeight / alheight); + } } \ No newline at end of file