public void changeLAF(int iLAFIndex) {
    try {
      // Change LAF
      if (iLAFIndex >= marrLaf.length) iLAFIndex = marrLaf.length - 1;
      UIManager.setLookAndFeel(
          (LookAndFeel) Class.forName(marrLaf[iLAFIndex].getClassName()).newInstance());

      // Update UI
      ((JMenuItem) mvtLAFItem.elementAt(iLAFIndex)).setSelected(true);
      SwingUtilities.updateComponentTreeUI(this);
      SwingUtilities.updateComponentTreeUI(mnuMain);
      WindowManager.updateLookAndField();

      // Store config
      try {
        Hashtable prt = Global.loadHashtable(Global.FILE_CONFIG);
        prt.put("LAF", String.valueOf(iLAFIndex));
        Global.storeHashtable(prt, Global.FILE_CONFIG);
      } catch (Exception e) {
      }
    } catch (Exception e) {
      e.printStackTrace();
      MessageBox.showMessageDialog(this, e, Global.APP_NAME, MessageBox.ERROR_MESSAGE);
    }
  }
 /**
  * Saves statistics for one particle in a results table. This is a method subclasses may want to
  * override.
  */
 protected void saveResults(ImageStatistics stats, Roi roi) {
   analyzer.saveResults(stats, roi);
   if (recordStarts) {
     rt.addValue("XStart", stats.xstart);
     rt.addValue("YStart", stats.ystart);
   }
   if (addToManager) {
     if (roiManager == null) {
       if (Macro.getOptions() != null && Interpreter.isBatchMode())
         roiManager = Interpreter.getBatchModeRoiManager();
       if (roiManager == null) {
         Frame frame = WindowManager.getFrame("ROI Manager");
         if (frame == null) IJ.run("ROI Manager...");
         frame = WindowManager.getFrame("ROI Manager");
         if (frame == null || !(frame instanceof RoiManager)) {
           addToManager = false;
           return;
         }
         roiManager = (RoiManager) frame;
       }
       if (resetCounter) roiManager.runCommand("reset");
     }
     if (imp.getStackSize() > 1) roi.setPosition(imp.getCurrentSlice());
     if (lineWidth != 1) roi.setStrokeWidth(lineWidth);
     roiManager.add(imp, roi, rt.getCounter());
   }
   if (showResults) rt.addResults();
 }
Exemple #3
0
 void addToRoiManager(ImagePlus imp) {
   if (IJ.macroRunning() && Interpreter.isBatchModeRoiManager())
     IJ.error("run(\"Add to Manager\") may not work in batch mode macros");
   Frame frame = WindowManager.getFrame("ROI Manager");
   if (frame == null) IJ.run("ROI Manager...");
   if (imp == null) return;
   Roi roi = imp.getRoi();
   if (roi == null) return;
   frame = WindowManager.getFrame("ROI Manager");
   if (frame == null || !(frame instanceof RoiManager)) IJ.error("ROI Manager not found");
   RoiManager rm = (RoiManager) frame;
   boolean altDown = IJ.altKeyDown();
   IJ.setKeyUp(IJ.ALL_KEYS);
   if (altDown && !IJ.macroRunning()) IJ.setKeyDown(KeyEvent.VK_SHIFT);
   if (roi.getState() == Roi.CONSTRUCTING) { // wait (up to 2 sec.) until ROI finished
     long start = System.currentTimeMillis();
     while (true) {
       IJ.wait(10);
       if (roi.getState() != Roi.CONSTRUCTING) break;
       if ((System.currentTimeMillis() - start) > 2000) {
         IJ.beep();
         IJ.error("Add to Manager", "Selection is not complete");
         return;
       }
     }
   }
   rm.runCommand("add");
   IJ.setKeyUp(IJ.ALL_KEYS);
 }
Exemple #4
0
 /**
  * Creates a new GenericDialog with the specified title. Uses the current image image window as
  * the parent frame or the ImageJ frame if no image windows are open. Dialog parameters are
  * recorded by ImageJ's command recorder but this requires that the first word of each label be
  * unique.
  */
 public GenericDialog(String title) {
   this(
       title,
       WindowManager.getCurrentImage() != null
           ? (Frame) WindowManager.getCurrentImage().getWindow()
           : IJ.getInstance() != null ? IJ.getInstance() : new Frame());
 }
