/** * A request for the MesquiteModule to perform a command. It is passed two strings, the name of * the command and the arguments. This should be overridden by any module that wants to respond to * a command. */ public Object doCommand(String commandName, String arguments, CommandChecker checker) { if (checker.compare(MesquiteModule.class, null, null, commandName, "paint")) { MesquiteInteger io = new MesquiteInteger(0); int column = MesquiteInteger.fromString(arguments, io); int row = MesquiteInteger.fromString(arguments, io); if (MesquiteInteger.isCombinable(row)) { if (!MesquiteLong.isCombinable(currentColor)) removeColor(row, true); else setColor(row, (int) currentColor); } } else if (checker.compare( this.getClass(), "Sets the color to be used to paint cells", "[name of color]", commandName, "setColor")) { int bc = ColorDistribution.standardColorNames.indexOf(parser.getFirstToken(arguments)); if (bc >= 0 && MesquiteLong.isCombinable(bc)) { removeColor.setValue(false); currentColor = bc; savedColor = bc; colorString = "Color " + ColorDistribution.standardColorNames.getValue(bc); } } else if (checker.compare( this.getClass(), "Sets the color of selected taxa", "[name of color]", commandName, "setColorSelected")) { int bc = ColorDistribution.standardColorNames.indexOf(parser.getFirstToken(arguments)); if (bc >= 0 && MesquiteLong.isCombinable(bc)) { for (int it = 0; it < taxa.getNumTaxa(); it++) if (taxa.getSelected(it)) setColor(it, bc); } } else if (checker.compare( this.getClass(), "Removes color from all the cells", null, commandName, "removeAllColor")) { removeAllColor(true); } else if (checker.compare( this.getClass(), "Sets the paint brush so that it removes colors from any cells touched", null, commandName, "removeColor")) { if (StringUtil.blank(arguments)) removeColor.setValue(!removeColor.getValue()); else removeColor.toggleValue(parser.getFirstToken(arguments)); if (removeColor.getValue()) { colorString = "Remove color"; currentColor = MesquiteLong.unassigned; } else { colorString = "Color " + ColorDistribution.standardColorNames.getValue((int) currentColor); currentColor = savedColor; } } else return super.doCommand(commandName, arguments, checker); return null; }
public void textValueChanged(TextEvent e) { boolean b = false; String s = tf.getText(); try { int value = MesquiteInteger.fromString(s); b = (value <= maxValue && value >= minValue && value != currentValue); } catch (NumberFormatException ex) { } enterButton.setEnabled(b && !enterLock); }
public boolean isTextValid() { boolean b = false; String s = tf.getText(); try { int value = MesquiteInteger.fromString(s); b = (value <= maxValue && value >= minValue); } catch (NumberFormatException e) { } return b; }
public void acceptText() { String s = tf.getText(); oldText = null; text = s; try { int value = MesquiteInteger.fromString(s); crement(value); } catch (NumberFormatException e) { } }
/*.................................................................................................................*/ public void processSingleXMLPreference(String tag, String content) { if ("bootStrapReps".equalsIgnoreCase(tag)) bootstrapreps = MesquiteInteger.fromString(content); if ("mxram".equalsIgnoreCase(tag)) mxram = MesquiteInteger.fromString(content); if ("convertGapsToMissing".equalsIgnoreCase(tag)) convertGapsToMissing = MesquiteBoolean.fromTrueFalseString(content); if ("resamplingAllConsensusTrees".equalsIgnoreCase(tag)) resamplingAllConsensusTrees = MesquiteBoolean.fromTrueFalseString(content); if ("harvestOnlyStrictConsensus".equalsIgnoreCase(tag)) harvestOnlyStrictConsensus = MesquiteBoolean.fromTrueFalseString(content); if ("searchStyle".equalsIgnoreCase(tag)) searchStyle = MesquiteInteger.fromString(content); if ("searchArguments".equalsIgnoreCase(tag)) searchArguments = StringUtil.cleanXMLEscapeCharacters(content); if ("bootstrapSearchArguments".equalsIgnoreCase(tag)) bootstrapSearchArguments = StringUtil.cleanXMLEscapeCharacters(content); if ("otherOptions".equalsIgnoreCase(tag)) otherOptions = StringUtil.cleanXMLEscapeCharacters(content); // parallel, etc. preferencesSet = true; }
/*.................................................................................................................*/ public void processSingleXMLPreference(String tag, String content) { if ("availMemory".equalsIgnoreCase(tag)) availMemory = MesquiteInteger.fromString(content); super.processSingleXMLPreference(tag, content); }
public void runFilesAvailable(int fileNum) { String[] logFileNames = getLogFileNames(); if ((progIndicator != null && progIndicator.isAborted()) || logFileNames == null) return; String[] outputFilePaths = new String[logFileNames.length]; outputFilePaths[fileNum] = externalProcRunner.getOutputFilePath(logFileNames[fileNum]); String filePath = outputFilePaths[fileNum]; if (fileNum == 0 && outputFilePaths.length > 0 && !StringUtil.blank(outputFilePaths[0]) && !bootstrapOrJackknife()) { // tree file if (ownerModule instanceof NewTreeProcessor) { String treeFilePath = filePath; if (taxa != null) { TaxaSelectionSet outgroupSet = (TaxaSelectionSet) taxa.getSpecsSet(outgroupTaxSetString, TaxaSelectionSet.class); ((NewTreeProcessor) ownerModule).newTreeAvailable(treeFilePath, outgroupSet); } else ((NewTreeProcessor) ownerModule).newTreeAvailable(treeFilePath, null); } } else if (fileNum == 1 && outputFilePaths.length > 1 && !StringUtil.blank(outputFilePaths[1]) && !bootstrapOrJackknife()) { // log file if (MesquiteFile.fileExists(filePath)) { String s = MesquiteFile.getFileLastContents(filePath); if (!StringUtil.blank(s)) if (progIndicator != null) { parser.setString(s); String rep = parser.getFirstToken(); // generation number logln(""); if (MesquiteInteger.isNumber(rep)) { int numReps = MesquiteInteger.fromString(rep) + 1; progIndicator.setText( "Replicate: " + numReps); // + ", ln L = " + parser.getNextToken()); if (bootstrapOrJackknife()) { logln("Replicate " + numReps + " of " + bootstrapreps); } logln("Replicate " + numReps + " of " + totalNumHits); progIndicator.spin(); double timePerRep = 0; if (MesquiteInteger.isCombinable(numReps) && numReps > 0) { timePerRep = timer.timeSinceVeryStartInSeconds() / numReps; // this is time per rep } int timeLeft = 0; if (bootstrapOrJackknife()) { timeLeft = (int) ((bootstrapreps - numReps) * timePerRep); } else { String token = parser.getNextToken(); // algorithm token = parser.getNextToken(); // Tree token = parser.getNextToken(); // Score String best = parser.getNextToken(); // Best logln(" Score " + token + "; best found so far " + best); timeLeft = (int) ((totalNumHits - numReps) * timePerRep); } logln( " Running time so far " + StringUtil.secondsToHHMMSS((int) timer.timeSinceVeryStartInSeconds()) + ", approximate time remaining " + StringUtil.secondsToHHMMSS(timeLeft)); } } count++; } else if (MesquiteTrunk.debugMode) logln("*** File does not exist (" + filePath + ") ***"); } }