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.analysis.AlignSeq; |
24 |
|
import jalview.analysis.AlignmentUtils; |
25 |
|
import jalview.datamodel.Alignment; |
26 |
|
import jalview.datamodel.AlignmentAnnotation; |
27 |
|
import jalview.datamodel.Annotation; |
28 |
|
import jalview.datamodel.HiddenColumns; |
29 |
|
import jalview.datamodel.Sequence; |
30 |
|
import jalview.datamodel.SequenceGroup; |
31 |
|
import jalview.datamodel.SequenceI; |
32 |
|
import jalview.io.FileFormat; |
33 |
|
import jalview.io.FormatAdapter; |
34 |
|
import jalview.util.Comparison; |
35 |
|
import jalview.util.MessageManager; |
36 |
|
import jalview.util.Platform; |
37 |
|
|
38 |
|
import java.awt.Color; |
39 |
|
import java.awt.Cursor; |
40 |
|
import java.awt.Dimension; |
41 |
|
import java.awt.Font; |
42 |
|
import java.awt.FontMetrics; |
43 |
|
import java.awt.Graphics; |
44 |
|
import java.awt.Graphics2D; |
45 |
|
import java.awt.RenderingHints; |
46 |
|
import java.awt.Toolkit; |
47 |
|
import java.awt.datatransfer.StringSelection; |
48 |
|
import java.awt.event.ActionEvent; |
49 |
|
import java.awt.event.ActionListener; |
50 |
|
import java.awt.event.MouseEvent; |
51 |
|
import java.awt.event.MouseListener; |
52 |
|
import java.awt.event.MouseMotionListener; |
53 |
|
import java.awt.geom.AffineTransform; |
54 |
|
import java.util.Arrays; |
55 |
|
import java.util.Collections; |
56 |
|
import java.util.Iterator; |
57 |
|
|
58 |
|
import javax.swing.JCheckBoxMenuItem; |
59 |
|
import javax.swing.JMenuItem; |
60 |
|
import javax.swing.JPanel; |
61 |
|
import javax.swing.JPopupMenu; |
62 |
|
import javax.swing.SwingUtilities; |
63 |
|
import javax.swing.ToolTipManager; |
64 |
|
|
65 |
|
|
66 |
|
|
67 |
|
|
68 |
|
|
69 |
|
|
|
|
| 25.4% |
Uncovered Elements: 477 (639) |
Complexity: 148 |
Complexity Density: 0.36 |
|
70 |
|
public class AnnotationLabels extends JPanel |
71 |
|
implements MouseListener, MouseMotionListener, ActionListener |
72 |
|
{ |
73 |
|
private static final String HTML_END_TAG = "</html>"; |
74 |
|
|
75 |
|
private static final String HTML_START_TAG = "<html>"; |
76 |
|
|
77 |
|
|
78 |
|
|
79 |
|
|
80 |
|
private static final int HEIGHT_ADJUSTER_WIDTH = 50; |
81 |
|
|
82 |
|
|
83 |
|
|
84 |
|
|
85 |
|
private static int HEIGHT_ADJUSTER_HEIGHT = 10; |
86 |
|
|
87 |
|
private static final Font font = new Font("Arial", Font.PLAIN, 11); |
88 |
|
|
89 |
|
private static final String TOGGLE_LABELSCALE = MessageManager |
90 |
|
.getString("label.scale_label_to_column"); |
91 |
|
|
92 |
|
private static final String ADDNEW = MessageManager |
93 |
|
.getString("label.add_new_row"); |
94 |
|
|
95 |
|
private static final String EDITNAME = MessageManager |
96 |
|
.getString("label.edit_label_description"); |
97 |
|
|
98 |
|
private static final String HIDE = MessageManager |
99 |
|
.getString("label.hide_row"); |
100 |
|
|
101 |
|
private static final String DELETE = MessageManager |
102 |
|
.getString("label.delete_row"); |
103 |
|
|
104 |
|
private static final String SHOWALL = MessageManager |
105 |
|
.getString("label.show_all_hidden_rows"); |
106 |
|
|
107 |
|
private static final String OUTPUT_TEXT = MessageManager |
108 |
|
.getString("label.export_annotation"); |
109 |
|
|
110 |
|
private static final String COPYCONS_SEQ = MessageManager |
111 |
|
.getString("label.copy_consensus_sequence"); |
112 |
|
|
113 |
|
private final boolean debugRedraw = false; |
114 |
|
|
115 |
|
private AlignmentPanel ap; |
116 |
|
|
117 |
|
AlignViewport av; |
118 |
|
|
119 |
|
private MouseEvent dragEvent; |
120 |
|
|
121 |
|
private int oldY; |
122 |
|
|
123 |
|
private int selectedRow; |
124 |
|
|
125 |
|
private int scrollOffset = 0; |
126 |
|
|
127 |
|
private boolean hasHiddenRows; |
128 |
|
|
129 |
|
private boolean resizePanel = false; |
130 |
|
|
131 |
|
|
132 |
|
|
133 |
|
|
134 |
|
@param |
135 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (6) |
Complexity: 1 |
Complexity Density: 0.17 |
|
136 |
267 |
public AnnotationLabels(AlignmentPanel ap)... |
137 |
|
{ |
138 |
|
|
139 |
267 |
this.ap = ap; |
140 |
267 |
av = ap.av; |
141 |
267 |
ToolTipManager.sharedInstance().registerComponent(this); |
142 |
|
|
143 |
267 |
addMouseListener(this); |
144 |
267 |
addMouseMotionListener(this); |
145 |
267 |
addMouseWheelListener(ap.getAnnotationPanel()); |
146 |
|
} |
147 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
148 |
122 |
public AnnotationLabels(AlignViewport av)... |
149 |
|
{ |
150 |
122 |
this.av = av; |
151 |
|
} |
152 |
|
|
153 |
|
|
154 |
|
|
155 |
|
|
156 |
|
@param |
157 |
|
|
158 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (2) |
Complexity: 1 |
Complexity Density: 0.5 |
|
159 |
448 |
public void setScrollOffset(int y)... |
160 |
|
{ |
161 |
448 |
scrollOffset = y; |
162 |
448 |
repaint(); |
163 |
|
} |
164 |
|
|
165 |
|
|
166 |
|
|
167 |
|
|
168 |
|
|
169 |
|
@param |
170 |
|
|
171 |
|
|
|
|
| 0% |
Uncovered Elements: 20 (20) |
Complexity: 5 |
Complexity Density: 0.42 |
|
172 |
0 |
void getSelectedRow(int y)... |
173 |
|
{ |
174 |
0 |
int height = 0; |
175 |
0 |
AlignmentAnnotation[] aa = ap.av.getAlignment() |
176 |
|
.getAlignmentAnnotation(); |
177 |
0 |
selectedRow = -2; |
178 |
0 |
if (aa != null) |
179 |
|
{ |
180 |
0 |
for (int i = 0; i < aa.length; i++) |
181 |
|
{ |
182 |
0 |
selectedRow = -1; |
183 |
0 |
if (!aa[i].visible) |
184 |
|
{ |
185 |
0 |
continue; |
186 |
|
} |
187 |
|
|
188 |
0 |
height += aa[i].height; |
189 |
|
|
190 |
0 |
if (y < height) |
191 |
|
{ |
192 |
0 |
selectedRow = i; |
193 |
|
|
194 |
0 |
break; |
195 |
|
} |
196 |
|
} |
197 |
|
} |
198 |
|
} |
199 |
|
|
200 |
|
|
201 |
|
|
202 |
|
|
203 |
|
@param |
204 |
|
|
205 |
|
|
|
|
| 0% |
Uncovered Elements: 52 (52) |
Complexity: 14 |
Complexity Density: 0.5 |
|
206 |
0 |
@Override... |
207 |
|
public void actionPerformed(ActionEvent evt) |
208 |
|
{ |
209 |
0 |
AlignmentAnnotation[] aa = ap.av.getAlignment() |
210 |
|
.getAlignmentAnnotation(); |
211 |
|
|
212 |
0 |
String action = evt.getActionCommand(); |
213 |
0 |
if (ADDNEW.equals(action)) |
214 |
|
{ |
215 |
|
|
216 |
|
|
217 |
|
|
218 |
0 |
AlignmentAnnotation newAnnotation = new AlignmentAnnotation(null, |
219 |
|
null, new Annotation[ap.av.getAlignment().getWidth()]); |
220 |
0 |
editLabelDescription(newAnnotation, true); |
221 |
|
} |
222 |
0 |
else if (EDITNAME.equals(action)) |
223 |
|
{ |
224 |
|
|
225 |
|
|
226 |
|
|
227 |
0 |
editLabelDescription(aa[selectedRow], false); |
228 |
|
} |
229 |
0 |
else if (HIDE.equals(action)) |
230 |
|
{ |
231 |
0 |
aa[selectedRow].visible = false; |
232 |
|
} |
233 |
0 |
else if (DELETE.equals(action)) |
234 |
|
{ |
235 |
0 |
ap.av.getAlignment().deleteAnnotation(aa[selectedRow]); |
236 |
0 |
ap.av.getCalcManager().removeWorkerForAnnotation(aa[selectedRow]); |
237 |
|
} |
238 |
0 |
else if (SHOWALL.equals(action)) |
239 |
|
{ |
240 |
0 |
for (int i = 0; i < aa.length; i++) |
241 |
|
{ |
242 |
0 |
if (!aa[i].visible && aa[i].annotations != null) |
243 |
|
{ |
244 |
0 |
aa[i].visible = true; |
245 |
|
} |
246 |
|
} |
247 |
|
} |
248 |
0 |
else if (OUTPUT_TEXT.equals(action)) |
249 |
|
{ |
250 |
0 |
new AnnotationExporter(ap).exportAnnotation(aa[selectedRow]); |
251 |
|
} |
252 |
0 |
else if (COPYCONS_SEQ.equals(action)) |
253 |
|
{ |
254 |
0 |
SequenceI cons = null; |
255 |
0 |
if (aa[selectedRow].groupRef != null) |
256 |
|
{ |
257 |
0 |
cons = aa[selectedRow].groupRef.getConsensusSeq(); |
258 |
|
} |
259 |
|
else |
260 |
|
{ |
261 |
0 |
cons = av.getConsensusSeq(); |
262 |
|
} |
263 |
0 |
if (cons != null) |
264 |
|
{ |
265 |
0 |
copy_annotseqtoclipboard(cons); |
266 |
|
} |
267 |
|
} |
268 |
0 |
else if (TOGGLE_LABELSCALE.equals(action)) |
269 |
|
{ |
270 |
0 |
aa[selectedRow].scaleColLabel = !aa[selectedRow].scaleColLabel; |
271 |
|
} |
272 |
|
|
273 |
0 |
ap.refresh(true); |
274 |
|
} |
275 |
|
|
276 |
|
|
277 |
|
|
278 |
|
|
279 |
|
|
280 |
|
|
281 |
|
@param |
282 |
|
@param |
283 |
|
|
|
|
| 0% |
Uncovered Elements: 5 (5) |
Complexity: 1 |
Complexity Density: 0.2 |
|
284 |
0 |
void editLabelDescription(AlignmentAnnotation annotation, boolean addNew)... |
285 |
|
{ |
286 |
0 |
String name = MessageManager.getString("label.annotation_name"); |
287 |
0 |
String description = MessageManager |
288 |
|
.getString("label.annotation_description"); |
289 |
0 |
String title = MessageManager |
290 |
|
.getString("label.edit_annotation_name_description"); |
291 |
0 |
EditNameDialog dialog = new EditNameDialog(annotation.label, |
292 |
|
annotation.description, name, description); |
293 |
|
|
294 |
0 |
dialog.showDialog(ap.alignFrame, title, |
295 |
|
new Runnable() |
296 |
|
{ |
|
|
| 0% |
Uncovered Elements: 13 (13) |
Complexity: 4 |
Complexity Density: 0.44 |
|
297 |
0 |
@Override... |
298 |
|
public void run() |
299 |
|
{ |
300 |
0 |
annotation.label = dialog.getName(); |
301 |
0 |
String text = dialog.getDescription(); |
302 |
0 |
if (text != null && text.length() == 0) |
303 |
|
{ |
304 |
0 |
text = null; |
305 |
|
} |
306 |
0 |
annotation.description = text; |
307 |
0 |
if (addNew) |
308 |
|
{ |
309 |
0 |
ap.av.getAlignment().addAnnotation(annotation); |
310 |
0 |
ap.av.getAlignment().setAnnotationIndex(annotation, 0); |
311 |
|
} |
312 |
0 |
ap.refresh(true); |
313 |
|
} |
314 |
|
}); |
315 |
|
} |
316 |
|
|
|
|
| 0% |
Uncovered Elements: 6 (6) |
Complexity: 2 |
Complexity Density: 0.5 |
|
317 |
0 |
@Override... |
318 |
|
public void mousePressed(MouseEvent evt) |
319 |
|
{ |
320 |
0 |
getSelectedRow(evt.getY() - getScrollOffset()); |
321 |
0 |
oldY = evt.getY(); |
322 |
0 |
if (evt.isPopupTrigger()) |
323 |
|
{ |
324 |
0 |
showPopupMenu(evt); |
325 |
|
} |
326 |
|
} |
327 |
|
|
328 |
|
|
329 |
|
|
330 |
|
|
331 |
|
@param |
332 |
|
|
|
|
| 0% |
Uncovered Elements: 69 (69) |
Complexity: 10 |
Complexity Density: 0.2 |
|
333 |
0 |
void showPopupMenu(MouseEvent evt)... |
334 |
|
{ |
335 |
0 |
evt.consume(); |
336 |
0 |
final AlignmentAnnotation[] aa = ap.av.getAlignment() |
337 |
|
.getAlignmentAnnotation(); |
338 |
|
|
339 |
0 |
JPopupMenu pop = new JPopupMenu( |
340 |
|
MessageManager.getString("label.annotations")); |
341 |
0 |
JMenuItem item = new JMenuItem(ADDNEW); |
342 |
0 |
item.addActionListener(this); |
343 |
0 |
pop.add(item); |
344 |
0 |
if (selectedRow < 0) |
345 |
|
{ |
346 |
0 |
if (hasHiddenRows) |
347 |
|
{ |
348 |
0 |
item = new JMenuItem(SHOWALL); |
349 |
0 |
item.addActionListener(this); |
350 |
0 |
pop.add(item); |
351 |
|
} |
352 |
0 |
pop.show(this, evt.getX(), evt.getY()); |
353 |
0 |
return; |
354 |
|
} |
355 |
0 |
item = new JMenuItem(EDITNAME); |
356 |
0 |
item.addActionListener(this); |
357 |
0 |
pop.add(item); |
358 |
0 |
item = new JMenuItem(HIDE); |
359 |
0 |
item.addActionListener(this); |
360 |
0 |
pop.add(item); |
361 |
|
|
362 |
0 |
if (selectedRow < aa.length) |
363 |
|
{ |
364 |
0 |
if (aa[selectedRow].sequenceRef != null) |
365 |
|
{ |
366 |
0 |
final String label = aa[selectedRow].label; |
367 |
0 |
JMenuItem hideType = new JMenuItem(); |
368 |
0 |
String text = MessageManager.getString("label.hide_all") + " " |
369 |
|
+ label; |
370 |
0 |
hideType.setText(text); |
371 |
0 |
hideType.addActionListener(new ActionListener() |
372 |
|
{ |
|
|
| 0% |
Uncovered Elements: 2 (2) |
Complexity: 1 |
Complexity Density: 0.5 |
|
373 |
0 |
@Override... |
374 |
|
public void actionPerformed(ActionEvent e) |
375 |
|
{ |
376 |
0 |
AlignmentUtils.showOrHideSequenceAnnotations( |
377 |
|
ap.av.getAlignment(), Collections.singleton(label), |
378 |
|
null, false, false); |
379 |
0 |
ap.refresh(true); |
380 |
|
} |
381 |
|
}); |
382 |
0 |
pop.add(hideType); |
383 |
|
} |
384 |
|
} |
385 |
0 |
item = new JMenuItem(DELETE); |
386 |
0 |
item.addActionListener(this); |
387 |
0 |
pop.add(item); |
388 |
0 |
if (hasHiddenRows) |
389 |
|
{ |
390 |
0 |
item = new JMenuItem(SHOWALL); |
391 |
0 |
item.addActionListener(this); |
392 |
0 |
pop.add(item); |
393 |
|
} |
394 |
0 |
item = new JMenuItem(OUTPUT_TEXT); |
395 |
0 |
item.addActionListener(this); |
396 |
0 |
pop.add(item); |
397 |
|
|
398 |
|
|
399 |
0 |
if (selectedRow < aa.length) |
400 |
|
{ |
401 |
0 |
final String label = aa[selectedRow].label; |
402 |
0 |
if (!aa[selectedRow].autoCalculated) |
403 |
|
{ |
404 |
0 |
if (aa[selectedRow].graph == AlignmentAnnotation.NO_GRAPH) |
405 |
|
{ |
406 |
|
|
407 |
0 |
pop.addSeparator(); |
408 |
|
|
409 |
0 |
item = new JCheckBoxMenuItem(TOGGLE_LABELSCALE, |
410 |
|
aa[selectedRow].scaleColLabel); |
411 |
0 |
item.addActionListener(this); |
412 |
0 |
pop.add(item); |
413 |
|
} |
414 |
|
} |
415 |
0 |
else if (label.indexOf("Consensus") > -1) |
416 |
|
{ |
417 |
0 |
addConsensusMenuOptions(ap, aa[selectedRow], pop); |
418 |
|
|
419 |
0 |
final JMenuItem consclipbrd = new JMenuItem(COPYCONS_SEQ); |
420 |
0 |
consclipbrd.addActionListener(this); |
421 |
0 |
pop.add(consclipbrd); |
422 |
|
} |
423 |
|
} |
424 |
0 |
pop.show(this, evt.getX(), evt.getY()); |
425 |
|
} |
426 |
|
|
427 |
|
|
428 |
|
|
429 |
|
|
430 |
|
|
431 |
|
|
432 |
|
|
433 |
|
|
434 |
|
@param |
435 |
|
@param |
436 |
|
@param |
437 |
|
|
|
|
| 0% |
Uncovered Elements: 28 (28) |
Complexity: 3 |
Complexity Density: 0.12 |
|
438 |
0 |
static void addConsensusMenuOptions(AlignmentPanel ap,... |
439 |
|
AlignmentAnnotation ann, |
440 |
|
JPopupMenu pop) |
441 |
|
{ |
442 |
0 |
pop.addSeparator(); |
443 |
|
|
444 |
0 |
final JCheckBoxMenuItem cbmi = new JCheckBoxMenuItem( |
445 |
|
MessageManager.getString("label.ignore_gaps_consensus"), |
446 |
0 |
(ann.groupRef != null) ? ann.groupRef.getIgnoreGapsConsensus() |
447 |
|
: ap.av.isIgnoreGapsConsensus()); |
448 |
0 |
final AlignmentAnnotation aaa = ann; |
449 |
0 |
cbmi.addActionListener(new ActionListener() |
450 |
|
{ |
|
|
| 0% |
Uncovered Elements: 7 (7) |
Complexity: 2 |
Complexity Density: 0.4 |
|
451 |
0 |
@Override... |
452 |
|
public void actionPerformed(ActionEvent e) |
453 |
|
{ |
454 |
0 |
if (aaa.groupRef != null) |
455 |
|
{ |
456 |
0 |
aaa.groupRef.setIgnoreGapsConsensus(cbmi.getState()); |
457 |
0 |
ap.getAnnotationPanel() |
458 |
|
.paint(ap.getAnnotationPanel().getGraphics()); |
459 |
|
} |
460 |
|
else |
461 |
|
{ |
462 |
0 |
ap.av.setIgnoreGapsConsensus(cbmi.getState(), ap); |
463 |
|
} |
464 |
0 |
ap.alignmentChanged(); |
465 |
|
} |
466 |
|
}); |
467 |
0 |
pop.add(cbmi); |
468 |
|
|
469 |
0 |
if (aaa.groupRef != null) |
470 |
|
{ |
471 |
|
|
472 |
|
|
473 |
|
|
474 |
0 |
final JCheckBoxMenuItem chist = new JCheckBoxMenuItem( |
475 |
|
MessageManager.getString("label.show_group_histogram"), |
476 |
|
ann.groupRef.isShowConsensusHistogram()); |
477 |
0 |
chist.addActionListener(new ActionListener() |
478 |
|
{ |
|
|
| 0% |
Uncovered Elements: 2 (2) |
Complexity: 1 |
Complexity Density: 0.5 |
|
479 |
0 |
@Override... |
480 |
|
public void actionPerformed(ActionEvent e) |
481 |
|
{ |
482 |
0 |
aaa.groupRef.setShowConsensusHistogram(chist.getState()); |
483 |
0 |
ap.repaint(); |
484 |
|
} |
485 |
|
}); |
486 |
0 |
pop.add(chist); |
487 |
0 |
final JCheckBoxMenuItem cprofl = new JCheckBoxMenuItem( |
488 |
|
MessageManager.getString("label.show_group_logo"), |
489 |
|
ann.groupRef.isShowSequenceLogo()); |
490 |
0 |
cprofl.addActionListener(new ActionListener() |
491 |
|
{ |
|
|
| 0% |
Uncovered Elements: 2 (2) |
Complexity: 1 |
Complexity Density: 0.5 |
|
492 |
0 |
@Override... |
493 |
|
public void actionPerformed(ActionEvent e) |
494 |
|
{ |
495 |
0 |
aaa.groupRef.setshowSequenceLogo(cprofl.getState()); |
496 |
0 |
ap.repaint(); |
497 |
|
} |
498 |
|
}); |
499 |
0 |
pop.add(cprofl); |
500 |
0 |
final JCheckBoxMenuItem cproflnorm = new JCheckBoxMenuItem( |
501 |
|
MessageManager.getString("label.normalise_group_logo"), |
502 |
|
ann.groupRef.isNormaliseSequenceLogo()); |
503 |
0 |
cproflnorm.addActionListener(new ActionListener() |
504 |
|
{ |
|
|
| 0% |
Uncovered Elements: 3 (3) |
Complexity: 1 |
Complexity Density: 0.33 |
|
505 |
0 |
@Override... |
506 |
|
public void actionPerformed(ActionEvent e) |
507 |
|
{ |
508 |
0 |
aaa.groupRef.setNormaliseSequenceLogo(cproflnorm.getState()); |
509 |
|
|
510 |
0 |
aaa.groupRef.setshowSequenceLogo(true); |
511 |
0 |
ap.repaint(); |
512 |
|
} |
513 |
|
}); |
514 |
0 |
pop.add(cproflnorm); |
515 |
|
} |
516 |
|
else |
517 |
|
{ |
518 |
|
|
519 |
|
|
520 |
|
|
521 |
0 |
final JCheckBoxMenuItem chist = new JCheckBoxMenuItem( |
522 |
|
MessageManager.getString("label.show_histogram"), |
523 |
|
ap.av.isShowConsensusHistogram()); |
524 |
0 |
chist.addActionListener(new ActionListener() |
525 |
|
{ |
|
|
| 0% |
Uncovered Elements: 3 (3) |
Complexity: 1 |
Complexity Density: 0.33 |
|
526 |
0 |
@Override... |
527 |
|
public void actionPerformed(ActionEvent e) |
528 |
|
{ |
529 |
0 |
ap.av.setShowConsensusHistogram(chist.getState()); |
530 |
0 |
ap.alignFrame.setMenusForViewport(); |
531 |
0 |
ap.repaint(); |
532 |
|
} |
533 |
|
}); |
534 |
0 |
pop.add(chist); |
535 |
0 |
final JCheckBoxMenuItem cprof = new JCheckBoxMenuItem( |
536 |
|
MessageManager.getString("label.show_logo"), |
537 |
|
ap.av.isShowSequenceLogo()); |
538 |
0 |
cprof.addActionListener(new ActionListener() |
539 |
|
{ |
|
|
| 0% |
Uncovered Elements: 3 (3) |
Complexity: 1 |
Complexity Density: 0.33 |
|
540 |
0 |
@Override... |
541 |
|
public void actionPerformed(ActionEvent e) |
542 |
|
{ |
543 |
0 |
ap.av.setShowSequenceLogo(cprof.getState()); |
544 |
0 |
ap.alignFrame.setMenusForViewport(); |
545 |
0 |
ap.repaint(); |
546 |
|
} |
547 |
|
}); |
548 |
0 |
pop.add(cprof); |
549 |
0 |
final JCheckBoxMenuItem cprofnorm = new JCheckBoxMenuItem( |
550 |
|
MessageManager.getString("label.normalise_logo"), |
551 |
|
ap.av.isNormaliseSequenceLogo()); |
552 |
0 |
cprofnorm.addActionListener(new ActionListener() |
553 |
|
{ |
|
|
| 0% |
Uncovered Elements: 4 (4) |
Complexity: 1 |
Complexity Density: 0.25 |
|
554 |
0 |
@Override... |
555 |
|
public void actionPerformed(ActionEvent e) |
556 |
|
{ |
557 |
0 |
ap.av.setShowSequenceLogo(true); |
558 |
0 |
ap.av.setNormaliseSequenceLogo(cprofnorm.getState()); |
559 |
0 |
ap.alignFrame.setMenusForViewport(); |
560 |
0 |
ap.repaint(); |
561 |
|
} |
562 |
|
}); |
563 |
0 |
pop.add(cprofnorm); |
564 |
|
} |
565 |
|
} |
566 |
|
|
567 |
|
|
568 |
|
|
569 |
|
|
570 |
|
@param |
571 |
|
|
|
|
| 0% |
Uncovered Elements: 23 (23) |
Complexity: 4 |
Complexity Density: 0.24 |
|
572 |
0 |
@Override... |
573 |
|
public void mouseReleased(MouseEvent evt) |
574 |
|
{ |
575 |
0 |
if (evt.isPopupTrigger()) |
576 |
|
{ |
577 |
0 |
showPopupMenu(evt); |
578 |
0 |
return; |
579 |
|
} |
580 |
|
|
581 |
0 |
int start = selectedRow; |
582 |
0 |
getSelectedRow(evt.getY() - getScrollOffset()); |
583 |
0 |
int end = selectedRow; |
584 |
|
|
585 |
|
|
586 |
|
|
587 |
|
|
588 |
0 |
if (start != end) |
589 |
|
{ |
590 |
|
|
591 |
0 |
AlignmentAnnotation startAA = ap.av.getAlignment() |
592 |
|
.getAlignmentAnnotation()[start]; |
593 |
0 |
if (end == -1) |
594 |
|
{ |
595 |
0 |
end = ap.av.getAlignment().getAlignmentAnnotation().length - 1; |
596 |
|
} |
597 |
0 |
AlignmentAnnotation endAA = ap.av.getAlignment() |
598 |
|
.getAlignmentAnnotation()[end]; |
599 |
|
|
600 |
0 |
ap.av.getAlignment().getAlignmentAnnotation()[end] = startAA; |
601 |
0 |
ap.av.getAlignment().getAlignmentAnnotation()[start] = endAA; |
602 |
|
} |
603 |
|
|
604 |
0 |
resizePanel = false; |
605 |
0 |
dragEvent = null; |
606 |
0 |
repaint(); |
607 |
0 |
ap.getAnnotationPanel().repaint(); |
608 |
|
} |
609 |
|
|
610 |
|
|
611 |
|
|
612 |
|
|
613 |
|
|
|
|
| 0% |
Uncovered Elements: 5 (5) |
Complexity: 3 |
Complexity Density: 1 |
|
614 |
0 |
@Override... |
615 |
|
public void mouseExited(MouseEvent evt) |
616 |
|
{ |
617 |
0 |
if (resizePanel && dragEvent == null) |
618 |
|
{ |
619 |
0 |
resizePanel = false; |
620 |
0 |
repaint(); |
621 |
|
} |
622 |
|
} |
623 |
|
|
624 |
|
|
625 |
|
|
626 |
|
|
627 |
|
|
628 |
|
|
629 |
|
@param |
630 |
|
|
|
|
| 0% |
Uncovered Elements: 17 (17) |
Complexity: 3 |
Complexity Density: 0.23 |
|
631 |
0 |
@Override... |
632 |
|
public void mouseDragged(MouseEvent evt) |
633 |
|
{ |
634 |
0 |
dragEvent = evt; |
635 |
|
|
636 |
0 |
if (resizePanel) |
637 |
|
{ |
638 |
0 |
Dimension d = ap.annotationScroller.getPreferredSize(); |
639 |
0 |
int dif = evt.getY() - oldY; |
640 |
|
|
641 |
0 |
dif /= ap.av.getCharHeight(); |
642 |
0 |
dif *= ap.av.getCharHeight(); |
643 |
|
|
644 |
0 |
if ((d.height - dif) > 20) |
645 |
|
{ |
646 |
0 |
ap.annotationScroller |
647 |
|
.setPreferredSize(new Dimension(d.width, d.height - dif)); |
648 |
0 |
d = ap.annotationSpaceFillerHolder.getPreferredSize(); |
649 |
0 |
ap.annotationSpaceFillerHolder |
650 |
|
.setPreferredSize(new Dimension(d.width, d.height - dif)); |
651 |
0 |
ap.paintAlignment(true, false); |
652 |
|
} |
653 |
|
|
654 |
0 |
ap.addNotify(); |
655 |
|
} |
656 |
|
else |
657 |
|
{ |
658 |
0 |
repaint(); |
659 |
|
} |
660 |
|
} |
661 |
|
|
662 |
|
|
663 |
|
|
664 |
|
|
665 |
|
@param |
666 |
|
|
|
|
| 0% |
Uncovered Elements: 11 (11) |
Complexity: 3 |
Complexity Density: 0.33 |
|
667 |
0 |
@Override... |
668 |
|
public void mouseMoved(MouseEvent evt) |
669 |
|
{ |
670 |
0 |
showOrHideAdjuster(evt); |
671 |
|
|
672 |
0 |
getSelectedRow(evt.getY() - getScrollOffset()); |
673 |
|
|
674 |
0 |
if (selectedRow > -1 && ap.av.getAlignment() |
675 |
|
.getAlignmentAnnotation().length > selectedRow) |
676 |
|
{ |
677 |
0 |
AlignmentAnnotation[] anns = ap.av.getAlignment() |
678 |
|
.getAlignmentAnnotation(); |
679 |
0 |
AlignmentAnnotation aa = anns[selectedRow]; |
680 |
|
|
681 |
0 |
String desc = getTooltip(aa); |
682 |
0 |
this.setToolTipText(desc); |
683 |
0 |
String msg = getStatusMessage(aa, anns); |
684 |
0 |
ap.alignFrame.setStatus(msg); |
685 |
|
} |
686 |
|
} |
687 |
|
|
688 |
|
|
689 |
|
|
690 |
|
|
691 |
|
|
692 |
|
|
693 |
|
@param |
694 |
|
@param |
695 |
|
@return |
696 |
|
|
|
|
| 96.7% |
Uncovered Elements: 1 (30) |
Complexity: 8 |
Complexity Density: 0.5 |
|
697 |
6 |
static String getStatusMessage(AlignmentAnnotation aa,... |
698 |
|
AlignmentAnnotation[] anns) |
699 |
|
{ |
700 |
6 |
if (aa == null) |
701 |
|
{ |
702 |
1 |
return null; |
703 |
|
} |
704 |
|
|
705 |
5 |
StringBuilder msg = new StringBuilder(32); |
706 |
5 |
if (aa.sequenceRef != null) |
707 |
|
{ |
708 |
3 |
msg.append(aa.sequenceRef.getName()).append(" : "); |
709 |
|
} |
710 |
|
|
711 |
5 |
if (aa.graphGroup == -1) |
712 |
|
{ |
713 |
2 |
msg.append(aa.label); |
714 |
|
} |
715 |
3 |
else if (anns != null) |
716 |
|
{ |
717 |
3 |
boolean first = true; |
718 |
9 |
for (int i = anns.length - 1; i >= 0; i--) |
719 |
|
{ |
720 |
6 |
if (anns[i].graphGroup == aa.graphGroup) |
721 |
|
{ |
722 |
5 |
if (!first) |
723 |
|
{ |
724 |
2 |
msg.append(", "); |
725 |
|
} |
726 |
5 |
msg.append(anns[i].label); |
727 |
5 |
first = false; |
728 |
|
} |
729 |
|
} |
730 |
|
} |
731 |
|
|
732 |
5 |
return msg.toString(); |
733 |
|
} |
734 |
|
|
735 |
|
|
736 |
|
|
737 |
|
|
738 |
|
|
739 |
|
|
740 |
|
|
741 |
|
@param |
742 |
|
@return |
743 |
|
|
|
|
| 97% |
Uncovered Elements: 1 (33) |
Complexity: 9 |
Complexity Density: 0.47 |
|
744 |
13 |
static String getTooltip(AlignmentAnnotation aa)... |
745 |
|
{ |
746 |
13 |
if (aa == null) |
747 |
|
{ |
748 |
1 |
return null; |
749 |
|
} |
750 |
12 |
StringBuilder tooltip = new StringBuilder(); |
751 |
12 |
if (aa.description != null && !aa.description.equals("New description")) |
752 |
|
{ |
753 |
|
|
754 |
|
|
755 |
|
|
756 |
10 |
String desc = aa.getDescription(true).trim(); |
757 |
10 |
if (!desc.toLowerCase().startsWith(HTML_START_TAG)) |
758 |
|
{ |
759 |
7 |
tooltip.append(HTML_START_TAG); |
760 |
7 |
desc = desc.replace("<", "<"); |
761 |
|
} |
762 |
3 |
else if (desc.toLowerCase().endsWith(HTML_END_TAG)) |
763 |
|
{ |
764 |
3 |
desc = desc.substring(0, desc.length() - HTML_END_TAG.length()); |
765 |
|
} |
766 |
10 |
tooltip.append(desc); |
767 |
|
} |
768 |
|
else |
769 |
|
{ |
770 |
|
|
771 |
2 |
tooltip.append(HTML_START_TAG); |
772 |
|
} |
773 |
12 |
if (aa.hasScore()) |
774 |
|
{ |
775 |
5 |
if (tooltip.length() > HTML_START_TAG.length()) |
776 |
|
{ |
777 |
3 |
tooltip.append("<br/>"); |
778 |
|
} |
779 |
|
|
780 |
|
|
781 |
|
|
782 |
5 |
tooltip.append(" Score: ").append(String.valueOf(aa.score)); |
783 |
|
} |
784 |
|
|
785 |
12 |
if (tooltip.length() > HTML_START_TAG.length()) |
786 |
|
{ |
787 |
10 |
return tooltip.append(HTML_END_TAG).toString(); |
788 |
|
} |
789 |
|
|
790 |
|
|
791 |
|
|
792 |
|
|
793 |
2 |
return null; |
794 |
|
} |
795 |
|
|
796 |
|
|
797 |
|
|
798 |
|
|
799 |
|
|
800 |
|
@param |
801 |
|
|
|
|
| 0% |
Uncovered Elements: 9 (9) |
Complexity: 3 |
Complexity Density: 0.6 |
|
802 |
0 |
protected void showOrHideAdjuster(MouseEvent evt)... |
803 |
|
{ |
804 |
0 |
boolean was = resizePanel; |
805 |
0 |
resizePanel = evt.getY() < HEIGHT_ADJUSTER_HEIGHT |
806 |
|
&& evt.getX() < HEIGHT_ADJUSTER_WIDTH; |
807 |
|
|
808 |
0 |
if (resizePanel != was) |
809 |
|
{ |
810 |
0 |
setCursor(Cursor |
811 |
0 |
.getPredefinedCursor(resizePanel ? Cursor.S_RESIZE_CURSOR |
812 |
|
: Cursor.DEFAULT_CURSOR)); |
813 |
0 |
repaint(); |
814 |
|
} |
815 |
|
} |
816 |
|
|
|
|
| 0% |
Uncovered Elements: 70 (70) |
Complexity: 21 |
Complexity Density: 0.48 |
|
817 |
0 |
@Override... |
818 |
|
public void mouseClicked(MouseEvent evt) |
819 |
|
{ |
820 |
0 |
final AlignmentAnnotation[] aa = ap.av.getAlignment() |
821 |
|
.getAlignmentAnnotation(); |
822 |
0 |
if (!evt.isPopupTrigger() && SwingUtilities.isLeftMouseButton(evt)) |
823 |
|
{ |
824 |
0 |
if (selectedRow > -1 && selectedRow < aa.length) |
825 |
|
{ |
826 |
0 |
if (aa[selectedRow].groupRef != null) |
827 |
|
{ |
828 |
0 |
if (evt.getClickCount() >= 2) |
829 |
|
{ |
830 |
|
|
831 |
|
|
832 |
0 |
ap.getSeqPanel().ap.getIdPanel().highlightSearchResults(null); |
833 |
|
|
834 |
0 |
SequenceGroup sg = ap.av.getSelectionGroup(); |
835 |
0 |
if (sg == null || sg == aa[selectedRow].groupRef |
836 |
|
|| !(Platform.isControlDown(evt) || evt.isShiftDown())) |
837 |
|
{ |
838 |
0 |
if (Platform.isControlDown(evt) || evt.isShiftDown()) |
839 |
|
{ |
840 |
|
|
841 |
0 |
ap.av.setSelectionGroup( |
842 |
|
new SequenceGroup(aa[selectedRow].groupRef)); |
843 |
|
} |
844 |
|
else |
845 |
|
{ |
846 |
|
|
847 |
0 |
ap.av.setSelectionGroup(aa[selectedRow].groupRef); |
848 |
|
} |
849 |
|
} |
850 |
|
else |
851 |
|
{ |
852 |
|
|
853 |
0 |
int remainToAdd = aa[selectedRow].groupRef.getSize(); |
854 |
0 |
for (SequenceI sgs : aa[selectedRow].groupRef.getSequences()) |
855 |
|
{ |
856 |
0 |
if (jalview.util.Platform.isControlDown(evt)) |
857 |
|
{ |
858 |
0 |
sg.addOrRemove(sgs, --remainToAdd == 0); |
859 |
|
} |
860 |
|
else |
861 |
|
{ |
862 |
|
|
863 |
|
|
864 |
0 |
sg.addSequence(sgs, --remainToAdd == 0); |
865 |
|
} |
866 |
|
} |
867 |
|
} |
868 |
|
|
869 |
0 |
ap.paintAlignment(false, false); |
870 |
0 |
PaintRefresher.Refresh(ap, ap.av.getSequenceSetId()); |
871 |
0 |
ap.av.sendSelection(); |
872 |
|
} |
873 |
|
else |
874 |
|
{ |
875 |
0 |
ap.getSeqPanel().ap.getIdPanel().highlightSearchResults( |
876 |
|
aa[selectedRow].groupRef.getSequences(null)); |
877 |
|
} |
878 |
0 |
return; |
879 |
|
} |
880 |
0 |
else if (aa[selectedRow].sequenceRef != null) |
881 |
|
{ |
882 |
0 |
if (evt.getClickCount() == 1) |
883 |
|
{ |
884 |
0 |
ap.getSeqPanel().ap.getIdPanel() |
885 |
|
.highlightSearchResults(Arrays.asList(new SequenceI[] |
886 |
|
{ aa[selectedRow].sequenceRef })); |
887 |
|
} |
888 |
0 |
else if (evt.getClickCount() >= 2) |
889 |
|
{ |
890 |
0 |
ap.getSeqPanel().ap.getIdPanel().highlightSearchResults(null); |
891 |
0 |
SequenceGroup sg = ap.av.getSelectionGroup(); |
892 |
0 |
if (sg != null) |
893 |
|
{ |
894 |
|
|
895 |
|
|
896 |
|
|
897 |
0 |
if (!(Platform.isControlDown(evt) || evt.isShiftDown())) |
898 |
|
{ |
899 |
0 |
sg = new SequenceGroup(sg); |
900 |
0 |
sg.clear(); |
901 |
0 |
sg.addSequence(aa[selectedRow].sequenceRef, false); |
902 |
|
} |
903 |
|
else |
904 |
|
{ |
905 |
0 |
if (Platform.isControlDown(evt)) |
906 |
|
{ |
907 |
0 |
sg.addOrRemove(aa[selectedRow].sequenceRef, true); |
908 |
|
} |
909 |
|
else |
910 |
|
{ |
911 |
|
|
912 |
|
|
913 |
0 |
sg.addSequence(aa[selectedRow].sequenceRef, true); |
914 |
|
} |
915 |
|
} |
916 |
|
} |
917 |
|
else |
918 |
|
{ |
919 |
0 |
sg = new SequenceGroup(); |
920 |
0 |
sg.setStartRes(0); |
921 |
0 |
sg.setEndRes(ap.av.getAlignment().getWidth() - 1); |
922 |
0 |
sg.addSequence(aa[selectedRow].sequenceRef, false); |
923 |
|
} |
924 |
0 |
ap.av.setSelectionGroup(sg); |
925 |
0 |
ap.paintAlignment(false, false); |
926 |
0 |
PaintRefresher.Refresh(ap, ap.av.getSequenceSetId()); |
927 |
0 |
ap.av.sendSelection(); |
928 |
|
} |
929 |
|
|
930 |
|
} |
931 |
|
} |
932 |
0 |
return; |
933 |
|
} |
934 |
|
} |
935 |
|
|
936 |
|
|
937 |
|
|
938 |
|
|
939 |
|
@param |
940 |
|
|
941 |
|
|
|
|
| 0% |
Uncovered Elements: 28 (28) |
Complexity: 5 |
Complexity Density: 0.25 |
|
942 |
0 |
protected void copy_annotseqtoclipboard(SequenceI sq)... |
943 |
|
{ |
944 |
0 |
SequenceI[] seqs = new SequenceI[] { sq }; |
945 |
0 |
String[] omitHidden = null; |
946 |
0 |
SequenceI[] dseqs = new SequenceI[] { sq.getDatasetSequence() }; |
947 |
0 |
if (dseqs[0] == null) |
948 |
|
{ |
949 |
0 |
dseqs[0] = new Sequence(sq); |
950 |
0 |
dseqs[0].setSequence(AlignSeq.extractGaps(Comparison.GapChars, |
951 |
|
sq.getSequenceAsString())); |
952 |
|
|
953 |
0 |
sq.setDatasetSequence(dseqs[0]); |
954 |
|
} |
955 |
0 |
Alignment ds = new Alignment(dseqs); |
956 |
0 |
if (av.hasHiddenColumns()) |
957 |
|
{ |
958 |
0 |
Iterator<int[]> it = av.getAlignment().getHiddenColumns() |
959 |
|
.getVisContigsIterator(0, sq.getLength(), false); |
960 |
0 |
omitHidden = new String[] { sq.getSequenceStringFromIterator(it) }; |
961 |
|
} |
962 |
|
|
963 |
0 |
int[] alignmentStartEnd = new int[] { 0, ds.getWidth() - 1 }; |
964 |
0 |
if (av.hasHiddenColumns()) |
965 |
|
{ |
966 |
0 |
alignmentStartEnd = av.getAlignment().getHiddenColumns() |
967 |
|
.getVisibleStartAndEndIndex(av.getAlignment().getWidth()); |
968 |
|
} |
969 |
|
|
970 |
0 |
String output = new FormatAdapter().formatSequences(FileFormat.Fasta, |
971 |
|
seqs, omitHidden, alignmentStartEnd); |
972 |
|
|
973 |
0 |
Toolkit.getDefaultToolkit().getSystemClipboard() |
974 |
|
.setContents(new StringSelection(output), Desktop.instance); |
975 |
|
|
976 |
0 |
HiddenColumns hiddenColumns = null; |
977 |
|
|
978 |
0 |
if (av.hasHiddenColumns()) |
979 |
|
{ |
980 |
0 |
hiddenColumns = new HiddenColumns( |
981 |
|
av.getAlignment().getHiddenColumns()); |
982 |
|
} |
983 |
|
|
984 |
0 |
Desktop.jalviewClipboard = new Object[] { seqs, ds, |
985 |
|
|
986 |
|
|
987 |
|
|
988 |
|
|
989 |
|
hiddenColumns }; |
990 |
|
} |
991 |
|
|
992 |
|
|
993 |
|
|
994 |
|
|
995 |
|
@param |
996 |
|
|
997 |
|
|
|
|
| 63.6% |
Uncovered Elements: 4 (11) |
Complexity: 3 |
Complexity Density: 0.43 |
|
998 |
478 |
@Override... |
999 |
|
public void paintComponent(Graphics g) |
1000 |
|
{ |
1001 |
|
|
1002 |
478 |
int width = getWidth(); |
1003 |
478 |
if (width == 0) |
1004 |
|
{ |
1005 |
0 |
width = ap.calculateIdWidth().width; |
1006 |
|
} |
1007 |
|
|
1008 |
478 |
Graphics2D g2 = (Graphics2D) g; |
1009 |
478 |
if (av.antiAlias) |
1010 |
|
{ |
1011 |
0 |
g2.setRenderingHint(RenderingHints.KEY_ANTIALIASING, |
1012 |
|
RenderingHints.VALUE_ANTIALIAS_ON); |
1013 |
|
} |
1014 |
|
|
1015 |
478 |
drawComponent(g2, true, width); |
1016 |
|
|
1017 |
|
} |
1018 |
|
|
1019 |
|
|
1020 |
|
|
1021 |
|
|
1022 |
|
|
1023 |
|
@param |
1024 |
|
|
1025 |
|
@param |
1026 |
|
|
1027 |
|
|
1028 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
1029 |
248 |
public void drawComponent(Graphics g, int width)... |
1030 |
|
{ |
1031 |
248 |
drawComponent(g, false, width); |
1032 |
|
} |
1033 |
|
|
1034 |
|
|
1035 |
|
|
1036 |
|
|
1037 |
|
|
1038 |
|
@param |
1039 |
|
|
1040 |
|
@param |
1041 |
|
|
1042 |
|
|
1043 |
|
@param |
1044 |
|
|
1045 |
|
|
|
|
| 52.9% |
Uncovered Elements: 66 (140) |
Complexity: 32 |
Complexity Density: 0.36 |
|
1046 |
726 |
public void drawComponent(Graphics g, boolean clip, int width)... |
1047 |
|
{ |
1048 |
726 |
if (av.getFont().getSize() < 10) |
1049 |
|
{ |
1050 |
0 |
g.setFont(font); |
1051 |
|
} |
1052 |
|
else |
1053 |
|
{ |
1054 |
726 |
g.setFont(av.getFont()); |
1055 |
|
} |
1056 |
|
|
1057 |
726 |
FontMetrics fm = g.getFontMetrics(g.getFont()); |
1058 |
726 |
g.setColor(Color.white); |
1059 |
726 |
g.fillRect(0, 0, getWidth(), getHeight()); |
1060 |
|
|
1061 |
726 |
g.translate(0, getScrollOffset()); |
1062 |
726 |
g.setColor(Color.black); |
1063 |
|
|
1064 |
726 |
AlignmentAnnotation[] aa = av.getAlignment().getAlignmentAnnotation(); |
1065 |
726 |
int fontHeight = g.getFont().getSize(); |
1066 |
726 |
int y = 0; |
1067 |
726 |
int x = 0; |
1068 |
726 |
int graphExtras = 0; |
1069 |
726 |
int offset = 0; |
1070 |
726 |
Font baseFont = g.getFont(); |
1071 |
726 |
FontMetrics baseMetrics = fm; |
1072 |
726 |
int ofontH = fontHeight; |
1073 |
726 |
int sOffset = 0; |
1074 |
726 |
int visHeight = 0; |
1075 |
726 |
int[] visr = (ap != null && ap.getAnnotationPanel() != null) |
1076 |
|
? ap.getAnnotationPanel().getVisibleVRange() |
1077 |
|
: null; |
1078 |
726 |
if (clip && visr != null) |
1079 |
|
{ |
1080 |
478 |
sOffset = visr[0]; |
1081 |
478 |
visHeight = visr[1]; |
1082 |
|
} |
1083 |
726 |
boolean visible = true, before = false, after = false; |
1084 |
726 |
if (aa != null) |
1085 |
|
{ |
1086 |
726 |
hasHiddenRows = false; |
1087 |
726 |
int olY = 0; |
1088 |
5126 |
for (int i = 0; i < aa.length; i++) |
1089 |
|
{ |
1090 |
4400 |
visible = true; |
1091 |
4400 |
if (!aa[i].visible) |
1092 |
|
{ |
1093 |
420 |
hasHiddenRows = true; |
1094 |
420 |
continue; |
1095 |
|
} |
1096 |
3980 |
olY = y; |
1097 |
3980 |
y += aa[i].height; |
1098 |
3980 |
if (clip) |
1099 |
|
{ |
1100 |
2752 |
if (y < sOffset) |
1101 |
|
{ |
1102 |
0 |
if (!before) |
1103 |
|
{ |
1104 |
0 |
if (debugRedraw) |
1105 |
|
{ |
1106 |
0 |
System.out.println("before vis: " + i); |
1107 |
|
} |
1108 |
0 |
before = true; |
1109 |
|
} |
1110 |
|
|
1111 |
0 |
continue; |
1112 |
|
} |
1113 |
2752 |
if (olY > visHeight) |
1114 |
|
{ |
1115 |
|
|
1116 |
126 |
if (!after) |
1117 |
|
{ |
1118 |
118 |
if (debugRedraw) |
1119 |
|
{ |
1120 |
0 |
System.out.println( |
1121 |
|
"Scroll offset: " + sOffset + " after vis: " + i); |
1122 |
|
} |
1123 |
118 |
after = true; |
1124 |
|
} |
1125 |
|
|
1126 |
126 |
continue; |
1127 |
|
} |
1128 |
|
} |
1129 |
3854 |
g.setColor(Color.black); |
1130 |
|
|
1131 |
3854 |
offset = -aa[i].height / 2; |
1132 |
|
|
1133 |
3854 |
if (aa[i].hasText) |
1134 |
|
{ |
1135 |
3586 |
offset += fm.getHeight() / 2; |
1136 |
3586 |
offset -= fm.getDescent(); |
1137 |
|
} |
1138 |
|
else |
1139 |
|
{ |
1140 |
268 |
offset += fm.getDescent(); |
1141 |
|
} |
1142 |
|
|
1143 |
3854 |
x = width - fm.stringWidth(aa[i].label) - 3; |
1144 |
|
|
1145 |
3854 |
if (aa[i].graphGroup > -1) |
1146 |
|
{ |
1147 |
0 |
int groupSize = 0; |
1148 |
|
|
1149 |
|
|
1150 |
0 |
for (int gg = 0; gg < aa.length; gg++) |
1151 |
|
{ |
1152 |
0 |
if (aa[gg].graphGroup == aa[i].graphGroup) |
1153 |
|
{ |
1154 |
0 |
groupSize++; |
1155 |
|
} |
1156 |
|
} |
1157 |
0 |
if (groupSize * (fontHeight + 8) < aa[i].height) |
1158 |
|
{ |
1159 |
0 |
graphExtras = (aa[i].height - (groupSize * (fontHeight + 8))) |
1160 |
|
/ 2; |
1161 |
|
} |
1162 |
|
else |
1163 |
|
{ |
1164 |
|
|
1165 |
0 |
float h = aa[i].height / (float) groupSize, s; |
1166 |
0 |
if (h < 9) |
1167 |
|
{ |
1168 |
0 |
visible = false; |
1169 |
|
} |
1170 |
|
else |
1171 |
|
{ |
1172 |
0 |
fontHeight = -8 + (int) h; |
1173 |
0 |
s = ((float) fontHeight) / (float) ofontH; |
1174 |
0 |
Font f = baseFont |
1175 |
|
.deriveFont(AffineTransform.getScaleInstance(s, s)); |
1176 |
0 |
g.setFont(f); |
1177 |
0 |
fm = g.getFontMetrics(); |
1178 |
0 |
graphExtras = (aa[i].height - (groupSize * (fontHeight + 8))) |
1179 |
|
/ 2; |
1180 |
|
} |
1181 |
|
} |
1182 |
0 |
if (visible) |
1183 |
|
{ |
1184 |
0 |
for (int gg = 0; gg < aa.length; gg++) |
1185 |
|
{ |
1186 |
0 |
if (aa[gg].graphGroup == aa[i].graphGroup) |
1187 |
|
{ |
1188 |
0 |
x = width - fm.stringWidth(aa[gg].label) - 3; |
1189 |
0 |
g.drawString(aa[gg].label, x, y - graphExtras); |
1190 |
|
|
1191 |
0 |
if (aa[gg]._linecolour != null) |
1192 |
|
{ |
1193 |
|
|
1194 |
0 |
g.setColor(aa[gg]._linecolour); |
1195 |
0 |
g.drawLine(x, y - graphExtras + 3, |
1196 |
|
x + fm.stringWidth(aa[gg].label), |
1197 |
|
y - graphExtras + 3); |
1198 |
|
} |
1199 |
|
|
1200 |
0 |
g.setColor(Color.black); |
1201 |
0 |
graphExtras += fontHeight + 8; |
1202 |
|
} |
1203 |
|
} |
1204 |
|
} |
1205 |
0 |
g.setFont(baseFont); |
1206 |
0 |
fm = baseMetrics; |
1207 |
0 |
fontHeight = ofontH; |
1208 |
|
} |
1209 |
|
else |
1210 |
|
{ |
1211 |
3854 |
g.drawString(aa[i].label, x, y + offset); |
1212 |
|
} |
1213 |
|
} |
1214 |
|
} |
1215 |
|
|
1216 |
726 |
if (!resizePanel && dragEvent != null && aa != null) |
1217 |
|
{ |
1218 |
0 |
g.setColor(Color.lightGray); |
1219 |
0 |
g.drawString(aa[selectedRow].label, dragEvent.getX(), |
1220 |
|
dragEvent.getY() - getScrollOffset()); |
1221 |
|
} |
1222 |
|
|
1223 |
726 |
if (!av.getWrapAlignment() && ((aa == null) || (aa.length < 1))) |
1224 |
|
{ |
1225 |
0 |
g.drawString(MessageManager.getString("label.right_click"), 2, 8); |
1226 |
0 |
g.drawString(MessageManager.getString("label.to_add_annotation"), 2, |
1227 |
|
18); |
1228 |
|
} |
1229 |
|
} |
1230 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
1231 |
1683 |
public int getScrollOffset()... |
1232 |
|
{ |
1233 |
1683 |
return scrollOffset; |
1234 |
|
} |
1235 |
|
|
|
|
| - |
Uncovered Elements: 0 (0) |
Complexity: 1 |
Complexity Density: - |
|
1236 |
0 |
@Override... |
1237 |
|
public void mouseEntered(MouseEvent e) |
1238 |
|
{ |
1239 |
|
} |
1240 |
|
} |