Exemple #5
0
  public void run(String arg) {
    ImagePlus imp = WindowManager.getCurrentImage();
    if (imp == null) {
      IJ.noImage();
      return;
    }

    ImageStack stack1 = imp.getStack();
    String fileName = imp.getTitle();
    int endslice = stack1.getSize();

    ImagePlus imp2 = duplicateStack(imp);
    imp2.show();
    String duplicateName = imp2.getTitle();
    // IJ.showMessage("Box",fileName);
    ImageStack stack2 = imp2.getStack();
    stack1.deleteSlice(1);
    stack2.deleteSlice(endslice);

    String calculatorstring =
        ("image1='"
            + fileName
            + "' operation=Subtract image2="
            + imp2.getTitle()
            + " create stack");

    IJ.run("Image Calculator...", calculatorstring);
    ImagePlus imp3 = WindowManager.getCurrentImage();
    imp3.setTitle(fileName + " DeltaF up");
    imp2.getWindow().close();
    imp.getWindow().close();
  }
 private String getWindowCloser() {
   String result = "";
   boolean isActiveForm = false;
   WebForm[] allForms = FormManager.getAll();
   // remove all closed windows except the active window
   for (int i = 0; i < allForms.length; i++) {
     WebForm form = allForms[i];
     if (form != FormManager.getActive()) {
       IWindow window = W4TContext.getWindowManager().findWindow(form);
       if (window != null && WindowManager.isClosing(window)) {
         NoscriptFormStack.getInstance().remove(form);
       }
     }
   }
   // 'close' active window
   IWindow activeWindow = WindowManager.getActive();
   if (WindowManager.isClosing(activeWindow) && !WindowManager.isClosed(activeWindow)) {
     isActiveForm = true;
     NoscriptFormStack.getInstance().remove(FormManager.getActive());
     WindowManager.setClosed(activeWindow, true);
   }
   // create meta tag to redirect to previous form
   if (isActiveForm && !NoscriptFormStack.getInstance().isEmpty()) {
     WebForm newForm = NoscriptFormStack.getInstance().pop();
     result =
         "<meta http-equiv=\"refresh\" content=\"0; url="
             + RenderUtil.createEncodedFormGetURL(newForm)
             + "\">";
   }
   return result;
 }
 /**
  * Update the visibility of the CASA window group
  *
  * @param preferredId
  */
 public static void updateGroupVisibility(String preferredId) {
   WindowManager wm = WindowManager.getDefault();
   TopComponentGroup group = wm.findTopComponentGroup("casa_ui"); // NOI18N
   if (group == null) {
     return; // group not found (should not happen)
   }
   //
   boolean isDesignViewSelected = false;
   for (Mode mode : wm.getModes()) {
     TopComponent selected = mode.getSelectedTopComponent();
     if (selected != null) {
       MultiViewHandler mvh = MultiViews.findMultiViewHandler(selected);
       if (mvh != null) {
         MultiViewPerspective mvp = mvh.getSelectedPerspective();
         if (mvp != null) {
           String id = mvp.preferredID();
           if (preferredId.equals(id)) {
             isDesignViewSelected = true;
             break;
           }
         }
       }
     }
   }
   synchronized (groupVisible) {
     if (isDesignViewSelected && !groupVisible) {
       group.open();
       groupVisible = Boolean.TRUE;
     } else if (!isDesignViewSelected && groupVisible) {
       group.close();
       groupVisible = Boolean.FALSE;
     }
   }
 }
Exemple #8
0
 private void initWidthAndHeight(Context context) {
   WindowManager windowManager = (WindowManager) context.getSystemService(Context.WINDOW_SERVICE);
   Display display = windowManager.getDefaultDisplay();
   Point point = new Point();
   display.getSize(point);
   width = point.x;
   height = point.y;
 }
  /**
   * Construct a CommandHandler instance
   *
   * @param commands
   */
  public CommandHandler(ArrayList<Command> commands) {
    WindowManager.getDebugWindow().printInfo("Registering commands");

    for (Command c : commands) {
      registerCommand(c);
    }

    WindowManager.getDebugWindow().printInfo(commands.size() + " commands registered");
  }
