1 package jalview.viewmodel;
3 import jalview.api.AlignmentColsCollectionI;
4 import jalview.api.AlignmentRowsCollectionI;
5 import jalview.datamodel.AlignmentI;
6 import jalview.datamodel.HiddenColumns;
7 import jalview.datamodel.HiddenSequences;
8 import jalview.datamodel.VisibleColsCollection;
9 import jalview.datamodel.VisibleRowsCollection;
11 public class OverviewDimensionsHideHidden extends OverviewDimensions
13 private ViewportRanges ranges;
15 public OverviewDimensionsHideHidden(ViewportRanges vpranges,
16 boolean showAnnotationPanel)
18 super(vpranges, showAnnotationPanel);
24 public void updateViewportFromMouse(int mousex, int mousey,
25 HiddenSequences hiddenSeqs, HiddenColumns hiddenCols)
43 // Convert x value to residue position
46 // need to determine where scrollCol should be, given x
47 // to do this also need to know width of viewport, and some hidden column
50 // convert x to residues - this is an absolute position
51 int xAsRes = Math.round((float) x * alwidth / width);
53 // get viewport width in residues
54 int vpwidth = ranges.getEndRes() - ranges.getStartRes() + 1;
56 if (xAsRes + vpwidth > alwidth)
58 // went past the end of the alignment, adjust backwards
60 // if last position was before the end of the alignment, need to update
61 if ((scrollCol + vpwidth - 1) < alwidth)
63 xAsRes = alwidth - vpwidth;
73 // Convert y value to sequence position
76 // convert y to residues
77 int yAsSeq = Math.round((float) y * alheight / sequencesHeight);
79 // get viewport height in sequences
80 // add 1 because height includes both endSeq and startSeq
81 int vpheight = ranges.getEndSeq() - ranges.getStartSeq() + 1;
83 if (yAsSeq + vpheight > alheight)
85 // went past the end of the alignment, adjust backwards
86 if ((scrollRow + vpheight - 1) < alheight)
88 yAsSeq = alheight - vpheight;
96 // update scroll values
103 public void setBoxPosition(HiddenSequences hiddenSeqs,
104 HiddenColumns hiddenCols)
106 // work with visible values of startRes and endRes
107 int startRes = ranges.getStartRes();
108 int endRes = ranges.getEndRes();
110 // work with visible values of startSeq and endSeq
111 int startSeq = ranges.getStartSeq();
112 int endSeq = ranges.getEndSeq();
114 setBoxPosition(startRes, endRes, startSeq, endSeq);
118 public AlignmentColsCollectionI getColumns(AlignmentI al)
120 return new VisibleColsCollection(0,
121 ranges.getAbsoluteAlignmentWidth() - 1, al);
125 public AlignmentRowsCollectionI getRows(AlignmentI al)
127 return new VisibleRowsCollection(0,
128 ranges.getAbsoluteAlignmentHeight() - 1, al);
132 protected void resetAlignmentDims()
134 alwidth = ranges.getVisibleAlignmentWidth();
135 alheight = ranges.getVisibleAlignmentHeight();