X-Git-Url: http://source.jalview.org/gitweb/?a=blobdiff_plain;f=src%2Fjalview%2Fviewmodel%2FOverviewDimensions.java;h=a837d53b83d6d435b9d4218ea160c5505acc09c2;hb=968c3bcde941e502fcf7d497343600f4f58f6c9a;hp=7c4ba9ee80ccad8501cbbd3382d39316cdc45a3e;hpb=cdd071033b669ae1489f3bba67c4a0a041776b31;p=jalview.git diff --git a/src/jalview/viewmodel/OverviewDimensions.java b/src/jalview/viewmodel/OverviewDimensions.java index 7c4ba9e..a837d53 100644 --- a/src/jalview/viewmodel/OverviewDimensions.java +++ b/src/jalview/viewmodel/OverviewDimensions.java @@ -1,21 +1,42 @@ +/* + * Jalview - A Sequence Alignment Editor and Viewer ($$Version-Rel$$) + * Copyright (C) $$Year-Rel$$ The Jalview Authors + * + * This file is part of Jalview. + * + * Jalview is free software: you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation, either version 3 + * of the License, or (at your option) any later version. + * + * Jalview is distributed in the hope that it will be useful, but + * WITHOUT ANY WARRANTY; without even the implied warranty + * of MERCHANTABILITY or FITNESS FOR A PARTICULAR + * PURPOSE. See the GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with Jalview. If not, see . + * The Jalview Authors are detailed in the 'AUTHORS' file. + */ package jalview.viewmodel; import jalview.api.AlignmentColsCollectionI; import jalview.api.AlignmentRowsCollectionI; import jalview.datamodel.AlignmentI; -import jalview.datamodel.ColumnSelection; +import jalview.datamodel.HiddenColumns; import jalview.datamodel.HiddenSequences; import java.awt.Graphics; public abstract class OverviewDimensions { - - private static final int DEFAULT_GRAPH_HEIGHT = 20; 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; @@ -25,9 +46,7 @@ public abstract class OverviewDimensions protected int boxHeight = -1; protected int scrollCol = -1; protected int scrollRow = -1; - protected int alwidth; - protected int alheight; public OverviewDimensions(ViewportRanges ranges, @@ -130,11 +149,13 @@ public abstract class OverviewDimensions public float getPixelsPerCol() { + resetAlignmentDims(); return (float) width / alwidth; } public float getPixelsPerSeq() { + resetAlignmentDims(); return (float) sequencesHeight / alheight; } @@ -148,16 +169,71 @@ public abstract class OverviewDimensions sequencesHeight = h - graphHeight; } + /** + * Update the viewport location from a mouse click in the overview panel + * + * @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 updateViewportFromMouse(int mousex, int mousey, - HiddenSequences hiddenSeqs, ColumnSelection hiddenCols, - ViewportRanges ranges); + HiddenSequences hiddenSeqs, HiddenColumns hiddenCols); + /** + * Set the overview panel's box position to match the viewport + * + * @param hiddenSeqs + * the alignment's hidden sequences + * @param hiddenCols + * the alignment's hidden columns + */ public abstract void setBoxPosition(HiddenSequences hiddenSeqs, - ColumnSelection hiddenCols, ViewportRanges ranges); + HiddenColumns hiddenCols); - public abstract AlignmentColsCollectionI getColumns( - ViewportRanges ranges, ColumnSelection hiddenCols); + /** + * Get the collection of columns used by this overview dimensions object + * + * @param hiddenCols + * the alignment's hidden columns + * @return a column collection + */ + public abstract AlignmentColsCollectionI getColumns(AlignmentI al); - public abstract AlignmentRowsCollectionI getRows( - ViewportRanges ranges, AlignmentI al); + /** + * Get the collection of rows used by this overview dimensions object + * + * @param al + * the alignment + * @return a row collection + */ + 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 endRes, int startSeq, + int endSeq) + { + 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 + // since the box includes both the start and end residues, add 1 to the + // difference + boxWidth = Math + .round((float) (endRes - startRes + 1) * width / alwidth); + // boxHeight is the height in sequences translated to pixels + boxHeight = Math.round((float) (endSeq - startSeq + 1) + * sequencesHeight / alheight); + } } \ No newline at end of file