1 |
|
|
2 |
|
|
3 |
|
|
4 |
|
|
5 |
|
|
6 |
|
|
7 |
|
|
8 |
|
|
9 |
|
|
10 |
|
|
11 |
|
|
12 |
|
|
13 |
|
|
14 |
|
|
15 |
|
|
16 |
|
|
17 |
|
|
18 |
|
|
19 |
|
|
20 |
|
|
21 |
|
package jalview.gui; |
22 |
|
|
23 |
|
import jalview.datamodel.AlignmentI; |
24 |
|
import jalview.datamodel.SequenceI; |
25 |
|
|
26 |
|
import java.awt.Component; |
27 |
|
import java.util.ArrayList; |
28 |
|
import java.util.HashMap; |
29 |
|
import java.util.Iterator; |
30 |
|
import java.util.List; |
31 |
|
import java.util.Map; |
32 |
|
|
33 |
|
|
34 |
|
|
35 |
|
|
36 |
|
|
37 |
|
@author |
38 |
|
@version |
39 |
|
|
|
|
| 55.7% |
Uncovered Elements: 58 (131) |
Complexity: 34 |
Complexity Density: 0.45 |
|
40 |
|
public class PaintRefresher |
41 |
|
{ |
42 |
|
static Map<String, List<Component>> components = new HashMap<>(); |
43 |
|
|
44 |
|
|
45 |
|
|
46 |
|
|
47 |
|
|
48 |
|
@param |
49 |
|
@param |
50 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (11) |
Complexity: 3 |
Complexity Density: 0.43 |
|
51 |
769 |
public static void Register(Component comp, String seqSetId)... |
52 |
|
{ |
53 |
769 |
if (components.containsKey(seqSetId)) |
54 |
|
{ |
55 |
627 |
List<Component> comps = components.get(seqSetId); |
56 |
627 |
if (!comps.contains(comp)) |
57 |
|
{ |
58 |
501 |
comps.add(comp); |
59 |
|
} |
60 |
|
} |
61 |
|
else |
62 |
|
{ |
63 |
142 |
List<Component> vcoms = new ArrayList<>(); |
64 |
142 |
vcoms.add(comp); |
65 |
142 |
components.put(seqSetId, vcoms); |
66 |
|
} |
67 |
|
} |
68 |
|
|
69 |
|
|
70 |
|
|
71 |
|
|
72 |
|
|
73 |
|
@param |
74 |
|
|
|
|
| 85.7% |
Uncovered Elements: 2 (14) |
Complexity: 4 |
Complexity Density: 0.5 |
|
75 |
410 |
public static void RemoveComponent(Component comp)... |
76 |
|
{ |
77 |
410 |
if (components == null) |
78 |
|
{ |
79 |
0 |
return; |
80 |
|
} |
81 |
|
|
82 |
410 |
Iterator<String> it = components.keySet().iterator(); |
83 |
22456 |
while (it.hasNext()) |
84 |
|
{ |
85 |
22046 |
List<Component> comps = components.get(it.next()); |
86 |
22046 |
comps.remove(comp); |
87 |
22046 |
if (comps.isEmpty()) |
88 |
|
{ |
89 |
41 |
it.remove(); |
90 |
|
} |
91 |
|
} |
92 |
|
} |
93 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
94 |
80 |
public static void Refresh(Component source, String id)... |
95 |
|
{ |
96 |
80 |
Refresh(source, id, false, false); |
97 |
|
} |
98 |
|
|
|
|
| 89.5% |
Uncovered Elements: 2 (19) |
Complexity: 8 |
Complexity Density: 0.73 |
|
99 |
147 |
public static void Refresh(Component source, String id,... |
100 |
|
boolean alignmentChanged, boolean validateSequences) |
101 |
|
{ |
102 |
147 |
List<Component> comps = components.get(id); |
103 |
|
|
104 |
147 |
if (comps == null) |
105 |
|
{ |
106 |
0 |
return; |
107 |
|
} |
108 |
|
|
109 |
147 |
for (Component comp : comps) |
110 |
|
{ |
111 |
947 |
if (comp == source) |
112 |
|
{ |
113 |
71 |
continue; |
114 |
|
} |
115 |
|
|
116 |
876 |
if (validateSequences && comp instanceof AlignmentPanel |
117 |
|
&& source instanceof AlignmentPanel) |
118 |
|
{ |
119 |
124 |
validateSequences(((AlignmentPanel) source).av.getAlignment(), |
120 |
|
((AlignmentPanel) comp).av.getAlignment()); |
121 |
|
} |
122 |
|
|
123 |
876 |
if (comp instanceof AlignmentPanel && alignmentChanged) |
124 |
|
{ |
125 |
124 |
((AlignmentPanel) comp).alignmentChanged(); |
126 |
|
} |
127 |
|
|
128 |
876 |
comp.repaint(); |
129 |
|
} |
130 |
|
} |
131 |
|
|
|
|
| 20.6% |
Uncovered Elements: 54 (68) |
Complexity: 15 |
Complexity Density: 0.38 |
|
132 |
124 |
static void validateSequences(AlignmentI source, AlignmentI comp)... |
133 |
|
{ |
134 |
124 |
SequenceI[] a1; |
135 |
124 |
if (source.getHiddenSequences().getSize() > 0) |
136 |
|
{ |
137 |
124 |
a1 = source.getHiddenSequences().getFullAlignment() |
138 |
|
.getSequencesArray(); |
139 |
|
} |
140 |
|
else |
141 |
|
{ |
142 |
0 |
a1 = source.getSequencesArray(); |
143 |
|
} |
144 |
|
|
145 |
124 |
SequenceI[] a2; |
146 |
124 |
if (comp.getHiddenSequences().getSize() > 0) |
147 |
|
{ |
148 |
123 |
a2 = comp.getHiddenSequences().getFullAlignment().getSequencesArray(); |
149 |
|
} |
150 |
|
else |
151 |
|
{ |
152 |
1 |
a2 = comp.getSequencesArray(); |
153 |
|
} |
154 |
|
|
155 |
124 |
int i, iSize = a1.length, j, jSize = a2.length; |
156 |
|
|
157 |
124 |
if (iSize == jSize) |
158 |
|
{ |
159 |
124 |
return; |
160 |
|
} |
161 |
|
|
162 |
0 |
boolean exists = false; |
163 |
0 |
for (i = 0; i < iSize; i++) |
164 |
|
{ |
165 |
0 |
exists = false; |
166 |
|
|
167 |
0 |
for (j = 0; j < jSize; j++) |
168 |
|
{ |
169 |
0 |
if (a2[j] == a1[i]) |
170 |
|
{ |
171 |
0 |
exists = true; |
172 |
0 |
break; |
173 |
|
} |
174 |
|
} |
175 |
|
|
176 |
0 |
if (!exists) |
177 |
|
{ |
178 |
0 |
if (i < comp.getHeight()) |
179 |
|
{ |
180 |
|
|
181 |
|
|
182 |
0 |
if (comp.getDataset() != source.getDataset()) |
183 |
|
{ |
184 |
|
|
185 |
|
|
186 |
0 |
System.err.println( |
187 |
|
"IMPLEMENTATION PROBLEM: DATASET out of sync due to an insert whilst calling PaintRefresher.validateSequences(AlignmentI, ALignmentI)"); |
188 |
|
} |
189 |
0 |
List<SequenceI> alsq = comp.getSequences(); |
190 |
0 |
synchronized (alsq) |
191 |
|
{ |
192 |
0 |
alsq.add(i, a1[i]); |
193 |
|
} |
194 |
|
} |
195 |
|
else |
196 |
|
{ |
197 |
0 |
comp.addSequence(a1[i]); |
198 |
|
} |
199 |
|
|
200 |
0 |
if (comp.getHiddenSequences().getSize() > 0) |
201 |
|
{ |
202 |
0 |
a2 = comp.getHiddenSequences().getFullAlignment() |
203 |
|
.getSequencesArray(); |
204 |
|
} |
205 |
|
else |
206 |
|
{ |
207 |
0 |
a2 = comp.getSequencesArray(); |
208 |
|
} |
209 |
|
|
210 |
0 |
jSize = a2.length; |
211 |
|
} |
212 |
|
} |
213 |
|
|
214 |
0 |
iSize = a1.length; |
215 |
0 |
jSize = a2.length; |
216 |
|
|
217 |
0 |
for (j = 0; j < jSize; j++) |
218 |
|
{ |
219 |
0 |
exists = false; |
220 |
0 |
for (i = 0; i < iSize; i++) |
221 |
|
{ |
222 |
0 |
if (a2[j] == a1[i]) |
223 |
|
{ |
224 |
0 |
exists = true; |
225 |
0 |
break; |
226 |
|
} |
227 |
|
} |
228 |
|
|
229 |
0 |
if (!exists) |
230 |
|
{ |
231 |
0 |
comp.deleteSequence(a2[j]); |
232 |
|
} |
233 |
|
} |
234 |
|
} |
235 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (12) |
Complexity: 3 |
Complexity Density: 0.38 |
|
236 |
262 |
static AlignmentPanel[] getAssociatedPanels(String id)... |
237 |
|
{ |
238 |
262 |
List<Component> comps = components.get(id); |
239 |
262 |
if (comps == null) |
240 |
|
{ |
241 |
1 |
return new AlignmentPanel[0]; |
242 |
|
} |
243 |
261 |
List<AlignmentPanel> tmp = new ArrayList<>(); |
244 |
261 |
for (Component comp : comps) |
245 |
|
{ |
246 |
1342 |
if (comp instanceof AlignmentPanel) |
247 |
|
{ |
248 |
302 |
tmp.add((AlignmentPanel) comp); |
249 |
|
} |
250 |
|
} |
251 |
261 |
return tmp.toArray(new AlignmentPanel[tmp.size()]); |
252 |
|
} |
253 |
|
|
254 |
|
} |