Search in sources :

Example 71 with AlphaComposite

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

the class HiFiButtonUI method paintText.

/**
 * {@inheritDoc}
 */
@Override
protected void paintText(Graphics g, AbstractButton b, Rectangle textRect, String text) {
    ButtonModel model = b.getModel();
    FontMetrics fm = JTattooUtilities.getFontMetrics(b, g, b.getFont());
    int mnemIndex = b.getDisplayedMnemonicIndex();
    int offs = 0;
    if (model.isArmed() && model.isPressed()) {
        offs = 1;
    }
    Graphics2D g2D = (Graphics2D) g;
    Composite composite = g2D.getComposite();
    AlphaComposite alpha = AlphaComposite.getInstance(AlphaComposite.SRC_OVER, 0.6f);
    g2D.setComposite(alpha);
    Color foreground = b.getForeground();
    Color background = b.getBackground();
    if (background instanceof ColorUIResource) {
        if (model.isPressed() && model.isArmed()) {
            foreground = AbstractLookAndFeel.getTheme().getSelectionForegroundColor();
        } else if (model.isRollover()) {
            foreground = AbstractLookAndFeel.getTheme().getRolloverForegroundColor();
        }
    }
    if (!model.isEnabled()) {
        foreground = AbstractLookAndFeel.getTheme().getDisabledForegroundColor();
    }
    if (ColorHelper.getGrayValue(foreground) > 64) {
        g2D.setColor(Color.black);
    } else {
        g2D.setColor(Color.white);
    }
    JTattooUtilities.drawStringUnderlineCharAt(b, g, text, mnemIndex, textRect.x + offs + 1, textRect.y + offs + fm.getAscent() + 1);
    g2D.setComposite(composite);
    g2D.setColor(foreground);
    JTattooUtilities.drawStringUnderlineCharAt(b, g, text, mnemIndex, textRect.x + offs, textRect.y + offs + 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 72 with AlphaComposite

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

the class BernsteinInternalFrameTitlePane method paintBackground.

/**
 * {@inheritDoc}
 */
@Override
public void paintBackground(Graphics g) {
    BernsteinUtils.fillComponent(g, this);
    Graphics2D g2D = (Graphics2D) g;
    Composite composite = g2D.getComposite();
    AlphaComposite alpha = AlphaComposite.getInstance(AlphaComposite.SRC_OVER, 0.4f);
    g2D.setComposite(alpha);
    JTattooUtilities.fillHorGradient(g, AbstractLookAndFeel.getTheme().getDefaultColors(), 0, 0, getWidth(), getHeight());
    g2D.setComposite(composite);
    if (isActive()) {
        g.setColor(AbstractLookAndFeel.getTheme().getWindowBorderColor());
    } else {
        g.setColor(AbstractLookAndFeel.getTheme().getWindowInactiveBorderColor());
    }
    g.drawLine(0, getHeight() - 1, getWidth(), getHeight() - 1);
}
Also used : AlphaComposite(java.awt.AlphaComposite) Composite(java.awt.Composite) AlphaComposite(java.awt.AlphaComposite) Graphics2D(java.awt.Graphics2D)

Example 73 with AlphaComposite

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

the class BernsteinTitlePane method paintBackground.

/**
 * {@inheritDoc}
 */
@Override
public void paintBackground(Graphics g) {
    if (backgroundImage != null) {
        g.drawImage(backgroundImage, 0, 0, null);
    } else {
        BernsteinUtils.fillComponent(g, this);
    }
    Graphics2D g2D = (Graphics2D) g;
    Composite composite = g2D.getComposite();
    AlphaComposite alpha = null;
    if (backgroundImage != null) {
        alpha = AlphaComposite.getInstance(AlphaComposite.SRC_OVER, alphaValue);
    } else {
        alpha = AlphaComposite.getInstance(AlphaComposite.SRC_OVER, 0.4f);
    }
    g2D.setComposite(alpha);
    JTattooUtilities.fillHorGradient(g, AbstractLookAndFeel.getTheme().getDefaultColors(), 0, 0, getWidth(), getHeight());
    g2D.setComposite(composite);
}
Also used : AlphaComposite(java.awt.AlphaComposite) Composite(java.awt.Composite) AlphaComposite(java.awt.AlphaComposite) Graphics2D(java.awt.Graphics2D)

Example 74 with AlphaComposite

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

the class BaseMenuUI 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 (c.getParent() instanceof JMenuBar) {
        if (model.isRollover() || model.isArmed() || c instanceof JMenu && model.isSelected()) {
            backColor = AbstractLookAndFeel.getMenuSelectionBackgroundColor();
            if (model.isRollover()) {
                backColor = ColorHelper.brighter(backColor, 10);
            }
            g.setColor(backColor);
            g.fillRect(x, y, w, h);
            if (paintRolloverBorder && model.isRollover() && !model.isSelected()) {
                backColor = ColorHelper.darker(backColor, 20);
                g.setColor(backColor);
                g.drawRect(x, y, w - 1, h - 1);
            }
            g.setColor(AbstractLookAndFeel.getMenuSelectionForegroundColor());
        }
    } else {
        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);
            g2D.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) JMenuBar(javax.swing.JMenuBar) JMenu(javax.swing.JMenu) Graphics2D(java.awt.Graphics2D)

Example 75 with AlphaComposite

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

the class TextureTabbedPaneUI method paintText.

/**
 * {@inheritDoc}
 */
@Override
protected void paintText(Graphics g, int tabPlacement, Font font, FontMetrics metrics, int tabIndex, String title, Rectangle textRect, boolean isSelected) {
    Color backColor = tabPane.getBackgroundAt(tabIndex);
    if (!(backColor instanceof UIResource) || !AbstractLookAndFeel.getTheme().isDarkTexture()) {
        super.paintText(g, tabPlacement, font, metrics, tabIndex, title, textRect, isSelected);
        return;
    }
    g.setFont(font);
    View v = getTextViewForTab(tabIndex);
    if (v != null) {
        // html
        Graphics2D g2D = (Graphics2D) g;
        Object savedRenderingHint = null;
        if (AbstractLookAndFeel.getTheme().isTextAntiAliasingOn()) {
            savedRenderingHint = g2D.getRenderingHint(RenderingHints.KEY_TEXT_ANTIALIASING);
            g2D.setRenderingHint(RenderingHints.KEY_TEXT_ANTIALIASING, AbstractLookAndFeel.getTheme().getTextAntiAliasingHint());
        }
        v.paint(g, textRect);
        if (AbstractLookAndFeel.getTheme().isTextAntiAliasingOn()) {
            g2D.setRenderingHint(RenderingHints.KEY_TEXT_ANTIALIASING, savedRenderingHint);
        }
    } else {
        // plain text
        int mnemIndex = tabPane.getDisplayedMnemonicIndexAt(tabIndex);
        if (tabPane.isEnabled() && tabPane.isEnabledAt(tabIndex)) {
            if (isSelected) {
                Color titleColor = AbstractLookAndFeel.getTabSelectionForegroundColor();
                if (ColorHelper.getGrayValue(titleColor) > 164) {
                    g.setColor(Color.black);
                } else {
                    g.setColor(Color.white);
                }
                JTattooUtilities.drawStringUnderlineCharAt(tabPane, g, title, mnemIndex, textRect.x + 1, textRect.y + 1 + metrics.getAscent());
                g.setColor(titleColor);
                Graphics2D g2D = (Graphics2D) g;
                Shape savedClip = g2D.getClip();
                Area clipArea = new Area(new Rectangle2D.Double(textRect.x, textRect.y, textRect.width, textRect.height / 2 + 1));
                if (savedClip != null) {
                    clipArea.intersect(new Area(savedClip));
                }
                g2D.setClip(clipArea);
                JTattooUtilities.drawStringUnderlineCharAt(tabPane, g, title, mnemIndex, textRect.x, textRect.y + metrics.getAscent());
                clipArea = new Area(new Rectangle2D.Double(textRect.x, textRect.y + textRect.height / 2 + 1, textRect.width, textRect.height));
                if (savedClip != null) {
                    clipArea.intersect(new Area(savedClip));
                }
                g2D.setClip(clipArea);
                g2D.setColor(ColorHelper.darker(titleColor, 20));
                JTattooUtilities.drawStringUnderlineCharAt(tabPane, g, title, mnemIndex, textRect.x, textRect.y + metrics.getAscent());
                g2D.setClip(savedClip);
            } else {
                g.setColor(tabPane.getForegroundAt(tabIndex));
                JTattooUtilities.drawStringUnderlineCharAt(tabPane, g, title, mnemIndex, textRect.x, textRect.y + metrics.getAscent());
            }
        } else {
            // tab disabled
            Graphics2D g2D = (Graphics2D) g;
            Composite savedComposite = g2D.getComposite();
            AlphaComposite alpha = AlphaComposite.getInstance(AlphaComposite.SRC_OVER, 0.6f);
            g2D.setComposite(alpha);
            g.setColor(Color.white);
            JTattooUtilities.drawStringUnderlineCharAt(tabPane, g, title, mnemIndex, textRect.x, textRect.y + metrics.getAscent() + 1);
            g2D.setComposite(savedComposite);
            g.setColor(AbstractLookAndFeel.getDisabledForegroundColor());
            JTattooUtilities.drawStringUnderlineCharAt(tabPane, g, title, mnemIndex, textRect.x, textRect.y + metrics.getAscent());
        }
    }
}
Also used : Shape(java.awt.Shape) Composite(java.awt.Composite) AlphaComposite(java.awt.AlphaComposite) AlphaComposite(java.awt.AlphaComposite) Color(java.awt.Color) Rectangle2D(java.awt.geom.Rectangle2D) RoundRectangle2D(java.awt.geom.RoundRectangle2D) View(javax.swing.text.View) ColorUIResource(javax.swing.plaf.ColorUIResource) UIResource(javax.swing.plaf.UIResource) Graphics2D(java.awt.Graphics2D) Area(java.awt.geom.Area)

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