1 package jalview.viewmodel;
3 import jalview.api.AlignmentColsCollectionI;
4 import jalview.api.AlignmentRowsCollectionI;
5 import jalview.datamodel.AlignmentI;
6 import jalview.datamodel.AllColsCollection;
7 import jalview.datamodel.AllRowsCollection;
8 import jalview.datamodel.ColumnSelection;
9 import jalview.datamodel.HiddenSequences;
11 public class OverviewDimensionsAllVisible extends OverviewDimensions
13 public OverviewDimensionsAllVisible(ViewportRanges ranges,
14 boolean showAnnotationPanel)
16 super(ranges, showAnnotationPanel);
18 alwidth = ranges.getVisibleAlignmentWidth();
19 alheight = ranges.getVisibleAlignmentHeight();
23 public void updateViewportFromMouse(int mousex, int mousey,
24 HiddenSequences hiddenSeqs, ColumnSelection hiddenCols,
25 ViewportRanges ranges)
30 alwidth = ranges.getVisibleAlignmentWidth();
31 alheight = ranges.getVisibleAlignmentHeight();
44 // Convert x value to residue position
47 // need to determine where scrollCol should be, given x
48 // to do this also need to know width of viewport, and some hidden column
51 // convert x to residues - this is an absolute position
52 int xAsRes = Math.round((float) x * alwidth / width);
54 // get viewport width in residues
55 int vpwidth = ranges.getEndRes() - ranges.getStartRes() + 1;
57 if (xAsRes + vpwidth > alwidth)
59 // went past the end of the alignment, adjust backwards
61 // if last position was before the end of the alignment, need to update
62 if ((scrollCol + vpwidth - 1) < alwidth)
64 xAsRes = alwidth - vpwidth;
74 // Convert y value to sequence position
77 // convert y to residues
78 int yAsSeq = Math.round((float) y * alheight / sequencesHeight);
80 // get viewport height in sequences
81 // add 1 because height includes both endSeq and startSeq
82 int vpheight = ranges.getEndSeq() - ranges.getStartSeq() + 1;
84 if (yAsSeq + vpheight > alheight)
86 // went past the end of the alignment, adjust backwards
87 if ((scrollRow + vpheight - 1) < alheight)
89 yAsSeq = alheight - vpheight;
97 // update scroll values
104 public void setBoxPosition(HiddenSequences hiddenSeqs,
105 ColumnSelection hiddenCols, ViewportRanges ranges)
107 alwidth = ranges.getVisibleAlignmentWidth();
108 alheight = ranges.getVisibleAlignmentHeight();
110 // work with visible values of startRes and endRes
111 int startRes = ranges.getStartRes();
112 int endRes = ranges.getEndRes();
114 // work with visible values of startSeq and endSeq
115 int startSeq = ranges.getStartSeq();
116 int endSeq = ranges.getEndSeq();
118 // boxX, boxY is the x,y location equivalent to startRes, startSeq
119 boxX = Math.round((float) startRes * width / alwidth);
120 boxY = Math.round((float) startSeq * sequencesHeight / alheight);
122 // boxWidth is the width in residues translated to pixels
123 // since the box includes both the start and end residues, add 1 to the
126 .round((float) (endRes - startRes + 1) * width / alwidth);
127 // boxHeight is the height in sequences translated to pixels
128 boxHeight = Math.round((float) (endSeq - startSeq + 1)
129 * sequencesHeight / alheight);
134 public AlignmentColsCollectionI getColumns(ViewportRanges ranges,
135 ColumnSelection hiddenCols)
137 return new AllColsCollection(0,
138 ranges.getVisibleAlignmentWidth() - 1, hiddenCols);
142 public AlignmentRowsCollectionI getRows(ViewportRanges ranges,
145 return new AllRowsCollection(0,
146 ranges.getVisibleAlignmentHeight() - 1, al);