Exemple #10
0
  public void run(String arg) {
    int[] wList = WindowManager.getIDList();
    if (wList == null) {
      IJ.error("No images are open.");
      return;
    }

    double thalf = 0.5;
    boolean keep;

    GenericDialog gd = new GenericDialog("Bleach correction");

    gd.addNumericField("t½:", thalf, 1);
    gd.addCheckbox("Keep source stack:", true);
    gd.showDialog();
    if (gd.wasCanceled()) return;

    long start = System.currentTimeMillis();
    thalf = gd.getNextNumber();
    keep = gd.getNextBoolean();
    if (keep) IJ.run("Duplicate...", "title='Bleach corrected' duplicate");
    ImagePlus imp1 = WindowManager.getCurrentImage();
    int d1 = imp1.getStackSize();
    double v1, v2;
    int width = imp1.getWidth();
    int height = imp1.getHeight();
    ImageProcessor ip1, ip2, ip3;

    int slices = imp1.getStackSize();
    ImageStack stack1 = imp1.getStack();
    ImageStack stack2 = imp1.getStack();
    int currentSlice = imp1.getCurrentSlice();

    for (int n = 1; n <= slices; n++) {
      ip1 = stack1.getProcessor(n);
      ip3 = stack1.getProcessor(1);
      ip2 = stack2.getProcessor(n);
      for (int x = 0; x < width; x++) {
        for (int y = 0; y < height; y++) {
          v1 = ip1.getPixelValue(x, y);
          v2 = ip3.getPixelValue(x, y);

          // =B8/(EXP(-C$7*A8))
          v1 = (v1 / Math.exp(-n * thalf));
          ip2.putPixelValue(x, y, v1);
        }
      }
      IJ.showProgress((double) n / slices);
      IJ.showStatus(n + "/" + slices);
    }

    // stack2.show();
    imp1.updateAndDraw();
  }
Exemple #11
0
 private static Frame getParentFrame() {
   Frame parent =
       WindowManager.getCurrentImage() != null
           ? (Frame) WindowManager.getCurrentImage().getWindow()
           : IJ.getInstance() != null ? IJ.getInstance() : new Frame();
   if (IJ.isMacOSX() && IJ.isJava18()) {
     ImageJ ij = IJ.getInstance();
     if (ij != null && ij.isActive()) parent = ij;
     else parent = null;
   }
   return parent;
 }
Exemple #12
0
  @Override
  public void onComponentEvent(ComponentEvent ce) {
    super.onComponentEvent(ce);
    if (ce.getEventTypeInt() == Event.ONMOUSEDOWN) {

      // dont bring to front on clicks where active is model as active window
      // may have just been opened from this click event
      Window active = manager.getActive();
      if (active != null && active != this && !active.isModal()) {
        manager.bringToFront(this);
      }
    }
  }
Exemple #13
0
  /**
   * Send a message to an Object.
   *
   * @param engine The engine.
   * @param msg The message that is sent.
   * @param ob The object receiving the message.
   * @return The result of the message being sent.
   */
  public String sendMessageToObject(Engine engine, String msg, OObject ob) {
    if (msg.equalsIgnoreCase(UIKeyword.WINDOW_OPEN)) {
      this.run(engine, ob);
    } else if (msg.equalsIgnoreCase(UIKeyword.WINDOW_CLOSE)) {
      String title = this.getTitle(ob);

      OWindow w = WindowManager.getInstance().get(title);
      w.dispatchEvent(new WindowEvent(w, WindowEvent.WINDOW_CLOSING));
      WindowManager.getInstance().removeWindow(title);
    }

    return "";
  }
