コード例 #1
0
  public void paintContentArea(
      TabbedPanelContentPanel p, Graphics g, int x, int y, int width, int height) {
    if (enabled && PAINT_CONTENT_AREA) {
      tabData.initialize(p.getTabbedPanel());
      PanePainter pane = paneHandler.getPainter(tabData.getAreaOrientation());

      initTabLocations(pane);

      int tx = 0;
      int ty = 0;

      if (tabData.getTabbedPanel().hasContentArea()) {
        Point l = getLocationInTabbedPanel(p, tabData.getTabbedPanel());

        int yComp = 0;
        int xComp = 0;

        if (pane.getTabCount() == 0 && tabData.getTabCount() > 0) {
          if (tabData.getAreaOrientation() == Direction.UP) {
            yComp = tabData.getTabAreaHeight();
          } else if (tabData.getAreaOrientation() == Direction.DOWN) {
            yComp = -tabData.getTabAreaHeight();
          } else if (tabData.getAreaOrientation() == Direction.LEFT) {
            xComp = tabData.getTabAreaWidth();
          } else {
            xComp = -tabData.getTabAreaWidth();
          }
        }

        tx = -l.x + (xComp > 0 ? xComp : 0);
        ty = -l.y + (yComp > 0 ? yComp : 0);

        int extraWidth = 0;
        int extraHeight = 0;

        if (tabAreaNotVisibleFix && !tabData.getTabbedPanel().isTabAreaVisible()) {
          extraWidth =
              !tabData.isHorizontalLayout()
                  ? tabMinimumSizes[getDirectionIndex(tabData.getAreaOrientation())].width
                      - raiseds[getDirectionIndex(tabData.getAreaOrientation())]
                      + (tabData.getAreaOrientation() == Direction.LEFT
                          ? areaInsets[getDirectionIndex(Direction.LEFT)].left
                          : areaInsets[getDirectionIndex(Direction.RIGHT)].right)
                  : 0;
          extraHeight =
              tabData.isHorizontalLayout()
                  ? tabMinimumSizes[getDirectionIndex(tabData.getAreaOrientation())].height
                      - raiseds[getDirectionIndex(tabData.getAreaOrientation())]
                      + (tabData.getAreaOrientation() == Direction.UP
                          ? areaInsets[getDirectionIndex(Direction.UP)].top
                          : areaInsets[getDirectionIndex(Direction.DOWN)].bottom)
                  : 0;
        }

        tx -= tabData.getAreaOrientation() == Direction.LEFT ? extraWidth : 0;
        ty -= tabData.getAreaOrientation() == Direction.UP ? extraHeight : 0;

        pane.setSize(
            tabData.getTabbedPanelSize().width - Math.abs(xComp) + extraWidth,
            tabData.getTabbedPanelSize().height - Math.abs(yComp) + extraHeight);

        pane.doValidation();
      } else {
        if (tabData.isHorizontalLayout()) {
          pane.setSize(p.getWidth(), p.getHeight() + tabData.getTabAreaHeight());
        } else {
          pane.setSize(p.getWidth() + tabData.getTabAreaWidth(), p.getHeight());
        }

        pane.doValidation();

        if (tabData.getAreaOrientation() == Direction.UP) ty -= tabData.getTabAreaHeight();
        else if (tabData.getAreaOrientation() == Direction.LEFT) tx -= tabData.getTabAreaWidth();
      }

      pane.paint(g, tx, ty);

      tabData.reset();

      reset(pane);
    }
  }
