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 |
|
|
|
|
| 0% |
Uncovered Elements: 65 (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 |
|
|
|
|
| 0% |
Uncovered Elements: 20 (20) |
Complexity: 5 |
Complexity Density: 0.42 |
|
73 |
0 |
public OverviewDimensions(ViewportRanges ranges,... |
74 |
|
boolean showAnnotationPanel) |
75 |
|
{ |
76 |
|
|
77 |
0 |
float initialScale = (float) ranges.getAbsoluteAlignmentWidth() |
78 |
|
/ (float) ranges.getAbsoluteAlignmentHeight(); |
79 |
|
|
80 |
0 |
if (!showAnnotationPanel) |
81 |
|
{ |
82 |
0 |
graphHeight = 0; |
83 |
|
} |
84 |
|
|
85 |
0 |
if (ranges.getAbsoluteAlignmentWidth() > ranges |
86 |
|
.getAbsoluteAlignmentHeight()) |
87 |
|
{ |
88 |
|
|
89 |
0 |
width = MAX_WIDTH; |
90 |
0 |
sequencesHeight = Math.round(MAX_WIDTH / initialScale); |
91 |
0 |
if (sequencesHeight < MIN_SEQ_HEIGHT) |
92 |
|
{ |
93 |
0 |
sequencesHeight = MIN_SEQ_HEIGHT; |
94 |
|
} |
95 |
|
} |
96 |
|
else |
97 |
|
{ |
98 |
|
|
99 |
0 |
width = Math.round(MAX_WIDTH * initialScale); |
100 |
0 |
sequencesHeight = MAX_SEQ_HEIGHT; |
101 |
|
|
102 |
0 |
if (width < MIN_WIDTH) |
103 |
|
{ |
104 |
0 |
width = MIN_WIDTH; |
105 |
|
} |
106 |
|
} |
107 |
|
} |
108 |
|
|
109 |
|
|
110 |
|
|
111 |
|
|
112 |
|
@param |
113 |
|
|
114 |
|
|
|
|
| 0% |
Uncovered Elements: 2 (2) |
Complexity: 1 |
Complexity Density: 0.5 |
|
115 |
0 |
public void drawBox(Graphics g)... |
116 |
|
{ |
117 |
0 |
g.drawRect(boxX, boxY, boxWidth, boxHeight); |
118 |
0 |
g.drawRect(boxX + 1, boxY + 1, boxWidth - 2, boxHeight - 2); |
119 |
|
} |
120 |
|
|
|
|
| 0% |
Uncovered Elements: 1 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
121 |
0 |
public int getBoxX()... |
122 |
|
{ |
123 |
0 |
return boxX; |
124 |
|
} |
125 |
|
|
|
|
| 0% |
Uncovered Elements: 1 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
126 |
0 |
public int getBoxY()... |
127 |
|
{ |
128 |
0 |
return boxY; |
129 |
|
} |
130 |
|
|
|
|
| 0% |
Uncovered Elements: 1 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
131 |
0 |
public int getBoxWidth()... |
132 |
|
{ |
133 |
0 |
return boxWidth; |
134 |
|
} |
135 |
|
|
|
|
| 0% |
Uncovered Elements: 1 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
136 |
0 |
public int getBoxHeight()... |
137 |
|
{ |
138 |
0 |
return boxHeight; |
139 |
|
} |
140 |
|
|
|
|
| 0% |
Uncovered Elements: 1 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
141 |
0 |
public int getWidth()... |
142 |
|
{ |
143 |
0 |
return width; |
144 |
|
} |
145 |
|
|
|
|
| 0% |
Uncovered Elements: 1 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
146 |
0 |
public int getHeight()... |
147 |
|
{ |
148 |
0 |
return sequencesHeight + graphHeight; |
149 |
|
} |
150 |
|
|
|
|
| 0% |
Uncovered Elements: 1 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
151 |
0 |
public int getSequencesHeight()... |
152 |
|
{ |
153 |
0 |
return sequencesHeight; |
154 |
|
} |
155 |
|
|
|
|
| 0% |
Uncovered Elements: 1 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
156 |
0 |
public int getGraphHeight()... |
157 |
|
{ |
158 |
0 |
return graphHeight; |
159 |
|
} |
160 |
|
|
|
|
| 0% |
Uncovered Elements: 2 (2) |
Complexity: 1 |
Complexity Density: 0.5 |
|
161 |
0 |
public float getPixelsPerCol()... |
162 |
|
{ |
163 |
0 |
resetAlignmentDims(); |
164 |
0 |
return 1 / widthRatio; |
165 |
|
} |
166 |
|
|
|
|
| 0% |
Uncovered Elements: 2 (2) |
Complexity: 1 |
Complexity Density: 0.5 |
|
167 |
0 |
public float getPixelsPerSeq()... |
168 |
|
{ |
169 |
0 |
resetAlignmentDims(); |
170 |
0 |
return 1 / heightRatio; |
171 |
|
} |
172 |
|
|
|
|
| 0% |
Uncovered Elements: 4 (4) |
Complexity: 2 |
Complexity Density: 1 |
|
173 |
0 |
public void setWidth(int w)... |
174 |
|
{ |
175 |
0 |
width = w < 1 ? 1 : w; |
176 |
0 |
widthRatio = (float) alwidth / width; |
177 |
|
} |
178 |
|
|
|
|
| 0% |
Uncovered Elements: 4 (4) |
Complexity: 2 |
Complexity Density: 1 |
|
179 |
0 |
public void setHeight(int h)... |
180 |
|
{ |
181 |
0 |
sequencesHeight = (h < 1 ? 1 : h) - graphHeight; |
182 |
0 |
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 |
|
|
|
|
| 0% |
Uncovered Elements: 6 (6) |
Complexity: 1 |
Complexity Density: 0.17 |
|
275 |
0 |
protected void setBoxPosition(int startRes, int startSeq, int vpwidth,... |
276 |
|
int vpheight) |
277 |
|
{ |
278 |
0 |
resetAlignmentDims(); |
279 |
|
|
280 |
|
|
281 |
0 |
int xPos = Math.min(startRes, alwidth - vpwidth + 1); |
282 |
0 |
boxX = Math.round(xPos / widthRatio); |
283 |
0 |
boxY = Math.round(startSeq / heightRatio); |
284 |
|
|
285 |
|
|
286 |
0 |
boxWidth = Math.round(vpwidth / widthRatio); |
287 |
|
|
288 |
|
|
289 |
0 |
boxHeight = Math.round(vpheight / heightRatio); |
290 |
|
} |
291 |
|
|
292 |
|
|
293 |
|
|
294 |
|
|
295 |
|
@param |
296 |
|
|
297 |
|
@param |
298 |
|
|
299 |
|
@return |
300 |
|
|
|
|
| 0% |
Uncovered Elements: 1 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
301 |
0 |
public boolean isPositionInBox(int x, int y)... |
302 |
|
{ |
303 |
0 |
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 |
|
} |