Search in sources :

Example 76 with AlphaComposite

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

the class TextureToggleButtonUI method paintIcon.

/**
 * {@inheritDoc}
 */
@Override
protected void paintIcon(Graphics g, JComponent c, Rectangle iconRect) {
    AbstractButton b = (AbstractButton) c;
    Graphics2D g2D = (Graphics2D) g;
    Composite savedComposite = g2D.getComposite();
    if (!b.isContentAreaFilled()) {
        AlphaComposite alpha = AlphaComposite.getInstance(AlphaComposite.SRC_OVER, 0.9f);
        g2D.setComposite(alpha);
    }
    super.paintIcon(g, c, iconRect);
    g2D.setComposite(savedComposite);
}
Also used : AbstractButton(javax.swing.AbstractButton) Composite(java.awt.Composite) AlphaComposite(java.awt.AlphaComposite) AlphaComposite(java.awt.AlphaComposite) Graphics2D(java.awt.Graphics2D)

Example 77 with AlphaComposite

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

the class TextureToggleButtonUI method paintText.

/**
 * {@inheritDoc}
 */
@Override
protected void paintText(Graphics g, AbstractButton b, Rectangle textRect, String text) {
    Graphics2D g2D = (Graphics2D) g;
    Composite savedComposite = g2D.getComposite();
    ButtonModel model = b.getModel();
    FontMetrics fm = JTattooUtilities.getFontMetrics(b, g, b.getFont());
    int mnemIndex = b.getDisplayedMnemonicIndex();
    if (model.isEnabled()) {
        int offs = 0;
        if (model.isArmed() && model.isPressed()) {
            offs = 1;
        }
        Color foreground = b.getForeground();
        if (foreground instanceof ColorUIResource) {
            if (model.isPressed() && model.isArmed() || model.isSelected()) {
                foreground = AbstractLookAndFeel.getTheme().getPressedForegroundColor();
            } else if (model.isRollover()) {
                foreground = AbstractLookAndFeel.getTheme().getRolloverForegroundColor();
            }
        }
        if (AbstractLookAndFeel.getTheme().isTextShadowOn() && ColorHelper.getGrayValue(foreground) > 164) {
            AlphaComposite alpha = AlphaComposite.getInstance(AlphaComposite.SRC_OVER, 0.4f);
            g2D.setComposite(alpha);
            g.setColor(Color.black);
            JTattooUtilities.drawStringUnderlineCharAt(b, g, text, mnemIndex, textRect.x + offs, textRect.y + offs + fm.getAscent() + 1);
            g2D.setComposite(savedComposite);
        }
        g.setColor(foreground);
        JTattooUtilities.drawStringUnderlineCharAt(b, g, text, mnemIndex, textRect.x + offs, textRect.y + offs + fm.getAscent());
    } else {
        AlphaComposite alpha = AlphaComposite.getInstance(AlphaComposite.SRC_OVER, 0.8f);
        g2D.setComposite(alpha);
        Color fc = b.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(b, g, text, mnemIndex, textRect.x, textRect.y + 1 + fm.getAscent());
        g2D.setComposite(savedComposite);
        g.setColor(fc);
        JTattooUtilities.drawStringUnderlineCharAt(b, g, text, mnemIndex, textRect.x, textRect.y + fm.getAscent());
    }
}
Also used : Composite(java.awt.Composite) AlphaComposite(java.awt.AlphaComposite) FontMetrics(java.awt.FontMetrics) AlphaComposite(java.awt.AlphaComposite) Color(java.awt.Color) ButtonModel(javax.swing.ButtonModel) ColorUIResource(javax.swing.plaf.ColorUIResource) Graphics2D(java.awt.Graphics2D)

Example 78 with AlphaComposite

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

the class TexturePopupMenuSeparatorUI method paint.

/**
 * {@inheritDoc}
 */
@Override
public void paint(final Graphics g, final JComponent c) {
    TextureUtils.fillComponent(g, c, TextureUtils.MENUBAR_TEXTURE_TYPE);
    if (AbstractLookAndFeel.getTheme().getTextureSet().equals("Default")) {
        Graphics2D g2D = (Graphics2D) g;
        Composite savedComposite = g2D.getComposite();
        AlphaComposite alpha = AlphaComposite.getInstance(AlphaComposite.SRC_OVER, 0.6f);
        g2D.setComposite(alpha);
        int w = c.getWidth();
        drawLine(g, 2, w, BORDER_COLORS[0]);
        drawLine(g, 3, w, BORDER_COLORS[1]);
        drawLine(g, 4, w, BORDER_COLORS[2]);
        drawLine(g, 5, w, BORDER_COLORS[3]);
        g2D.setComposite(savedComposite);
    } else {
        Graphics2D g2D = (Graphics2D) g;
        Composite savedComposite = g2D.getComposite();
        AlphaComposite alpha = AlphaComposite.getInstance(AlphaComposite.SRC_OVER, 0.6f);
        g2D.setComposite(alpha);
        if (AbstractLookAndFeel.getTheme().isDarkTexture()) {
            g.setColor(Color.black);
        } else {
            g.setColor(Color.gray);
        }
        g.drawLine(1, 3, c.getWidth() - 2, 3);
        alpha = AlphaComposite.getInstance(AlphaComposite.SRC_OVER, 0.3f);
        g2D.setComposite(alpha);
        g.setColor(Color.white);
        g.drawLine(1, 4, c.getWidth() - 2, 4);
        g2D.setComposite(savedComposite);
    }
}
Also used : AlphaComposite(java.awt.AlphaComposite) Composite(java.awt.Composite) AlphaComposite(java.awt.AlphaComposite) Graphics2D(java.awt.Graphics2D)

