(List<Tree> trees)
| 887 | |
| 888 | |
| 889 | private void checkLabelAttribute(List<Tree> trees) { |
| 890 | |
| 891 | boolean hasLabel = false; |
| 892 | |
| 893 | for (Tree tree : trees) { |
| 894 | for (Node node : tree.getNodes()) { |
| 895 | if (node.getAttribute("label") != null) { |
| 896 | hasLabel = true; |
| 897 | } |
| 898 | } |
| 899 | } |
| 900 | |
| 901 | if (hasLabel) { |
| 902 | String labelName = null; |
| 903 | |
| 904 | do { |
| 905 | labelName = JOptionPane.showInputDialog( |
| 906 | "The node/branches of the tree are labelled\n" + |
| 907 | "(i.e., with bootstrap values or posterior probabilities).\n\n" + |
| 908 | "Please select a name for these values.", "label"); |
| 909 | if (labelName == null) { |
| 910 | labelName = "label"; |
| 911 | } |
| 912 | labelName = labelName.trim(); |
| 913 | |
| 914 | if (labelName.length() == 0) { |
| 915 | Toolkit.getDefaultToolkit().beep(); |
| 916 | } |
| 917 | } while (labelName == null || labelName.length() == 0); |
| 918 | |
| 919 | if (!labelName.equals("label")) { |
| 920 | for (Tree tree : trees) { |
| 921 | for (Node node : tree.getNodes()) { |
| 922 | Object value = node.getAttribute("label"); |
| 923 | if (value != null) { |
| 924 | node.removeAttribute("label"); |
| 925 | node.setAttribute(labelName, value); |
| 926 | } |
| 927 | } |
| 928 | } |
| 929 | } |
| 930 | } |
| 931 | } |
| 932 | |
| 933 | |
| 934 | protected boolean writeToFile(File file) throws IOException { |
no test coverage detected