Пример #1
0
  public RichTooltip createTooltip() {
    String body = (String) getValue(TOOLTIP_BODY);
    if (body == null) {
      body = (String) getValue(Action.LONG_DESCRIPTION);
    }
    if (body == null) {
      body = getDescription();
    }
    if (body == null) {
      return null;
    }

    String title = (String) getValue(TOOLTIP_TITLE);
    if (title == null) {
      title = getText();
    }

    RichTooltip tooltip = new RichTooltip(title, body);

    String titleIcon = (String) getValue(TOOLTIP_ICON);
    if (titleIcon != null) {
      tooltip.setMainImage(ImageUtilities.loadImage(titleIcon));
    } else {
      tooltip.setMainImage(getLargeImage());
    }

    String footer = (String) getValue(TOOLTIP_FOOTER);
    if (footer != null) {
      tooltip.addFooterSection(footer);
      String footerIcon = (String) getValue(TOOLTIP_FOOTER_ICON);
      if (footerIcon != null) {
        tooltip.setFooterImage(ImageUtilities.loadImage(footerIcon));
      }
    }
    return tooltip;
  }
Пример #2
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);
    }