tree = new NJTree(seq, type, pwtype, start, end);\r
\r
treeCanvas = new TreeCanvas(av, tree, scrollPane, longestName);\r
-\r
+ treeCanvas.setShowDistances(true); // We know this tree has distances. JBPNote TODO: prolly should add this as a userdefined default\r
+ setViewStateFromTreeCanvas(treeCanvas);\r
tree.reCount(tree.getTopNode());\r
tree.findHeight(tree.getTopNode());\r
scrollPane.setViewportView(treeCanvas);\r
\r
}\r
+ private void setViewStateFromTreeCanvas(TreeCanvas tree) {\r
+ // update view menu state from treeCanvas render state\r
+ distanceMenu.setSelected(tree.showDistances);\r
+ bootstrapMenu.setSelected(tree.showBootstrap);\r
+ placeholdersMenu.setSelected(tree.markPlaceholders);\r
+ }\r
+\r
+ private void setTreeCanvasFromViewState(TreeCanvas tree) {\r
+ // update view menu state from treeCanvas render state\r
+ tree.showDistances = distanceMenu.isSelected();\r
+ tree.showBootstrap = bootstrapMenu.isSelected();\r
+ tree.markPlaceholders = placeholdersMenu.isSelected();\r
+ }\r
+\r
+\r
public TreePanel(AlignViewport av, Vector seqVector, NewickFile newtree,\r
String type, String pwtype)\r
{\r
tree = new NJTree(seq, newtree);\r
// Now have to calculate longest name based on the leaves\r
Vector leaves = tree.findLeaves(tree.getTopNode(),new Vector());\r
-\r
- for (int i=0;i < leaves.size();i++)\r
- if (longestName.length()<((Sequence) ((SequenceNode) leaves.elementAt(i)).element()).getName().length())\r
- longestName = TreeCanvas.PLACEHOLDER+((Sequence) ((SequenceNode) leaves.elementAt(i)).element()).getName();\r
-\r
+ boolean has_placeholders = false;\r
+ for (int i=0;i < leaves.size();i++) {\r
+ SequenceNode lf = (SequenceNode) leaves.elementAt(i);\r
+ if (lf.isPlaceholder())\r
+ has_placeholders = true;\r
+ if (longestName.length()<((Sequence) lf.element()).getName().length())\r
+ longestName = TreeCanvas.PLACEHOLDER+((Sequence) lf.element()).getName();\r
+ }\r
tree.reCount(tree.getTopNode());\r
tree.findHeight(tree.getTopNode());\r
\r
treeCanvas.setShowBootstrap(newtree.HasBootstrap());\r
treeCanvas.setShowDistances(newtree.HasDistances());\r
scrollPane.setViewportView(treeCanvas);\r
- distanceMenu.setSelected(newtree.HasDistances());\r
- bootstrapMenu.setSelected(newtree.HasBootstrap());\r
- if (true) // JBPNote TODO: preference for always marking placeholders in new associated tree\r
- placeholdersMenu.setSelected(treeCanvas.markPlaceholders);\r
-\r
+ treeCanvas.setMarkPlaceholders(has_placeholders);\r
+ setViewStateFromTreeCanvas(treeCanvas);\r
+ // JBPNote TODO: preference for always marking placeholders in new associated tree\r
}\r
\r
\r