@author Andrew Rambaut @version $Id$ $HeadURL$ $LastChangedBy$ $LastChangedDate$ $LastChangedRevision$
| 47 | * $LastChangedRevision$ |
| 48 | */ |
| 49 | public 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 | } |
nothing calls this directly
no outgoing calls
no test coverage detected
searching dependent graphs…