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());
}
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);
}
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);
}
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());
}
}
}
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());
}
}
}
Aggregations