Exemple #14
0
 /** Quit using a separate thread, hopefully avoiding thread deadlocks. */
 public void run() {
   quitting = true;
   boolean changes = false;
   int[] wList = WindowManager.getIDList();
   if (wList != null) {
     for (int i = 0; i < wList.length; i++) {
       ImagePlus imp = WindowManager.getImage(wList[i]);
       if (imp != null && imp.changes == true) {
         changes = true;
         break;
       }
     }
   }
   Frame[] frames = WindowManager.getNonImageWindows();
   if (frames != null) {
     for (int i = 0; i < frames.length; i++) {
       if (frames[i] != null && (frames[i] instanceof Editor)) {
         if (((Editor) frames[i]).fileChanged()) {
           changes = true;
           break;
         }
       }
     }
   }
   if (windowClosed
       && !changes
       && Menus.window.getItemCount() > Menus.WINDOW_MENU_ITEMS
       && !(IJ.macroRunning() && WindowManager.getImageCount() == 0)) {
     GenericDialog gd = new GenericDialog("ImageJ", this);
     gd.addMessage("Are you sure you want to quit ImageJ?");
     gd.showDialog();
     quitting = !gd.wasCanceled();
     windowClosed = false;
   }
   if (!quitting) return;
   if (!WindowManager.closeAllWindows()) {
     quitting = false;
     return;
   }
   // IJ.log("savePreferences");
   if (applet == null) {
     saveWindowLocations();
     Prefs.savePreferences();
   }
   IJ.cleanup();
   // setVisible(false);
   // IJ.log("dispose");
   dispose();
   if (exitWhenQuitting) System.exit(0);
 }
Exemple #15
0
 public void run(String arg) {
   imp = WindowManager.getCurrentImage();
   if (arg.equals("add")) {
     addToRoiManager(imp);
     return;
   }
   if (imp == null) {
     IJ.noImage();
     return;
   }
   if (arg.equals("all")) imp.setRoi(0, 0, imp.getWidth(), imp.getHeight());
   else if (arg.equals("none")) imp.killRoi();
   else if (arg.equals("restore")) imp.restoreRoi();
   else if (arg.equals("spline")) fitSpline();
   else if (arg.equals("circle")) fitCircle(imp);
   else if (arg.equals("ellipse")) createEllipse(imp);
   else if (arg.equals("hull")) convexHull(imp);
   else if (arg.equals("mask")) createMask(imp);
   else if (arg.equals("from")) createSelectionFromMask(imp);
   else if (arg.equals("inverse")) invert(imp);
   else if (arg.equals("toarea")) lineToArea(imp);
   else if (arg.equals("toline")) areaToLine(imp);
   else if (arg.equals("properties")) {
     setProperties("Properties ", imp.getRoi());
     imp.draw();
   } else if (arg.equals("band")) makeBand(imp);
   else if (arg.equals("tobox")) toBoundingBox(imp);
   else runMacro(arg);
 }
  public String[] getOpenImageNames() {
    int[] imageIDList = WindowManager.getIDList();
    String[] imageNames = new String[imageIDList.length];
    // imageNames[0] = "None";

    if (!imageIDList.equals(null) && imageIDList.length > 1) {
      for (int i = 0; i < imageIDList.length; i++) {
        ImagePlus tempIMP = WindowManager.getImage(imageIDList[i]);
        imageNames[i] = tempIMP.getTitle();
      }
      return imageNames;
    } else {
      imageNames[0] = "None";
      return imageNames;
    }
  }
  public void changeDictionary(String strLanguage) {
    // Change dictionary
    MonitorDictionary.setCurrentLanguage(strLanguage);
    DefaultDictionary.setCurrentLanguage(strLanguage);
    ErrorDictionary.setCurrentLanguage(strLanguage);

    // Update UI
    updateLanguage();
    WindowManager.updateLanguage();
    int iIndex = mvtLanguage.indexOf(strLanguage);
    if (iIndex >= 0) {
      JRadioButtonMenuItem mnu = (JRadioButtonMenuItem) mvtLanguageItem.elementAt(iIndex);
      mnu.setSelected(true);
    }

    // Store config
    Hashtable prt = null;
    try {
      prt = Global.loadHashtable(Global.FILE_CONFIG);
    } catch (Exception e) {
      prt = new Hashtable();
    }
    prt.put("Language", strLanguage);
    try {
      Global.storeHashtable(prt, Global.FILE_CONFIG);
    } catch (Exception e) {
    }
  }
