Exemplo n.º 1
0
  private void initPaintableTabLocations(PanePainter pane) {
    reset(pane);
    if (tabData.getPreTab() != null) {
      tabData.getTabList().add(0, tabData.getPreTab());
      tabData.getVisibleTabRects().add(0, new Rectangle(0, 0, 0, 0));
    }

    if (tabData.getPostTab() != null) {
      tabData.getTabList().add(tabData.getPostTab());
      tabData.getVisibleTabRects().add(new Rectangle(0, 0, 0, 0));
    }

    setSize(0);
    int selectedIndex = -1;

    for (int i = 0; i < tabData.getTabCount(); i++) {
      final Tab tab = (Tab) tabData.getTabList().get(i);

      SizeIcon icon =
          new SizeIcon(
              getInternalTabWidth(tab) - getWidthCompensate(tabData.getAreaOrientation()),
              getInternalTabHeight(tab) - getHeightCompensate(tabData.getAreaOrientation()),
              isSwapWidthHeight(tabData.getAreaOrientation()));

      pane.addTab(EMPTY_STRING, icon, getComponent());

      if (tab.isHighlighted()) selectedIndex = pane.getTabCount() - 1;

      if (!tab.isEnabled()) {
        pane.setEnabledAt(i, false);
        pane.setDisabledIconAt(i, icon);
      }

      setSize(getSize() + (tabData.isHorizontalLayout() ? tab.getWidth() : tab.getHeight()));
    }

    pane.setSelectedIndex(selectedIndex);
    pane.doValidation();
  }
Exemplo n.º 2
0
  private void initTabLocations(PanePainter pane) {
    findPaintableTabs();

    Dimension minSize = getTabExternalMinSize(tabData.getAreaOrientation());
    Insets aInsets = getTabAreaInsets(tabData.getAreaOrientation());

    int selectedIndex = -1;

    if (tabData.getTabbedPanel().isTabAreaVisible()) {
      for (int i = 0; i < tabData.getTabCount(); i++) {
        final Tab tab = (Tab) tabData.getTabList().get(i);
        final Rectangle visibleRect = (Rectangle) tabData.getVisibleTabRects().get(i);
        Insets insets = getTabInsets(tabData.getAreaOrientation());

        int iconWidth =
            Math.max(
                -insets.left - insets.right,
                getInternalTabWidth(tab) - (tab.getWidth() - visibleRect.width));

        int iconHeight =
            Math.max(
                -insets.top - insets.bottom,
                getInternalTabHeight(tab) - (tab.getHeight() - visibleRect.height));

        Point l = getLocationInTabbedPanel(tab, tabData.getTabbedPanel());

        if ((tabData.isHorizontalLayout()
                && (visibleRect.width >= minSize.width
                    || minSize.width < tabData.getTabbedPanelWidth() - l.x - aInsets.right))
            || (!tabData.isHorizontalLayout()
                && (visibleRect.height >= minSize.height
                    || minSize.height < tabData.getTabbedPanelHeight() - l.y - aInsets.bottom))) {
          final int iWidth = iconWidth;
          final int iHeight = iconHeight;

          SizeIcon icon =
              new SizeIcon(
                  iWidth - getWidthCompensate(tabData.getAreaOrientation()),
                  iHeight - getHeightCompensate(tabData.getAreaOrientation()),
                  isSwapWidthHeight(tabData.getAreaOrientation()));

          int j = pane.getTabCount();
          pane.addTab(EMPTY_STRING, icon, getComponent());

          if (i == tabData.getSelectedTabPainterIndex()) {
            selectedIndex = j;
          }

          if (!tab.isEnabled()) {
            pane.setEnabledAt(j, false);
            pane.setDisabledIconAt(j, icon);
          }
        }
      }
    } else if (tabAreaNotVisibleFix) {
      pane.addTab(EMPTY_STRING, componentCache.getComponent());
    }

    if (pane.getTabCount() > 0) pane.setSelectedIndex(selectedIndex);

    pane.doValidation();
  }