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

Method doImport

src/figtree/application/FigTreeFrame.java:949–989  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

947 }
948
949 public final void doImport() {
950
951 FileDialog dialog = new FileDialog(this,
952 "Import Annotations File...",
953 FileDialog.LOAD);
954
955 dialog.setVisible(true);
956 if (dialog.getFile() != null) {
957 File file = new File(dialog.getDirectory(), dialog.getFile());
958
959 try {
960 Map<AnnotationDefinition, Map<Taxon, Object>> annotations = importAnnotationsFromFile(file);
961
962 treeViewer.setTaxonAnnotations(annotations);
963
964 // Hack to show tips states...
965// String[] annotationNames = new String[annotations.keySet().size()];
966// DiscreteColourDecorator[] decorators = new DiscreteColourDecorator[annotations.keySet().size()];
967//
968// int i = 0;
969// for (AnnotationDefinition definition: annotations.keySet()) {
970// Map<Taxon, Object> annotation = annotations.get(definition);
971// annotationNames[i] = definition.getName();
972// decorators[i] = new HSBDiscreteColourDecorator(annotationNames[i], annotation.keySet());
973// i++;
974// }
975// treeViewer.setTipLabelPainter(new StatesPainter(annotationNames, decorators));
976
977
978 } catch (FileNotFoundException fnfe) {
979 JOptionPane.showMessageDialog(this, "Unable to open file: File not found",
980 "Unable to open file",
981 JOptionPane.ERROR_MESSAGE);
982 } catch (IOException ioe) {
983 JOptionPane.showMessageDialog(this, "Unable to read file: " + ioe.getMessage(),
984 "Unable to read file",
985 JOptionPane.ERROR_MESSAGE);
986 }
987 }
988
989 }
990
991 protected Map<AnnotationDefinition, Map<Taxon, Object>> importAnnotationsFromFile(File file) throws IOException {
992

Callers 1

actionPerformedMethod · 0.95

Calls 4

setTaxonAnnotationsMethod · 0.80
setVisibleMethod · 0.45
getFileMethod · 0.45

Tested by

no test coverage detected