コード例 #1
0
ファイル: ImageJTask.java プロジェクト: CBOUWER93/Icy-Kernel
    public ImageJToolRibbonBand() {
      super(NAME, new IcyIcon("brackets"));

      // action to convert to IJ image
      toIJAction =
          new ActionListener() {
            @Override
            public void actionPerformed(ActionEvent e) {
              ThreadUtil.bgRun(
                  new Runnable() {
                    @Override
                    public void run() {
                      final Sequence seq = Icy.getMainInterface().getFocusedSequence();

                      if (seq != null) {
                        final ProgressFrame pf = new ProgressFrame("Converting to ImageJ image...");
                        final ImagePlus ip = ImageJUtil.convertToImageJImage(seq, pf);
                        pf.close();

                        ThreadUtil.invokeLater(
                            new Runnable() {
                              @Override
                              public void run() {
                                // show the image
                                ip.show();
                              }
                            });
                      }
                    }
                  });
            }
          };

      // action to convert to ICY sequence
      toICYAction =
          new ActionListener() {
            @Override
            public void actionPerformed(ActionEvent e) {
              ThreadUtil.bgRun(
                  new Runnable() {
                    @Override
                    public void run() {
                      final ImagePlus ip = WindowManager.getCurrentImage();

                      if (ip != null) {
                        final ProgressFrame pf = new ProgressFrame("Converting to ImageJ image...");
                        final Sequence seq = ImageJUtil.convertToIcySequence(ip, pf);
                        pf.close();

                        ThreadUtil.invokeLater(
                            new Runnable() {
                              @Override
                              public void run() {
                                // show the sequence
                                new Viewer(seq);
                              }
                            });
                      }
                    }
                  });
            }
          };

      // convert operation
      button = new IcyCommandButton("Convert to ImageJ", new IcyIcon("to_ij"));

      toIJ = false;
      updateAction(true);

      addCommandButton(button, RibbonElementPriority.TOP);

      final RichTooltip richToolTip =
          new RichTooltip(
              "Detached windows",
              "Icy need to be set in detached mode to use ImageJ efficiently and enable image conversion.");
      richToolTip.setMainImage(detachForIJ);
      richToolTip.addDescriptionSection(
          "This button has the same effect as the detached mode button in the top toolbar.");

      // detach windows button
      detachedBtn =
          new IcyCommandToggleButton(
              "Detached mode", new IcyIcon(ResourceUtil.ICON_DETACHED_WINDOW));
      detachedBtn.setActionRichTooltip(richToolTip);
      detachedBtn.addActionListener(
          new ActionListener() {
            @Override
            public void actionPerformed(ActionEvent e) {
              final boolean value = (detachedGrp.getSelected() == detachedBtn);

              // set detached mode
              Icy.getMainInterface().setDetachedMode(value);
              // and save state
              GeneralPreferences.setMultiWindowMode(value);
            }
          });

      detachedGrp = new CommandToggleButtonGroup();
      detachedGrp.add(detachedBtn);

      addCommandButton(detachedBtn, RibbonElementPriority.TOP);

      RibbonUtil.setPermissiveResizePolicies(this);
    }
コード例 #2
0
ファイル: ImageJTask.java プロジェクト: CBOUWER93/Icy-Kernel
 public void setDetachedBtnPressed(boolean value) {
   detachedGrp.setSelected(detachedBtn, value);
 }