Example 79 with AlphaComposite

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

the class TextureSplitPaneDivider method paint.

/**
 * {@inheritDoc}
 */
@Override
public void paint(final Graphics g) {
    if (!isFlatMode()) {
        TextureUtils.fillComponent(g, this, TextureUtils.getTextureType(splitPane));
        Graphics2D g2D = (Graphics2D) g;
        Composite savedComposite = g2D.getComposite();
        AlphaComposite alpha = AlphaComposite.getInstance(AlphaComposite.SRC_OVER, 0.5f);
        g2D.setComposite(alpha);
        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;
        }
        Icon horBumps = null;
        Icon verBumps = null;
        if (UIManager.getLookAndFeel() instanceof AbstractLookAndFeel) {
            AbstractLookAndFeel laf = (AbstractLookAndFeel) UIManager.getLookAndFeel();
            horBumps = laf.getIconFactory().getSplitterHorBumpIcon();
            verBumps = laf.getIconFactory().getSplitterVerBumpIcon();
        }
        if (orientation == JSplitPane.HORIZONTAL_SPLIT) {
            if (horBumps != null && width > horBumps.getIconWidth()) {
                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 {
            if (verBumps != null && height > verBumps.getIconHeight()) {
                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 : AbstractLookAndFeel(com.jtattoo.plaf.AbstractLookAndFeel) AlphaComposite(java.awt.AlphaComposite) Composite(java.awt.Composite) AlphaComposite(java.awt.AlphaComposite) Icon(javax.swing.Icon) Graphics2D(java.awt.Graphics2D)

Example 80 with AlphaComposite

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

the class TextureTabbedPaneUI method paintContentBorder.

/**
 * {@inheritDoc}
 */
@Override
protected void paintContentBorder(Graphics g, int tabPlacement, int selectedIndex, int x, int y, int w, int h) {
    int textureType = TextureUtils.getTextureType(tabPane);
    int tabAreaHeight = calculateTabAreaHeight(tabPlacement, runCount, maxTabHeight);
    int tabAreaWidth = calculateTabAreaWidth(tabPlacement, runCount, maxTabWidth);
    // paint the background
    if (tabPane.isOpaque()) {
        int xt = tabPlacement == RIGHT ? w - tabAreaWidth : 0;
        int yt = tabPlacement == BOTTOM ? h - tabAreaHeight : 0;
        int wt = tabPlacement == TOP || tabPlacement == BOTTOM ? w : tabAreaWidth;
        int ht = tabPlacement == LEFT || tabPlacement == RIGHT ? h : tabAreaHeight;
        g.setColor(tabAreaBackground);
        g.fillRect(xt, yt, wt, ht);
    }
    if (isContentOpaque()) {
        int xt = tabPlacement == LEFT ? tabAreaWidth : 0;
        int yt = tabPlacement == TOP ? tabAreaHeight : 0;
        int wt = tabPlacement == LEFT || tabPlacement == RIGHT ? w - tabAreaWidth : w;
        int ht = tabPlacement == TOP || tabPlacement == BOTTOM ? h - tabAreaHeight : h;
        TextureUtils.fillComponent(g, tabPane, xt, yt, wt, ht, textureType);
    }
    int sepHeight = tabAreaInsets.bottom;
    if (sepHeight > 0) {
        Insets bi = new Insets(0, 0, 0, 0);
        if (tabPane.getBorder() != null) {
            bi = tabPane.getBorder().getBorderInsets(tabPane);
        }
        switch(tabPlacement) {
            case TOP:
                {
                    TextureUtils.fillComponent(g, tabPane, x, y + tabAreaHeight - sepHeight + bi.top, w, sepHeight, getSelectedTexture());
                    if (textureType == TextureUtils.MENUBAR_TEXTURE_TYPE) {
                        Graphics2D g2D = (Graphics2D) g;
                        Composite saveComposite = g2D.getComposite();
                        AlphaComposite alpha = AlphaComposite.getInstance(AlphaComposite.SRC_OVER, 0.5f);
                        g2D.setComposite(alpha);
                        g2D.setColor(Color.black);
                        g2D.drawLine(x, y, w, y);
                        g2D.drawLine(w, y, w, y + tabAreaHeight - sepHeight);
                        alpha = AlphaComposite.getInstance(AlphaComposite.SRC_OVER, 0.2f);
                        g2D.setComposite(alpha);
                        g2D.setColor(Color.white);
                        g2D.drawLine(x, y + tabAreaHeight - sepHeight, w, y + tabAreaHeight - sepHeight);
                        alpha = AlphaComposite.getInstance(AlphaComposite.SRC_OVER, 0.1f);
                        g2D.setComposite(alpha);
                        g2D.drawLine(x, y + 1, x, y + tabAreaHeight - sepHeight - 1);
                        g2D.setComposite(saveComposite);
                    }
                    break;
                }
            case LEFT:
                {
                    TextureUtils.fillComponent(g, tabPane, x + tabAreaWidth - sepHeight + bi.left, y, sepHeight, h, getSelectedTexture());
                    break;
                }
            case BOTTOM:
                {
                    TextureUtils.fillComponent(g, tabPane, x, y + h - tabAreaHeight - bi.bottom, w, sepHeight, getSelectedTexture());
                    break;
                }
            case RIGHT:
                {
                    TextureUtils.fillComponent(g, tabPane, x + w - tabAreaWidth - bi.right, y, sepHeight, h, getSelectedTexture());
                    break;
                }
            default:
                break;
        }
    }
}
Also used : Insets(java.awt.Insets) Composite(java.awt.Composite) AlphaComposite(java.awt.AlphaComposite) AlphaComposite(java.awt.AlphaComposite) 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