Examples of RibbonBandResizePolicy


Examples of org.pushingpixels.flamingo.api.ribbon.resize.RibbonBandResizePolicy

      if (!c.isVisible())
        return;
      Insets ins = c.getInsets();

      int availableHeight = c.getHeight() - ins.top - ins.bottom;
      RibbonBandResizePolicy resizePolicy = ((AbstractRibbonBand) c)
          .getCurrentResizePolicy();

      if (resizePolicy instanceof IconRibbonBandResizePolicy) {
        collapsedButton.setVisible(true);
        int w = collapsedButton.getPreferredSize().width;
        // System.out.println("Width for collapsed of '"
        // + ribbonBand.getTitle() + "' is " + w);
        collapsedButton.setBounds((c.getWidth() - w) / 2, ins.top, w, c
            .getHeight()
            - ins.top - ins.bottom);

        // System.out.println("Collapsed " + collapsedButton.getHeight()
        // + ":" + c.getHeight());

        if (collapsedButton.getPopupCallback() == null) {
          final AbstractRibbonBand popupBand = ribbonBand.cloneBand();
          popupBand.setControlPanel(ribbonBand.getControlPanel());
          List<RibbonBandResizePolicy> resizePolicies = ribbonBand
              .getResizePolicies();
          popupBand.setResizePolicies(resizePolicies);
          RibbonBandResizePolicy largest = resizePolicies.get(0);
          popupBand.setCurrentResizePolicy(largest);
          int gap = popupBand.getControlPanel().getUI()
              .getLayoutGap();
          final Dimension size = new Dimension(ins.left + ins.right
              + gap
              + largest.getPreferredWidth(availableHeight, gap),
              ins.top
                  + ins.bottom
                  + Math.max(c.getHeight(), ribbonBand
                      .getControlPanel()
                      .getPreferredSize().height
View Full Code Here

Examples of org.pushingpixels.flamingo.api.ribbon.resize.RibbonBandResizePolicy

      // start with the most "permissive" resize policy for each band
      for (AbstractRibbonBand<?> band : selectedTask.getBands()) {
        List<RibbonBandResizePolicy> policies = band
            .getResizePolicies();
        RibbonBandResizePolicy last = policies.get(0);
        band.setCurrentResizePolicy(last);
      }

      int availableBandHeight = c.getHeight();
      int availableWidth = c.getWidth();
      if (selectedTask.getBandCount() > 0) {
        RibbonBandResizeSequencingPolicy resizeSequencingPolicy = selectedTask
            .getResizeSequencingPolicy();
        resizeSequencingPolicy.reset();
        AbstractRibbonBand<?> currToTakeFrom = resizeSequencingPolicy
            .next();
        while (true) {
          // check whether all bands have the current resize
          // policy as their last (most restrictive) registered policy
          boolean noMore = true;
          for (AbstractRibbonBand<?> band : selectedTask.getBands()) {
            RibbonBandResizePolicy currentResizePolicy = band
                .getCurrentResizePolicy();
            List<RibbonBandResizePolicy> resizePolicies = band
                .getResizePolicies();
            if (currentResizePolicy != resizePolicies
                .get(resizePolicies.size() - 1)) {
              noMore = false;
              break;
            }
          }
          if (noMore)
            break;

          // get the current preferred width of the bands
          int totalWidth = 0;
          // System.out.println("Iteration");
          for (AbstractRibbonBand<?> ribbonBand : selectedTask
              .getBands()) {
            RibbonBandResizePolicy currentResizePolicy = ribbonBand
                .getCurrentResizePolicy();

            Insets ribbonBandInsets = ribbonBand.getInsets();
            AbstractBandControlPanel controlPanel = ribbonBand
                .getControlPanel();
            if (controlPanel == null) {
              controlPanel = ribbonBand.getPopupRibbonBand()
                  .getControlPanel();
            }
            Insets controlPanelInsets = controlPanel.getInsets();
            int controlPanelGap = controlPanel.getUI()
                .getLayoutGap();
            int ribbonBandHeight = availableBandHeight
                - ribbonBandInsets.top
                - ribbonBandInsets.bottom;
            int availableHeight = ribbonBandHeight
                - ribbonBand.getUI().getBandTitleHeight();
            if (controlPanel != null) {
              availableHeight = availableHeight
                  - controlPanelInsets.top
                  - controlPanelInsets.bottom;
            }
            int preferredWidth = currentResizePolicy
                .getPreferredWidth(availableHeight,
                    controlPanelGap)
                + ribbonBandInsets.left
                + ribbonBandInsets.right;
            totalWidth += preferredWidth + bandGap;
            // System.out.println("\t"
            // + ribbonBand.getTitle()
            // + ":"
            // + currentResizePolicy.getClass()
            // .getSimpleName() + ":" + preferredWidth
            // + " under " + availableHeight + " with "
            // + controlPanel.getComponentCount()
            // + " children");
          }
          // System.out.println("\t:Total:" + totalWidth + "("
          // + availableWidth + ")");
          // System.out.println("\n");
          if (totalWidth < availableWidth)
            break;

          // try to take from the currently rotating band
          List<RibbonBandResizePolicy> policies = currToTakeFrom
              .getResizePolicies();
          int currPolicyIndex = policies.indexOf(currToTakeFrom
              .getCurrentResizePolicy());
          if (currPolicyIndex == (policies.size() - 1)) {
            // nothing to take
          } else {
            currToTakeFrom.setCurrentResizePolicy(policies
                .get(currPolicyIndex + 1));
          }
          currToTakeFrom = resizeSequencingPolicy.next();
        }
      }

      boolean ltr = c.getComponentOrientation().isLeftToRight();
      x = ltr ? 1 : c.getWidth() - 1;
      // System.out.println("Will get [" + availableWidth + "]:");
      for (AbstractRibbonBand<?> ribbonBand : selectedTask.getBands()) {
        Insets ribbonBandInsets = ribbonBand.getInsets();
        RibbonBandResizePolicy currentResizePolicy = ribbonBand
            .getCurrentResizePolicy();
        AbstractBandControlPanel controlPanel = ribbonBand
            .getControlPanel();
        if (controlPanel == null) {
          controlPanel = ribbonBand.getPopupRibbonBand()
              .getControlPanel();
        }
        Insets controlPanelInsets = controlPanel.getInsets();
        int controlPanelGap = controlPanel.getUI().getLayoutGap();
        int ribbonBandHeight = availableBandHeight;
        // - ribbonBandInsets.top - ribbonBandInsets.bottom;
        int availableHeight = ribbonBandHeight - ribbonBandInsets.top
            - ribbonBandInsets.bottom
            - ribbonBand.getUI().getBandTitleHeight();
        if (controlPanelInsets != null) {
          availableHeight = availableHeight - controlPanelInsets.top
              - controlPanelInsets.bottom;
        }

        int requiredBandWidth = currentResizePolicy.getPreferredWidth(
            availableHeight, controlPanelGap)
            + ribbonBandInsets.left + ribbonBandInsets.right;

        if (ltr) {
          ribbonBand.setBounds(x, y, requiredBandWidth,
View Full Code Here

Examples of org.pushingpixels.flamingo.api.ribbon.resize.RibbonBandResizePolicy

     */
    public void layoutContainer(Container c) {
      JFlowBandControlPanel flowBandControlPanel = (JFlowBandControlPanel) c;
      AbstractRibbonBand ribbonBand = flowBandControlPanel
          .getRibbonBand();
      RibbonBandResizePolicy currentResizePolicy = ribbonBand
          .getCurrentResizePolicy();
      if (currentResizePolicy == null)
        return;

      boolean ltr = c.getComponentOrientation().isLeftToRight();
      // need place for border
      Insets ins = c.getInsets();
      int x = ins.left;
      int gap = getLayoutGap();
      int availableHeight = c.getHeight() - ins.top - ins.bottom;

      if (SwingUtilities.getAncestorOfClass(
          CollapsedButtonPopupPanel.class, c) != null) {
        List<RibbonBandResizePolicy> resizePolicies = ribbonBand
            .getResizePolicies();
        // install the most permissive resize policy on the popup
        // panel of a collapsed ribbon band
        resizePolicies.get(0).install(availableHeight, gap);
      } else {
        if (currentResizePolicy instanceof IconRibbonBandResizePolicy) {
          return;
        }

        // Installs the resize policy
        currentResizePolicy.install(availableHeight, gap);
      }

      // compute the max preferred height of the components and the
      // number of rows
      int maxHeight = 0;
View Full Code Here

Examples of org.pushingpixels.flamingo.api.ribbon.resize.RibbonBandResizePolicy

    public void layoutContainer(Container c) {
      // System.out.println("Control panel real = " + c.getHeight());

      AbstractRibbonBand ribbonBand = ((JBandControlPanel) c)
          .getRibbonBand();
      RibbonBandResizePolicy currentResizePolicy = ribbonBand
          .getCurrentResizePolicy();
      if (currentResizePolicy == null)
        return;

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

      // need place for border
      Insets ins = c.getInsets();
      int gap = getLayoutGap();
      int x = ltr ? ins.left + gap / 2 : c.getWidth() - ins.right - gap
          / 2;
      int availableHeight = c.getHeight() - ins.top - ins.bottom;

      if (SwingUtilities.getAncestorOfClass(
          CollapsedButtonPopupPanel.class, c) != null) {
        // install the most permissive resize policy on the popup
        // panel of a collapsed ribbon band
        List<RibbonBandResizePolicy> resizePolicies = ribbonBand
            .getResizePolicies();
        resizePolicies.get(0).install(availableHeight, gap);
      } else {
        if (currentResizePolicy instanceof IconRibbonBandResizePolicy) {
          return;
        }

        // Installs the resize policy - this updates the display
        // priority of all the galleries and buttons
        currentResizePolicy.install(availableHeight, gap);
      }

      int controlPanelGroupIndex = 0;
      for (JBandControlPanel.ControlPanelGroup controlPanelGroup : ((JBandControlPanel) controlPanel)
          .getControlPanelGroups()) {
View Full Code Here

Examples of org.pushingpixels.flamingo.api.ribbon.resize.RibbonBandResizePolicy

  }
 
  @SuppressWarnings("rawtypes")
  private int checkPolicies(AbstractRibbonBand ribbonBand, int height, List<RibbonBandResizePolicy> resizePolicies) {
    for (int i = 0; i < (resizePolicies.size() - 1); i++) {
      RibbonBandResizePolicy policy1 = resizePolicies.get(i);
      RibbonBandResizePolicy policy2 = resizePolicies.get(i + 1);
      int width1 = policy1.getPreferredWidth(height, 4);
      int width2 = policy2.getPreferredWidth(height, 4);
      if (width1 < width2) {
        return i+1;
      }
    }
    return -1;
View Full Code Here

Examples of org.pushingpixels.flamingo.api.ribbon.resize.RibbonBandResizePolicy

  }
 
  @SuppressWarnings("rawtypes")
  private String getExceptionMessage(AbstractRibbonBand ribbonBand, int height, List<RibbonBandResizePolicy> resizePolicies,
      int errorIndex) {
    RibbonBandResizePolicy policy1 = resizePolicies.get(errorIndex-1);
    RibbonBandResizePolicy policy2 = resizePolicies.get(errorIndex);
    int width1 = policy1.getPreferredWidth(height, 4);
    // create the trace message
    StringBuilder builder = new StringBuilder();
    builder.append("Inconsistent preferred widths\n");
    builder.append("Ribbon band '" + ribbonBand.getTitle()
        + "' has the following resize policies\n");
    for (int j = 0; j < resizePolicies.size(); j++) {
      RibbonBandResizePolicy policy = resizePolicies.get(j);
      int width = policy.getPreferredWidth(height, 4);
      builder.append("\t" + policy.getClass().getName()
          + " with preferred width " + width + "\n");
    }
    builder.append(policy1.getClass().getName()
        + " with pref width " + width1
        + " is followed by resize policy "
View Full Code Here

Examples of org.pushingpixels.flamingo.api.ribbon.resize.RibbonBandResizePolicy

      public void contribute(RibbonBuildContext context, ARibbonContributor parent) {
        if (parent == null) {
          return;
        }
        band = new JFlowRibbonBand(TextUtils.removeTranslateComment(TextUtils.getText("ribbon.band." + attributes.getProperty("name"))), null);
        RibbonBandResizePolicy policy = band.getCurrentResizePolicy();
        band.setCurrentResizePolicy(policy);
        // read policies and sub-contributions
        context.processChildren(context.getCurrentPath(), this);
       
        parent.addChild(band, new ChildProperties(parseOrderSettings(attributes.getProperty("orderPriority", ""))));
View Full Code Here

Examples of org.pushingpixels.flamingo.api.ribbon.resize.RibbonBandResizePolicy

        + ins.bottom;
    List<RibbonBandResizePolicy> resizePolicies = ribbonBand
        .getResizePolicies();
    checkResizePoliciesConsistencyBase(ribbonBand);
    for (int i = 0; i < (resizePolicies.size() - 1); i++) {
      RibbonBandResizePolicy policy1 = resizePolicies.get(i);
      RibbonBandResizePolicy policy2 = resizePolicies.get(i + 1);
      int width1 = policy1.getPreferredWidth(height, 4);
      int width2 = policy2.getPreferredWidth(height, 4);
      if (width1 < width2) {
        // create the trace message
        StringBuilder builder = new StringBuilder();
        builder.append("Inconsistent preferred widths\n");
                builder.append("Ribbon band '");
                builder.append(ribbonBand.getTitle());
                builder.append("' has the following resize policies\n");
                for (RibbonBandResizePolicy policy : resizePolicies) {
                    int width = policy.getPreferredWidth(height, 4);
                    builder.append("\t");
                    builder.append(policy.getClass().getName());
                    builder.append(" with preferred width ");
                    builder.append(width).append("\n");
                }
                builder.append(policy1.getClass().getName());
                builder.append(" with pref width ");
                builder.append(width1);
                builder.append(" is followed by resize policy ");
                builder.append(policy2.getClass().getName());
                builder.append(" with larger pref width\n");

        throw new IllegalStateException(builder.toString());
      }
    }
View Full Code Here

Examples of org.pushingpixels.flamingo.api.ribbon.resize.RibbonBandResizePolicy

        .getResizePolicies();
    if (resizePolicies.size() == 0) {
      throw new IllegalStateException("Resize policy list is empty");
    }
    for (int i = 0; i < resizePolicies.size(); i++) {
      RibbonBandResizePolicy policy = resizePolicies.get(i);
      boolean isIcon = policy instanceof IconRibbonBandResizePolicy;
      if (isIcon && (i < (resizePolicies.size() - 1))) {
        throw new IllegalStateException(
            "Icon resize policy must be the last in the list");
      }
View Full Code Here

Examples of org.pushingpixels.flamingo.api.ribbon.resize.RibbonBandResizePolicy

      // start with the most "permissive" resize policy for each band
      for (AbstractRibbonBand<?> band : selectedTask.getBands()) {
        List<RibbonBandResizePolicy> policies = band
            .getResizePolicies();
        RibbonBandResizePolicy last = policies.get(0);
        band.setCurrentResizePolicy(last);
      }

      int availableBandHeight = c.getHeight();
      int availableWidth = c.getWidth();
      if (selectedTask.getBandCount() > 0) {
        RibbonBandResizeSequencingPolicy resizeSequencingPolicy = selectedTask
            .getResizeSequencingPolicy();
        resizeSequencingPolicy.reset();
        AbstractRibbonBand<?> currToTakeFrom = resizeSequencingPolicy
            .next();
        while (true) {
          // check whether all bands have the current resize
          // policy as their last (most restrictive) registered policy
          boolean noMore = true;
          for (AbstractRibbonBand<?> band : selectedTask.getBands()) {
            RibbonBandResizePolicy currentResizePolicy = band
                .getCurrentResizePolicy();
            List<RibbonBandResizePolicy> resizePolicies = band
                .getResizePolicies();
            if (currentResizePolicy != resizePolicies
                .get(resizePolicies.size() - 1)) {
              noMore = false;
              break;
            }
          }
          if (noMore)
            break;

          // get the current preferred width of the bands
          int totalWidth = 0;
          // System.out.println("Iteration");
          for (AbstractRibbonBand<?> ribbonBand : selectedTask
              .getBands()) {
            RibbonBandResizePolicy currentResizePolicy = ribbonBand
                .getCurrentResizePolicy();

            Insets ribbonBandInsets = ribbonBand.getInsets();
            AbstractBandControlPanel controlPanel = ribbonBand
                .getControlPanel();
            if (controlPanel == null) {
              controlPanel = ribbonBand.getPopupRibbonBand()
                  .getControlPanel();
            }
            Insets controlPanelInsets = controlPanel.getInsets();
            int controlPanelGap = controlPanel.getUI()
                .getLayoutGap();
            int ribbonBandHeight = availableBandHeight
                - ribbonBandInsets.top
                - ribbonBandInsets.bottom;
            int availableHeight = ribbonBandHeight
                - ribbonBand.getUI().getBandTitleHeight();
            if (controlPanel != null) {
              availableHeight = availableHeight
                  - controlPanelInsets.top
                  - controlPanelInsets.bottom;
            }
            int preferredWidth = currentResizePolicy
                .getPreferredWidth(availableHeight,
                    controlPanelGap)
                + ribbonBandInsets.left
                + ribbonBandInsets.right;
            totalWidth += preferredWidth + bandGap;
            // System.out.println("\t"
            // + ribbonBand.getTitle()
            // + ":"
            // + currentResizePolicy.getClass()
            // .getSimpleName() + ":" + preferredWidth
            // + " under " + availableHeight + " with "
            // + controlPanel.getComponentCount()
            // + " children");
          }
          // System.out.println("\t:Total:" + totalWidth + "("
          // + availableWidth + ")");
          // System.out.println("\n");
          if (totalWidth < availableWidth)
            break;

          // try to take from the currently rotating band
          List<RibbonBandResizePolicy> policies = currToTakeFrom
              .getResizePolicies();
          int currPolicyIndex = policies.indexOf(currToTakeFrom
              .getCurrentResizePolicy());
          if (currPolicyIndex == (policies.size() - 1)) {
            // nothing to take
          } else {
            currToTakeFrom.setCurrentResizePolicy(policies
                .get(currPolicyIndex + 1));
          }
          currToTakeFrom = resizeSequencingPolicy.next();
        }
      }

      boolean ltr = c.getComponentOrientation().isLeftToRight();
      x = ltr ? 1 : c.getWidth() - 1;
      // System.out.println("Will get [" + availableWidth + "]:");
      for (AbstractRibbonBand<?> ribbonBand : selectedTask.getBands()) {
        Insets ribbonBandInsets = ribbonBand.getInsets();
        RibbonBandResizePolicy currentResizePolicy = ribbonBand
            .getCurrentResizePolicy();
        AbstractBandControlPanel controlPanel = ribbonBand
            .getControlPanel();
        if (controlPanel == null) {
          controlPanel = ribbonBand.getPopupRibbonBand()
              .getControlPanel();
        }
        Insets controlPanelInsets = controlPanel.getInsets();
        int controlPanelGap = controlPanel.getUI().getLayoutGap();
        int ribbonBandHeight = availableBandHeight;
        // - ribbonBandInsets.top - ribbonBandInsets.bottom;
        int availableHeight = ribbonBandHeight - ribbonBandInsets.top
            - ribbonBandInsets.bottom
            - ribbonBand.getUI().getBandTitleHeight();
        if (controlPanelInsets != null) {
          availableHeight = availableHeight - controlPanelInsets.top
              - controlPanelInsets.bottom;
        }

        int requiredBandWidth = currentResizePolicy.getPreferredWidth(
            availableHeight, controlPanelGap)
            + ribbonBandInsets.left + ribbonBandInsets.right;

        if (ltr) {
          ribbonBand.setBounds(x, y, requiredBandWidth,
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.