コード例 #2
0
  public void paintTabArea(TabbedPanel tp, Graphics g, int x, int y, int width, int height) {
    int heightTemp = height;
    int widthTemp = width;
    int xTemp = x;
    int yTemp = y;
    if (enabled && tp.isTabAreaVisible()) {

      tabData.initialize(tp);

      PanePainter pane = paneHandler.getPainter(tabData.getAreaOrientation());

      initTabLocations(pane);
      Insets aInsets = getTabAreaInsets(tabData.getAreaOrientation());

      if (tp.getTabCount() > 0) {
        // Adjust x, y
        if (tabData.getAreaOrientation() == Direction.DOWN) {
          yTemp += tabData.getTabbedPanelHeight() - heightTemp;
        } else if (tabData.getAreaOrientation() == Direction.RIGHT) {
          xTemp += tabData.getTabbedPanelWidth() - widthTemp;
        }

        widthTemp = xTemp < 0 ? widthTemp + xTemp : widthTemp;
        heightTemp = yTemp < 0 ? heightTemp + yTemp : heightTemp;

        xTemp = Math.max(0, xTemp);
        yTemp = Math.max(0, yTemp);

        if (tabData.isHorizontalLayout())
          pane.setSize(tabData.getTabbedPanelSize().width, getTabbedPanelExtraSize());
        else pane.setSize(getTabbedPanelExtraSize(), tabData.getTabbedPanelHeight());

        if (PAINT_TAB_AREA && !(pane.getTabCount() == 0 && tabData.getTabCount() > 0)) {
          Shape originalClip = g.getClip();

          int tx =
              -xTemp
                  - (tabData.getAreaOrientation() == Direction.RIGHT
                      ? -tabData.getTabbedPanelWidth() + getTabbedPanelExtraSize()
                      : 0);
          int ty =
              -yTemp
                  - (tabData.getAreaOrientation() == Direction.DOWN
                      ? -tabData.getTabbedPanelHeight() + getTabbedPanelExtraSize()
                      : 0);

          Rectangle firstVisibleRect = (Rectangle) tabData.getVisibleTabRects().get(0);
          Rectangle lastVisibleRect =
              (Rectangle) tabData.getVisibleTabRects().get(tabData.getTabCount() - 1);
          Tab lastTab = (Tab) tabData.getTabList().get(tabData.getTabCount() - 1);

          if (tabData.isHorizontalLayout()) {
            int extraWidth =
                lastTab.getWidth() == lastVisibleRect.width
                    ? 0
                    : 2 * tabData.getTabbedPanelSize().width - tabData.getTabAreaWidth();
            pane.setSize(pane.getWidth() + extraWidth, pane.getHeight());

            pane.doValidation();

            // Before tabs
            g.clipRect(
                0,
                0,
                aInsets.left + (firstVisibleRect.width > 0 && firstVisibleRect.x == 0 ? 1 : 0),
                heightTemp);
            pane.paint(g, tx, ty);
            g.setClip(originalClip);

            // After tabs
            tx -= extraWidth;

            int clipExtraWidth = extraWidth == 0 ? 1 : 0;
            g.clipRect(
                aInsets.left + tabData.getTabAreaWidth() - clipExtraWidth,
                0,
                widthTemp - aInsets.left - tabData.getTabAreaWidth() + clipExtraWidth,
                heightTemp);
            pane.paint(g, tx, ty);
            g.setClip(originalClip);
          } else {
            int extraHeight =
                lastTab.getHeight() == lastVisibleRect.height
                    ? 0
                    : 2 * tabData.getTabbedPanelSize().height - tabData.getTabAreaHeight();
            pane.setSize(pane.getWidth(), pane.getHeight() + extraHeight);

            pane.doValidation();

            // Before tabs
            g.clipRect(
                0,
                0,
                widthTemp,
                aInsets.top + (firstVisibleRect.height > 0 && firstVisibleRect.y == 0 ? 1 : 0));
            pane.paint(g, tx, ty);
            g.setClip(originalClip);

            // After tabs
            ty -= extraHeight;

            int clipExtraHeight = extraHeight == 0 ? 1 : 0;
            g.clipRect(
                0,
                aInsets.top + tabData.getTabAreaHeight() - clipExtraHeight,
                widthTemp,
                heightTemp - aInsets.top - tabData.getTabAreaHeight() + clipExtraHeight);
            pane.paint(g, tx, ty);
            g.setClip(originalClip);
          }
        }

        // First and last tab
        paintTabs(pane, tabData, g, xTemp, yTemp, widthTemp, heightTemp);

        tabData.reset();

        reset(pane);
      }
    }
  }
