/** Called from io/Opener.java. */
  public void run(String path) {
    if (path.equals("")) return;
    File theFile = new File(path);
    String directory = theFile.getParent();
    String fileName = theFile.getName();
    if (directory == null) directory = "";

    // Try and recognise file type and load the file if recognised
    ImagePlus imp = openImage(directory, fileName, path);
    if (imp == null) {
      IJ.showStatus("");
      return; // failed to load file or plugin has opened and displayed it
    }
    ImageStack stack = imp.getStack();
    // get the title from the stack (falling back to the fileName)
    String title = imp.getTitle().equals("") ? fileName : imp.getTitle();
    // set the stack of this HandleExtraFileTypes object
    // to that attached to the ImagePlus object returned by openImage()
    setStack(title, stack);
    // copy over the calibration info since it doesn't come with the ImageProcessor
    setCalibration(imp.getCalibration());
    // also copy the Show Info field over if it exists
    if (imp.getProperty("Info") != null) setProperty("Info", imp.getProperty("Info"));
    // copy the FileInfo
    setFileInfo(imp.getOriginalFileInfo());
    // copy dimensions
    if (IJ.getVersion().compareTo("1.38s") >= 0)
      setDimensions(imp.getNChannels(), imp.getNSlices(), imp.getNFrames());
    if (IJ.getVersion().compareTo("1.41o") >= 0) setOpenAsHyperStack(imp.getOpenAsHyperStack());
  }
Beispiel #2
0
 void checkForCalibrationConflict(ImagePlus imp, Calibration cal) {
   Calibration gcal = imp.getGlobalCalibration();
   if (gcal == null || !showConflictMessage || IJ.isMacro()) return;
   if (cal.pixelWidth == gcal.pixelWidth && cal.getUnit().equals(gcal.getUnit())) return;
   GenericDialog gd = new GenericDialog(imp.getTitle());
   gd.addMessage("The calibration of this image conflicts\nwith the current global calibration.");
   gd.addCheckbox("Disable_Global Calibration", true);
   gd.addCheckbox("Disable_these Messages", false);
   gd.showDialog();
   if (gd.wasCanceled()) return;
   boolean disable = gd.getNextBoolean();
   if (disable) {
     imp.setGlobalCalibration(null);
     imp.setCalibration(cal);
     WindowManager.repaintImageWindows();
   }
   boolean dontShow = gd.getNextBoolean();
   if (dontShow) showConflictMessage = false;
 }
  private boolean showDialog() {
    String[] types = {"RAW", "JPEG", "ZLIB"};
    GenericDialog gd = new GenericDialog("Generate Bricks");
    gd.addChoice("FileType", types, filetype);
    gd.addNumericField("JPEG quality", jpeg_quality, 0);
    gd.addNumericField("Max file size (MB)", bdsizelimit, 0);

    int[] wlist = WindowManager.getIDList();
    if (wlist == null) return false;

    String[] titles = new String[wlist.length];
    for (int i = 0; i < wlist.length; i++) titles[i] = "";

    int tnum = 0;
    for (int i = 0; i < wlist.length; i++) {
      ImagePlus imp = WindowManager.getImage(wlist[i]);
      if (imp != null) {
        titles[tnum] = imp.getTitle();
        tnum++;
      }
    }
    gd.addChoice("Source image: ", titles, titles[0]);

    gd.showDialog();
    if (gd.wasCanceled()) return false;

    filetype = types[gd.getNextChoiceIndex()];
    jpeg_quality = (int) gd.getNextNumber();
    if (jpeg_quality > 100) jpeg_quality = 100;
    if (jpeg_quality < 0) jpeg_quality = 0;
    bdsizelimit = (int) gd.getNextNumber();

    int id = gd.getNextChoiceIndex();
    lvImgTitle = new ArrayList<String>();
    lvImgTitle.add(titles[id]);

    Prefs.set("filetype.string", filetype);
    Prefs.set("jpeg_quality.int", jpeg_quality);
    Prefs.set("bdsizelimit.int", bdsizelimit);

    return true;
  }