Examples of JCommandButtonPanel


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

            pluginsButton.setDisplayState(CommandButtonDisplayState.MEDIUM);
            pluginsButton.setCommandButtonKind(JCommandButton.CommandButtonKind.POPUP_ONLY);
            pluginsButton.setPopupCallback(new PopupPanelCallback() {

                public JPopupPanel getPopupPanel(JCommandButton jcb) {
                    JCommandButtonPanel pluginsPanel = new JCommandButtonPanel(CommandButtonDisplayState.BIG);
                    Integer lastManipulatorType = null;
                    int group = 1;
                    pluginsPanel.addButtonGroup(NbBundle.getMessage(DataTableTopComponent.class, "DataTableTopComponent.general.actions.plugins.group.name", group));
                    for (final PluginGeneralActionsManipulator m : plugins) {
                        if (lastManipulatorType == null) {
                            lastManipulatorType = m.getType();
                        }
                        if (lastManipulatorType != m.getType()) {
                            group++;
                            pluginsPanel.addButtonGroup(NbBundle.getMessage(DataTableTopComponent.class, "DataTableTopComponent.general.actions.plugins.group.name", group));
                        }
                        lastManipulatorType = m.getType();
                        pluginsPanel.addButtonToLastGroup(preparePluginGeneralActionsButton(m));
                    }
                    JCommandPopupMenu popup = new JCommandPopupMenu(pluginsPanel, 8, 8);
                    return popup;
                }
            });
