예제 #1
0
    public void updateAction(boolean ij) {
      if (toIJ != ij) {
        final RichTooltip toolTip = new RichTooltip();
        toIJ = ij;

        if (ij) {
          toolTip.setTitle("Convert to ImageJ");
          toolTip.addDescriptionSection("Convert the selected Icy sequence to ImageJ image.");
          toolTip.addFooterSection("Icy needs to be in detached mode to enabled this feature.");

          // convert to IJ image
          button.setText("Convert to IJ");
          // button.setIcon(new IcyIcon("icon_icy_ij_2", false));
          button.setIcon(new IcyIcon("to_ij", true));
          button.setActionRichTooltip(toolTip);
          button.removeActionListener(toICYAction);
          button.addActionListener(toIJAction);
        } else {
          toolTip.setTitle("Convert to Icy");
          toolTip.addDescriptionSection("Convert the selected ImageJ image to Icy sequence.");
          toolTip.addFooterSection("Icy needs to be in detached mode to enabled this feature.");

          // convert to ICY sequence
          button.setText("Convert to Icy");
          // button.setIcon(new IcyIcon("icon_ij_icy_2", false));
          button.setIcon(new IcyIcon("to_icy", true));
          button.setActionRichTooltip(toolTip);
          button.removeActionListener(toIJAction);
          button.addActionListener(toICYAction);
        }
      }
    }
예제 #2
0
  public BoundMenuCommandButton(
      CommandButtonKind kind,
      String text,
      String description,
      ResizableIcon icon,
      ResizableIcon disabledIcon,
      Action action) {
    super(text, icon);
    this.action = action;
    setCommandButtonKind(kind);
    setDisabledIcon(disabledIcon);
    addActionListener(action);

    RichTooltip tooltip = new RichTooltip();
    tooltip.setTitle(getText());
    tooltip.addDescriptionSection(
        description == null || description.length() == 0 ? " " : description);
    setActionRichTooltip(tooltip);
    setPopupRichTooltip(tooltip);

    PropertyChangeListener l =
        new PropertyChangeListener() {
          @Override
          public void propertyChange(PropertyChangeEvent evt) {
            if ("enabled".equals(evt.getPropertyName())) {
              updateState();
            }
            if (Action.SHORT_DESCRIPTION.equals(evt.getPropertyName())) {
              updateTooltip();
            }
          }
        };

    action.addPropertyChangeListener(l);

    updateState();
    updateTooltip();
  }
예제 #3
0
    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);
    }