1 package jalview.viewmodel;
3 import jalview.datamodel.AlignmentColsCollection;
4 import jalview.datamodel.AlignmentI;
5 import jalview.datamodel.AlignmentRowsCollection;
6 import jalview.datamodel.ColumnSelection;
7 import jalview.datamodel.HiddenSequences;
9 public class OverviewDimensionsAllVisible extends OverviewDimensions
11 private float pixelsPerCol;
13 private float pixelsPerSeq;
15 public OverviewDimensionsAllVisible(ViewportRanges ranges,
16 boolean showAnnotationPanel)
18 super(ranges, showAnnotationPanel);
20 int alwidth = ranges.getVisibleAlignmentWidth();
21 int alheight = ranges.getVisibleAlignmentHeight();
23 pixelsPerCol = (float) width / alwidth;
24 pixelsPerSeq = (float) sequencesHeight / alheight;
28 public void updateViewportFromMouse(int mousex, int mousey,
29 HiddenSequences hiddenSeqs, ColumnSelection hiddenCols,
30 ViewportRanges ranges)
35 int alwidth = ranges.getVisibleAlignmentWidth();
36 int alheight = ranges.getVisibleAlignmentHeight();
49 // Convert x value to residue position
52 // need to determine where scrollCol should be, given x
53 // to do this also need to know width of viewport, and some hidden column
56 // convert x to residues - this is an absolute position
57 int xAsRes = Math.round((float) x * alwidth / width);
59 // get viewport width in residues
60 int vpwidth = ranges.getEndRes() - ranges.getStartRes() + 1;
62 if (xAsRes + vpwidth > alwidth)
64 // went past the end of the alignment, adjust backwards
66 // if last position was before the end of the alignment, need to update
67 if ((scrollCol + vpwidth - 1) < alwidth)
69 xAsRes = alwidth - vpwidth;
79 // Convert y value to sequence position
82 // convert y to residues
83 int yAsSeq = Math.round((float) y * alheight / sequencesHeight);
85 // get viewport height in sequences
86 // add 1 because height includes both endSeq and startSeq
87 int vpheight = ranges.getEndSeq() - ranges.getStartSeq() + 1;
89 if (yAsSeq + vpheight > alheight)
91 // went past the end of the alignment, adjust backwards
92 if ((scrollRow + vpheight - 1) < alheight)
94 yAsSeq = alheight - vpheight;
102 // update scroll values
109 public void setBoxPosition(HiddenSequences hiddenSeqs,
110 ColumnSelection hiddenCols, ViewportRanges ranges)
112 int alwidth = ranges.getVisibleAlignmentWidth();
113 int alheight = ranges.getVisibleAlignmentHeight();
115 // work with visible values of startRes and endRes
116 int startRes = ranges.getStartRes();
117 int endRes = ranges.getEndRes();
119 // work with visible values of startSeq and endSeq
120 int startSeq = ranges.getStartSeq();
121 int endSeq = ranges.getEndSeq();
123 // boxX, boxY is the x,y location equivalent to startRes, startSeq
124 boxX = Math.round((float) startRes * width / alwidth);
125 boxY = Math.round((float) startSeq * sequencesHeight / alheight);
127 // boxWidth is the width in residues translated to pixels
128 // since the box includes both the start and end residues, add 1 to the
131 .round((float) (endRes - startRes + 1) * width / alwidth);
132 // boxHeight is the height in sequences translated to pixels
133 boxHeight = Math.round((float) (endSeq - startSeq + 1)
134 * sequencesHeight / alheight);
139 public AlignmentColsCollection getColumns(ViewportRanges ranges,
140 ColumnSelection hiddenCols)
142 return new AlignmentColsCollection(0,
143 ranges.getVisibleAlignmentWidth() - 1, hiddenCols);
147 public AlignmentRowsCollection getRows(ViewportRanges ranges,
150 return new AlignmentRowsCollection(0,
151 ranges.getVisibleAlignmentHeight() - 1, al);
155 public float getPixelsPerCol()
161 public float getPixelsPerSeq()