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 java.awt.Graphics; |
24 |
|
|
25 |
|
import jalview.api.AlignmentColsCollectionI; |
26 |
|
import jalview.api.AlignmentRowsCollectionI; |
27 |
|
import jalview.datamodel.AlignmentI; |
28 |
|
import jalview.datamodel.HiddenColumns; |
29 |
|
import jalview.datamodel.HiddenSequences; |
30 |
|
|
|
|
| 96.9% |
Uncovered Elements: 2 (65) |
Complexity: 22 |
Complexity Density: 0.59 |
|
31 |
|
public abstract class OverviewDimensions |
32 |
|
{ |
33 |
|
protected static final int MAX_WIDTH = 400; |
34 |
|
|
35 |
|
protected static final int MIN_WIDTH = 120; |
36 |
|
|
37 |
|
protected static final int MIN_SEQ_HEIGHT = 40; |
38 |
|
|
39 |
|
protected static final int MAX_SEQ_HEIGHT = 300; |
40 |
|
|
41 |
|
private static final int DEFAULT_GRAPH_HEIGHT = 20; |
42 |
|
|
43 |
|
protected int width; |
44 |
|
|
45 |
|
protected int sequencesHeight; |
46 |
|
|
47 |
|
protected int graphHeight = DEFAULT_GRAPH_HEIGHT; |
48 |
|
|
49 |
|
protected int boxX = -1; |
50 |
|
|
51 |
|
protected int boxY = -1; |
52 |
|
|
53 |
|
protected int boxWidth = -1; |
54 |
|
|
55 |
|
protected int boxHeight = -1; |
56 |
|
|
57 |
|
protected int alwidth; |
58 |
|
|
59 |
|
protected int alheight; |
60 |
|
|
61 |
|
protected float widthRatio; |
62 |
|
|
63 |
|
protected float heightRatio; |
64 |
|
|
65 |
|
|
66 |
|
|
67 |
|
|
68 |
|
@param |
69 |
|
|
70 |
|
@param |
71 |
|
|
72 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (20) |
Complexity: 5 |
Complexity Density: 0.42 |
|
73 |
83 |
public OverviewDimensions(ViewportRanges ranges,... |
74 |
|
boolean showAnnotationPanel) |
75 |
|
{ |
76 |
|
|
77 |
83 |
float initialScale = (float) ranges.getAbsoluteAlignmentWidth() |
78 |
|
/ (float) ranges.getAbsoluteAlignmentHeight(); |
79 |
|
|
80 |
83 |
if (!showAnnotationPanel) |
81 |
|
{ |
82 |
2 |
graphHeight = 0; |
83 |
|
} |
84 |
|
|
85 |
83 |
if (ranges.getAbsoluteAlignmentWidth() > ranges |
86 |
|
.getAbsoluteAlignmentHeight()) |
87 |
|
{ |
88 |
|
|
89 |
42 |
width = MAX_WIDTH; |
90 |
42 |
sequencesHeight = Math.round(MAX_WIDTH / initialScale); |
91 |
42 |
if (sequencesHeight < MIN_SEQ_HEIGHT) |
92 |
|
{ |
93 |
25 |
sequencesHeight = MIN_SEQ_HEIGHT; |
94 |
|
} |
95 |
|
} |
96 |
|
else |
97 |
|
{ |
98 |
|
|
99 |
41 |
width = Math.round(MAX_WIDTH * initialScale); |
100 |
41 |
sequencesHeight = MAX_SEQ_HEIGHT; |
101 |
|
|
102 |
41 |
if (width < MIN_WIDTH) |
103 |
|
{ |
104 |
4 |
width = MIN_WIDTH; |
105 |
|
} |
106 |
|
} |
107 |
|
} |
108 |
|
|
109 |
|
|
110 |
|
|
111 |
|
|
112 |
|
@param |
113 |
|
|
114 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (2) |
Complexity: 1 |
Complexity Density: 0.5 |
|
115 |
21 |
public void drawBox(Graphics g)... |
116 |
|
{ |
117 |
21 |
g.drawRect(boxX, boxY, boxWidth, boxHeight); |
118 |
21 |
g.drawRect(boxX + 1, boxY + 1, boxWidth - 2, boxHeight - 2); |
119 |
|
} |
120 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
121 |
320 |
public int getBoxX()... |
122 |
|
{ |
123 |
320 |
return boxX; |
124 |
|
} |
125 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
126 |
311 |
public int getBoxY()... |
127 |
|
{ |
128 |
311 |
return boxY; |
129 |
|
} |
130 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
131 |
315 |
public int getBoxWidth()... |
132 |
|
{ |
133 |
315 |
return boxWidth; |
134 |
|
} |
135 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
136 |
297 |
public int getBoxHeight()... |
137 |
|
{ |
138 |
297 |
return boxHeight; |
139 |
|
} |
140 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
141 |
1245 |
public int getWidth()... |
142 |
|
{ |
143 |
1245 |
return width; |
144 |
|
} |
145 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
146 |
1120 |
public int getHeight()... |
147 |
|
{ |
148 |
1120 |
return sequencesHeight + graphHeight; |
149 |
|
} |
150 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
151 |
579 |
public int getSequencesHeight()... |
152 |
|
{ |
153 |
579 |
return sequencesHeight; |
154 |
|
} |
155 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
156 |
498 |
public int getGraphHeight()... |
157 |
|
{ |
158 |
498 |
return graphHeight; |
159 |
|
} |
160 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (2) |
Complexity: 1 |
Complexity Density: 0.5 |
|
161 |
245 |
public float getPixelsPerCol()... |
162 |
|
{ |
163 |
245 |
resetAlignmentDims(); |
164 |
245 |
return 1 / widthRatio; |
165 |
|
} |
166 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (2) |
Complexity: 1 |
Complexity Density: 0.5 |
|
167 |
245 |
public float getPixelsPerSeq()... |
168 |
|
{ |
169 |
245 |
resetAlignmentDims(); |
170 |
245 |
return 1 / heightRatio; |
171 |
|
} |
172 |
|
|
|
|
| 75% |
Uncovered Elements: 1 (4) |
Complexity: 2 |
Complexity Density: 1 |
|
173 |
438 |
public void setWidth(int w)... |
174 |
|
{ |
175 |
438 |
width = w < 1 ? 1 : w; |
176 |
438 |
widthRatio = (float) alwidth / width; |
177 |
|
} |
178 |
|
|
|
|
| 75% |
Uncovered Elements: 1 (4) |
Complexity: 2 |
Complexity Density: 1 |
|
179 |
438 |
public void setHeight(int h)... |
180 |
|
{ |
181 |
438 |
sequencesHeight = (h < 1 ? 1 : h) - graphHeight; |
182 |
438 |
heightRatio = (float) alheight / sequencesHeight; |
183 |
|
} |
184 |
|
|
185 |
|
|
186 |
|
|
187 |
|
|
188 |
|
@param |
189 |
|
|
190 |
|
@param |
191 |
|
|
192 |
|
@param |
193 |
|
|
194 |
|
@param |
195 |
|
|
196 |
|
|
197 |
|
public abstract void updateViewportFromMouse(int mousex, int mousey, |
198 |
|
HiddenSequences hiddenSeqs, HiddenColumns hiddenCols); |
199 |
|
|
200 |
|
|
201 |
|
|
202 |
|
|
203 |
|
@param |
204 |
|
|
205 |
|
@param |
206 |
|
|
207 |
|
@param |
208 |
|
|
209 |
|
@param |
210 |
|
|
211 |
|
|
212 |
|
public abstract void adjustViewportFromMouse(int mousex, int mousey, |
213 |
|
HiddenSequences hiddenSeqs, HiddenColumns hiddenCols); |
214 |
|
|
215 |
|
|
216 |
|
|
217 |
|
|
218 |
|
|
219 |
|
@param |
220 |
|
|
221 |
|
@param |
222 |
|
|
223 |
|
@param |
224 |
|
|
225 |
|
@param |
226 |
|
|
227 |
|
|
228 |
|
public abstract void setDragPoint(int x, int y, |
229 |
|
HiddenSequences hiddenSeqs, HiddenColumns hiddenCols); |
230 |
|
|
231 |
|
|
232 |
|
|
233 |
|
|
234 |
|
|
235 |
|
protected abstract void updateViewportFromTopLeft(int leftx, int topy, |
236 |
|
HiddenSequences hiddenSeqs, HiddenColumns hiddenCols); |
237 |
|
|
238 |
|
|
239 |
|
|
240 |
|
|
241 |
|
@param |
242 |
|
|
243 |
|
@param |
244 |
|
|
245 |
|
|
246 |
|
public abstract void setBoxPosition(HiddenSequences hiddenSeqs, |
247 |
|
HiddenColumns hiddenCols); |
248 |
|
|
249 |
|
|
250 |
|
|
251 |
|
|
252 |
|
@param |
253 |
|
|
254 |
|
@return |
255 |
|
|
256 |
|
public abstract AlignmentColsCollectionI getColumns(AlignmentI al); |
257 |
|
|
258 |
|
|
259 |
|
|
260 |
|
|
261 |
|
@param |
262 |
|
|
263 |
|
@return |
264 |
|
|
265 |
|
public abstract AlignmentRowsCollectionI getRows(AlignmentI al); |
266 |
|
|
267 |
|
|
268 |
|
|
269 |
|
|
270 |
|
protected abstract void resetAlignmentDims(); |
271 |
|
|
272 |
|
|
273 |
|
|
274 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (6) |
Complexity: 1 |
Complexity Density: 0.17 |
|
275 |
399 |
protected void setBoxPosition(int startRes, int startSeq, int vpwidth,... |
276 |
|
int vpheight) |
277 |
|
{ |
278 |
399 |
resetAlignmentDims(); |
279 |
|
|
280 |
|
|
281 |
399 |
int xPos = Math.min(startRes, alwidth - vpwidth + 1); |
282 |
399 |
boxX = Math.round(xPos / widthRatio); |
283 |
399 |
boxY = Math.round(startSeq / heightRatio); |
284 |
|
|
285 |
|
|
286 |
399 |
boxWidth = Math.round(vpwidth / widthRatio); |
287 |
|
|
288 |
|
|
289 |
399 |
boxHeight = Math.round(vpheight / heightRatio); |
290 |
|
} |
291 |
|
|
292 |
|
|
293 |
|
|
294 |
|
|
295 |
|
@param |
296 |
|
|
297 |
|
@param |
298 |
|
|
299 |
|
@return |
300 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
301 |
42 |
public boolean isPositionInBox(int x, int y)... |
302 |
|
{ |
303 |
42 |
return (x > boxX && y > boxY && x < boxX + boxWidth |
304 |
|
&& y < boxY + boxHeight); |
305 |
|
} |
306 |
|
|
307 |
|
|
308 |
|
|
309 |
|
|
310 |
|
protected abstract int getLeftXFromCentreX(int mousex, |
311 |
|
HiddenColumns hidden); |
312 |
|
|
313 |
|
|
314 |
|
|
315 |
|
|
316 |
|
protected abstract int getTopYFromCentreY(int mousey, |
317 |
|
HiddenSequences hidden); |
318 |
|
|
319 |
|
} |