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