Package org.pushingpixels.flamingo.api.common

Examples of org.pushingpixels.flamingo.api.common.RichTooltip


        }
        KeyStroke ks = (KeyStroke) button.getClientProperty(RibbonActionContributorFactory.ACTION_ACCELERATOR)
        if(ks != null) {
          AFreeplaneAction action = (AFreeplaneAction) button.getClientProperty(RibbonActionContributorFactory.ACTION_KEY_PROPERTY);
          if(action != null) {
            RichTooltip tip = RibbonActionContributorFactory.getRichTooltip(action, ks);
            if(tip != null) {
              entry.setActionRichTooltip(tip);
            }
          }
        }
View Full Code Here


        }
        KeyStroke ks = context.getBuilder().getAcceleratorManager().getAccelerator(getKey());
        if(ks != null) {
          AFreeplaneAction action = context.getBuilder().getMode().getAction(getKey());
          if(action != null) {
            RichTooltip tip = RibbonActionContributorFactory.getRichTooltip(action, ks);
            if(tip != null) {
              entry.setActionRichTooltip(tip);
            }
          }
        }
View Full Code Here

                new CoreRibbonResizePolicies.None(projetoBand.getControlPanel()),
                new CoreRibbonResizePolicies.None(projetoBand.getControlPanel()),
                new IconRibbonBandResizePolicy(projetoBand.getControlPanel())));

        btnVolumeNovoCenario = new JCommandButton(null, getResizableIconFromResource("newvolscenario.png"));
        btnVolumeNovoCenario.setActionRichTooltip(new RichTooltip("Cenário", "Cria um novo cenário"));
        btnVolumeNovoCenario.addActionListener(new ActionListener() {

            @Override
            public void actionPerformed(ActionEvent e) {
                novoCenarioVolume();
            }
        });

        btnVolumeDuplicarCenario = new JCommandButton(null, getResizableIconFromResource("dupCenarioVolume.png"));
        btnVolumeDuplicarCenario.addActionListener(new ActionListener() {

            @Override
            public void actionPerformed(ActionEvent e) {
                DuplicarCenarioPresenter dpCenario = new DuplicarCenarioPresenter(Main.this);

            }
        });


        volumeBand.addCommandButton(btnVolumeNovoCenario, RibbonElementPriority.TOP);
        volumeBand.addCommandButton(btnVolumeDuplicarCenario, RibbonElementPriority.TOP);


        JRibbonBand indLocalBand = new JRibbonBand("Índice de Local", getResizableIconFromResource("exit.png"));

        btnIndLocalNovoCenario = new JCommandButton(null, getResizableIconFromResource("newilscenario.png"));


        btnIndLocalNovoCenario.addActionListener(new ActionListener() {

            @Override
            public void actionPerformed(ActionEvent e) {
                iLocal++;
                IconNode node = new IconNode("Cenário " + iLocal, true, new ImageIcon(Configuracao.getPath() + "images/cenario4.png"), IconNode.CENARIO_INDICELOCAL);
                addNode("Índice de Local", node);
            }
        });

        indLocalBand.addCommandButton(btnIndLocalNovoCenario, RibbonElementPriority.LOW);

        indLocalBand.setPreferredSize(new Dimension(100, 100));

        indLocalBand.setResizePolicies((List) Arrays.asList(
                new CoreRibbonResizePolicies.None(projetoBand.getControlPanel()),
                new IconRibbonBandResizePolicy(projetoBand.getControlPanel())));

        JRibbonBand dadosBand = new JRibbonBand("world!", null);
        dadosBand.setResizePolicies((List) Arrays.asList(new IconRibbonBandResizePolicy(dadosBand.getControlPanel())));

        JRibbonBand configuracoesBand = new JRibbonBand("Configurações", null);
        configuracoesBand.setResizePolicies((List) Arrays.asList(
                new CoreRibbonResizePolicies.None(configuracoesBand.getControlPanel())));

        JCommandButton btnConfiguracoes = new JCommandButton(null, getResizableIconFromResource("settings.png"));
        btnConfiguracoes.setActionRichTooltip(new RichTooltip("Configurações", "Permite alterar as configurações do sistema"));
        btnConfiguracoes.addActionListener(new ActionListener() {

            @Override
            public void actionPerformed(ActionEvent e) {
                ConfiguracoesView configuracoes = new ConfiguracoesView(null, true);
View Full Code Here

    VisualController.getInstance().propertyChange(new PropertyChangeEvent(mediator, "InternalFrameCount", null, null));
  }

 
  private void setTooltip(JCommandButton button, String prefix) {
    button.setActionRichTooltip(new RichTooltip(Messages.getString(prefix + ".text"), Messages.getString(prefix + ".tooltip")));
  }
View Full Code Here

    button.setActionRichTooltip(new RichTooltip(Messages.getString(prefix + ".text"), Messages.getString(prefix + ".tooltip")));
  }

 
  private void setPopupTooltip(JCommandButton button, String prefix) {
    button.setPopupRichTooltip(new RichTooltip(Messages.getString(prefix + ".text"), Messages.getString(prefix + ".tooltip")));
  }
View Full Code Here

      Font font = FlamingoUtilities.getFont(parent, "Ribbon.font",
          "Button.font", "Panel.font");
      Insets ins = richTooltipPanel.getInsets();
      int y = ins.top;
      RichTooltip tooltipInfo = richTooltipPanel.getTooltipInfo();
      FontRenderContext frc = new FontRenderContext(
          new AffineTransform(), true, false);
      int gap = getLayoutGap();

      int fontHeight = parent.getFontMetrics(font).getHeight();
      Font titleFont = font.deriveFont(Font.BOLD);

      boolean ltr = richTooltipPanel.getComponentOrientation()
          .isLeftToRight();

      // The title label
      int titleLabelWidth = parent.getWidth() - ins.left - ins.right;
      AttributedString titleAtributedDescription = new AttributedString(
          tooltipInfo.getTitle());
      titleAtributedDescription.addAttribute(TextAttribute.FONT,
          titleFont);
      LineBreakMeasurer titleLineBreakMeasurer = new LineBreakMeasurer(
          titleAtributedDescription.getIterator(), frc);
      int titleCurrOffset = 0;
      while (true) {
        TextLayout tl = titleLineBreakMeasurer
            .nextLayout(titleLabelWidth);
        if (tl == null)
          break;
        int charCount = tl.getCharacterCount();
        String line = tooltipInfo.getTitle().substring(titleCurrOffset,
            titleCurrOffset + charCount);

        JLabel titleLabel = new JLabel(line);
        titleLabel.setFont(titleFont);
        titleLabels.add(titleLabel);
        richTooltipPanel.add(titleLabel);
        int currLabelWidth = titleLabel.getPreferredSize().width;
        if (ltr) {
          titleLabel.setBounds(ins.left, y, currLabelWidth,
              fontHeight);
        } else {
          titleLabel.setBounds(parent.getWidth() - ins.right
              - currLabelWidth, y, currLabelWidth, fontHeight);
        }
        y += titleLabel.getHeight();

        titleCurrOffset += charCount;
      }
      y += gap;

      // The main image
      int x = ltr ? ins.left : parent.getWidth() - ins.right;
      if (tooltipInfo.getMainImage() != null) {
        mainImageLabel = new JLabel(new ImageIcon(tooltipInfo
            .getMainImage()));
        richTooltipPanel.add(mainImageLabel);
        int mainImageWidth = mainImageLabel.getPreferredSize().width;
        if (ltr) {
          mainImageLabel.setBounds(x, y, mainImageWidth,
              mainImageLabel.getPreferredSize().height);
          x += mainImageWidth;
        } else {
          mainImageLabel.setBounds(x - mainImageWidth, y,
              mainImageWidth,
              mainImageLabel.getPreferredSize().height);
          x -= mainImageWidth;
        }
      }
      if (ltr) {
        x += 2 * gap;
      } else {
        x -= 2 * gap;
      }

      // The description text
      int descLabelWidth = ltr ? parent.getWidth() - x - ins.right : x
          - ins.left;
      for (String descText : tooltipInfo.getDescriptionSections()) {
        AttributedString attributedDescription = new AttributedString(
            descText);
        attributedDescription.addAttribute(TextAttribute.FONT, font);
        LineBreakMeasurer lineBreakMeasurer = new LineBreakMeasurer(
            attributedDescription.getIterator(), frc);
        int currOffset = 0;
        while (true) {
          TextLayout tl = lineBreakMeasurer
              .nextLayout(descLabelWidth);
          if (tl == null)
            break;
          int charCount = tl.getCharacterCount();
          String line = descText.substring(currOffset, currOffset
              + charCount);

          JLabel descLabel = new JLabel(line);
          descriptionLabels.add(descLabel);
          richTooltipPanel.add(descLabel);
          int currDescWidth = descLabel.getPreferredSize().width;
          if (ltr) {
            descLabel.setBounds(x, y, currDescWidth, fontHeight);
          } else {
            descLabel.setBounds(x - currDescWidth, y,
                currDescWidth, fontHeight);
          }
          y += descLabel.getHeight();

          currOffset += charCount;
        }
        // add an empty line after the paragraph
        y += fontHeight;
      }
      // remove the empty line after the last paragraph
      y -= fontHeight;

      if (mainImageLabel != null) {
        y = Math.max(y, mainImageLabel.getY()
            + mainImageLabel.getHeight());
      }

      if ((tooltipInfo.getFooterImage() != null)
          || (tooltipInfo.getFooterSections().size() > 0)) {
        y += gap;
        // The footer separator
        footerSeparator = new JSeparator(JSeparator.HORIZONTAL);
        richTooltipPanel.add(footerSeparator);
        footerSeparator.setBounds(ins.left, y, parent.getWidth()
            - ins.left - ins.right, footerSeparator
            .getPreferredSize().height);

        y += footerSeparator.getHeight() + gap;

        // The footer image
        x = ltr ? ins.left : parent.getWidth() - ins.right;
        if (tooltipInfo.getFooterImage() != null) {
          footerImageLabel = new JLabel(new ImageIcon(tooltipInfo
              .getFooterImage()));
          richTooltipPanel.add(footerImageLabel);
          int footerImageWidth = footerImageLabel.getPreferredSize().width;
          if (ltr) {
            footerImageLabel.setBounds(x, y, footerImageWidth,
                footerImageLabel.getPreferredSize().height);
            x += footerImageWidth + 2 * gap;
          } else {
            footerImageLabel.setBounds(x - footerImageWidth, y,
                footerImageWidth, footerImageLabel
                    .getPreferredSize().height);
            x -= (footerImageWidth + 2 * gap);
          }
        }

        // The footer text
        int footerLabelWidth = ltr ? parent.getWidth() - x - ins.right
            : x - ins.left;
        for (String footerText : tooltipInfo.getFooterSections()) {
          AttributedString attributedDescription = new AttributedString(
              footerText);
          attributedDescription
              .addAttribute(TextAttribute.FONT, font);
          LineBreakMeasurer lineBreakMeasurer = new LineBreakMeasurer(
View Full Code Here

      // The height is defined based on the width and the
      // text broken into multiline paragraphs

      int descTextWidth = getDescriptionTextWidth();
      int width = ins.left + 2 * gap + descTextWidth + ins.right;
      RichTooltip tooltipInfo = richTooltipPanel.getTooltipInfo();
      FontRenderContext frc = new FontRenderContext(
          new AffineTransform(), true, false);
      if (tooltipInfo.getMainImage() != null) {
        width += tooltipInfo.getMainImage().getWidth(null);
      }

      int fontHeight = parent.getFontMetrics(font).getHeight();

      int height = ins.top;

      // The title label
      int titleTextHeight = 0;
      AttributedString titleAttributedDescription = new AttributedString(
          tooltipInfo.getTitle());
      titleAttributedDescription.addAttribute(TextAttribute.FONT,
          titleFont);
      LineBreakMeasurer titleLineBreakMeasurer = new LineBreakMeasurer(
          titleAttributedDescription.getIterator(), frc);
      int maxTitleLineWidth = 0;
      while (true) {
        TextLayout tl = titleLineBreakMeasurer
            .nextLayout(descTextWidth);
        if (tl == null)
          break;
        titleTextHeight += fontHeight;
        int lineWidth = (int) Math.ceil(tl.getBounds().getWidth());
        maxTitleLineWidth = Math.max(maxTitleLineWidth, lineWidth);
      }
      height += titleTextHeight;

      // The description text
      int descriptionTextHeight = 0;
      for (String descText : tooltipInfo.getDescriptionSections()) {
        AttributedString descAttributedDescription = new AttributedString(
            descText);
        descAttributedDescription
            .addAttribute(TextAttribute.FONT, font);
        LineBreakMeasurer descLineBreakMeasurer = new LineBreakMeasurer(
            descAttributedDescription.getIterator(), frc);
        while (true) {
          TextLayout tl = descLineBreakMeasurer
              .nextLayout(descTextWidth);
          if (tl == null)
            break;
          descriptionTextHeight += fontHeight;
        }
        // add an empty line after the paragraph
        descriptionTextHeight += fontHeight;
      }
      if (!tooltipInfo.getDescriptionSections().isEmpty()) {
        // remove the empty line after the last paragraph
        descriptionTextHeight -= fontHeight;
        // add gap between the title and the description
        descriptionTextHeight += gap;
      }

      if (tooltipInfo.getMainImage() != null) {
        height += Math.max(descriptionTextHeight, new JLabel(
            new ImageIcon(tooltipInfo.getMainImage()))
            .getPreferredSize().height);
      } else {
        height += descriptionTextHeight;
      }

      if ((tooltipInfo.getFooterImage() != null)
          || (tooltipInfo.getFooterSections().size() > 0)) {
        height += gap;
        // The footer separator
        height += new JSeparator(JSeparator.HORIZONTAL)
            .getPreferredSize().height;

        height += gap;

        int footerTextHeight = 0;
        int availableWidth = descTextWidth;
        if (tooltipInfo.getFooterImage() != null) {
          availableWidth -= tooltipInfo.getFooterImage().getWidth(
              null);
        }
        if (tooltipInfo.getMainImage() != null) {
          availableWidth += tooltipInfo.getMainImage().getWidth(null);
        }
        for (String footerText : tooltipInfo.getFooterSections()) {
          AttributedString footerAttributedDescription = new AttributedString(
              footerText);
          footerAttributedDescription.addAttribute(
              TextAttribute.FONT, font);
          LineBreakMeasurer footerLineBreakMeasurer = new LineBreakMeasurer(
              footerAttributedDescription.getIterator(), frc);
          while (true) {
            TextLayout tl = footerLineBreakMeasurer
                .nextLayout(availableWidth);
            if (tl == null)
              break;
            footerTextHeight += fontHeight;
          }
          // add an empty line after the paragraph
          footerTextHeight += fontHeight;
        }
        // remove the empty line after the last paragraph
        footerTextHeight -= fontHeight;

        if (tooltipInfo.getFooterImage() != null) {
          height += Math.max(footerTextHeight, new JLabel(
              new ImageIcon(tooltipInfo.getFooterImage()))
              .getPreferredSize().height);
        } else {
          height += footerTextHeight;
        }
      }

      height += ins.bottom;

      // special case for rich tooltips that only have titles
      if (tooltipInfo.getDescriptionSections().isEmpty()
          && (tooltipInfo.getMainImage() == null)
          && tooltipInfo.getFooterSections().isEmpty()
          && (tooltipInfo.getFooterImage() == null)) {
        width = maxTitleLineWidth + 1 + ins.left + ins.right;
      }

      return new Dimension(width, height);
    }
View Full Code Here

   *            The new rich tooltip for the expand button of this ribbon
   *            band.
   * @see #getExpandButtonRichTooltip()
   */
  public void setExpandButtonRichTooltip(RichTooltip expandButtonRichTooltip) {
    RichTooltip old = this.expandButtonRichTooltip;
    this.expandButtonRichTooltip = expandButtonRichTooltip;
    this.firePropertyChange("expandButtonRichTooltip", old,
        this.expandButtonRichTooltip);
  }
View Full Code Here

            tabButton.setBounds(x - finalWidth, y + 1, finalWidth,
                taskToggleButtonHeight - 1);
            x -= (finalWidth + tabButtonGap);
          }
          // show the tooltip with the full title
          RichTooltip tooltip = new RichTooltip();
          tooltip.setTitle(task.getTitle());
          tabButton.setActionRichTooltip(tooltip);
        }
        ((JComponent) c).putClientProperty(
            TaskToggleButtonsHostPanel.IS_SQUISHED, Boolean.TRUE);
      }
View Full Code Here

   *            The rich tooltip of the application menu button.
   * @see #getApplicationMenuRichTooltip()
   * @see #setApplicationMenu(RibbonApplicationMenu)
   */
  public synchronized void setApplicationMenuRichTooltip(RichTooltip tooltip) {
    RichTooltip old = this.applicationMenuRichTooltip;
    this.applicationMenuRichTooltip = tooltip;
    this.firePropertyChange("applicationMenuRichTooltip", old,
        this.applicationMenuRichTooltip);
  }
View Full Code Here

TOP

Related Classes of org.pushingpixels.flamingo.api.common.RichTooltip

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.