Exemple #18
0
 void remove() {
   ImagePlus imp = WindowManager.getCurrentImage();
   if (imp != null) imp.setOverlay(null);
   overlay2 = null;
   RoiManager rm = RoiManager.getInstance();
   if (rm != null) rm.runCommand("show none");
 }
Exemple #19
0
 /** Handles CheckboxMenuItem state changes. */
 public void itemStateChanged(ItemEvent e) {
   MenuItem item = (MenuItem) e.getSource();
   MenuComponent parent = (MenuComponent) item.getParent();
   String cmd = e.getItem().toString();
   if ((Menu) parent == Menus.window) WindowManager.activateWindow(cmd, item);
   else doCommand(cmd);
 }
  public void showLikeQuickAction(int xOffset, int yOffset) {
    preShow();
    window.setAnimationStyle(R.style.Animations_PopUpMenu_Center);
    int[] location = new int[2];
    anchor.getLocationOnScreen(location);
    Rect anchorRect =
        new Rect(
            location[0],
            location[1],
            location[0] + anchor.getWidth(),
            location[1] + anchor.getHeight());

    root.setLayoutParams(
        new ViewGroup.LayoutParams(
            ViewGroup.LayoutParams.WRAP_CONTENT, ViewGroup.LayoutParams.WRAP_CONTENT));
    root.measure(ViewGroup.LayoutParams.WRAP_CONTENT, ViewGroup.LayoutParams.WRAP_CONTENT);

    int rootWidth = root.getMeasuredWidth();
    int rootHeight = root.getMeasuredHeight();
    int screenWidth = windowManager.getDefaultDisplay().getWidth();
    int xPos = ((screenWidth - rootWidth) / 2) + xOffset;
    int yPos = anchorRect.top - rootHeight + yOffset;

    //  display on bottom
    if (rootHeight > anchorRect.top) {
      yPos = anchorRect.bottom + yOffset;
      window.setAnimationStyle(R.style.Animations_PopDownMenu_Center);
    }
    window.showAtLocation(anchor, Gravity.NO_GRAVITY, xPos, yPos);
  }
Exemple #21
0
 void createMask(ImagePlus imp) {
   Roi roi = imp.getRoi();
   boolean useInvertingLut = Prefs.useInvertingLut;
   Prefs.useInvertingLut = false;
   if (roi == null || !(roi.isArea() || roi.getType() == Roi.POINT)) {
     createMaskFromThreshold(imp);
     Prefs.useInvertingLut = useInvertingLut;
     return;
   }
   ImagePlus maskImp = null;
   Frame frame = WindowManager.getFrame("Mask");
   if (frame != null && (frame instanceof ImageWindow))
     maskImp = ((ImageWindow) frame).getImagePlus();
   if (maskImp == null) {
     ImageProcessor ip = new ByteProcessor(imp.getWidth(), imp.getHeight());
     if (!Prefs.blackBackground) ip.invertLut();
     maskImp = new ImagePlus("Mask", ip);
     maskImp.show();
   }
   ImageProcessor ip = maskImp.getProcessor();
   ip.setRoi(roi);
   ip.setValue(255);
   ip.fill(ip.getMask());
   maskImp.updateAndDraw();
   Prefs.useInvertingLut = useInvertingLut;
 }
