use of com.intellij.openapi.ui.GraphicsConfig in project intellij-community by JetBrains.
the class SidePanelSeparator method paintComponent.
@Override
protected void paintComponent(Graphics g) {
final JBColor separatorColor = new JBColor(GroupedElementsRenderer.POPUP_SEPARATOR_FOREGROUND, Gray._80);
g.setColor(separatorColor);
if ("--".equals(getCaption())) {
final GraphicsConfig config = GraphicsUtil.setupAAPainting(g);
final int h = getHeight() / 2;
g.drawLine(30, h, getWidth() - 30, h);
((Graphics2D) g).setPaint(new GradientPaint(5, h, ColorUtil.toAlpha(separatorColor, 0), 30, h, separatorColor));
g.drawLine(5, h, 30, h);
((Graphics2D) g).setPaint(new GradientPaint(getWidth() - 5, h, ColorUtil.toAlpha(separatorColor, 0), getWidth() - 30, h, separatorColor));
g.drawLine(getWidth() - 5, h, getWidth() - 30, h);
config.restore();
return;
}
Rectangle viewR = new Rectangle(0, getVgap(), getWidth() - 1, getHeight() - getVgap() - 1);
Rectangle iconR = new Rectangle();
Rectangle textR = new Rectangle();
String s = SwingUtilities.layoutCompoundLabel(g.getFontMetrics(), getCaption(), null, CENTER, LEFT, CENTER, LEFT, viewR, iconR, textR, 0);
GraphicsUtil.setupAAPainting(g);
g.setColor(new JBColor(Gray._255.withAlpha(80), Gray._0.withAlpha(80)));
g.drawString(s, textR.x + 10, textR.y + 1 + g.getFontMetrics().getAscent());
g.setColor(new JBColor(new Color(0x5F6D7B), Gray._120));
g.drawString(s, textR.x + 10, textR.y + g.getFontMetrics().getAscent());
}
use of com.intellij.openapi.ui.GraphicsConfig in project intellij-community by JetBrains.
the class LabelPainter method paint.
public void paint(@NotNull Graphics2D g2, int x, int y, int height) {
if (myLabels.isEmpty())
return;
GraphicsConfig config = GraphicsUtil.setupAAPainting(g2);
g2.setFont(getReferenceFont());
g2.setStroke(new BasicStroke(1.5f));
FontMetrics fontMetrics = g2.getFontMetrics();
int baseLine = SimpleColoredComponent.getTextBaseLine(fontMetrics, height);
g2.setColor(myBackground);
g2.fillRect(x, y, myWidth, height);
if (myGreyBackground != null && myCompact) {
g2.setColor(myGreyBackground);
g2.fillRect(x, y + baseLine - fontMetrics.getAscent() - TOP_TEXT_PADDING, myWidth, fontMetrics.getHeight() + TOP_TEXT_PADDING + BOTTOM_TEXT_PADDING);
}
x += LEFT_PADDING;
for (Pair<String, LabelIcon> label : myLabels) {
LabelIcon icon = label.second;
String text = label.first;
if (myGreyBackground != null && !myCompact) {
g2.setColor(myGreyBackground);
g2.fill(new RoundRectangle2D.Double(x - LEFT_PADDING, y + baseLine - fontMetrics.getAscent() - TOP_TEXT_PADDING, icon.getIconWidth() + fontMetrics.stringWidth(text) + 3 * LEFT_PADDING, fontMetrics.getHeight() + TOP_TEXT_PADDING + BOTTOM_TEXT_PADDING, LABEL_ARC, LABEL_ARC));
}
icon.paintIcon(null, g2, x, y + (height - icon.getIconHeight()) / 2);
x += icon.getIconWidth();
g2.setColor(myForeground);
g2.drawString(text, x, y + baseLine);
x += fontMetrics.stringWidth(text) + (myCompact ? COMPACT_MIDDLE_PADDING : MIDDLE_PADDING);
}
config.restore();
}
use of com.intellij.openapi.ui.GraphicsConfig in project intellij-community by JetBrains.
the class DarculaPasswordFieldUI method paintBackground.
@Override
protected void paintBackground(Graphics graphics) {
Graphics2D g = (Graphics2D) graphics;
final JTextComponent c = getComponent();
final Container parent = c.getParent();
if (c.isOpaque() && parent != null) {
g.setColor(parent.getBackground());
g.fillRect(0, 0, c.getWidth(), c.getHeight());
}
final Border border = c.getBorder();
if (border instanceof DarculaTextBorder) {
if (c.isEnabled() && c.isEditable()) {
g.setColor(c.getBackground());
}
final int width = c.getWidth();
final int height = c.getHeight();
final Insets i = border.getBorderInsets(c);
if (c.hasFocus()) {
final GraphicsConfig config = new GraphicsConfig(g);
g.setRenderingHint(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON);
g.setRenderingHint(RenderingHints.KEY_STROKE_CONTROL, RenderingHints.VALUE_STROKE_NORMALIZE);
g.fillRoundRect(i.left - JBUI.scale(5), i.top - JBUI.scale(2), width - i.left - i.right + JBUI.scale(10), height - i.top - i.bottom + JBUI.scale(6), JBUI.scale(5), JBUI.scale(5));
config.restore();
} else {
g.fillRect(i.left - JBUI.scale(5), i.top - JBUI.scale(2), width - i.left - i.right + JBUI.scale(12), height - i.top - i.bottom + JBUI.scale(6));
}
} else {
super.paintBackground(g);
}
}
use of com.intellij.openapi.ui.GraphicsConfig in project intellij-community by JetBrains.
the class DarculaProgressBarUI method paintDeterminate.
@Override
protected void paintDeterminate(Graphics g, JComponent c) {
if (!(g instanceof Graphics2D)) {
return;
}
if (progressBar.getOrientation() != SwingConstants.HORIZONTAL || !c.getComponentOrientation().isLeftToRight()) {
super.paintDeterminate(g, c);
return;
}
final GraphicsConfig config = GraphicsUtil.setupAAPainting(g);
// area for border
Insets b = progressBar.getInsets();
int w = progressBar.getWidth();
int h = progressBar.getPreferredSize().height;
if (!isEven(c.getHeight() - h))
h++;
int barRectWidth = w - (b.right + b.left);
int barRectHeight = h - (b.top + b.bottom);
if (barRectWidth <= 0 || barRectHeight <= 0) {
return;
}
int amountFull = getAmountFull(b, barRectWidth, barRectHeight);
g.setColor(c.getParent().getBackground());
Graphics2D g2 = (Graphics2D) g;
if (c.isOpaque()) {
g.fillRect(0, 0, w, h);
}
final float R = JBUI.scale(8f);
final float R2 = JBUI.scale(9f);
final float off = JBUI.scale(1f);
g2.translate(0, (c.getHeight() - h) / 2);
g2.setColor(progressBar.getForeground());
g2.fill(new RoundRectangle2D.Float(0, 0, w - off, h - off, R2, R2));
g2.setColor(c.getParent().getBackground());
g2.fill(new RoundRectangle2D.Float(off, off, w - 2f * off - off, h - 2f * off - off, R, R));
g2.setColor(progressBar.getForeground());
g2.fill(new RoundRectangle2D.Float(2f * off, 2f * off, amountFull - JBUI.scale(5f), h - JBUI.scale(5f), JBUI.scale(7f), JBUI.scale(7f)));
g2.translate(0, -(c.getHeight() - h) / 2);
// Deal with possible text painting
if (progressBar.isStringPainted()) {
paintString(g, b.left, b.top, barRectWidth, barRectHeight, amountFull, b);
}
config.restore();
}
use of com.intellij.openapi.ui.GraphicsConfig in project intellij-community by JetBrains.
the class DarculaProgressBarUI method paintIndeterminate.
@Override
protected void paintIndeterminate(Graphics g2d, JComponent c) {
if (!(g2d instanceof Graphics2D)) {
return;
}
Graphics2D g = (Graphics2D) g2d;
// area for border
Insets b = progressBar.getInsets();
int barRectWidth = progressBar.getWidth() - (b.right + b.left);
int barRectHeight = progressBar.getHeight() - (b.top + b.bottom);
if (barRectWidth <= 0 || barRectHeight <= 0) {
return;
}
//boxRect = getBox(boxRect);
g.setColor(new JBColor(Gray._240, Gray._128));
int w = c.getWidth();
int h = c.getPreferredSize().height;
if (!isEven(c.getHeight() - h))
h++;
if (c.isOpaque()) {
g.fillRect(0, (c.getHeight() - h) / 2, w, h);
}
g.setColor(new JBColor(Gray._165, Gray._88));
final GraphicsConfig config = GraphicsUtil.setupAAPainting(g);
g.translate(0, (c.getHeight() - h) / 2);
int x = -offset;
final float R = JBUI.scale(8f);
final float R2 = JBUI.scale(9f);
final float off = JBUI.scale(1f);
final Area innerBorderRoundRect = new Area(new RoundRectangle2D.Float(off, off, w - 2f * off, h - 2f * off, R, R));
final Area containingRoundRect = new Area(new RoundRectangle2D.Float(2f * off, 2f * off, w - 4f * off, h - 4f * off, R, R));
while (x < Math.max(c.getWidth(), c.getHeight())) {
Path2D.Double path = new Path2D.Double();
float ww = getPeriodLength() / 2f;
path.moveTo(x, 0);
path.lineTo(x + ww, 0);
path.lineTo(x + ww - h / 2, h);
path.lineTo(x - h / 2, h);
path.lineTo(x, 0);
path.closePath();
final Area area = new Area(path);
area.intersect(containingRoundRect);
g.fill(area);
x += getPeriodLength();
}
offset = (offset + 1) % getPeriodLength();
Area area = new Area(new Rectangle2D.Float(0, 0, w, h));
area.subtract(innerBorderRoundRect);
g.setColor(Gray._128);
if (c.isOpaque()) {
g.fill(area);
}
area.subtract(new Area(new RoundRectangle2D.Float(0, 0, w, h, R2, R2)));
g.setColor(c.getParent().getBackground());
if (c.isOpaque()) {
g.fill(area);
}
Area insetArea = new Area(innerBorderRoundRect);
insetArea.subtract(containingRoundRect);
g.fill(insetArea);
g.translate(0, -(c.getHeight() - h) / 2);
// Deal with possible text painting
if (progressBar.isStringPainted()) {
if (progressBar.getOrientation() == SwingConstants.HORIZONTAL) {
paintString(g, b.left, b.top, barRectWidth, barRectHeight, boxRect.x, boxRect.width);
} else {
paintString(g, b.left, b.top, barRectWidth, barRectHeight, boxRect.y, boxRect.height);
}
}
config.restore();
}
Aggregations