コード例 #3
0
  private void paintTabs(
      PanePainter pane, TabData tabData, Graphics g, int x, int y, int width, int height) {
    if (enabled && PAINT_TAB) {
      Tab lastTab = (Tab) tabData.getTabList().get(tabData.getTabList().size() - 1);
      Rectangle lastVisibleRect =
          (Rectangle) tabData.getVisibleTabRects().get(tabData.getTabCount() - 1);

      // Fix post/pre tabs
      initPaintableTabLocations(pane);

      Insets aInsets = getTabAreaInsets(tabData.getAreaOrientation());

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

      if (tabData.isHorizontalLayout()) {
        int w =
            aInsets.left
                + aInsets.right
                + Math.max(0, tabData.getTabAreaWidth() - l.x - lastVisibleRect.width)
                + EXTRA_SIZE;

        for (int i = 0; i < tabData.getTabList().size(); i++)
          w += ((Tab) tabData.getTabList().get(i)).getWidth();

        pane.setSize(w, getTabbedPanelExtraSize());
      } else {
        int h =
            aInsets.top
                + aInsets.bottom
                + Math.max(0, tabData.getTabAreaHeight() - l.y - lastVisibleRect.height)
                + EXTRA_SIZE;

        for (int i = 0; i < tabData.getTabList().size(); i++)
          h += ((Tab) tabData.getTabList().get(i)).getHeight();

        pane.setSize(getTabbedPanelExtraSize(), h);
      }

      pane.doValidation();

      int index = tabData.getPreTab() == null ? 0 : tabData.getTabCount() > 1 ? 1 : 0;

      Shape originalClip = g.getClip();

      int tx =
          -x
              - (tabData.getAreaOrientation() == Direction.RIGHT
                  ? -tabData.getTabbedPanelWidth() + getTabbedPanelExtraSize()
                  : 0);
      int ty =
          -y
              - (tabData.getAreaOrientation() == Direction.DOWN
                  ? -tabData.getTabbedPanelHeight() + getTabbedPanelExtraSize()
                  : 0);

      Rectangle visibleRect = (Rectangle) tabData.getVisibleTabRects().get(index);
      Tab tab = (Tab) tabData.getTabList().get(index);

      if (tabData.isHorizontalLayout()) {
        tx -=
            (tabData.getPreTab() != null
                ? tab.getX() - tabData.getPreTab().getX() + visibleRect.x
                : visibleRect.x);
        g.clipRect(aInsets.left, 0, tabData.getTabAreaWidth(), height);
      } else {
        ty -=
            (tabData.getPreTab() != null
                ? tab.getY() - tabData.getPreTab().getY() + visibleRect.y
                : visibleRect.y);
        g.clipRect(0, aInsets.top, width, tabData.getTabAreaHeight());
      }

      applyFocusAndHover(pane, true);
      pane.paint(g, tx, ty);
      applyFocusAndHover(pane, false);

      g.setClip(originalClip);
    }
  }
コード例 #4
0
  private void estimateContentTabAreaBorderColor(
      PanePainter pane, int index, final Direction direction) {
    Dimension preSize = pane.getSize();

    reset(pane);

    pane.addTab(EMPTY_STRING, SizeIcon.EMPTY, getComponent());

    pane.setSelectedIndex(-1);

    Dimension paneSize = pane.getMinimumSize();

    if (direction.isHorizontal()) pane.setSize(paneSize.width, paneSize.height * 2);
    else pane.setSize(paneSize.width * 2, paneSize.height);

    pane.doValidation();

    Rectangle tabBounds = pane.getBoundsAt(0);

    BufferedImage img =
        new BufferedImage(pane.getWidth(), pane.getHeight(), BufferedImage.TYPE_INT_ARGB);

    int x = 0;
    int y = 0;

    if (direction == Direction.UP) {
      x = tabBounds.x + (tabBounds.width / 2);
      y = pane.getHeight() - contentInsets[index].top - contentInsets[index].bottom - 1;
    } else if (direction == Direction.DOWN) {
      x = tabBounds.x + (tabBounds.width / 2);
      y = contentInsets[index].top + contentInsets[index].bottom;
    } else if (direction == Direction.LEFT) {
      x = pane.getWidth() - contentInsets[index].left - contentInsets[index].right - 1;
      y = tabBounds.y + (tabBounds.height / 2);
    } else {
      x += contentInsets[index].left + contentInsets[index].right;
      y = tabBounds.y + (tabBounds.height / 2);
    }

    final int px = x;
    final int py = y;

    RGBImageFilter colorFilter =
        new RGBImageFilter() {
          @Override
          public int filterRGB(int x, int y, int rgb) {
            if (px == x && py == y) {
              int r = (rgb >> 16) & 0xff;
              int g = (rgb >> 8) & 0xff;
              int b = (rgb) & 0xff;
              int a = (rgb >> 24) & 0xff;
              contentTabAreaBorderColors[getDirectionIndex(direction.getOpposite())] =
                  new Color(r, g, b, a);
            }

            return rgb;
          }
        };

    FilteredImageSource source = new FilteredImageSource(img.getSource(), colorFilter);
    pane.paint(img.getGraphics());

    BufferedImage img2 =
        new BufferedImage(pane.getWidth(), pane.getHeight(), BufferedImage.TYPE_INT_ARGB);
    img2.getGraphics().drawImage(Toolkit.getDefaultToolkit().createImage(source), 0, 0, null);

    pane.setSize(preSize);

    pane.doValidation();
  }