MCPcopy Create free account
hub / github.com/rambaut/figtree / ExtendedTreeViewer

Class ExtendedTreeViewer

src/figtree/treeviewer/ExtendedTreeViewer.java:49–270  ·  view source on GitHub ↗

@author Andrew Rambaut @version $Id$ $HeadURL$ $LastChangedBy$ $LastChangedDate$ $LastChangedRevision$

Source from the content-addressed store, hash-verified

47 * $LastChangedRevision$
48 */
49public class ExtendedTreeViewer extends DefaultTreeViewer implements StatusProvider {
50
51 public ExtendedTreeViewer() {
52 this(null);
53 }
54
55 public ExtendedTreeViewer(JFrame frame) {
56 super(frame);
57
58 // setTreesPerPage(1);
59
60 setBackground(Color.white);
61
62 }
63
64 public void setPattern(Pattern pattern) {
65 if (pattern != null) {
66 // setBranchDecorator(new ParsimonyBranchDecorator(pattern));
67 } else {
68 setBranchDecorator(null, false);
69 }
70 }
71
72 public void addTree(Tree tree) {
73
74 Set<String> names = new TreeSet<String>();
75 for (Node node : tree.getNodes()) {
76 names.addAll(node.getAttributeNames());
77 }
78 for (Taxon taxon : tree.getTaxa()) {
79 names.addAll(taxon.getAttributeNames());
80 }
81 for (String name : names) {
82 if (!name.startsWith("!")) {
83 AnnotationDefinition annotation = getAnnotationDefinitions().get(name);
84
85 Set<Attributable> items = new HashSet<Attributable>(tree.getNodes());
86 items.addAll(tree.getTaxa());
87
88 AnnotationDefinition.Type type = AnnotationDefinition.guessType(name, items);
89
90 if (annotation == null) {
91 annotation = new AnnotationDefinition(name, type);
92 getAnnotationDefinitions().put(name, annotation);
93 } else if (type != annotation.getType()){
94 AnnotationDefinition.Type newType = AnnotationDefinition.Type.STRING;
95 if (type == AnnotationDefinition.Type.INTEGER &&
96 annotation.getType() == AnnotationDefinition.Type.REAL) {
97 newType = AnnotationDefinition.Type.REAL;
98 }
99
100 if (newType != type) {
101 annotation = new AnnotationDefinition(name, newType);
102 getAnnotationDefinitions().put(name, annotation);
103 }
104
105 }
106 }

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…