Пример #1
0
  /**
   * 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;
  }
Пример #2
0
 /*.................................................................................................................*/
 public int[] getTaxonNumberTranslation(Taxa taxa) {
   int max = -1;
   for (int it = 0; it < taxa.getNumTaxa(); it++) {
     long translateNumber = getTaxonNumberInTree(taxa, it);
     if (MesquiteLong.isCombinable(translateNumber) && translateNumber > max) {
       max = (int) translateNumber;
     }
   }
   int[] translate = new int[max + 1];
   for (int it = 0; it < data.getNumTaxa(); it++) {
     long translateNumber = getTaxonNumberInTree(taxa, it);
     if (MesquiteLong.isCombinable(translateNumber) && translateNumber >= 0) {
       translate[(int) translateNumber] = it;
     }
   }
   return translate;
 }
 /*.................................................................................................................*/
 public void processOutputFiles() {
   if (outputFileProcessor != null && outputFilePaths != null && lastModified != null) {
     String[] paths = outputFileProcessor.modifyOutputPaths(outputFilePaths);
     for (int i = 0; i < paths.length && i < lastModified.length; i++) {
       File file = new File(paths[i]);
       long lastMod = file.lastModified();
       if (!MesquiteLong.isCombinable(lastModified[i]) || lastMod > lastModified[i]) {
         outputFileProcessor.processOutputFile(paths, i);
         lastModified[i] = lastMod;
       }
     }
   }
 }