1 |
|
|
2 |
|
|
3 |
|
|
4 |
|
|
5 |
|
|
6 |
|
|
7 |
|
|
8 |
|
|
9 |
|
|
10 |
|
|
11 |
|
|
12 |
|
|
13 |
|
|
14 |
|
|
15 |
|
|
16 |
|
|
17 |
|
|
18 |
|
|
19 |
|
|
20 |
|
|
21 |
|
package jalview.viewmodel; |
22 |
|
|
23 |
|
import jalview.api.AlignmentColsCollectionI; |
24 |
|
import jalview.api.AlignmentRowsCollectionI; |
25 |
|
import jalview.datamodel.AlignmentI; |
26 |
|
import jalview.datamodel.AllColsCollection; |
27 |
|
import jalview.datamodel.AllRowsCollection; |
28 |
|
import jalview.datamodel.HiddenColumns; |
29 |
|
import jalview.datamodel.HiddenSequences; |
30 |
|
|
|
|
| 92.9% |
Uncovered Elements: 6 (84) |
Complexity: 18 |
Complexity Density: 0.31 |
|
31 |
|
public class OverviewDimensionsShowHidden extends OverviewDimensions |
32 |
|
{ |
33 |
|
private ViewportRanges ranges; |
34 |
|
|
35 |
|
private int xdiff; |
36 |
|
|
37 |
|
|
38 |
|
private int ydiff; |
39 |
|
|
40 |
|
|
41 |
|
|
42 |
|
|
43 |
|
|
44 |
|
@param |
45 |
|
|
46 |
|
@param |
47 |
|
|
48 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (3) |
Complexity: 1 |
Complexity Density: 0.33 |
|
49 |
29 |
public OverviewDimensionsShowHidden(ViewportRanges vpranges,... |
50 |
|
boolean showAnnotationPanel) |
51 |
|
{ |
52 |
29 |
super(vpranges, showAnnotationPanel); |
53 |
29 |
ranges = vpranges; |
54 |
29 |
resetAlignmentDims(); |
55 |
|
} |
56 |
|
|
57 |
|
|
58 |
|
|
59 |
|
|
60 |
|
@param |
61 |
|
|
62 |
|
@param |
63 |
|
|
64 |
|
@param |
65 |
|
|
66 |
|
@param |
67 |
|
|
68 |
|
@param |
69 |
|
|
70 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (9) |
Complexity: 1 |
Complexity Density: 0.11 |
|
71 |
54 |
@Override... |
72 |
|
public void updateViewportFromMouse(int mousex, int mousey, |
73 |
|
HiddenSequences hiddenSeqs, HiddenColumns hiddenCols) |
74 |
|
{ |
75 |
54 |
resetAlignmentDims(); |
76 |
|
|
77 |
|
|
78 |
|
|
79 |
54 |
int xAsRes = getLeftXFromCentreX(mousex, hiddenCols); |
80 |
54 |
int yAsSeq = getTopYFromCentreY(mousey, hiddenSeqs); |
81 |
|
|
82 |
|
|
83 |
54 |
int visXAsRes = hiddenCols.absoluteToVisibleColumn(xAsRes); |
84 |
54 |
yAsSeq = hiddenSeqs.adjustForHiddenSeqs( |
85 |
|
hiddenSeqs.findIndexWithoutHiddenSeqs(yAsSeq)); |
86 |
54 |
yAsSeq = Math.max(yAsSeq, 0); |
87 |
54 |
int visYAsSeq = hiddenSeqs.findIndexWithoutHiddenSeqs(yAsSeq); |
88 |
54 |
visYAsSeq = Math.max(visYAsSeq, 0); |
89 |
|
|
90 |
|
|
91 |
54 |
updateViewportFromTopLeft(visXAsRes, visYAsSeq, hiddenSeqs, hiddenCols); |
92 |
|
} |
93 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (6) |
Complexity: 1 |
Complexity Density: 0.17 |
|
94 |
3 |
@Override... |
95 |
|
public void adjustViewportFromMouse(int mousex, int mousey, |
96 |
|
HiddenSequences hiddenSeqs, HiddenColumns hiddenCols) |
97 |
|
{ |
98 |
3 |
resetAlignmentDims(); |
99 |
|
|
100 |
|
|
101 |
|
|
102 |
|
|
103 |
|
|
104 |
3 |
int vpx = Math.round((float) mousex * alwidth / width); |
105 |
3 |
int visXAsRes = hiddenCols.absoluteToVisibleColumn(vpx) + xdiff; |
106 |
|
|
107 |
3 |
int vpy = Math.round(mousey * heightRatio); |
108 |
3 |
int visYAsRes = hiddenSeqs.findIndexWithoutHiddenSeqs(vpy) + ydiff; |
109 |
|
|
110 |
|
|
111 |
3 |
updateViewportFromTopLeft(visXAsRes, visYAsRes, hiddenSeqs, hiddenCols); |
112 |
|
} |
113 |
|
|
114 |
|
|
115 |
|
@inheritDoc |
116 |
|
|
117 |
|
|
|
|
| 82.9% |
Uncovered Elements: 6 (35) |
Complexity: 8 |
Complexity Density: 0.38 |
|
118 |
57 |
@Override... |
119 |
|
protected void updateViewportFromTopLeft(int leftx, int topy, |
120 |
|
HiddenSequences hiddenSeqs, HiddenColumns hiddenCols) |
121 |
|
{ |
122 |
57 |
int visXAsRes = leftx; |
123 |
57 |
int visYAsSeq = topy; |
124 |
|
|
125 |
57 |
if (visXAsRes < 0) |
126 |
|
{ |
127 |
43 |
visXAsRes = 0; |
128 |
|
} |
129 |
|
|
130 |
57 |
if (visYAsSeq < 0) |
131 |
|
{ |
132 |
0 |
visYAsSeq = 0; |
133 |
|
} |
134 |
|
|
135 |
57 |
if (ranges.isWrappedMode()) |
136 |
|
{ |
137 |
3 |
visYAsSeq = 0; |
138 |
|
} |
139 |
|
|
140 |
|
|
141 |
|
|
142 |
|
|
143 |
57 |
int vpwidth = ranges.getViewportWidth(); |
144 |
|
|
145 |
|
|
146 |
57 |
int visAlignWidth = hiddenCols.absoluteToVisibleColumn(alwidth - 1); |
147 |
57 |
if (visXAsRes + vpwidth - 1 > visAlignWidth) |
148 |
|
{ |
149 |
|
|
150 |
|
|
151 |
|
|
152 |
5 |
if (ranges.getEndRes() < visAlignWidth) |
153 |
|
{ |
154 |
5 |
visXAsRes = hiddenCols.absoluteToVisibleColumn(hiddenCols |
155 |
|
.offsetByVisibleColumns(-(vpwidth - 1), alwidth - 1)); |
156 |
|
} |
157 |
|
else |
158 |
|
{ |
159 |
0 |
visXAsRes = ranges.getStartRes(); |
160 |
|
} |
161 |
|
} |
162 |
|
|
163 |
|
|
164 |
|
|
165 |
|
|
166 |
57 |
int vpheight = ranges.getViewportHeight(); |
167 |
|
|
168 |
|
|
169 |
57 |
int visAlignHeight = hiddenSeqs.findIndexWithoutHiddenSeqs(alheight); |
170 |
|
|
171 |
57 |
if (visYAsSeq + vpheight - 1 > visAlignHeight) |
172 |
|
{ |
173 |
|
|
174 |
3 |
if (ranges.getEndSeq() < visAlignHeight) |
175 |
|
{ |
176 |
3 |
visYAsSeq = hiddenSeqs.findIndexWithoutHiddenSeqs( |
177 |
|
hiddenSeqs.subtractVisibleRows(vpheight - 1, alheight - 1)); |
178 |
|
} |
179 |
|
else |
180 |
|
{ |
181 |
0 |
visYAsSeq = ranges.getStartSeq(); |
182 |
|
} |
183 |
|
} |
184 |
|
|
185 |
|
|
186 |
57 |
ranges.setStartResAndSeq(visXAsRes, visYAsSeq); |
187 |
|
} |
188 |
|
|
189 |
|
|
190 |
|
|
191 |
|
|
192 |
|
|
193 |
|
@param |
194 |
|
|
195 |
|
@param |
196 |
|
|
197 |
|
@param |
198 |
|
|
199 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (5) |
Complexity: 1 |
Complexity Density: 0.2 |
|
200 |
121 |
@Override... |
201 |
|
public void setBoxPosition(HiddenSequences hiddenSeqs, |
202 |
|
HiddenColumns hiddenCols) |
203 |
|
{ |
204 |
|
|
205 |
121 |
int startRes = hiddenCols.visibleToAbsoluteColumn(ranges.getStartRes()); |
206 |
121 |
int endRes = hiddenCols.visibleToAbsoluteColumn(ranges.getEndRes()); |
207 |
|
|
208 |
|
|
209 |
121 |
int startSeq = hiddenSeqs.adjustForHiddenSeqs(ranges.getStartSeq()); |
210 |
121 |
int endSeq = hiddenSeqs.adjustForHiddenSeqs(ranges.getEndSeq()); |
211 |
|
|
212 |
121 |
setBoxPosition(startRes, startSeq, endRes - startRes + 1, |
213 |
|
endSeq - startSeq + 1); |
214 |
|
} |
215 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
216 |
32 |
@Override... |
217 |
|
public AlignmentColsCollectionI getColumns(AlignmentI al) |
218 |
|
{ |
219 |
32 |
return new AllColsCollection(0, ranges.getAbsoluteAlignmentWidth() - 1, |
220 |
|
al); |
221 |
|
} |
222 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
223 |
16 |
@Override... |
224 |
|
public AlignmentRowsCollectionI getRows(AlignmentI al) |
225 |
|
{ |
226 |
16 |
return new AllRowsCollection(0, ranges.getAbsoluteAlignmentHeight() - 1, |
227 |
|
al); |
228 |
|
} |
229 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (4) |
Complexity: 1 |
Complexity Density: 0.25 |
|
230 |
242 |
@Override... |
231 |
|
protected void resetAlignmentDims() |
232 |
|
{ |
233 |
242 |
alwidth = ranges.getAbsoluteAlignmentWidth(); |
234 |
242 |
alheight = ranges.getAbsoluteAlignmentHeight(); |
235 |
|
|
236 |
242 |
widthRatio = (float) alwidth / width; |
237 |
242 |
heightRatio = (float) alheight / sequencesHeight; |
238 |
|
} |
239 |
|
|
240 |
|
|
241 |
|
@inheritDoc |
242 |
|
|
243 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (2) |
Complexity: 1 |
Complexity Density: 0.5 |
|
244 |
54 |
@Override... |
245 |
|
protected int getLeftXFromCentreX(int mousex, HiddenColumns hidden) |
246 |
|
{ |
247 |
54 |
int vpx = Math.round((float) mousex * alwidth / width); |
248 |
54 |
return hidden.offsetByVisibleColumns(-ranges.getViewportWidth() / 2, |
249 |
|
vpx); |
250 |
|
} |
251 |
|
|
252 |
|
|
253 |
|
@inheritDoc |
254 |
|
|
255 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (2) |
Complexity: 1 |
Complexity Density: 0.5 |
|
256 |
54 |
@Override... |
257 |
|
protected int getTopYFromCentreY(int mousey, HiddenSequences hidden) |
258 |
|
{ |
259 |
54 |
int vpy = Math.round(mousey * heightRatio); |
260 |
54 |
return hidden.subtractVisibleRows(ranges.getViewportHeight() / 2, vpy); |
261 |
|
} |
262 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (5) |
Complexity: 1 |
Complexity Density: 0.2 |
|
263 |
3 |
@Override... |
264 |
|
public void setDragPoint(int x, int y, HiddenSequences hiddenSeqs, |
265 |
|
HiddenColumns hiddenCols) |
266 |
|
{ |
267 |
3 |
resetAlignmentDims(); |
268 |
|
|
269 |
|
|
270 |
|
|
271 |
3 |
int vpx = Math.round(x * widthRatio); |
272 |
3 |
int vpy = Math.round(y * heightRatio); |
273 |
|
|
274 |
3 |
xdiff = ranges.getStartRes() - hiddenCols.absoluteToVisibleColumn(vpx); |
275 |
3 |
ydiff = ranges.getStartSeq() |
276 |
|
- hiddenSeqs.findIndexWithoutHiddenSeqs(vpy); |
277 |
|
} |
278 |
|
|
279 |
|
} |