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 private float pixelsPerCol;
15 private float pixelsPerSeq;
17 public OverviewDimensionsAllVisible(ViewportRanges ranges,
18 boolean showAnnotationPanel)
20 super(ranges, showAnnotationPanel);
22 int alwidth = ranges.getVisibleAlignmentWidth();
23 int alheight = ranges.getVisibleAlignmentHeight();
25 pixelsPerCol = (float) width / alwidth;
26 pixelsPerSeq = (float) sequencesHeight / alheight;
30 public void updateViewportFromMouse(int mousex, int mousey,
31 HiddenSequences hiddenSeqs, ColumnSelection hiddenCols,
32 ViewportRanges ranges)
37 int alwidth = ranges.getVisibleAlignmentWidth();
38 int alheight = ranges.getVisibleAlignmentHeight();
51 // Convert x value to residue position
54 // need to determine where scrollCol should be, given x
55 // to do this also need to know width of viewport, and some hidden column
58 // convert x to residues - this is an absolute position
59 int xAsRes = Math.round((float) x * alwidth / width);
61 // get viewport width in residues
62 int vpwidth = ranges.getEndRes() - ranges.getStartRes() + 1;
64 if (xAsRes + vpwidth > alwidth)
66 // went past the end of the alignment, adjust backwards
68 // if last position was before the end of the alignment, need to update
69 if ((scrollCol + vpwidth - 1) < alwidth)
71 xAsRes = alwidth - vpwidth;
81 // Convert y value to sequence position
84 // convert y to residues
85 int yAsSeq = Math.round((float) y * alheight / sequencesHeight);
87 // get viewport height in sequences
88 // add 1 because height includes both endSeq and startSeq
89 int vpheight = ranges.getEndSeq() - ranges.getStartSeq() + 1;
91 if (yAsSeq + vpheight > alheight)
93 // went past the end of the alignment, adjust backwards
94 if ((scrollRow + vpheight - 1) < alheight)
96 yAsSeq = alheight - vpheight;
104 // update scroll values
111 public void setBoxPosition(HiddenSequences hiddenSeqs,
112 ColumnSelection hiddenCols, ViewportRanges ranges)
114 int alwidth = ranges.getVisibleAlignmentWidth();
115 int alheight = ranges.getVisibleAlignmentHeight();
117 // work with visible values of startRes and endRes
118 int startRes = ranges.getStartRes();
119 int endRes = ranges.getEndRes();
121 // work with visible values of startSeq and endSeq
122 int startSeq = ranges.getStartSeq();
123 int endSeq = ranges.getEndSeq();
125 // boxX, boxY is the x,y location equivalent to startRes, startSeq
126 boxX = Math.round((float) startRes * width / alwidth);
127 boxY = Math.round((float) startSeq * sequencesHeight / alheight);
129 // boxWidth is the width in residues translated to pixels
130 // since the box includes both the start and end residues, add 1 to the
133 .round((float) (endRes - startRes + 1) * width / alwidth);
134 // boxHeight is the height in sequences translated to pixels
135 boxHeight = Math.round((float) (endSeq - startSeq + 1)
136 * sequencesHeight / alheight);
141 public AlignmentColsCollectionI getColumns(ViewportRanges ranges,
142 ColumnSelection hiddenCols)
144 return new AllColsCollection(0,
145 ranges.getVisibleAlignmentWidth() - 1, hiddenCols);
149 public AlignmentRowsCollectionI getRows(ViewportRanges ranges,
152 return new AllRowsCollection(0,
153 ranges.getVisibleAlignmentHeight() - 1, al);
157 public float getPixelsPerCol()
163 public float getPixelsPerSeq()