View Full Code Here

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

      Insets bInsets = parent.getInsets();
      Insets groupInsets = getGroupInsets();
      int top = bInsets.top;
      int bottom = bInsets.bottom;

      JCommandButtonPanel panel = (JCommandButtonPanel) parent;
      boolean ltr = panel.getComponentOrientation().isLeftToRight();

      // compute max width of buttons
      int maxButtonWidth = 0;
      int maxButtonHeight = 0;
      int groupCount = panel.getGroupCount();
      for (int i = 0; i < groupCount; i++) {
        for (AbstractCommandButton button : panel.getGroupButtons(i)) {
          maxButtonWidth = Math.max(maxButtonWidth, button
              .getPreferredSize().width);
          maxButtonHeight = Math.max(maxButtonHeight, button
              .getPreferredSize().height);
        }
      }
      groupRects = new Rectangle[groupCount];

      int gap = getLayoutGap();
      int maxHeight = parent.getHeight() - bInsets.top - bInsets.bottom
          - groupInsets.top - groupInsets.bottom;
      // for N buttons, there are N-1 gaps. Add the gap to the
      // available width and divide by the max button width + gap.
      int buttonsInRow = (maxButtonHeight == 0) ? 0 : (maxHeight + gap)
          / (maxButtonHeight + gap);

      if (ltr) {
        int x = bInsets.left + groupInsets.left;
        for (int i = 0; i < groupCount; i++) {
          int leftGroupX = x;
          x += groupInsets.left;
          int currY = top + groupInsets.top;

          int buttonColumns = (buttonsInRow == 0) ? 0 : (int) (Math
              .ceil((double) panel.getGroupButtons(i).size()
                  / buttonsInRow));
          // spread the buttons so that we don't have extra space
          // on the bottom
          int actualButtonHeight = (buttonColumns > 1) ? (maxHeight - (buttonsInRow - 1)
              * gap)
              / buttonsInRow
              : maxButtonWidth;

          for (AbstractCommandButton button : panel
              .getGroupButtons(i)) {
            int endY = currY + actualButtonHeight;
            if (endY > (parent.getHeight() - bottom - groupInsets.bottom)) {
              currY = top + groupInsets.top;
              x += maxButtonWidth;
              x += gap;
            }
            button.setBounds(x, currY, maxButtonWidth,
                actualButtonHeight);
            // System.out.println(button.getText() + ":"
            // + button.isVisible() + ":" + button.getBounds());
            currY += actualButtonHeight;
            currY += gap;
          }
          x += maxButtonWidth + groupInsets.bottom;
          int rightGroupX = x;
          groupRects[i] = new Rectangle(leftGroupX, top,
              (rightGroupX - leftGroupX), (parent.getHeight()
                  - top - bottom));
        }
      } else {
        int x = panel.getWidth() - bInsets.right - groupInsets.right;
        for (int i = 0; i < groupCount; i++) {
          int rightGroupX = x;
          x -= groupInsets.left;
          int currY = top + groupInsets.top;

          int buttonColumns = (buttonsInRow == 0) ? 0 : (int) (Math
              .ceil((double) panel.getGroupButtons(i).size()
                  / buttonsInRow));
          // spread the buttons so that we don't have extra space
          // on the bottom
          int actualButtonHeight = (buttonColumns > 1) ? (maxHeight - (buttonsInRow - 1)
              * gap)
              / buttonsInRow
              : maxButtonWidth;

          for (AbstractCommandButton button : panel
              .getGroupButtons(i)) {
            int endY = currY + actualButtonHeight;
            if (endY > (parent.getHeight() - bottom - groupInsets.bottom)) {
              currY = top + groupInsets.top;
              x -= maxButtonWidth;
View Full Code Here

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

     * (non-Javadoc)
     *
     * @see java.awt.LayoutManager#preferredLayoutSize(java.awt.Container)
     */
    public Dimension preferredLayoutSize(Container parent) {
      JCommandButtonPanel panel = (JCommandButtonPanel) parent;

      int maxButtonRowsToUse = panel.getMaxButtonRows();

      Insets bInsets = parent.getInsets();
      Insets groupInsets = getGroupInsets();
      int insetsHeight = bInsets.top + groupInsets.top + bInsets.bottom
          + groupInsets.bottom;

      // compute max width of buttons
      int maxButtonWidth = 0;
      int maxButtonHeight = 0;
      int groupCount = panel.getGroupCount();
      for (int i = 0; i < groupCount; i++) {
        for (AbstractCommandButton button : panel.getGroupButtons(i)) {
          maxButtonWidth = Math.max(maxButtonWidth, button
              .getPreferredSize().width);
          maxButtonHeight = Math.max(maxButtonHeight, button
              .getPreferredSize().height);
        }
      }

      // total width
      int gap = getLayoutGap();
      boolean usePanelHeight = (maxButtonRowsToUse <= 0);

      int availableHeight = panel.getHeight();
      availableHeight -= insetsHeight;
      if (usePanelHeight) {
        // this hasn't been set. Compute using the available
        // height
        maxButtonRowsToUse = (availableHeight + gap)
            / (maxButtonHeight + gap);
      }
      // go over all groups and see how many columns each one needs
      int width = bInsets.left + bInsets.right;
      for (int i = 0; i < groupCount; i++) {
        width += (groupInsets.left + groupInsets.right);

        int buttonColumns = (int) (Math.ceil((double) panel
            .getGroupButtons(i).size()
            / maxButtonRowsToUse));
        width += buttonColumns * maxButtonWidth + (buttonColumns - 1)
            * gap;
      }
 
View Full Code Here

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

      int left = bInsets.left;
      int right = bInsets.right;

      int y = bInsets.top;

      JCommandButtonPanel panel = (JCommandButtonPanel) parent;
      boolean ltr = panel.getComponentOrientation().isLeftToRight();

      // compute max width of buttons
      int maxButtonWidth = 0;
      int maxButtonHeight = 0;
      int groupCount = panel.getGroupCount();
      for (int i = 0; i < groupCount; i++) {
        for (AbstractCommandButton button : panel.getGroupButtons(i)) {
          maxButtonWidth = Math.max(maxButtonWidth, button
              .getPreferredSize().width);
          maxButtonHeight = Math.max(maxButtonHeight, button
              .getPreferredSize().height);
        }
      }
      groupRects = new Rectangle[groupCount];

      int gap = getLayoutGap();
      int maxWidth = parent.getWidth() - bInsets.left - bInsets.right
          - groupInsets.left - groupInsets.right;
      // for N buttons, there are N-1 gaps. Add the gap to the
      // available width and divide by the max button width + gap.
      int buttonsInRow = (maxButtonWidth == 0) ? 0 : (maxWidth + gap)
          / (maxButtonWidth + gap);
      int maxButtonColumnsToUse = panel.getMaxButtonColumns();
      if (maxButtonColumnsToUse > 0) {
        buttonsInRow = Math.min(buttonsInRow, maxButtonColumnsToUse);
      }

      // System.out.println("Layout : " + buttonsInRow);
      for (int i = 0; i < groupCount; i++) {
        int topGroupY = y;
        y += groupInsets.top;

        JLabel groupLabel = groupLabels[i];
        if (buttonPanel.isToShowGroupLabels()) {
          int labelWidth = groupLabel.getPreferredSize().width;
          int labelHeight = getGroupTitleHeight(i);
          if (groupLabel.getComponentOrientation().isLeftToRight()) {
            groupLabel.setBounds(left + groupInsets.left, y,
                labelWidth, labelHeight);
          } else {
            groupLabel.setBounds(parent.getWidth() - right
                - groupInsets.right - labelWidth, y,
                labelWidth, labelHeight);
          }
          y += labelHeight + gap;
        }

        int buttonRows = (buttonsInRow == 0) ? 0 : (int) (Math
            .ceil((double) panel.getGroupButtons(i).size()
                / buttonsInRow));
        if (maxButtonColumnsToUse > 0) {
          buttonsInRow = Math
              .min(buttonsInRow, maxButtonColumnsToUse);
        }

        // spread the buttons so that we don't have extra space
        // on the right
        int actualButtonWidth = (buttonRows > 1) ? (maxWidth - (buttonsInRow - 1)
            * gap)
            / buttonsInRow
            : maxButtonWidth;
        if (maxButtonColumnsToUse == 1)
          actualButtonWidth = maxWidth;

        if (ltr) {
          int currX = left + groupInsets.left;
          for (AbstractCommandButton button : panel
              .getGroupButtons(i)) {
            int endX = currX + actualButtonWidth;
            if (endX > (parent.getWidth() - right - groupInsets.right)) {
              currX = left + groupInsets.left;
              y += maxButtonHeight;
              y += gap;
            }
            button.setBounds(currX, y, actualButtonWidth,
                maxButtonHeight);
            // System.out.println(button.getText() + ":"
            // + button.isVisible() + ":" + button.getBounds());
            currX += actualButtonWidth;
            currX += gap;
          }
        } else {
          int currX = parent.getWidth() - right - groupInsets.right;
          for (AbstractCommandButton button : panel
              .getGroupButtons(i)) {
            int startX = currX - actualButtonWidth;
            if (startX < (left + groupInsets.left)) {
              currX = parent.getWidth() - right
                  - groupInsets.right;
View Full Code Here

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

     * (non-Javadoc)
     *
     * @see java.awt.LayoutManager#preferredLayoutSize(java.awt.Container)
     */
    public Dimension preferredLayoutSize(Container parent) {
      JCommandButtonPanel panel = (JCommandButtonPanel) parent;

      int maxButtonColumnsToUse = panel.getMaxButtonColumns();

      Insets bInsets = parent.getInsets();
      Insets groupInsets = getGroupInsets();
      int insetsWidth = bInsets.left + groupInsets.left + bInsets.right
          + groupInsets.right;

      // compute max width of buttons
      int maxButtonWidth = 0;
      int maxButtonHeight = 0;
      int groupCount = panel.getGroupCount();
      for (int i = 0; i < groupCount; i++) {
        for (AbstractCommandButton button : panel.getGroupButtons(i)) {
          maxButtonWidth = Math.max(maxButtonWidth, button
              .getPreferredSize().width);
          maxButtonHeight = Math.max(maxButtonHeight, button
              .getPreferredSize().height);
        }
      }

      // total height
      int gap = getLayoutGap();
      boolean usePanelWidth = (maxButtonColumnsToUse <= 0);
      int availableWidth = panel.getWidth();
      availableWidth -= insetsWidth;

      if (usePanelWidth) {
        // this hasn't been set. Compute using the available
        // width
        maxButtonColumnsToUse = (availableWidth + gap)
            / (maxButtonWidth + gap);
      }
      int height = bInsets.top + bInsets.bottom;
      // System.out.print(height + "[" + maxButtonColumnsToUse + "]");
      for (int i = 0; i < groupCount; i++) {
        if (groupLabels[i].isVisible()) {
          height += (getGroupTitleHeight(i) + gap);
        }

        height += (groupInsets.top + groupInsets.bottom);

        int buttonRows = (int) (Math.ceil((double) panel
            .getGroupButtons(i).size()
            / maxButtonColumnsToUse));
        height += buttonRows * maxButtonHeight + (buttonRows - 1) * gap;
        // System.out.print(" " + height);
      }
View Full Code Here

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

        if (rolloverCallback == null) {
          rolloverCallback = new PrimaryRolloverCallback() {
            public void menuEntryActivated(JPanel targetPanel) {
              targetPanel.removeAll();
              targetPanel.setLayout(new BorderLayout());
              JCommandButtonPanel secondary = new JRibbonApplicationMenuPopupPanelSecondary(primeEntry);
              secondary.setToShowGroupLabels(false);
              String groupDesc = menuName;
              secondary.addButtonGroup(groupDesc);
              List<AFreeplaneAction> openActions = lastOpenedList.createOpenLastMapActionList();
              for (AFreeplaneAction action : openActions) {
                String restoreable = (String) action.getValue(Action.DEFAULT);
                StringTokenizer tokens = new StringTokenizer(restoreable, ";");
                File file = lastOpenedList.createFileFromRestorable(tokens);
                JCommandButton menuButton = new JCommandButton(file.getName());
                menuButton.addActionListener(action);
                menuButton.setCommandButtonKind(CommandButtonKind.ACTION_ONLY);
                menuButton.setHorizontalAlignment(SwingUtilities.LEADING);
                menuButton.setPopupOrientationKind(CommandButtonPopupOrientationKind.SIDEWARD);
                menuButton.setEnabled(true);
                menuButton.setActionRichTooltip(new RichTooltip((String) action
                    .getValue(Action.SHORT_DESCRIPTION), file.toString()));
                secondary.addButtonToLastGroup(menuButton);
              }
              JScrollablePanel<JCommandButtonPanel> scrollPanel = new JScrollablePanel<JCommandButtonPanel>(
                  secondary, ScrollType.VERTICALLY);
              targetPanel.add(scrollPanel, BorderLayout.CENTER);
            }
View Full Code Here

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

      int left = bInsets.left;
      int right = bInsets.right;

      int y = bInsets.top;

      JCommandButtonPanel panel = (JCommandButtonPanel) parent;
      boolean ltr = panel.getComponentOrientation().isLeftToRight();

      // compute max width of buttons
      int maxButtonWidth = 0;
      int maxButtonHeight = 0;
      int groupCount = panel.getGroupCount();
      for (int i = 0; i < groupCount; i++) {
        for (AbstractCommandButton button : panel.getGroupButtons(i)) {
          maxButtonWidth = Math.max(maxButtonWidth, button
              .getPreferredSize().width);
          maxButtonHeight = Math.max(maxButtonHeight, button
              .getPreferredSize().height);
        }
      }
      groupRects = new Rectangle[groupCount];

      int gap = getLayoutGap();
      int maxWidth = parent.getWidth() - bInsets.left - bInsets.right
          - groupInsets.left - groupInsets.right;
      // for N buttons, there are N-1 gaps. Add the gap to the
      // available width and divide by the max button width + gap.
      int buttonsInRow = (maxButtonWidth == 0) ? 0 : (maxWidth + gap)
          / (maxButtonWidth + gap);
      int maxButtonColumnsToUse = panel.getMaxButtonColumns();
      if (maxButtonColumnsToUse > 0) {
        buttonsInRow = Math.min(buttonsInRow, maxButtonColumnsToUse);
      }

      // System.out.println("Layout : " + buttonsInRow);
      for (int i = 0; i < groupCount; i++) {
        int topGroupY = y;
        y += groupInsets.top;

        JLabel groupLabel = groupLabels[i];
        if (buttonPanel.isToShowGroupLabels()) {
          int labelWidth = groupLabel.getPreferredSize().width;
          int labelHeight = getGroupTitleHeight(i);
          if (groupLabel.getComponentOrientation().isLeftToRight()) {
            groupLabel.setBounds(left + groupInsets.left, y,
                labelWidth, labelHeight);
          } else {
            groupLabel.setBounds(parent.getWidth() - right
                - groupInsets.right - labelWidth, y,
                labelWidth, labelHeight);
          }
          y += labelHeight + gap;
        }

        int buttonRows = (buttonsInRow == 0) ? 0 : (int) (Math
            .ceil((double) panel.getGroupButtons(i).size()
                / buttonsInRow));
        if (maxButtonColumnsToUse > 0) {
          buttonsInRow = Math
              .min(buttonsInRow, maxButtonColumnsToUse);
        }

        // spread the buttons so that we don't have extra space
        // on the right
        int actualButtonWidth = (buttonRows > 1) ? (maxWidth - (buttonsInRow - 1)
            * gap)
            / buttonsInRow
            : maxButtonWidth;
        if (maxButtonColumnsToUse == 1)
          actualButtonWidth = maxWidth;

        if (ltr) {
          int currX = left + groupInsets.left;
          for (AbstractCommandButton button : panel
              .getGroupButtons(i)) {
            int endX = currX + actualButtonWidth;
            if (endX > (parent.getWidth() - right - groupInsets.right)) {
              currX = left + groupInsets.left;
              y += maxButtonHeight;
              y += gap;
            }
            button.setBounds(currX, y, actualButtonWidth,
                maxButtonHeight);
            // System.out.println(button.getText() + ":"
            // + button.isVisible() + ":" + button.getBounds());
            currX += actualButtonWidth;
            currX += gap;
          }
        } else {
          int currX = parent.getWidth() - right - groupInsets.right;
          for (AbstractCommandButton button : panel
              .getGroupButtons(i)) {
            int startX = currX - actualButtonWidth;
            if (startX < (left + groupInsets.left)) {
              currX = parent.getWidth() - right
                  - groupInsets.right;
View Full Code Here

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

     *
     * @see java.awt.LayoutManager#preferredLayoutSize(java.awt.Container)
     */
    @Override
        public Dimension preferredLayoutSize(Container parent) {
      JCommandButtonPanel panel = (JCommandButtonPanel) parent;

      int maxButtonColumnsToUse = panel.getMaxButtonColumns();

      Insets bInsets = parent.getInsets();
      Insets groupInsets = getGroupInsets();
      int insetsWidth = bInsets.left + groupInsets.left + bInsets.right
          + groupInsets.right;

      // compute max width of buttons
      int maxButtonWidth = 0;
      int maxButtonHeight = 0;
      int groupCount = panel.getGroupCount();
      for (int i = 0; i < groupCount; i++) {
        for (AbstractCommandButton button : panel.getGroupButtons(i)) {
          maxButtonWidth = Math.max(maxButtonWidth, button
              .getPreferredSize().width);
          maxButtonHeight = Math.max(maxButtonHeight, button
              .getPreferredSize().height);
        }
      }

      // total height
      int gap = getLayoutGap();
      boolean usePanelWidth = (maxButtonColumnsToUse <= 0);
      int availableWidth = panel.getWidth();
      availableWidth -= insetsWidth;

      if (usePanelWidth) {
        // this hasn't been set. Compute using the available
        // width
        maxButtonColumnsToUse = (availableWidth + gap)
            / (maxButtonWidth + gap);
      }
      int height = bInsets.top + bInsets.bottom;
      // System.out.print(height + "[" + maxButtonColumnsToUse + "]");
      for (int i = 0; i < groupCount; i++) {
        if (groupLabels[i].isVisible()) {
          height += (getGroupTitleHeight(i) + gap);
        }

        height += (groupInsets.top + groupInsets.bottom);

        int buttonRows = (int) (Math.ceil((double) panel
            .getGroupButtons(i).size()
            / maxButtonColumnsToUse));
        height += buttonRows * maxButtonHeight + (buttonRows - 1) * gap;
        // System.out.print(" " + height);
      }
View Full Code Here

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

      Insets bInsets = parent.getInsets();
      Insets groupInsets = getGroupInsets();
      int top = bInsets.top;
      int bottom = bInsets.bottom;

      JCommandButtonPanel panel = (JCommandButtonPanel) parent;
      boolean ltr = panel.getComponentOrientation().isLeftToRight();

      // compute max width of buttons
      int maxButtonWidth = 0;
      int maxButtonHeight = 0;
      int groupCount = panel.getGroupCount();
      for (int i = 0; i < groupCount; i++) {
        for (AbstractCommandButton button : panel.getGroupButtons(i)) {
          maxButtonWidth = Math.max(maxButtonWidth, button
              .getPreferredSize().width);
          maxButtonHeight = Math.max(maxButtonHeight, button
              .getPreferredSize().height);
        }
      }
      groupRects = new Rectangle[groupCount];

      int gap = getLayoutGap();
      int maxHeight = parent.getHeight() - bInsets.top - bInsets.bottom
          - groupInsets.top - groupInsets.bottom;
      // for N buttons, there are N-1 gaps. Add the gap to the
      // available width and divide by the max button width + gap.
      int buttonsInRow = (maxButtonHeight == 0) ? 0 : (maxHeight + gap)
          / (maxButtonHeight + gap);

      if (ltr) {
        int x = bInsets.left + groupInsets.left;
        for (int i = 0; i < groupCount; i++) {
          int leftGroupX = x;
          x += groupInsets.left;
          int currY = top + groupInsets.top;

          int buttonColumns = (buttonsInRow == 0) ? 0 : (int) (Math
              .ceil((double) panel.getGroupButtons(i).size()
                  / buttonsInRow));
          // spread the buttons so that we don't have extra space
          // on the bottom
          int actualButtonHeight = (buttonColumns > 1) ? (maxHeight - (buttonsInRow - 1)
              * gap)
              / buttonsInRow
              : maxButtonWidth;

          for (AbstractCommandButton button : panel
              .getGroupButtons(i)) {
            int endY = currY + actualButtonHeight;
            if (endY > (parent.getHeight() - bottom - groupInsets.bottom)) {
              currY = top + groupInsets.top;
              x += maxButtonWidth;
              x += gap;
            }
            button.setBounds(x, currY, maxButtonWidth,
                actualButtonHeight);
            // System.out.println(button.getText() + ":"
            // + button.isVisible() + ":" + button.getBounds());
            currY += actualButtonHeight;
            currY += gap;
          }
          x += maxButtonWidth + groupInsets.bottom;
          int rightGroupX = x;
          groupRects[i] = new Rectangle(leftGroupX, top,
              (rightGroupX - leftGroupX), (parent.getHeight()
                  - top - bottom));
        }
      } else {
        int x = panel.getWidth() - bInsets.right - groupInsets.right;
        for (int i = 0; i < groupCount; i++) {
          int rightGroupX = x;
          x -= groupInsets.left;
          int currY = top + groupInsets.top;

          int buttonColumns = (buttonsInRow == 0) ? 0 : (int) (Math
              .ceil((double) panel.getGroupButtons(i).size()
                  / buttonsInRow));
          // spread the buttons so that we don't have extra space
          // on the bottom
          int actualButtonHeight = (buttonColumns > 1) ? (maxHeight - (buttonsInRow - 1)
              * gap)
              / buttonsInRow
              : maxButtonWidth;

          for (AbstractCommandButton button : panel
              .getGroupButtons(i)) {
            int endY = currY + actualButtonHeight;
            if (endY > (parent.getHeight() - bottom - groupInsets.bottom)) {
              currY = top + groupInsets.top;
              x -= maxButtonWidth;
View Full Code Here

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

     *
     * @see java.awt.LayoutManager#preferredLayoutSize(java.awt.Container)
     */
    @Override
        public Dimension preferredLayoutSize(Container parent) {
      JCommandButtonPanel panel = (JCommandButtonPanel) parent;

      int maxButtonRowsToUse = panel.getMaxButtonRows();

      Insets bInsets = parent.getInsets();
      Insets groupInsets = getGroupInsets();
      int insetsHeight = bInsets.top + groupInsets.top + bInsets.bottom
          + groupInsets.bottom;

      // compute max width of buttons
      int maxButtonWidth = 0;
      int maxButtonHeight = 0;
      int groupCount = panel.getGroupCount();
      for (int i = 0; i < groupCount; i++) {
        for (AbstractCommandButton button : panel.getGroupButtons(i)) {
          maxButtonWidth = Math.max(maxButtonWidth, button
              .getPreferredSize().width);
          maxButtonHeight = Math.max(maxButtonHeight, button
              .getPreferredSize().height);
        }
      }

      // total width
      int gap = getLayoutGap();
      boolean usePanelHeight = (maxButtonRowsToUse <= 0);

      int availableHeight = panel.getHeight();
      availableHeight -= insetsHeight;
      if (usePanelHeight) {
        // this hasn't been set. Compute using the available
        // height
        maxButtonRowsToUse = (availableHeight + gap)
            / (maxButtonHeight + gap);
      }
      // go over all groups and see how many columns each one needs
      int width = bInsets.left + bInsets.right;
      for (int i = 0; i < groupCount; i++) {
        width += (groupInsets.left + groupInsets.right);

        int buttonColumns = (int) (Math.ceil((double) panel
            .getGroupButtons(i).size()
            / maxButtonRowsToUse));
        width += buttonColumns * maxButtonWidth + (buttonColumns - 1)
            * gap;
      }
 
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. 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.