use of java.awt.Composite in project LoboEvolution by LoboEvolution.
the class BernsteinInternalFrameTitlePane method paintPalette.
/**
* {@inheritDoc}
*/
@Override
public void paintPalette(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.Composite in project LoboEvolution by LoboEvolution.
the class AluminiumUtils method fillComponent.
/**
* <p>fillComponent.</p>
*
* @param g a {@link java.awt.Graphics} object.
* @param c a {@link java.awt.Component} object.
*/
public static void fillComponent(Graphics g, Component c) {
Graphics2D g2D = (Graphics2D) g;
int w = c.getWidth();
int h = c.getHeight();
if (AbstractLookAndFeel.getTheme().isBackgroundPatternOn()) {
// pattern
Point p = JTattooUtilities.getRelLocation(c);
Dimension d = JTattooUtilities.getFrameSize(c);
int y = -p.y;
int iw = BG_IMAGE.getIconWidth();
int ih = BG_IMAGE.getIconHeight();
while (y < h) {
int x = -p.x;
while (x < w) {
BG_IMAGE.paintIcon(c, g, x, y);
x += iw;
}
y += ih;
}
// higlight
if (backgroundImage == null || backgroundImage.getWidth(null) != d.width || backgroundImage.getHeight(null) != d.height) {
backgroundImage = c.createImage(d.width, d.height);
Graphics2D ig2D = (Graphics2D) backgroundImage.getGraphics();
Point pt1 = new Point(0, 0);
Point pt2 = new Point(d.width, 0);
float[] fractions = { 0.0f, 0.5f, 1.0f };
Color c1 = new Color(220, 220, 220);
Color[] colors = { c1, Color.white, c1 };
ig2D.setPaint(new LinearGradientPaint(pt1, pt2, fractions, colors));
ig2D.fillRect(0, 0, d.width, d.height);
ig2D.dispose();
}
Composite savedComposite = g2D.getComposite();
g2D.setComposite(AlphaComposite.getInstance(AlphaComposite.SRC_OVER, 0.7f));
g2D.drawImage(backgroundImage, -p.x, 0, null);
g2D.setComposite(savedComposite);
} else {
g.setColor(c.getBackground());
g.fillRect(0, 0, w, h);
}
}
use of java.awt.Composite in project LoboEvolution by LoboEvolution.
the class BaseButtonUI method paint.
/**
* {@inheritDoc}
*/
@Override
public void paint(final Graphics g, final JComponent c) {
Graphics2D g2D = (Graphics2D) g;
AbstractButton b = (AbstractButton) c;
Font f = c.getFont();
g.setFont(f);
FontMetrics fm = JTattooUtilities.getFontMetrics(b, g, b.getFont());
Insets insets = c.getInsets();
viewRect.x = insets.left;
viewRect.y = insets.top;
viewRect.width = b.getWidth() - (insets.right + viewRect.x);
viewRect.height = b.getHeight() - (insets.bottom + viewRect.y);
textRect.x = textRect.y = textRect.width = textRect.height = 0;
iconRect.x = iconRect.y = iconRect.width = iconRect.height = 0;
int iconTextGap = b.getIconTextGap();
String text = SwingUtilities.layoutCompoundLabel(c, fm, b.getText(), b.getIcon(), b.getVerticalAlignment(), b.getHorizontalAlignment(), b.getVerticalTextPosition(), b.getHorizontalTextPosition(), viewRect, iconRect, textRect, b.getText() == null ? 0 : iconTextGap);
paintBackground(g, b);
if (b.getIcon() != null) {
if (!b.isEnabled()) {
Composite savedComposite = g2D.getComposite();
AlphaComposite alpha = AlphaComposite.getInstance(AlphaComposite.SRC_OVER, 0.5f);
g2D.setComposite(alpha);
paintIcon(g, c, iconRect);
g2D.setComposite(savedComposite);
} else {
if (b.getModel().isPressed() && b.getModel().isRollover()) {
iconRect.x++;
iconRect.y++;
}
paintIcon(g, c, iconRect);
}
}
if (text != null && !text.equals("")) {
View v = (View) c.getClientProperty(BasicHTML.propertyKey);
if (v != null) {
Object savedRenderingHint = null;
if (AbstractLookAndFeel.getTheme().isTextAntiAliasingOn()) {
savedRenderingHint = g2D.getRenderingHint(RenderingHints.KEY_TEXT_ANTIALIASING);
g2D.setRenderingHint(RenderingHints.KEY_TEXT_ANTIALIASING, RenderingHints.VALUE_TEXT_ANTIALIAS_ON);
}
v.paint(g, textRect);
if (AbstractLookAndFeel.getTheme().isTextAntiAliasingOn()) {
g2D.setRenderingHint(RenderingHints.KEY_TEXT_ANTIALIASING, savedRenderingHint);
}
} else {
paintText(g, b, textRect, text);
}
}
if (b.isFocusPainted() && b.hasFocus()) {
paintFocus(g, b, viewRect, textRect, iconRect);
}
}
use of java.awt.Composite 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());
}
}
use of java.awt.Composite 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);
}
Aggregations