/*................................................................................................*/ private boolean hireFillers(String directoryPath) { String[] files = directory.list(); String treePath; for (int i = 0; i < files.length; i++) { if (files[i] != null) { String fileLowerCase = files[i].toLowerCase(); if (fileLowerCase.endsWith(".nex") || fileLowerCase.endsWith(".nexus")) { treePath = directoryPath + MesquiteFile.fileSeparator + files[i]; File treeFile = new File(treePath); String treeFileName = treeFile.getName(); if (StringUtil.blank(treeFileName)) { return false; } TreeBlockFiller newFiller; newFiller = (TreeBlockFiller) hireNamedEmployee(TreeBlockFiller.class, "#SampleOneTreeFromFile"); // treePath); if (newFiller != null) { if (((SampleOneTreeFromFile) newFiller).setFilePath(treePath) && ((SampleOneTreeFromFile) newFiller).processFile()) { fillerTasks.addElement(newFiller); } else Debugg.println( "Filler " + i + " processFile = " + ((SampleOneTreeFromFile) newFiller).processFile()); } } } } return true; }
/*................................................................................................*/ private TreeVector fillBlock(Taxa taxa) { // TODO: fill in TreeVector filledVector = new TreeVector(taxa); int vectorTreeCount = 0; for (int fillers = 0; fillers < fillerTasks.size(); fillers++) { if (fillerTasks.get(fillers) instanceof SampleOneTreeFromFile) { ((SampleOneTreeFromFile) fillerTasks.get(fillers)) .resetTreesToSample(); // One unnecessary resetting of bits on first call TreeVector tempTreeVector = new TreeVector(taxa); ((TreeBlockFiller) fillerTasks.get(fillers)).fillTreeBlock(tempTreeVector, 1); if (tempTreeVector.getNumberOfTrees() < 1) { logln( "Not enough trees were supplied by " + ((TreeBlockFiller) fillerTasks.get(fillers)).getName() + "; " + tempTreeVector.getNumberOfTrees() + " provided, one requested."); ; } if (tempTreeVector.getNumberOfTrees() > 0) { int treeCount = 0; while (treeCount < 1 && treeCount < tempTreeVector .getNumberOfTrees()) { // Check so we don't ask for more trees that are there. filledVector.addElement(tempTreeVector.getTree(treeCount), false); if (filledVector != null && tempTreeVector != null) { if (filledVector.getTree(vectorTreeCount) != null && tempTreeVector.getName() != null) { if (filledVector.getTree(vectorTreeCount).getName() != null) logln( filledVector.getTree(vectorTreeCount).getName() + " added from " + tempTreeVector.getName()); } } treeCount++; vectorTreeCount++; } } tempTreeVector.dispose(); // disposed to reduce memory demands // (fillerTask.get(fillers)). } } return filledVector; }
/*.................................................................................................................*/ public TreeDisplayExtra createTreeDisplayExtra(TreeDisplay treeDisplay) { PAdjustToolExtra newPj = new PAdjustToolExtra(this, treeDisplay); extras.addElement(newPj); return newPj; }