Debian Codegraph @

src/dr/app/bss/TreesTableRecord.java

raw symbols SCIP
1 /*
2 * TreesTableRecord.java
3 *
4 * Copyright (c) 2002-2015 Alexei Drummond, Andrew Rambaut and Marc Suchard
5 *
6 * This file is part of BEAST.
7 * See the NOTICE file distributed with this work for additional
8 * information regarding copyright ownership and licensing.
9 *
10 * BEAST is free software; you can redistribute it and/or modify
11 * it under the terms of the GNU Lesser General Public License as
12 * published by the Free Software Foundation; either version 2
13 * of the License, or (at your option) any later version.
14 *
15 * BEAST is distributed in the hope that it will be useful,
16 * but WITHOUT ANY WARRANTY; without even the implied warranty of
17 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18 * GNU Lesser General Public License for more details.
19 *
20 * You should have received a copy of the GNU Lesser General Public
21 * License along with BEAST; if not, write to the
22 * Free Software Foundation, Inc., 51 Franklin St, Fifth Floor,
23 * Boston, MA 02110-1301 USA
24 */
25
26 package dr.app.bss;
27
28 import java.io.Serializable;
29
30 import dr.evolution.tree.Tree;
31 import dr.evolution.util.Taxa;
32
33 @SuppressWarnings("serial")
34 public class TreesTableRecord implements Serializable {
35
36 private String name = "";
37 private Taxa taxa = null;
38 private Tree tree = null;
39
40 private boolean treeSet = false;
41 private boolean taxaSet = false;
42
43 public TreesTableRecord() {
44 }// END: Constructor
45
46 public TreesTableRecord(String name, Tree tree) {
47 this.name = name;
48 this.tree = tree;
49
50 treeSet = true;
51 applyTreeName();
52 }// END: Constructor
53
54 public TreesTableRecord(String name, Taxa taxa) {
55 this.name = name;
56 this.taxa = taxa;
57
58 taxaSet = true;
59 applyTaxaName();
60 }// END: Constructor
61
62 private void applyTaxaName() {
63
64 if (taxaSet && name != null) {
65
66 for (int i = 0; i < taxa.getTaxonCount(); i++) {
67 taxa.setTaxonAttribute(i, Utils.TREE_FILENAME, name);
68 }
69 }
70 }// END: applyTaxaName
71
72 private void applyTreeName() {
73
74 if (treeSet && name != null) {
75
76 for (int i = 0; i < tree.getTaxonCount(); i++) {
77 tree.getTaxon(i).setAttribute(Utils.TREE_FILENAME, name);
78 }
79 }
80 }// END: applyTreeName
81
82 public int getTaxaCount() {
83
84 int taxaCount = 0;
85
86 if (taxaSet) {
87
88 taxaCount = taxa.getTaxonCount();
89
90 } else if (treeSet) {
91
92 taxaCount = tree.getTaxonCount();
93
94 } else {
95 // do nothing
96 }
97
98 return taxaCount;
99 }// END: getTaxaCount
100
101 public String getName() {
102 return name;
103 }
104
105 public Tree getTree() {
106 return tree;
107 }
108
109 public Taxa getTaxa() {
110 return taxa;
111 }
112
113 public String toString() {
114 return getName();
115 }
116
117 public boolean isTreeSet() {
118 return this.treeSet;
119 }
120
121 public boolean isTaxaSet() {
122 return this.taxaSet;
123 }
124
125 }// END: class