1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18 package de.mindcrimeilab.xsanalyzer.ui.renderer;
19
20 import java.awt.Component;
21
22 import javax.swing.DefaultListCellRenderer;
23 import javax.swing.JLabel;
24 import javax.swing.JList;
25 import javax.swing.ListCellRenderer;
26
27 import de.mindcrimeilab.xsanalyzer.model.SimilarTypeListModelEntry;
28
29
30
31
32
33
34
35 public class SimilarTypeRenderer extends DefaultListCellRenderer implements ListCellRenderer {
36
37 private final ListCellRenderer renderDelegate;
38
39 public SimilarTypeRenderer() {
40 renderDelegate = new SchemaElementsRenderer();
41 }
42
43 @Override
44 public Component getListCellRendererComponent(JList list, Object value, int index, boolean isSelected, boolean cellHasFocus) {
45 final JLabel cell;
46
47 if (value instanceof SimilarTypeListModelEntry) {
48 SimilarTypeListModelEntry entry = (SimilarTypeListModelEntry) value;
49
50 cell = (JLabel) renderDelegate.getListCellRendererComponent(list, entry.getType(), index, isSelected, cellHasFocus);
51 cell.setText(cell.getText());
52 cell.setToolTipText("Computed similarity md5 sum:" + entry.getTypeSignature() + ".");
53 }
54 else {
55 cell = (JLabel) super.getListCellRendererComponent(list, value, index, isSelected, cellHasFocus);
56 }
57 return cell;
58 }
59 }