Package org.pushingpixels.flamingo.api.common.icon

Examples of org.pushingpixels.flamingo.api.common.icon.ResizableIcon


    JRibbonApplicationMenuButton appMenuButton = getApplicationMenuButton(ribbonFrame);
    if (appMenuButton == null) {
      return;
    }

    ResizableIcon appIcon = ribbonFrame.getApplicationIcon();
    if (appIcon != null) {
      appMenuButton.setIcon(appIcon);
    }
  }
View Full Code Here


  @Override
  public Point getKeyTipAnchorCenterPoint(AbstractCommandButton commandButton) {
    Insets ins = commandButton.getInsets();
    int height = commandButton.getHeight();
    ResizableIcon buttonIcon = commandButton.getIcon();
    // bottom-right corner of the icon area
    return new Point(ins.left + buttonIcon.getIconWidth(), height - ins.top
        - ins.bottom);
  }
View Full Code Here

    JSeparator jsep = new JSeparator(JSeparator.VERTICAL);
    int layoutHGap = 2 * FlamingoUtilities.getHLayoutGap(commandButton);

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

    ResizableIcon buttonIcon = commandButton.getIcon();

    if (ltr) {
      int x = ins.left;
      // small icon, 1-line text, 1-line extra text and action arrow
      if (buttonIcon != null) {
        result.iconRect.x = x;
        result.iconRect.y = (height - buttonIcon.getIconHeight()) / 2;
        result.iconRect.width = buttonIcon.getIconWidth();
        result.iconRect.height = buttonIcon.getIconHeight();

        x += buttonIcon.getIconWidth();
      }
      if (buttonKind == JCommandButton.CommandButtonKind.ACTION_AND_POPUP_MAIN_POPUP) {
        result.actionClickArea.x = 0;
        result.actionClickArea.y = 0;
        result.actionClickArea.width = x + layoutHGap;
        result.actionClickArea.height = height;

        result.popupClickArea.x = x + layoutHGap;
        result.popupClickArea.y = 0;
        result.popupClickArea.width = width - x - layoutHGap;
        result.popupClickArea.height = height;

        result.separatorOrientation = CommandButtonSeparatorOrientation.VERTICAL;
        result.separatorArea = new Rectangle();
        result.separatorArea.x = x + layoutHGap;
        result.separatorArea.y = 0;
        result.separatorArea.width = new JSeparator(JSeparator.VERTICAL)
            .getPreferredSize().width;
        result.separatorArea.height = height;

        result.isTextInActionArea = false;
      }
      x += 2 * layoutHGap + jsep.getPreferredSize().width;

      TextLayoutInfo lineLayoutInfo = new TextLayoutInfo();
      lineLayoutInfo.text = commandButton.getText();
      lineLayoutInfo.textRect = new Rectangle();

      lineLayoutInfo.textRect.x = x;
      lineLayoutInfo.textRect.y = (height - labelHeight) / 2;
      lineLayoutInfo.textRect.width = fm.stringWidth(commandButton
          .getText());
      lineLayoutInfo.textRect.height = labelHeight;

      result.textLayoutInfoList = new ArrayList<TextLayoutInfo>();
      result.textLayoutInfoList.add(lineLayoutInfo);

      x += fm.getStringBounds(commandButton.getText(), g).getWidth();
      if (buttonKind == JCommandButton.CommandButtonKind.ACTION_AND_POPUP_MAIN_ACTION) {
        // popup click areas are right aligned
        result.actionClickArea.x = 0;
        result.actionClickArea.y = 0;
        result.actionClickArea.width = width - ins.right - labelHeight;
        result.actionClickArea.height = height;

        result.popupClickArea.x = width - ins.right - labelHeight;
        result.popupClickArea.y = 0;
        result.popupClickArea.width = labelHeight + ins.right;
        result.popupClickArea.height = height;

        result.separatorOrientation = CommandButtonSeparatorOrientation.VERTICAL;
        result.separatorArea = new Rectangle();
        result.separatorArea.x = width - ins.right - labelHeight;
        result.separatorArea.y = 0;
        result.separatorArea.width = new JSeparator(JSeparator.VERTICAL)
            .getPreferredSize().width;
        result.separatorArea.height = height;

        result.isTextInActionArea = true;
      }

      if (FlamingoUtilities.hasPopupAction(commandButton)) {
        result.popupActionRect.x = width - ins.right - labelHeight * 3
            / 4;
        result.popupActionRect.y = (height - labelHeight) / 2 - 1;
        result.popupActionRect.width = 1 + labelHeight / 2;
        result.popupActionRect.height = labelHeight + 2;
      }
    } else {
      int x = commandButton.getWidth() - ins.right;
      // small icon, 1-line text, 1-line extra text and action arrow
      if (buttonIcon != null) {
        result.iconRect.x = x - buttonIcon.getIconWidth();
        result.iconRect.y = (height - buttonIcon.getIconHeight()) / 2;
        result.iconRect.width = buttonIcon.getIconWidth();
        result.iconRect.height = buttonIcon.getIconHeight();

        x -= buttonIcon.getIconWidth();
      }
      if (buttonKind == JCommandButton.CommandButtonKind.ACTION_AND_POPUP_MAIN_POPUP) {
        result.actionClickArea.x = x + layoutHGap;
        result.actionClickArea.y = 0;
        result.actionClickArea.width = width - x - layoutHGap;
View Full Code Here

   * Creates the expand button for the associated ribbon band.
   *
   * @return Expand button for the associated ribbon band.
   */
  protected JCommandButton createExpandButton() {
    ResizableIcon icon = FlamingoUtilities
        .getRibbonBandExpandIcon(this.ribbonBand);
    JCommandButton result = new JCommandButton(null, icon);
    result.setFlat(true);
    result.putClientProperty(BasicCommandButtonUI.EMULATE_SQUARE_BUTTON,
        Boolean.TRUE);
View Full Code Here

    JCommandButton.CommandButtonKind buttonKind = (commandButton instanceof JCommandButton) ? ((JCommandButton) commandButton)
        .getCommandButtonKind()
        : JCommandButton.CommandButtonKind.ACTION_ONLY;

    ResizableIcon buttonIcon = commandButton.getIcon();

    boolean hasIcon = (commandButton.getIcon() != null);
    boolean hasText = (this.titlePart1 != null);
    boolean hasPopupIcon = FlamingoUtilities.hasPopupAction(commandButton);

    int layoutHGap = FlamingoUtilities.getHLayoutGap(commandButton);
    int layoutVGap = FlamingoUtilities.getVLayoutGap(commandButton);

    int prefHeight = this.getPreferredSize(commandButton).height;
    int shiftY = 0;
    if (height > prefHeight) {
      shiftY = (height - prefHeight) / 2;
    }

    int y = ins.top + shiftY - layoutVGap;

    // icon
    if (hasIcon) {
      y += layoutVGap;

      int iconHeight = buttonIcon.getIconHeight();
      int iconWidth = buttonIcon.getIconWidth();

      result.iconRect.x = (width - iconWidth) / 2;
      result.iconRect.y = y;
      result.iconRect.width = iconWidth;
      result.iconRect.height = iconHeight;
View Full Code Here

  @Override
  public Point getKeyTipAnchorCenterPoint(AbstractCommandButton commandButton) {
    Insets ins = commandButton.getInsets();
    int height = commandButton.getHeight();
    ResizableIcon buttonIcon = commandButton.getIcon();
    if (buttonIcon != null) {
      // bottom-right corner of the icon area
      return new Point(ins.left + buttonIcon.getIconWidth(),
          (height + buttonIcon.getIconHeight()) / 2);
    } else {
      // bottom-left corner of the button
      return new Point(ins.left, 3 * height / 4);
    }
  }
View Full Code Here

      if (width > prefWidth) {
        shiftX = (width - prefWidth) / 2;
      }
    }

    ResizableIcon buttonIcon = commandButton.getIcon();

    boolean hasIcon = (buttonIcon != null);
    boolean hasPopupIcon = FlamingoUtilities.hasPopupAction(commandButton);

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

    FontMetrics fm = g.getFontMetrics();
    int labelHeight = fm.getAscent() + fm.getDescent();

    JCommandButton.CommandButtonKind buttonKind = (commandButton instanceof JCommandButton) ? ((JCommandButton) commandButton)
        .getCommandButtonKind()
        : JCommandButton.CommandButtonKind.ACTION_ONLY;
    int layoutHGap = FlamingoUtilities.getHLayoutGap(commandButton);

    if (ltr) {
      int x = ins.left + shiftX - layoutHGap;

      // icon
      if (hasIcon) {
        x += layoutHGap;

        int iconHeight = buttonIcon.getIconHeight();
        int iconWidth = buttonIcon.getIconWidth();

        result.iconRect.x = x;
        result.iconRect.y = (height - iconHeight) / 2;
        result.iconRect.width = iconWidth;
        result.iconRect.height = iconHeight;

        x += (iconWidth + layoutHGap);
      }

      if (hasPopupIcon) {
        x += 2 * layoutHGap;

        result.popupActionRect.x = x;
        result.popupActionRect.y = (height - labelHeight) / 2 - 1;
        result.popupActionRect.width = 1 + labelHeight / 2;
        result.popupActionRect.height = labelHeight + 2;
        x += result.popupActionRect.width;

        x += 2 * layoutHGap;
      }

      int xBorderBetweenActionAndPopup = 0;
      int verticalSeparatorWidth = new JSeparator(JSeparator.VERTICAL)
          .getPreferredSize().width;
      // compute the action and popup click areas
      switch (buttonKind) {
      case ACTION_ONLY:
        result.actionClickArea.x = 0;
        result.actionClickArea.y = 0;
        result.actionClickArea.width = width;
        result.actionClickArea.height = height;
        result.isTextInActionArea = true;
        break;
      case POPUP_ONLY:
        result.popupClickArea.x = 0;
        result.popupClickArea.y = 0;
        result.popupClickArea.width = width;
        result.popupClickArea.height = height;
        result.isTextInActionArea = false;
        break;
      case ACTION_AND_POPUP_MAIN_ACTION:
      case ACTION_AND_POPUP_MAIN_POPUP:
        // 1. break after icon if button has icon
        // 2. no break (all popup) if button has no icon
        if (hasIcon) {
          // shift popup action rectangle to the right
          // to accomodate the vertical separator
          result.popupActionRect.x += verticalSeparatorWidth;

          xBorderBetweenActionAndPopup = result.iconRect.x
              + result.iconRect.width + layoutHGap;

          result.actionClickArea.x = 0;
          result.actionClickArea.y = 0;
          result.actionClickArea.width = xBorderBetweenActionAndPopup;
          result.actionClickArea.height = height;

          result.popupClickArea.x = xBorderBetweenActionAndPopup;
          result.popupClickArea.y = 0;
          result.popupClickArea.width = width
              - xBorderBetweenActionAndPopup;
          result.popupClickArea.height = height;

          result.separatorOrientation = CommandButtonSeparatorOrientation.VERTICAL;
          result.separatorArea = new Rectangle();
          result.separatorArea.x = xBorderBetweenActionAndPopup;
          result.separatorArea.y = 0;
          result.separatorArea.width = verticalSeparatorWidth;
          result.separatorArea.height = height;

          result.isTextInActionArea = true;
        } else {
          result.popupClickArea.x = 0;
          result.popupClickArea.y = 0;
          result.popupClickArea.width = width;
          result.popupClickArea.height = height;

          result.isTextInActionArea = true;
        }
        break;
      }
    } else {
      int x = width - ins.right - shiftX + layoutHGap;

      // icon
      if (hasIcon) {
        x -= layoutHGap;

        int iconHeight = buttonIcon.getIconHeight();
        int iconWidth = buttonIcon.getIconWidth();

        result.iconRect.x = x - iconWidth;
        result.iconRect.y = (height - iconHeight) / 2;
        result.iconRect.width = iconWidth;
        result.iconRect.height = iconHeight;
View Full Code Here

        JCommandButton button = new JCommandButton(bi.getKey());
        configureBreadcrumbButton(button);
        configureMainAction(button, bi);
        final Icon icon = bi.getIcon();
        if (icon != null) {
          button.setIcon(new ResizableIcon() {
            int iw = icon.getIconWidth();
            int ih = icon.getIconHeight();

            @Override
            public void paintIcon(Component c, Graphics g, int x,
View Full Code Here

          JCommandMenuButton menuButton = new JCommandMenuButton(bi
              .getKey(), null);
          final Icon icon = bi.getIcon();
          if (icon != null) {
            menuButton.setIcon(new ResizableIcon() {
              int iw = icon.getIconWidth();
              int ih = icon.getIconHeight();

              @Override
              public void paintIcon(Component c, Graphics g,
View Full Code Here

   * Installs subcomponents on the associated command button.
   */
  protected void installComponents() {
    this.updatePopupActionIcon();

    ResizableIcon buttonIcon = this.commandButton.getIcon();
    if (buttonIcon instanceof AsynchronousLoading) {
      ((AsynchronousLoading) buttonIcon)
          .addAsynchronousLoadListener(new AsynchronousLoadListener() {
            @Override
                        public void completed(boolean success) {
View Full Code Here

TOP

Related Classes of org.pushingpixels.flamingo.api.common.icon.ResizableIcon

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.