Search in sources :

Example 36 with AlphaComposite

use of java.awt.AlphaComposite in project LoboEvolution by LoboEvolution.

the class BaseSliderUI method paintThumb.

/**
 * {@inheritDoc}
 */
@Override
public void paintThumb(Graphics g) {
    Icon icon;
    if (slider.getOrientation() == SwingConstants.HORIZONTAL) {
        if ((isRollover || isDragging()) && slider.isEnabled()) {
            icon = getThumbHorIconRollover();
        } else {
            icon = getThumbHorIcon();
        }
    } else {
        if ((isRollover || isDragging()) && slider.isEnabled()) {
            icon = getThumbVerIconRollover();
        } else {
            icon = getThumbVerIcon();
        }
    }
    Graphics2D g2D = (Graphics2D) g;
    Composite savedComposite = g2D.getComposite();
    if (!slider.isEnabled()) {
        g.setColor(AbstractLookAndFeel.getBackgroundColor());
        g.fillRect(thumbRect.x + 1, thumbRect.y + 1, thumbRect.width - 2, thumbRect.height - 2);
        AlphaComposite alpha = AlphaComposite.getInstance(AlphaComposite.SRC_OVER, 0.6f);
        g2D.setComposite(alpha);
    }
    icon.paintIcon(null, g, thumbRect.x, thumbRect.y);
    g2D.setComposite(savedComposite);
}
Also used : Composite(java.awt.Composite) AlphaComposite(java.awt.AlphaComposite) AlphaComposite(java.awt.AlphaComposite) Icon(javax.swing.Icon) Graphics2D(java.awt.Graphics2D)

Example 37 with AlphaComposite

use of java.awt.AlphaComposite in project LoboEvolution by LoboEvolution.

the class BaseSplitPaneDivider method paint.

/**
 * {@inheritDoc}
 */
@Override
public void paint(final Graphics g) {
    if (!isFlatMode()) {
        Graphics2D g2D = (Graphics2D) g;
        Composite savedComposite = g2D.getComposite();
        int width = getSize().width;
        int height = getSize().height;
        int dx = 0;
        int dy = 0;
        if (width % 2 == 1) {
            dx = 1;
        }
        if (height % 2 == 1) {
            dy = 1;
        }
        Color color = AbstractLookAndFeel.getBackgroundColor();
        Color cHi = ColorHelper.brighter(color, 25);
        Color cLo = ColorHelper.darker(color, 5);
        Color[] colors = ColorHelper.createColorArr(cHi, cLo, 10);
        if (UIManager.getLookAndFeel() instanceof AbstractLookAndFeel) {
            AbstractLookAndFeel laf = (AbstractLookAndFeel) UIManager.getLookAndFeel();
            if (orientation == JSplitPane.HORIZONTAL_SPLIT) {
                JTattooUtilities.fillVerGradient(g, colors, 0, 0, width, height);
                Icon horBumps = laf.getIconFactory().getSplitterHorBumpIcon();
                if (horBumps != null && width > horBumps.getIconWidth()) {
                    AlphaComposite alpha = AlphaComposite.getInstance(AlphaComposite.SRC_OVER, 0.7f);
                    g2D.setComposite(alpha);
                    if (splitPane.isOneTouchExpandable() && centerOneTouchButtons) {
                        int centerY = height / 2;
                        int x = (width - horBumps.getIconWidth()) / 2 + dx;
                        int y = centerY - horBumps.getIconHeight() - 40;
                        horBumps.paintIcon(this, g, x, y);
                        y = centerY + 40;
                        horBumps.paintIcon(this, g, x, y);
                    } else {
                        int x = (width - horBumps.getIconWidth()) / 2 + dx;
                        int y = (height - horBumps.getIconHeight()) / 2;
                        horBumps.paintIcon(this, g, x, y);
                    }
                }
            } else {
                JTattooUtilities.fillHorGradient(g, colors, 0, 0, width, height);
                Icon verBumps = laf.getIconFactory().getSplitterVerBumpIcon();
                if (verBumps != null && height > verBumps.getIconHeight()) {
                    AlphaComposite alpha = AlphaComposite.getInstance(AlphaComposite.SRC_OVER, 0.7f);
                    g2D.setComposite(alpha);
                    if (splitPane.isOneTouchExpandable() && centerOneTouchButtons) {
                        int centerX = width / 2;
                        int x = centerX - verBumps.getIconWidth() - 40;
                        int y = (height - verBumps.getIconHeight()) / 2 + dy;
                        verBumps.paintIcon(this, g, x, y);
                        x = centerX + 40;
                        verBumps.paintIcon(this, g, x, y);
                    } else {
                        int x = (width - verBumps.getIconWidth()) / 2;
                        int y = (height - verBumps.getIconHeight()) / 2 + dy;
                        verBumps.paintIcon(this, g, x, y);
                    }
                }
            }
        }
        g2D.setComposite(savedComposite);
    }
    paintComponents(g);
}
Also used : Composite(java.awt.Composite) AlphaComposite(java.awt.AlphaComposite) AlphaComposite(java.awt.AlphaComposite) Color(java.awt.Color) Icon(javax.swing.Icon) Graphics2D(java.awt.Graphics2D)

