/** {@inheritDoc} */
  @Override
  public void paint(final Graphics2D g2d, final Rectangle bounds, final E label) {
    // Applying graphics settings
    final Composite oc = LafUtils.setupAlphaComposite(g2d, transparency, transparency != null);
    final Map textHints =
        drawShade ? StyleConstants.defaultTextRenderingHints : StyleConstants.textRenderingHints;
    final Font oldFont = LafUtils.setupFont(g2d, label.getFont());
    final Map oldHints = SwingUtils.setupTextAntialias(g2d, textHints);

    // Retrieving icon & text
    final String text = label.getText();
    final Icon icon = (label.isEnabled()) ? label.getIcon() : label.getDisabledIcon();

    // Painting background
    if (backgroundPainter != null) {
      backgroundPainter.paint(g2d, bounds, label);
    }

    // We don't need to go futher if there is not icon/text
    if (icon == null && text == null) {
      return;
    }

    final FontMetrics fm = label.getFontMetrics(label.getFont());
    final String clippedText = layout(label, fm, label.getWidth(), label.getHeight());

    if (icon != null) {
      icon.paintIcon(label, g2d, paintIconR.x, paintIconR.y);
    }

    if (text != null) {
      final View v = (View) label.getClientProperty(BasicHTML.propertyKey);
      if (v != null) {
        // Painting HTML label view
        v.paint(g2d, paintTextR);
      } else {
        // Painting plain label view
        final int textX = paintTextR.x;
        final int textY = paintTextR.y + fm.getAscent();
        if (label.isEnabled()) {
          paintEnabledText(label, g2d, clippedText, textX, textY);
        } else {
          paintDisabledText(label, g2d, clippedText, textX, textY);
        }
      }
    }

    SwingUtils.restoreTextAntialias(g2d, oldHints);
    LafUtils.restoreFont(g2d, oldFont);
    LafUtils.restoreComposite(g2d, oc, transparency != null);
  }
  private void updateBorder() {
    // Preserve old borders
    if (SwingUtils.isPreserveBorders(radioButton)) {
      return;
    }

    // Actual margin
    final boolean ltr = radioButton.getComponentOrientation().isLeftToRight();
    final Insets m =
        new Insets(
            margin.top,
            ltr ? margin.left : margin.right,
            margin.bottom,
            ltr ? margin.right : margin.left);

    // Installing border
    radioButton.setBorder(LafUtils.createWebBorder(m));
  }
Exemple #3
0
  /** {@inheritDoc} */
  @Override
  public void updateBorder() {
    if (splitPane != null) {
      // Preserve old borders
      if (SwingUtils.isPreserveBorders(splitPane)) {
        return;
      }

      // Actual margin
      final boolean ltr = splitPane.getComponentOrientation().isLeftToRight();
      final Insets m =
          new Insets(
              margin.top,
              ltr ? margin.left : margin.right,
              margin.bottom,
              ltr ? margin.right : margin.left);

      // Installing border
      splitPane.setBorder(LafUtils.createWebBorder(m));
    }
  }
 @Override
 public Shape provideShape() {
   return LafUtils.getWebBorderShape(radioButton, getShadeWidth(), getRound());
 }
 /**
  * Paints custom text shade.
  *
  * @param g2d graphics context
  * @param text text
  * @param textX text X coordinate
  * @param textY text Y coordinate
  */
 protected void paintShadowText(
     final Graphics2D g2d, final String text, final int textX, final int textY) {
   g2d.translate(textX, textY);
   LafUtils.paintTextShadow(g2d, text, shadeColor);
   g2d.translate(-textX, -textY);
 }
Exemple #6
0
 @Override
 protected void paintComponent(Graphics g) {
   LafUtils.setupAlphaComposite((Graphics2D) g, opacity, opacity < 1f);
   super.paintComponent(g);
 }