Exemple #22
0
 public Zipper<Map<Integer, MZipper<RoiContainer>>> exec(
     Zipper<Map<Integer, MZipper<RoiContainer>>> z, int frame) {
   JFileChooser fc = new JFileChooser();
   int returnVal = fc.showOpenDialog(WindowManager.getCurrentWindow().getCanvas());
   Map<Integer, MZipper<RoiContainer>> newRois;
   if (returnVal == JFileChooser.APPROVE_OPTION) {
     try {
       FileInputStream f = new FileInputStream(fc.getSelectedFile().getCanonicalPath());
       MroiLisp parser = new MroiLisp(f);
       parser.ReInit(f);
       newRois = parser.roiFile();
       //				z.rights.clear();
       //				z.rights.add(newRois);
       //				z = z.right();
       //				return z;
       return z.insertAndStep(newRois);
     } catch (IOException e) {
       IJ.error("Couldn't open from " + fc.getSelectedFile().getName() + ": " + e.getMessage());
     } catch (mroi.ParseException e) {
       IJ.error("Failed in parsing: " + e.getMessage());
     } catch (Exception e) {
       IJ.error("Malformed input file: " + e.getMessage());
     }
   }
   return z;
 }
 void updateSliceSummary() {
   int slices = imp.getStackSize();
   float[] areas = rt.getColumn(ResultsTable.AREA);
   if (areas == null) areas = new float[0];
   String label = imp.getTitle();
   if (slices > 1) {
     label = imp.getStack().getShortSliceLabel(slice);
     label = label != null && !label.equals("") ? label : "" + slice;
   }
   String aLine = null;
   double sum = 0.0;
   int start = areas.length - particleCount;
   if (start < 0) return;
   for (int i = start; i < areas.length; i++) sum += areas[i];
   int places = Analyzer.getPrecision();
   Calibration cal = imp.getCalibration();
   String total = "\t" + ResultsTable.d2s(sum, places);
   String average = "\t" + ResultsTable.d2s(sum / particleCount, places);
   String fraction = "\t" + ResultsTable.d2s(sum * 100.0 / totalArea, 1);
   aLine = label + "\t" + particleCount + total + average + fraction;
   aLine = addMeans(aLine, areas.length > 0 ? start : -1);
   if (slices == 1) {
     Frame frame = WindowManager.getFrame("Summary");
     if (frame != null && (frame instanceof TextWindow) && summaryHdr.equals(prevHdr))
       tw = (TextWindow) frame;
   }
   if (tw == null) {
     String title = slices == 1 ? "Summary" : "Summary of " + imp.getTitle();
     tw = new TextWindow(title, summaryHdr, aLine, 450, 300);
     prevHdr = summaryHdr;
   } else tw.append(aLine);
 }
Exemple #24
0
  public Channels() {
    super("Channels");
    if (instance != null) {
      instance.toFront();
      return;
    }
    WindowManager.addWindow(this);
    instance = this;
    GridBagLayout gridbag = new GridBagLayout();
    GridBagConstraints c = new GridBagConstraints();
    setLayout(gridbag);
    int y = 0;
    c.gridx = 0;
    c.gridy = y++;
    c.gridwidth = 1;
    c.fill = GridBagConstraints.BOTH;
    c.anchor = GridBagConstraints.CENTER;
    int margin = 32;
    if (IJ.isMacOSX()) margin = 20;
    c.insets = new Insets(10, margin, 10, margin);
    choice = new Choice();
    for (int i = 0; i < modes.length; i++) choice.addItem(modes[i]);
    choice.select(0);
    choice.addItemListener(this);
    add(choice, c);

    CompositeImage ci = getImage();
    int nCheckBoxes = ci != null ? ci.getNChannels() : 3;
    if (nCheckBoxes > CompositeImage.MAX_CHANNELS) nCheckBoxes = CompositeImage.MAX_CHANNELS;
    checkbox = new Checkbox[nCheckBoxes];
    for (int i = 0; i < nCheckBoxes; i++) {
      checkbox[i] = new Checkbox("Channel " + (i + 1), true);
      c.insets = new Insets(0, 25, i < nCheckBoxes - 1 ? 0 : 10, 5);
      c.gridy = y++;
      add(checkbox[i], c);
      checkbox[i].addItemListener(this);
    }

    c.insets = new Insets(0, 15, 10, 15);
    c.fill = GridBagConstraints.NONE;
    c.gridy = y++;
    moreButton = new Button(moreLabel);
    moreButton.addActionListener(this);
    add(moreButton, c);
    update();

    pm = new PopupMenu();
    for (int i = 0; i < menuItems.length; i++) addPopupItem(menuItems[i]);
    add(pm);

    addKeyListener(IJ.getInstance()); // ImageJ handles keyboard shortcuts
    setResizable(false);
    pack();
    if (location == null) {
      GUI.center(this);
      location = getLocation();
    } else setLocation(location);
    show();
  }
Exemple #25
0
 /**
  * Adds a checkbox labelled "Preview" for "automatic" preview. The reference to this checkbox can
  * be retrieved by getPreviewCheckbox() and it provides the additional method previewRunning for
  * optical feedback while preview is prepared. PlugInFilters can have their "run" method
  * automatically called for preview under the following conditions: - the PlugInFilter must pass a
  * reference to itself (i.e., "this") as an argument to the AddPreviewCheckbox - it must implement
  * the DialogListener interface and set the filter parameters in the dialogItemChanged method. -
  * it must have DIALOG and PREVIEW set in its flags. A previewCheckbox is always off when the
  * filter is started and does not get recorded by the Macro Recorder.
  *
  * @param pfr A reference to the PlugInFilterRunner calling the PlugInFilter if automatic preview
  *     is desired, null otherwise.
  */
 public void addPreviewCheckbox(PlugInFilterRunner pfr) {
   if (previewCheckbox != null) return;
   ImagePlus imp = WindowManager.getCurrentImage();
   if (imp != null && imp.isComposite() && ((CompositeImage) imp).getMode() == IJ.COMPOSITE)
     return;
   this.pfr = pfr;
   addCheckbox(previewLabel, false, true);
 }
 void addToRoiManager(ImagePlus imp) {
   if (IJ.macroRunning() && Interpreter.isBatchModeRoiManager())
     IJ.error("run(\"Add to Manager\") may not work in batch mode macros");
   Frame frame = WindowManager.getFrame("ROI Manager");
   if (frame == null) IJ.run("ROI Manager...");
   if (imp == null) return;
   Roi roi = imp.getRoi();
   if (roi == null) return;
   frame = WindowManager.getFrame("ROI Manager");
   if (frame == null || !(frame instanceof RoiManager)) IJ.error("ROI Manager not found");
   RoiManager rm = (RoiManager) frame;
   boolean altDown = IJ.altKeyDown();
   IJ.setKeyUp(IJ.ALL_KEYS);
   if (altDown && !IJ.macroRunning()) IJ.setKeyDown(KeyEvent.VK_SHIFT);
   rm.runCommand("add");
   IJ.setKeyUp(IJ.ALL_KEYS);
 }
 public void changePassword() {
   try {
     DialogChangePassword dlgPass = new DialogChangePassword(this, channel);
     if (dlgPass != null) WindowManager.centeredWindow(dlgPass);
   } catch (Exception e) {
     e.printStackTrace();
     MessageBox.showMessageDialog(this, e, Global.APP_NAME, MessageBox.ERROR_MESSAGE);
   }
 }
 public static boolean hasBackgroundProcesses(@NotNull Project project) {
   final IdeFrame frame = ((WindowManagerEx) WindowManager.getInstance()).findFrameFor(project);
   final StatusBarEx statusBar = frame == null ? null : (StatusBarEx) frame.getStatusBar();
   if (statusBar != null) {
     final List<Pair<TaskInfo, ProgressIndicator>> processes = statusBar.getBackgroundProcesses();
     if (!processes.isEmpty()) return true;
   }
   return false;
 }
 public void showInFocusCenter() {
   final Component focused = getWndManager().getFocusedComponent(myProject);
   if (focused != null) {
     showInCenterOf(focused);
   } else {
     final JFrame frame = WindowManager.getInstance().getFrame(myProject);
     showInCenterOf(frame.getRootPane());
   }
 }
  public boolean isFocused() {
    IdeFocusManager fm = IdeFocusManager.getInstance(myProject);
    Component component = fm.getFocusedDescendantFor(myToolWindow.getComponent());
    if (component != null) return true;

    Component owner = fm.getLastFocusedFor(WindowManager.getInstance().getIdeFrame(myProject));

    return owner != null && SwingUtilities.isDescendingFrom(owner, myToolWindow.getComponent());
  }