1 |
|
|
2 |
|
|
3 |
|
|
4 |
|
|
5 |
|
|
6 |
|
|
7 |
|
|
8 |
|
|
9 |
|
|
10 |
|
|
11 |
|
|
12 |
|
|
13 |
|
|
14 |
|
|
15 |
|
|
16 |
|
|
17 |
|
|
18 |
|
|
19 |
|
|
20 |
|
|
21 |
|
package jalview.schemes; |
22 |
|
|
23 |
|
import java.util.Locale; |
24 |
|
|
25 |
|
import jalview.api.FeatureColourI; |
26 |
|
import jalview.datamodel.SequenceFeature; |
27 |
|
import jalview.datamodel.features.FeatureMatcher; |
28 |
|
import jalview.util.ColorUtils; |
29 |
|
import jalview.util.Format; |
30 |
|
import jalview.util.MessageManager; |
31 |
|
|
32 |
|
import java.awt.Color; |
33 |
|
import java.util.StringTokenizer; |
34 |
|
|
35 |
|
|
36 |
|
|
37 |
|
|
38 |
|
|
39 |
|
|
40 |
|
|
41 |
|
|
42 |
|
|
43 |
|
|
44 |
|
|
45 |
|
|
46 |
|
|
47 |
|
|
48 |
|
|
49 |
|
|
50 |
|
|
51 |
|
|
52 |
|
|
53 |
|
|
54 |
|
|
|
|
| 90.1% |
Uncovered Elements: 47 (475) |
Complexity: 124 |
Complexity Density: 0.44 |
|
55 |
|
public class FeatureColour implements FeatureColourI |
56 |
|
{ |
57 |
|
private static final String I18N_LABEL = MessageManager |
58 |
|
.getString("label.label"); |
59 |
|
|
60 |
|
private static final String I18N_SCORE = MessageManager |
61 |
|
.getString("label.score"); |
62 |
|
|
63 |
|
private static final String ABSOLUTE = "abso"; |
64 |
|
|
65 |
|
private static final String ABOVE = "above"; |
66 |
|
|
67 |
|
private static final String BELOW = "below"; |
68 |
|
|
69 |
|
|
70 |
|
|
71 |
|
|
72 |
|
private static final String LABEL = "label"; |
73 |
|
|
74 |
|
private static final String SCORE = "score"; |
75 |
|
|
76 |
|
private static final String ATTRIBUTE = "attribute"; |
77 |
|
|
78 |
|
private static final String NO_VALUE_MIN = "noValueMin"; |
79 |
|
|
80 |
|
private static final String NO_VALUE_MAX = "noValueMax"; |
81 |
|
|
82 |
|
private static final String NO_VALUE_NONE = "noValueNone"; |
83 |
|
|
84 |
|
static final Color DEFAULT_NO_COLOUR = null; |
85 |
|
|
86 |
|
private static final String BAR = "|"; |
87 |
|
|
88 |
|
final private Color colour; |
89 |
|
|
90 |
|
final private Color minColour; |
91 |
|
|
92 |
|
final private Color maxColour; |
93 |
|
|
94 |
|
|
95 |
|
|
96 |
|
|
97 |
|
|
98 |
|
final private Color noColour; |
99 |
|
|
100 |
|
|
101 |
|
|
102 |
|
|
103 |
|
|
104 |
|
private boolean graduatedColour; |
105 |
|
|
106 |
|
|
107 |
|
|
108 |
|
|
109 |
|
|
110 |
|
private boolean colourByLabel; |
111 |
|
|
112 |
|
|
113 |
|
|
114 |
|
|
115 |
|
|
116 |
|
private String[] attributeName; |
117 |
|
|
118 |
|
private float threshold; |
119 |
|
|
120 |
|
private float base; |
121 |
|
|
122 |
|
private float range; |
123 |
|
|
124 |
|
private boolean belowThreshold; |
125 |
|
|
126 |
|
private boolean aboveThreshold; |
127 |
|
|
128 |
|
private boolean isHighToLow; |
129 |
|
|
130 |
|
private boolean autoScaled; |
131 |
|
|
132 |
|
final private float minRed; |
133 |
|
|
134 |
|
final private float minGreen; |
135 |
|
|
136 |
|
final private float minBlue; |
137 |
|
|
138 |
|
final private float deltaRed; |
139 |
|
|
140 |
|
final private float deltaGreen; |
141 |
|
|
142 |
|
final private float deltaBlue; |
143 |
|
|
144 |
|
|
145 |
|
|
146 |
|
|
147 |
|
|
148 |
|
|
149 |
|
|
150 |
|
|
151 |
|
|
152 |
|
|
153 |
|
|
154 |
|
|
155 |
|
|
156 |
|
|
157 |
|
|
158 |
|
|
159 |
|
|
160 |
|
|
161 |
|
|
162 |
|
|
163 |
|
|
164 |
|
|
165 |
|
|
166 |
|
|
167 |
|
|
168 |
|
|
169 |
|
|
170 |
|
|
171 |
|
|
172 |
|
|
173 |
|
@param |
174 |
|
@return |
175 |
|
@throws |
176 |
|
|
177 |
|
|
|
|
| 85.2% |
Uncovered Elements: 27 (183) |
Complexity: 42 |
Complexity Density: 0.38 |
|
178 |
70 |
public static FeatureColourI parseJalviewFeatureColour(String descriptor)... |
179 |
|
{ |
180 |
70 |
StringTokenizer gcol = new StringTokenizer(descriptor, BAR, true); |
181 |
70 |
float min = Float.MIN_VALUE; |
182 |
70 |
float max = Float.MAX_VALUE; |
183 |
70 |
boolean byLabel = false; |
184 |
70 |
boolean byAttribute = false; |
185 |
70 |
String attName = null; |
186 |
70 |
String mincol = null; |
187 |
70 |
String maxcol = null; |
188 |
|
|
189 |
|
|
190 |
|
|
191 |
|
|
192 |
|
|
193 |
70 |
String nextToken = gcol.nextToken(); |
194 |
70 |
if (nextToken == BAR) |
195 |
|
{ |
196 |
0 |
throw new IllegalArgumentException( |
197 |
|
"Expected either 'label' or a colour specification in the line: " |
198 |
|
+ descriptor); |
199 |
|
} |
200 |
70 |
if (nextToken.toLowerCase(Locale.ROOT).startsWith(LABEL)) |
201 |
|
{ |
202 |
2 |
byLabel = true; |
203 |
|
|
204 |
2 |
mincol = (gcol.hasMoreTokens() ? gcol.nextToken() : null); |
205 |
2 |
mincol = (gcol.hasMoreTokens() ? gcol.nextToken() : null); |
206 |
|
} |
207 |
68 |
else if (nextToken.toLowerCase(Locale.ROOT).startsWith(SCORE)) |
208 |
|
{ |
209 |
1 |
mincol = (gcol.hasMoreTokens() ? gcol.nextToken() : null); |
210 |
1 |
mincol = (gcol.hasMoreTokens() ? gcol.nextToken() : null); |
211 |
|
} |
212 |
67 |
else if (nextToken.toLowerCase(Locale.ROOT).startsWith(ATTRIBUTE)) |
213 |
|
{ |
214 |
4 |
byAttribute = true; |
215 |
4 |
attName = (gcol.hasMoreTokens() ? gcol.nextToken() : null); |
216 |
4 |
attName = (gcol.hasMoreTokens() ? gcol.nextToken() : null); |
217 |
4 |
mincol = (gcol.hasMoreTokens() ? gcol.nextToken() : null); |
218 |
4 |
mincol = (gcol.hasMoreTokens() ? gcol.nextToken() : null); |
219 |
|
} |
220 |
|
else |
221 |
|
{ |
222 |
63 |
mincol = nextToken; |
223 |
|
} |
224 |
|
|
225 |
|
|
226 |
|
|
227 |
|
|
228 |
|
|
229 |
70 |
if (!gcol.hasMoreTokens()) |
230 |
|
{ |
231 |
55 |
if (byLabel || byAttribute) |
232 |
|
{ |
233 |
2 |
FeatureColourI fc = new FeatureColour(); |
234 |
2 |
fc.setColourByLabel(true); |
235 |
2 |
if (byAttribute) |
236 |
|
{ |
237 |
1 |
fc.setAttributeName( |
238 |
|
FeatureMatcher.fromAttributeDisplayName(attName)); |
239 |
|
} |
240 |
2 |
return fc; |
241 |
|
} |
242 |
|
|
243 |
53 |
Color colour = ColorUtils.parseColourString(descriptor); |
244 |
53 |
if (colour == null) |
245 |
|
{ |
246 |
1 |
throw new IllegalArgumentException( |
247 |
|
"Invalid colour descriptor: " + descriptor); |
248 |
|
} |
249 |
52 |
return new FeatureColour(colour); |
250 |
|
} |
251 |
|
|
252 |
|
|
253 |
|
|
254 |
|
|
255 |
|
|
256 |
|
|
257 |
|
|
258 |
|
|
259 |
|
|
260 |
|
|
261 |
15 |
boolean autoScaled = true; |
262 |
15 |
String tok = null, minval, maxval; |
263 |
15 |
String noValueColour = NO_VALUE_MIN; |
264 |
|
|
265 |
15 |
if (mincol != null) |
266 |
|
{ |
267 |
|
|
268 |
15 |
if (mincol.equals(BAR)) |
269 |
|
{ |
270 |
2 |
mincol = null; |
271 |
|
} |
272 |
|
else |
273 |
|
{ |
274 |
13 |
gcol.nextToken(); |
275 |
|
} |
276 |
15 |
maxcol = gcol.nextToken(); |
277 |
15 |
if (maxcol.equals(BAR)) |
278 |
|
{ |
279 |
2 |
maxcol = null; |
280 |
|
} |
281 |
|
else |
282 |
|
{ |
283 |
13 |
gcol.nextToken(); |
284 |
|
} |
285 |
15 |
tok = gcol.nextToken(); |
286 |
|
|
287 |
|
|
288 |
|
|
289 |
|
|
290 |
|
|
291 |
15 |
if (tok.equalsIgnoreCase(NO_VALUE_MIN)) |
292 |
|
{ |
293 |
1 |
tok = gcol.nextToken(); |
294 |
1 |
tok = gcol.nextToken(); |
295 |
|
} |
296 |
14 |
else if (tok.equalsIgnoreCase(NO_VALUE_MAX)) |
297 |
|
{ |
298 |
1 |
noValueColour = NO_VALUE_MAX; |
299 |
1 |
tok = gcol.nextToken(); |
300 |
1 |
tok = gcol.nextToken(); |
301 |
|
} |
302 |
13 |
else if (tok.equalsIgnoreCase(NO_VALUE_NONE)) |
303 |
|
{ |
304 |
1 |
noValueColour = NO_VALUE_NONE; |
305 |
1 |
tok = gcol.nextToken(); |
306 |
1 |
tok = gcol.nextToken(); |
307 |
|
} |
308 |
|
|
309 |
15 |
gcol.nextToken(); |
310 |
15 |
if (tok.toLowerCase(Locale.ROOT).startsWith(ABSOLUTE)) |
311 |
|
{ |
312 |
2 |
minval = gcol.nextToken(); |
313 |
2 |
gcol.nextToken(); |
314 |
2 |
autoScaled = false; |
315 |
|
} |
316 |
|
else |
317 |
|
{ |
318 |
13 |
minval = tok; |
319 |
|
} |
320 |
15 |
maxval = gcol.nextToken(); |
321 |
15 |
if (gcol.hasMoreTokens()) |
322 |
|
{ |
323 |
9 |
gcol.nextToken(); |
324 |
|
} |
325 |
15 |
try |
326 |
|
{ |
327 |
15 |
if (minval.length() > 0) |
328 |
|
{ |
329 |
15 |
min = Float.valueOf(minval).floatValue(); |
330 |
|
} |
331 |
|
} catch (Exception e) |
332 |
|
{ |
333 |
1 |
throw new IllegalArgumentException( |
334 |
|
"Couldn't parse the minimum value for graduated colour ('" |
335 |
|
+ minval + "')"); |
336 |
|
} |
337 |
14 |
try |
338 |
|
{ |
339 |
14 |
if (maxval.length() > 0) |
340 |
|
{ |
341 |
14 |
max = Float.valueOf(maxval).floatValue(); |
342 |
|
} |
343 |
|
} catch (Exception e) |
344 |
|
{ |
345 |
0 |
throw new IllegalArgumentException( |
346 |
|
"Couldn't parse the maximum value for graduated colour (" |
347 |
|
+ descriptor + ")"); |
348 |
|
} |
349 |
|
} |
350 |
|
else |
351 |
|
{ |
352 |
|
|
353 |
|
|
354 |
|
|
355 |
|
|
356 |
0 |
mincol = "white"; |
357 |
0 |
maxcol = "black"; |
358 |
0 |
byLabel = true; |
359 |
|
} |
360 |
|
|
361 |
|
|
362 |
|
|
363 |
|
|
364 |
14 |
FeatureColour featureColour; |
365 |
14 |
try |
366 |
|
{ |
367 |
14 |
Color minColour = ColorUtils.parseColourString(mincol); |
368 |
14 |
Color maxColour = ColorUtils.parseColourString(maxcol); |
369 |
14 |
Color noColour = noValueColour.equals(NO_VALUE_MAX) ? maxColour |
370 |
13 |
: (noValueColour.equals(NO_VALUE_NONE) ? null : minColour); |
371 |
14 |
featureColour = new FeatureColour(maxColour, minColour, maxColour, |
372 |
|
noColour, min, max); |
373 |
14 |
featureColour.setColourByLabel(minColour == null); |
374 |
14 |
featureColour.setAutoScaled(autoScaled); |
375 |
14 |
if (byAttribute) |
376 |
|
{ |
377 |
3 |
featureColour.setAttributeName( |
378 |
|
FeatureMatcher.fromAttributeDisplayName(attName)); |
379 |
|
} |
380 |
|
|
381 |
14 |
String ttype = null, tval = null; |
382 |
14 |
if (gcol.hasMoreTokens()) |
383 |
|
{ |
384 |
|
|
385 |
8 |
ttype = gcol.nextToken(); |
386 |
8 |
if (ttype.toLowerCase(Locale.ROOT).startsWith(BELOW)) |
387 |
|
{ |
388 |
4 |
featureColour.setBelowThreshold(true); |
389 |
|
} |
390 |
4 |
else if (ttype.toLowerCase(Locale.ROOT).startsWith(ABOVE)) |
391 |
|
{ |
392 |
4 |
featureColour.setAboveThreshold(true); |
393 |
|
} |
394 |
|
else |
395 |
|
{ |
396 |
0 |
if (!ttype.toLowerCase(Locale.ROOT).startsWith("no")) |
397 |
|
{ |
398 |
0 |
jalview.bin.Console.errPrintln( |
399 |
|
"Ignoring unrecognised threshold type : " + ttype); |
400 |
|
} |
401 |
|
} |
402 |
|
} |
403 |
14 |
if (featureColour.hasThreshold()) |
404 |
|
{ |
405 |
8 |
try |
406 |
|
{ |
407 |
8 |
gcol.nextToken(); |
408 |
8 |
tval = gcol.nextToken(); |
409 |
8 |
featureColour.setThreshold(Float.valueOf(tval).floatValue()); |
410 |
|
} catch (Exception e) |
411 |
|
{ |
412 |
0 |
jalview.bin.Console |
413 |
|
.errPrintln("Couldn't parse threshold value as a float: (" |
414 |
|
+ tval + ")"); |
415 |
|
} |
416 |
|
} |
417 |
14 |
if (gcol.hasMoreTokens()) |
418 |
|
{ |
419 |
0 |
jalview.bin.Console.errPrintln( |
420 |
|
"Ignoring additional tokens in parameters in graduated colour specification\n"); |
421 |
0 |
while (gcol.hasMoreTokens()) |
422 |
|
{ |
423 |
0 |
jalview.bin.Console.errPrintln(BAR + gcol.nextToken()); |
424 |
|
} |
425 |
0 |
jalview.bin.Console.errPrintln("\n"); |
426 |
|
} |
427 |
14 |
return featureColour; |
428 |
|
} catch (Exception e) |
429 |
|
{ |
430 |
0 |
throw new IllegalArgumentException(e.getMessage()); |
431 |
|
} |
432 |
|
} |
433 |
|
|
434 |
|
|
435 |
|
|
436 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
437 |
36 |
public FeatureColour()... |
438 |
|
{ |
439 |
36 |
this((Color) null); |
440 |
|
} |
441 |
|
|
442 |
|
|
443 |
|
|
444 |
|
|
445 |
|
|
446 |
|
|
447 |
|
|
448 |
|
@param |
449 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (6) |
Complexity: 3 |
Complexity Density: 1.5 |
|
450 |
1002 |
public FeatureColour(Color c)... |
451 |
|
{ |
452 |
|
|
453 |
|
|
454 |
|
|
455 |
1002 |
this(c, c == null ? Color.white : ColorUtils.bleachColour(c, 0.9f), |
456 |
1002 |
c == null ? Color.black : c, DEFAULT_NO_COLOUR, 0, 0); |
457 |
|
|
458 |
|
|
459 |
|
|
460 |
|
|
461 |
1002 |
setGraduatedColour(false); |
462 |
|
} |
463 |
|
|
464 |
|
|
465 |
|
|
466 |
|
|
467 |
|
@param |
468 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (20) |
Complexity: 1 |
Complexity Density: 0.05 |
|
469 |
10 |
public FeatureColour(FeatureColour fc)... |
470 |
|
{ |
471 |
10 |
graduatedColour = fc.graduatedColour; |
472 |
10 |
colour = fc.colour; |
473 |
10 |
minColour = fc.minColour; |
474 |
10 |
maxColour = fc.maxColour; |
475 |
10 |
noColour = fc.noColour; |
476 |
10 |
minRed = fc.minRed; |
477 |
10 |
minGreen = fc.minGreen; |
478 |
10 |
minBlue = fc.minBlue; |
479 |
10 |
deltaRed = fc.deltaRed; |
480 |
10 |
deltaGreen = fc.deltaGreen; |
481 |
10 |
deltaBlue = fc.deltaBlue; |
482 |
10 |
base = fc.base; |
483 |
10 |
range = fc.range; |
484 |
10 |
isHighToLow = fc.isHighToLow; |
485 |
10 |
attributeName = fc.attributeName; |
486 |
10 |
setAboveThreshold(fc.isAboveThreshold()); |
487 |
10 |
setBelowThreshold(fc.isBelowThreshold()); |
488 |
10 |
setThreshold(fc.getThreshold()); |
489 |
10 |
setAutoScaled(fc.isAutoScaled()); |
490 |
10 |
setColourByLabel(fc.isColourByLabel()); |
491 |
|
} |
492 |
|
|
493 |
|
|
494 |
|
|
495 |
|
|
496 |
|
|
497 |
|
|
498 |
|
|
499 |
|
|
500 |
|
|
501 |
|
|
502 |
|
@param |
503 |
|
@param |
504 |
|
@param |
505 |
|
@param |
506 |
|
@param |
507 |
|
@param |
508 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (28) |
Complexity: 4 |
Complexity Density: 0.18 |
|
509 |
1055 |
public FeatureColour(Color myColour, Color low, Color high,... |
510 |
|
Color noValueColour, float min, float max) |
511 |
|
{ |
512 |
1055 |
if (low == null) |
513 |
|
{ |
514 |
2 |
low = Color.white; |
515 |
|
} |
516 |
1055 |
if (high == null) |
517 |
|
{ |
518 |
2 |
high = Color.black; |
519 |
|
} |
520 |
1055 |
colour = myColour; |
521 |
1055 |
minColour = low; |
522 |
1055 |
maxColour = high; |
523 |
1055 |
setGraduatedColour(true); |
524 |
1055 |
noColour = noValueColour; |
525 |
1055 |
threshold = Float.NaN; |
526 |
1055 |
isHighToLow = min >= max; |
527 |
1055 |
minRed = low.getRed() / 255f; |
528 |
1055 |
minGreen = low.getGreen() / 255f; |
529 |
1055 |
minBlue = low.getBlue() / 255f; |
530 |
1055 |
deltaRed = (high.getRed() / 255f) - minRed; |
531 |
1055 |
deltaGreen = (high.getGreen() / 255f) - minGreen; |
532 |
1055 |
deltaBlue = (high.getBlue() / 255f) - minBlue; |
533 |
1055 |
if (isHighToLow) |
534 |
|
{ |
535 |
1009 |
base = max; |
536 |
1009 |
range = min - max; |
537 |
|
} |
538 |
|
else |
539 |
|
{ |
540 |
46 |
base = min; |
541 |
46 |
range = max - min; |
542 |
|
} |
543 |
|
} |
544 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
545 |
22717 |
@Override... |
546 |
|
public boolean isGraduatedColour() |
547 |
|
{ |
548 |
22717 |
return graduatedColour; |
549 |
|
} |
550 |
|
|
551 |
|
|
552 |
|
|
553 |
|
|
554 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (5) |
Complexity: 2 |
Complexity Density: 0.67 |
|
555 |
2087 |
public void setGraduatedColour(boolean b)... |
556 |
|
{ |
557 |
2087 |
graduatedColour = b; |
558 |
2087 |
if (b) |
559 |
|
{ |
560 |
1055 |
setColourByLabel(false); |
561 |
|
} |
562 |
|
} |
563 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
564 |
20083 |
@Override... |
565 |
|
public Color getColour() |
566 |
|
{ |
567 |
20083 |
return colour; |
568 |
|
} |
569 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
570 |
36 |
@Override... |
571 |
|
public Color getMinColour() |
572 |
|
{ |
573 |
36 |
return minColour; |
574 |
|
} |
575 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
576 |
36 |
@Override... |
577 |
|
public Color getMaxColour() |
578 |
|
{ |
579 |
36 |
return maxColour; |
580 |
|
} |
581 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
582 |
15 |
@Override... |
583 |
|
public Color getNoColour() |
584 |
|
{ |
585 |
15 |
return noColour; |
586 |
|
} |
587 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
588 |
22734 |
@Override... |
589 |
|
public boolean isColourByLabel() |
590 |
|
{ |
591 |
22734 |
return colourByLabel; |
592 |
|
} |
593 |
|
|
594 |
|
|
595 |
|
|
596 |
|
|
597 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (5) |
Complexity: 2 |
Complexity Density: 0.67 |
|
598 |
1105 |
@Override... |
599 |
|
public void setColourByLabel(boolean b) |
600 |
|
{ |
601 |
1105 |
colourByLabel = b; |
602 |
1105 |
if (b) |
603 |
|
{ |
604 |
30 |
setGraduatedColour(false); |
605 |
|
} |
606 |
|
} |
607 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
608 |
132 |
@Override... |
609 |
|
public boolean isBelowThreshold() |
610 |
|
{ |
611 |
132 |
return belowThreshold; |
612 |
|
} |
613 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (5) |
Complexity: 2 |
Complexity Density: 0.67 |
|
614 |
64 |
@Override... |
615 |
|
public void setBelowThreshold(boolean b) |
616 |
|
{ |
617 |
64 |
belowThreshold = b; |
618 |
64 |
if (b) |
619 |
|
{ |
620 |
20 |
setAboveThreshold(false); |
621 |
|
} |
622 |
|
} |
623 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
624 |
171 |
@Override... |
625 |
|
public boolean isAboveThreshold() |
626 |
|
{ |
627 |
171 |
return aboveThreshold; |
628 |
|
} |
629 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (5) |
Complexity: 2 |
Complexity Density: 0.67 |
|
630 |
65 |
@Override... |
631 |
|
public void setAboveThreshold(boolean b) |
632 |
|
{ |
633 |
65 |
aboveThreshold = b; |
634 |
65 |
if (b) |
635 |
|
{ |
636 |
34 |
setBelowThreshold(false); |
637 |
|
} |
638 |
|
} |
639 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
640 |
52 |
@Override... |
641 |
|
public float getThreshold() |
642 |
|
{ |
643 |
52 |
return threshold; |
644 |
|
} |
645 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
646 |
58 |
@Override... |
647 |
|
public void setThreshold(float f) |
648 |
|
{ |
649 |
58 |
threshold = f; |
650 |
|
} |
651 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
652 |
63 |
@Override... |
653 |
|
public boolean isAutoScaled() |
654 |
|
{ |
655 |
63 |
return autoScaled; |
656 |
|
} |
657 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
658 |
48 |
@Override... |
659 |
|
public void setAutoScaled(boolean b) |
660 |
|
{ |
661 |
48 |
this.autoScaled = b; |
662 |
|
} |
663 |
|
|
664 |
|
|
665 |
|
@inheritDoc |
666 |
|
|
|
|
| 0% |
Uncovered Elements: 9 (9) |
Complexity: 2 |
Complexity Density: 0.29 |
|
667 |
0 |
@Override... |
668 |
|
public void updateBounds(float min, float max) |
669 |
|
{ |
670 |
0 |
if (max < min) |
671 |
|
{ |
672 |
0 |
base = max; |
673 |
0 |
range = min - max; |
674 |
0 |
isHighToLow = true; |
675 |
|
} |
676 |
|
else |
677 |
|
{ |
678 |
0 |
base = min; |
679 |
0 |
range = max - min; |
680 |
0 |
isHighToLow = false; |
681 |
|
} |
682 |
|
} |
683 |
|
|
684 |
|
|
685 |
|
|
686 |
|
|
687 |
|
|
688 |
|
|
689 |
|
|
690 |
|
|
691 |
|
|
692 |
|
|
693 |
|
@param |
694 |
|
@return |
695 |
|
|
|
|
| 84.3% |
Uncovered Elements: 8 (51) |
Complexity: 16 |
Complexity Density: 0.59 |
|
696 |
19920 |
@Override... |
697 |
|
public Color getColor(SequenceFeature feature) |
698 |
|
{ |
699 |
19920 |
if (isColourByLabel()) |
700 |
|
{ |
701 |
14 |
String label = attributeName == null ? feature.getDescription() |
702 |
|
: feature.getValueAsString(attributeName); |
703 |
14 |
return label == null ? noColour |
704 |
|
: ColorUtils.createColourFromName(label); |
705 |
|
} |
706 |
|
|
707 |
19906 |
if (!isGraduatedColour()) |
708 |
|
{ |
709 |
19861 |
return getColour(); |
710 |
|
} |
711 |
|
|
712 |
|
|
713 |
|
|
714 |
|
|
715 |
|
|
716 |
|
|
717 |
45 |
float scr = feature.getScore(); |
718 |
45 |
if (attributeName != null) |
719 |
|
{ |
720 |
13 |
try |
721 |
|
{ |
722 |
13 |
String attVal = feature.getValueAsString(attributeName); |
723 |
13 |
scr = Float.valueOf(attVal); |
724 |
|
} catch (Throwable e) |
725 |
|
{ |
726 |
5 |
scr = Float.NaN; |
727 |
|
} |
728 |
|
} |
729 |
45 |
if (Float.isNaN(scr)) |
730 |
|
{ |
731 |
10 |
return noColour; |
732 |
|
} |
733 |
|
|
734 |
35 |
if (isAboveThreshold() && scr <= threshold) |
735 |
|
{ |
736 |
10 |
return null; |
737 |
|
} |
738 |
|
|
739 |
25 |
if (isBelowThreshold() && scr >= threshold) |
740 |
|
{ |
741 |
5 |
return null; |
742 |
|
} |
743 |
20 |
if (range == 0.0) |
744 |
|
{ |
745 |
0 |
return getMaxColour(); |
746 |
|
} |
747 |
20 |
float scl = (scr - base) / range; |
748 |
20 |
if (isHighToLow) |
749 |
|
{ |
750 |
0 |
scl = -scl; |
751 |
|
} |
752 |
20 |
if (scl < 0f) |
753 |
|
{ |
754 |
0 |
scl = 0f; |
755 |
|
} |
756 |
20 |
if (scl > 1f) |
757 |
|
{ |
758 |
0 |
scl = 1f; |
759 |
|
} |
760 |
20 |
return new Color(minRed + scl * deltaRed, minGreen + scl * deltaGreen, |
761 |
|
minBlue + scl * deltaBlue); |
762 |
|
} |
763 |
|
|
764 |
|
|
765 |
|
|
766 |
|
|
767 |
|
@return |
768 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (3) |
Complexity: 2 |
Complexity Density: 2 |
|
769 |
37 |
@Override... |
770 |
|
public float getMax() |
771 |
|
{ |
772 |
|
|
773 |
37 |
return (isHighToLow) ? base : (base + range); |
774 |
|
} |
775 |
|
|
776 |
|
|
777 |
|
|
778 |
|
|
779 |
|
@return |
780 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (3) |
Complexity: 2 |
Complexity Density: 2 |
|
781 |
37 |
@Override... |
782 |
|
public float getMin() |
783 |
|
{ |
784 |
|
|
785 |
37 |
return (isHighToLow) ? (base + range) : base; |
786 |
|
} |
787 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
788 |
1601 |
@Override... |
789 |
|
public boolean isSimpleColour() |
790 |
|
{ |
791 |
1601 |
return (!isColourByLabel() && !isGraduatedColour()); |
792 |
|
} |
793 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
794 |
48 |
@Override... |
795 |
|
public boolean hasThreshold() |
796 |
|
{ |
797 |
48 |
return isAboveThreshold() || isBelowThreshold(); |
798 |
|
} |
799 |
|
|
|
|
| 96.4% |
Uncovered Elements: 2 (55) |
Complexity: 13 |
Complexity Density: 0.39 |
|
800 |
29 |
@Override... |
801 |
|
public String toJalviewFormat(String featureType) |
802 |
|
{ |
803 |
29 |
String colourString = null; |
804 |
29 |
if (isSimpleColour()) |
805 |
|
{ |
806 |
9 |
colourString = Format.getHexString(getColour()); |
807 |
|
} |
808 |
|
else |
809 |
|
{ |
810 |
20 |
StringBuilder sb = new StringBuilder(32); |
811 |
20 |
if (isColourByAttribute()) |
812 |
|
{ |
813 |
3 |
sb.append(ATTRIBUTE).append(BAR); |
814 |
3 |
sb.append( |
815 |
|
FeatureMatcher.toAttributeDisplayName(getAttributeName())); |
816 |
|
} |
817 |
17 |
else if (isColourByLabel()) |
818 |
|
{ |
819 |
4 |
sb.append(LABEL); |
820 |
|
} |
821 |
|
else |
822 |
|
{ |
823 |
13 |
sb.append(SCORE); |
824 |
|
} |
825 |
20 |
if (isGraduatedColour()) |
826 |
|
{ |
827 |
14 |
sb.append(BAR).append(Format.getHexString(getMinColour())) |
828 |
|
.append(BAR); |
829 |
14 |
sb.append(Format.getHexString(getMaxColour())).append(BAR); |
830 |
|
|
831 |
|
|
832 |
|
|
833 |
|
|
834 |
|
|
835 |
14 |
String noValue = NO_VALUE_MIN; |
836 |
14 |
if (maxColour.equals(noColour)) |
837 |
|
{ |
838 |
5 |
noValue = NO_VALUE_MAX; |
839 |
|
} |
840 |
14 |
if (noColour == null) |
841 |
|
{ |
842 |
0 |
noValue = NO_VALUE_NONE; |
843 |
|
} |
844 |
14 |
sb.append(noValue).append(BAR); |
845 |
14 |
if (!isAutoScaled()) |
846 |
|
{ |
847 |
8 |
sb.append(ABSOLUTE).append(BAR); |
848 |
|
} |
849 |
|
} |
850 |
|
else |
851 |
|
{ |
852 |
|
|
853 |
|
|
854 |
|
|
855 |
|
|
856 |
6 |
if (hasThreshold()) |
857 |
|
{ |
858 |
3 |
sb.append(BAR).append(BAR).append(BAR); |
859 |
|
} |
860 |
|
} |
861 |
20 |
if (hasThreshold() || isGraduatedColour()) |
862 |
|
{ |
863 |
17 |
sb.append(getMin()).append(BAR); |
864 |
17 |
sb.append(getMax()).append(BAR); |
865 |
17 |
if (isBelowThreshold()) |
866 |
|
{ |
867 |
7 |
sb.append(BELOW).append(BAR).append(getThreshold()); |
868 |
|
} |
869 |
10 |
else if (isAboveThreshold()) |
870 |
|
{ |
871 |
4 |
sb.append(ABOVE).append(BAR).append(getThreshold()); |
872 |
|
} |
873 |
|
else |
874 |
|
{ |
875 |
6 |
sb.append("none"); |
876 |
|
} |
877 |
|
} |
878 |
20 |
colourString = sb.toString(); |
879 |
|
} |
880 |
29 |
return String.format("%s\t%s", featureType, colourString); |
881 |
|
} |
882 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
883 |
49 |
@Override... |
884 |
|
public boolean isColourByAttribute() |
885 |
|
{ |
886 |
49 |
return attributeName != null; |
887 |
|
} |
888 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
889 |
49 |
@Override... |
890 |
|
public String[] getAttributeName() |
891 |
|
{ |
892 |
49 |
return attributeName; |
893 |
|
} |
894 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
895 |
33 |
@Override... |
896 |
|
public void setAttributeName(String... name) |
897 |
|
{ |
898 |
33 |
attributeName = name; |
899 |
|
} |
900 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (17) |
Complexity: 5 |
Complexity Density: 0.45 |
|
901 |
51 |
@Override... |
902 |
|
public boolean isOutwithThreshold(SequenceFeature feature) |
903 |
|
{ |
904 |
51 |
if (!isGraduatedColour()) |
905 |
|
{ |
906 |
21 |
return false; |
907 |
|
} |
908 |
30 |
float scr = feature.getScore(); |
909 |
30 |
if (attributeName != null) |
910 |
|
{ |
911 |
9 |
try |
912 |
|
{ |
913 |
9 |
String attVal = feature.getValueAsString(attributeName); |
914 |
9 |
scr = Float.valueOf(attVal); |
915 |
|
} catch (Throwable e) |
916 |
|
{ |
917 |
5 |
scr = Float.NaN; |
918 |
|
} |
919 |
|
} |
920 |
30 |
if (Float.isNaN(scr)) |
921 |
|
{ |
922 |
5 |
return false; |
923 |
|
} |
924 |
|
|
925 |
25 |
return ((isAboveThreshold() && scr <= threshold) |
926 |
|
|| (isBelowThreshold() && scr >= threshold)); |
927 |
|
} |
928 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (29) |
Complexity: 8 |
Complexity Density: 0.47 |
|
929 |
17 |
@Override... |
930 |
|
public String getDescription() |
931 |
|
{ |
932 |
17 |
if (isSimpleColour()) |
933 |
|
{ |
934 |
1 |
return "r=" + colour.getRed() + ",g=" + colour.getGreen() + ",b=" |
935 |
|
+ colour.getBlue(); |
936 |
|
} |
937 |
16 |
StringBuilder tt = new StringBuilder(); |
938 |
16 |
String by = null; |
939 |
|
|
940 |
16 |
if (getAttributeName() != null) |
941 |
|
{ |
942 |
4 |
by = FeatureMatcher.toAttributeDisplayName(getAttributeName()); |
943 |
|
} |
944 |
12 |
else if (isColourByLabel()) |
945 |
|
{ |
946 |
5 |
by = I18N_LABEL; |
947 |
|
} |
948 |
|
else |
949 |
|
{ |
950 |
7 |
by = I18N_SCORE; |
951 |
|
} |
952 |
16 |
tt.append(MessageManager.formatMessage("action.by_title_param", by)); |
953 |
|
|
954 |
|
|
955 |
|
|
956 |
|
|
957 |
16 |
if (isAboveThreshold() || isBelowThreshold()) |
958 |
|
{ |
959 |
10 |
tt.append(" ("); |
960 |
10 |
if (isColourByLabel()) |
961 |
|
{ |
962 |
|
|
963 |
|
|
964 |
|
|
965 |
|
|
966 |
3 |
tt.append(I18N_SCORE).append(" "); |
967 |
|
} |
968 |
10 |
tt.append(isAboveThreshold() ? "> " : "< "); |
969 |
10 |
tt.append(getThreshold()).append(")"); |
970 |
|
} |
971 |
|
|
972 |
16 |
return tt.toString(); |
973 |
|
} |
974 |
|
|
975 |
|
} |