Example 38 with AlphaComposite

use of java.awt.AlphaComposite in project LoboEvolution by LoboEvolution.

the class BaseMenuItemUI method paintBackground.

/**
 * <p>paintBackground.</p>
 *
 * @param g a {@link java.awt.Graphics} object.
 * @param c a {@link javax.swing.JComponent} object.
 * @param x a int.
 * @param y a int.
 * @param w a int.
 * @param h a int.
 */
protected void paintBackground(Graphics g, JComponent c, int x, int y, int w, int h) {
    JMenuItem mi = (JMenuItem) c;
    Color backColor = mi.getBackground();
    if (backColor == null || backColor instanceof UIResource) {
        backColor = AbstractLookAndFeel.getMenuBackgroundColor();
    }
    ButtonModel model = mi.getModel();
    if (model.isArmed() || model.isRollover() || c instanceof JMenu && model.isSelected()) {
        g.setColor(AbstractLookAndFeel.getMenuSelectionBackgroundColor());
        g.fillRect(x, y, w, h);
        g.setColor(AbstractLookAndFeel.getMenuSelectionForegroundColor());
    } else if (!AbstractLookAndFeel.getTheme().isMenuOpaque()) {
        Graphics2D g2D = (Graphics2D) g;
        Composite savedComposite = g2D.getComposite();
        AlphaComposite alpha = AlphaComposite.getInstance(AlphaComposite.SRC_OVER, AbstractLookAndFeel.getTheme().getMenuAlpha());
        g2D.setComposite(alpha);
        g2D.setColor(backColor);
        g2D.fillRect(x, y, w, h);
        g2D.setComposite(savedComposite);
        g.setColor(AbstractLookAndFeel.getMenuForegroundColor());
    } else {
        g.setColor(backColor);
        g.fillRect(x, y, w, h);
        g.setColor(AbstractLookAndFeel.getMenuForegroundColor());
    }
}
Also used : Composite(java.awt.Composite) AlphaComposite(java.awt.AlphaComposite) AlphaComposite(java.awt.AlphaComposite) Color(java.awt.Color) JMenuItem(javax.swing.JMenuItem) ButtonModel(javax.swing.ButtonModel) UIResource(javax.swing.plaf.UIResource) JMenu(javax.swing.JMenu) Graphics2D(java.awt.Graphics2D)

Example 39 with AlphaComposite

use of java.awt.AlphaComposite in project LoboEvolution by LoboEvolution.

the class TextureLabelUI method paintDisabledText.

/**
 * {@inheritDoc}
 */
@Override
protected void paintDisabledText(JLabel l, Graphics g, String s, int textX, int textY) {
    int mnemIndex = l.getDisplayedMnemonicIndex();
    Graphics2D g2D = (Graphics2D) g;
    Composite savedComposite = g2D.getComposite();
    AlphaComposite alpha = AlphaComposite.getInstance(AlphaComposite.SRC_OVER, 0.8f);
    g2D.setComposite(alpha);
    Color fc = l.getForeground();
    if (ColorHelper.getGrayValue(fc) > 164) {
        fc = ColorHelper.brighter(AbstractLookAndFeel.getDisabledForegroundColor(), 40);
        g.setColor(Color.black);
    } else {
        fc = AbstractLookAndFeel.getDisabledForegroundColor();
        g.setColor(Color.white);
    }
    JTattooUtilities.drawStringUnderlineCharAt(l, g, s, mnemIndex, textX, textY + 1);
    g2D.setComposite(savedComposite);
    g.setColor(fc);
    JTattooUtilities.drawStringUnderlineCharAt(l, g, s, mnemIndex, textX, textY);
}
Also used : AlphaComposite(java.awt.AlphaComposite) Composite(java.awt.Composite) AlphaComposite(java.awt.AlphaComposite) Color(java.awt.Color) Graphics2D(java.awt.Graphics2D)

Example 40 with AlphaComposite

