コード例 #1
0
ファイル: Options.java プロジェクト: kkkkxu/BioImage
  // Miscellaneous Options
  void miscOptions() {
    String key = IJ.isMacintosh() ? "command" : "control";
    GenericDialog gd = new GenericDialog("Miscellaneous Options", IJ.getInstance());
    gd.addStringField("Divide by zero value:", "" + FloatBlitter.divideByZeroValue, 10);
    gd.addCheckbox("Use pointer cursor", Prefs.usePointerCursor);
    gd.addCheckbox("Hide \"Process Stack?\" dialog", IJ.hideProcessStackDialog);
    gd.addCheckbox("Require " + key + " key for shortcuts", Prefs.requireControlKey);
    gd.addCheckbox("Move isolated plugins to Misc. menu", Prefs.moveToMisc);
    if (!IJ.isMacOSX()) gd.addCheckbox("Run single instance listener", Prefs.runSocketListener);
    gd.addCheckbox("Enhanced line tool", Prefs.enhancedLineTool);
    gd.addCheckbox("Reverse CZT order of \">\" and \"<\"", Prefs.reverseNextPreviousOrder);
    gd.addCheckbox("Debug mode", IJ.debugMode);
    gd.addHelp(IJ.URL + "/docs/menus/edit.html#misc");
    gd.showDialog();
    if (gd.wasCanceled()) return;

    String divValue = gd.getNextString();
    if (divValue.equalsIgnoreCase("infinity") || divValue.equalsIgnoreCase("infinite"))
      FloatBlitter.divideByZeroValue = Float.POSITIVE_INFINITY;
    else if (divValue.equalsIgnoreCase("NaN")) FloatBlitter.divideByZeroValue = Float.NaN;
    else if (divValue.equalsIgnoreCase("max")) FloatBlitter.divideByZeroValue = Float.MAX_VALUE;
    else {
      Float f;
      try {
        f = new Float(divValue);
      } catch (NumberFormatException e) {
        f = null;
      }
      if (f != null) FloatBlitter.divideByZeroValue = f.floatValue();
    }
    IJ.register(FloatBlitter.class);

    Prefs.usePointerCursor = gd.getNextBoolean();
    IJ.hideProcessStackDialog = gd.getNextBoolean();
    Prefs.requireControlKey = gd.getNextBoolean();
    Prefs.moveToMisc = gd.getNextBoolean();
    if (!IJ.isMacOSX()) Prefs.runSocketListener = gd.getNextBoolean();
    Prefs.enhancedLineTool = gd.getNextBoolean();
    Prefs.reverseNextPreviousOrder = gd.getNextBoolean();
    IJ.setDebugMode(gd.getNextBoolean());
  }
コード例 #2
0
ファイル: ZProjector.java プロジェクト: halirutan/imagej1
  public void run(String arg) {
    imp = IJ.getImage();
    int stackSize = imp.getStackSize();
    if (imp == null) {
      IJ.noImage();
      return;
    }

    //  Make sure input image is a stack.
    if (stackSize == 1) {
      IJ.error("Z Project", "Stack required");
      return;
    }

    //  Check for inverting LUT.
    if (imp.getProcessor().isInvertedLut()) {
      if (!IJ.showMessageWithCancel("ZProjection", lutMessage)) return;
    }

    // Set default bounds.
    int channels = imp.getNChannels();
    int frames = imp.getNFrames();
    int slices = imp.getNSlices();
    isHyperstack =
        imp.isHyperStack()
            || (ij.macro.Interpreter.isBatchMode()
                && ((frames > 1 && frames < stackSize) || (slices > 1 && slices < stackSize)));
    boolean simpleComposite = channels == stackSize;
    if (simpleComposite) isHyperstack = false;
    startSlice = 1;
    if (isHyperstack) {
      int nSlices = imp.getNSlices();
      if (nSlices > 1) stopSlice = nSlices;
      else stopSlice = imp.getNFrames();
    } else stopSlice = stackSize;

    // Build control dialog
    GenericDialog gd = buildControlDialog(startSlice, stopSlice);
    gd.showDialog();
    if (gd.wasCanceled()) return;

    if (!imp.lock()) return; // exit if in use
    long tstart = System.currentTimeMillis();
    setStartSlice((int) gd.getNextNumber());
    setStopSlice((int) gd.getNextNumber());
    method = gd.getNextChoiceIndex();
    Prefs.set(METHOD_KEY, method);
    if (isHyperstack) {
      allTimeFrames = imp.getNFrames() > 1 && imp.getNSlices() > 1 ? gd.getNextBoolean() : false;
      doHyperStackProjection(allTimeFrames);
    } else if (imp.getType() == ImagePlus.COLOR_RGB) doRGBProjection(true);
    else doProjection(true);

    if (arg.equals("") && projImage != null) {
      long tstop = System.currentTimeMillis();
      projImage.setCalibration(imp.getCalibration());
      if (simpleComposite) IJ.run(projImage, "Grays", "");
      projImage.show("ZProjector: " + IJ.d2s((tstop - tstart) / 1000.0, 2) + " seconds");
    }

    imp.unlock();
    IJ.register(ZProjector.class);
    return;
  }