1 |
|
|
2 |
|
|
3 |
|
|
4 |
|
|
5 |
|
|
6 |
|
|
7 |
|
|
8 |
|
|
9 |
|
|
10 |
|
|
11 |
|
|
12 |
|
|
13 |
|
|
14 |
|
|
15 |
|
|
16 |
|
|
17 |
|
|
18 |
|
|
19 |
|
|
20 |
|
|
21 |
|
package jalview.renderer.seqfeatures; |
22 |
|
|
23 |
|
import jalview.api.AlignViewportI; |
24 |
|
import jalview.api.FeatureRenderer; |
25 |
|
import jalview.api.FeaturesDisplayedI; |
26 |
|
import jalview.datamodel.SequenceI; |
27 |
|
import jalview.viewmodel.seqfeatures.FeatureRendererModel; |
28 |
|
|
29 |
|
import java.awt.Color; |
30 |
|
import java.awt.Graphics; |
31 |
|
import java.awt.image.BufferedImage; |
32 |
|
|
33 |
|
|
34 |
|
|
35 |
|
|
36 |
|
@author |
37 |
|
|
38 |
|
|
|
|
| 0% |
Uncovered Elements: 51 (51) |
Complexity: 14 |
Complexity Density: 0.5 |
|
39 |
|
public class FeatureColourFinder |
40 |
|
{ |
41 |
|
|
42 |
|
|
43 |
|
|
44 |
|
private FeatureRenderer featureRenderer; |
45 |
|
|
46 |
|
|
47 |
|
|
48 |
|
|
49 |
|
|
50 |
|
private BufferedImage offscreenImage; |
51 |
|
|
52 |
|
|
53 |
|
|
54 |
|
|
55 |
|
@param |
56 |
|
|
|
|
| 0% |
Uncovered Elements: 2 (2) |
Complexity: 1 |
Complexity Density: 0.5 |
|
57 |
0 |
public FeatureColourFinder(FeatureRenderer fr)... |
58 |
|
{ |
59 |
0 |
featureRenderer = fr; |
60 |
0 |
offscreenImage = new BufferedImage(1, 1, BufferedImage.TYPE_INT_ARGB); |
61 |
|
} |
62 |
|
|
63 |
|
|
64 |
|
|
65 |
|
|
66 |
|
|
67 |
|
|
68 |
|
|
69 |
|
|
70 |
|
|
71 |
|
|
72 |
|
|
73 |
|
|
74 |
|
|
75 |
|
|
76 |
|
@param |
77 |
|
@param |
78 |
|
@param |
79 |
|
|
80 |
|
@return |
81 |
|
|
|
|
| 0% |
Uncovered Elements: 23 (23) |
Complexity: 6 |
Complexity Density: 0.46 |
|
82 |
0 |
public Color findFeatureColour(Color defaultColour, SequenceI seq,... |
83 |
|
int column) |
84 |
|
{ |
85 |
0 |
if (noFeaturesDisplayed()) |
86 |
|
{ |
87 |
0 |
return defaultColour; |
88 |
|
} |
89 |
|
|
90 |
0 |
Graphics g = null; |
91 |
|
|
92 |
|
|
93 |
|
|
94 |
|
|
95 |
|
|
96 |
0 |
if (featureRenderer.getTransparency() != 1f) |
97 |
|
{ |
98 |
0 |
g = offscreenImage.getGraphics(); |
99 |
0 |
if (defaultColour != null) |
100 |
|
{ |
101 |
0 |
offscreenImage.setRGB(0, 0, defaultColour.getRGB()); |
102 |
|
} |
103 |
|
} |
104 |
|
|
105 |
0 |
Color c = featureRenderer.findFeatureColour(seq, column + 1, g); |
106 |
0 |
if (c == null) |
107 |
|
{ |
108 |
0 |
return defaultColour; |
109 |
|
} |
110 |
|
|
111 |
0 |
if (g != null) |
112 |
|
{ |
113 |
0 |
c = new Color(offscreenImage.getRGB(0, 0)); |
114 |
|
} |
115 |
0 |
return c; |
116 |
|
} |
117 |
|
|
118 |
|
|
119 |
|
|
120 |
|
|
121 |
|
|
122 |
|
@return |
123 |
|
|
|
|
| 0% |
Uncovered Elements: 23 (23) |
Complexity: 7 |
Complexity Density: 0.54 |
|
124 |
0 |
boolean noFeaturesDisplayed()... |
125 |
|
{ |
126 |
0 |
if (featureRenderer == null) |
127 |
|
{ |
128 |
0 |
return true; |
129 |
|
} |
130 |
0 |
AlignViewportI av = featureRenderer.getViewport(); |
131 |
0 |
if (av.isShowComplementFeatures()) |
132 |
|
{ |
133 |
0 |
return false; |
134 |
|
} |
135 |
0 |
if (!av.isShowSequenceFeatures()) |
136 |
|
{ |
137 |
0 |
return true; |
138 |
|
} |
139 |
|
|
140 |
0 |
if (!((FeatureRendererModel) featureRenderer).hasRenderOrder()) |
141 |
|
{ |
142 |
0 |
return true; |
143 |
|
} |
144 |
|
|
145 |
0 |
FeaturesDisplayedI displayed = featureRenderer.getFeaturesDisplayed(); |
146 |
0 |
if (displayed == null || displayed.getVisibleFeatureCount() == 0) |
147 |
|
{ |
148 |
0 |
return true; |
149 |
|
} |
150 |
|
|
151 |
0 |
return false; |
152 |
|
} |
153 |
|
} |