use of java.awt.AlphaComposite in project LoboEvolution by LoboEvolution.

the class SmartInternalFrameTitlePane method paintBackground.

/**
 * {@inheritDoc}
 */
@Override
public void paintBackground(Graphics g) {
    Graphics2D g2D = (Graphics2D) g;
    int width = getWidth();
    int height = getHeight();
    Color backColor;
    Color frameColor;
    if (JTattooUtilities.isActive(this)) {
        backColor = AbstractLookAndFeel.getTheme().getWindowTitleColors()[10];
        frameColor = AbstractLookAndFeel.getTheme().getFrameColor();
        JTattooUtilities.fillHorGradient(g, AbstractLookAndFeel.getTheme().getWindowTitleColors(), 0, 0, width, height);
    } else {
        backColor = AbstractLookAndFeel.getTheme().getWindowInactiveTitleColors()[10];
        frameColor = ColorHelper.brighter(AbstractLookAndFeel.getTheme().getFrameColor(), 40);
        JTattooUtilities.fillHorGradient(g, AbstractLookAndFeel.getTheme().getWindowInactiveTitleColors(), 0, 0, width, height);
    }
    int iconWidth = 0;
    Icon icon = frame.getFrameIcon();
    if (icon != null) {
        iconWidth = icon.getIconWidth() + 5;
    }
    int titleWidth = 0;
    String frameTitle = frame.getTitle();
    if (frameTitle != null) {
        g.setFont(getFont());
        FontMetrics fm = JTattooUtilities.getFontMetrics(this, g, getFont());
        titleWidth = fm.stringWidth(JTattooUtilities.getClippedText(frame.getTitle(), fm, getWidth() - iconWidth - buttonsWidth - 15)) + 10;
    }
    int dx;
    int dw;
    boolean leftToRight = JTattooUtilities.isLeftToRight(frame);
    int xOffset = leftToRight ? iconWidth + 10 + titleWidth : width - 10 - iconWidth - titleWidth;
    if (leftToRight) {
        dw = width - buttonsWidth - xOffset - 10;
        dx = xOffset;
    } else {
        dw = xOffset - buttonsWidth - 10;
        dx = buttonsWidth + 10;
    }
    int dy = 3;
    if (!AbstractLookAndFeel.getTheme().isMacStyleWindowDecorationOn() && !AbstractLookAndFeel.getTheme().isCenterWindowTitleOn() && dw > 0) {
        Composite composite = g2D.getComposite();
        AlphaComposite alpha = AlphaComposite.getInstance(AlphaComposite.SRC_OVER, 0.6f);
        g2D.setComposite(alpha);
        float dc1 = 50.0f;
        float dc2 = 5.0f;
        Color c1 = ColorHelper.brighter(backColor, dc1);
        Color c2;
        while (dy + 5 < height) {
            c2 = ColorHelper.darker(backColor, dc2);
            dc2 += 5.0f;
            g.setColor(c1);
            g.drawLine(dx, dy, dx + dw, dy);
            dy++;
            g.setColor(c2);
            g.drawLine(dx, dy, dx + dw, dy);
            dy += 3;
        }
        g2D.setComposite(composite);
    }
    g.setColor(frameColor);
    g.drawLine(0, height - 1, width, height - 1);
}
Also used : AlphaComposite(java.awt.AlphaComposite) Composite(java.awt.Composite) FontMetrics(java.awt.FontMetrics) AlphaComposite(java.awt.AlphaComposite) Color(java.awt.Color) Icon(javax.swing.Icon) Graphics2D(java.awt.Graphics2D)

Aggregations

AlphaComposite (java.awt.AlphaComposite)80 Composite (java.awt.Composite)56 Graphics2D (java.awt.Graphics2D)56 Color (java.awt.Color)24 Paint (java.awt.Paint)10 ButtonModel (javax.swing.ButtonModel)10 FontMetrics (java.awt.FontMetrics)9 BufferedImage (java.awt.image.BufferedImage)9 ColorUIResource (javax.swing.plaf.ColorUIResource)9 UIResource (javax.swing.plaf.UIResource)8 GradientPaint (java.awt.GradientPaint)6 Shape (java.awt.Shape)6 Area (java.awt.geom.Area)6 Rectangle2D (java.awt.geom.Rectangle2D)6 Point (java.awt.Point)5 RoundRectangle2D (java.awt.geom.RoundRectangle2D)5 Icon (javax.swing.Icon)5 JMenuBar (javax.swing.JMenuBar)5 LinearGradientPaint (java.awt.LinearGradientPaint)4 AffineTransform (java.awt.geom.AffineTransform)4