⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 shapedgradienttheme.java

📁 修正了jdk1.6中对托盘事件产生异常的bug.
💻 JAVA
📖 第 1 页 / 共 2 页
字号:
    int rightSlopeWidth = (int) (rightSlope * rightSlopeHeight);
    int highlightedRaised = 2;

    boolean bottomLeftRounded = true;
    boolean topLeftRounded = true;
    boolean topRightRounded = true;
    boolean bottomRightRounded = true;

    titledTabProperties.setHighlightedRaised(highlightedRaised).setBorderSizePolicy(
        TitledTabBorderSizePolicy.EQUAL_SIZE);

    TitledTabStateProperties normalState = titledTabProperties.getNormalProperties();
    TitledTabStateProperties highlightState = titledTabProperties.getHighlightedProperties();
    TitledTabStateProperties disabledState = titledTabProperties.getDisabledProperties();

    Border normalBorder = new TabBorder(lineColor, null, leftSlope, rightSlope, leftSlopeHeight, rightSlopeHeight, false, topLeftRounded, topRightRounded,
                                        false, true, true, highlightedRaised);
    Border highlightBorder = new TabBorder(lineColor,
                                           highlightColor,
                                           leftSlope,
                                           rightSlope,
                                           leftSlopeHeight,
                                           rightSlopeHeight,
                                           bottomLeftRounded,
                                           topLeftRounded,
                                           topRightRounded,
                                           bottomRightRounded,
                                           false,
                                           true,
                                           highlightedRaised);

    normalState.getComponentProperties().setBorder(normalBorder).setInsets(new Insets(0, 0, 0, 0));
    highlightState.getComponentProperties().setBorder(highlightBorder);

    ColorProvider darkControlColor1 = new ColorMultiplier(darkControlColor, 1.1);
    ColorProvider darkControlColor2 = new ColorMultiplier(darkControlColor, 0.92);
    GradientComponentPainter normalComponentPainter = new GradientComponentPainter(darkControlColor1,
                                                                                   darkControlColor1,
                                                                                   darkControlColor2,
                                                                                   darkControlColor2);
    normalState.getShapedPanelProperties().setOpaque(false).setComponentPainter(normalComponentPainter);
    disabledState.getShapedPanelProperties().setComponentPainter(normalComponentPainter);

    if (highlightColor == null)
      highlightState.getShapedPanelProperties().setComponentPainter(blendedComponentPainter);
    else
      highlightState.getShapedPanelProperties().setComponentPainter(
          new GradientComponentPainter(highlightColor, highlightColor, controlColor, controlColor));

    Insets insets = normalBorder.getBorderInsets(null);
    int tabSpacing = 1 + insets.left + insets.right - (topLeftRounded ? CORNER_INSET : 0) - (topRightRounded ?
                                                                                             CORNER_INSET : 0) -
                     (int) (0.2 * (leftSlopeWidth + rightSlopeWidth));
    tabbedPanelProperties.setTabSpacing(-tabSpacing).setShadowEnabled(false);

    tabbedPanelProperties.getTabAreaComponentsProperties().getComponentProperties().setBorder(new SlopedTabLineBorder(
        lineColor,
        highlightColor,
        false,
        0f,
        0f,
        0,
        0,
        false,
        topLeftRounded,
        topRightRounded,
        false)).setInsets(new Insets(0, 0, 0, 0));

    tabbedPanelProperties.getTabAreaComponentsProperties().getShapedPanelProperties().setComponentPainter(
        blendedComponentPainter);

    tabbedPanelProperties.getTabAreaProperties().getShapedPanelProperties().setOpaque(false);

    tabbedPanelProperties.getContentPanelProperties().getComponentProperties()
        .setBorder(new OpenContentBorder(lineColor, lineColor,
                                         highlightColor == null ? null : new ColorBlender(highlightColor,
                                                                                          BackgroundPainterColorProvider.INSTANCE,
                                                                                          HighlightPainter.getBlendFactor(
                                                                                              1, 0)),
                                         1));
  }

  /**
   * Gets the theme name
   *
   * @return name for this theme
   */
  public String getName() {
    return "Shaped Gradient Theme";
  }

  /**
   * Gets the TabbedPanelProperties for this theme
   *
   * @return the TabbedPanelProperties
   */
  public TabbedPanelProperties getTabbedPanelProperties() {
    return tabbedPanelProperties;
  }

  /**
   * Gets the TitledTabProperties for this theme
   *
   * @return the TitledTabProperties
   */
  public TitledTabProperties getTitledTabProperties() {
    return titledTabProperties;
  }

  /**
   * Gets the line color provider
   *
   * @return the line color provider
   */
  public ColorProvider getLineColor() {
    return lineColor;
  }

  /**
   * Gets the highlight color provider
   *
   * @return the highlight color provider, null if no highlight
   */
  public ColorProvider getHighlightColor() {
    return highlightColor;
  }

  /**
   * Gets the alternate highlight color provider used for tab area
   * components gradient background and highlighted tab background
   * (when no highlight color is specified)
   *
   * @return the alternate highlight color provider
   */
  public ColorProvider getAlternateHighlightColor() {
    return alternateHighlight;
  }

  /**
   * Gets the control background color
   *
   * @return the control background color provider
   */
  public ColorProvider getControlColor() {
    return controlColor;
  }

  /**
   * Gets the dark control background color used for gradient for
   * normal tab and disabled tab
   *
   * @return the dark control background color provider
   */
  public ColorProvider getDarkControlColor() {
    return darkControlColor;
  }

  /**
   * Creates a tab border
   *
   * @param lineColor                  line color provider
   * @param highlightColor             highlight color provider, null for no highlight
   * @param leftSlope                  left slope
   * @param rightSlope                 right slope
   * @param bottomLeftRounded          true if bottom left should be rounded
   * @param topLeftRounded             true if top left should be rounded
   * @param topRightRounded            true if top right should be rounded
   * @param bottomRightRounded         true if bottom right should be rounded
   * @param isNormal                   true if this is a normal rendered border
   * @param highlightBottomLeftRounded true if highlight has bottom left rounded
   * @param raised                     raised
   * @return the created border
   */
  public Border createTabBorder(ColorProvider lineColor,
                                ColorProvider highlightColor,
                                float leftSlope,
                                float rightSlope,
                                boolean bottomLeftRounded,
                                boolean topLeftRounded,
                                boolean topRightRounded,
                                boolean bottomRightRounded,
                                boolean isNormal,
                                boolean highlightBottomLeftRounded,
                                int raised) {
    return new TabBorder(lineColor,
                         highlightColor,
                         leftSlope,
                         rightSlope,
                         25,
                         25,
                         bottomLeftRounded,
                         topLeftRounded,
                         topRightRounded,
                         bottomRightRounded,
                         isNormal,
                         highlightBottomLeftRounded,
                         raised);
  }
}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -