Search in sources :

Example 36 with GraphicsConfig

use of com.intellij.openapi.ui.GraphicsConfig in project intellij-community by JetBrains.

the class TwoColorsIcon method paintIcon.

@Override
public void paintIcon(final Component component, Graphics g, int x, int y) {
    Graphics2D g2d = (Graphics2D) g.create();
    final GraphicsConfig config = GraphicsUtil.setupAAPainting(g2d);
    try {
        final int w = getIconWidth();
        final int h = getIconHeight();
        g2d.setPaint(getPaint(getIconColor()));
        g2d.fillPolygon(new int[] { x, x + w, x }, new int[] { y, y, y + h }, 3);
        g2d.setPaint(getPaint(mySecondColor));
        g2d.fillPolygon(new int[] { x + w, x + w, x }, new int[] { y, y + h, y + h }, 3);
    } catch (Exception e) {
        g2d.dispose();
    } finally {
        config.restore();
    }
}
Also used : GraphicsConfig(com.intellij.openapi.ui.GraphicsConfig)

Example 37 with GraphicsConfig

use of com.intellij.openapi.ui.GraphicsConfig in project intellij-community by JetBrains.

the class UIUtil method drawSearchMatch.

public static void drawSearchMatch(Graphics2D g, float startXf, float endXf, int height, Color c1, Color c2) {
    final boolean drawRound = endXf - startXf > 4;
    GraphicsConfig config = new GraphicsConfig(g);
    g.setComposite(AlphaComposite.getInstance(AlphaComposite.SRC_OVER, 0.7f));
    g.setPaint(getGradientPaint(startXf, 2, c1, startXf, height - 5, c2));
    if (isJreHiDPI(g)) {
        GraphicsConfig c = GraphicsUtil.setupRoundedBorderAntialiasing(g);
        g.fill(new RoundRectangle2D.Float(startXf, 2, endXf - startXf, height - 4, 5, 5));
        c.restore();
        config.restore();
        return;
    }
    int startX = (int) startXf;
    int endX = (int) endXf;
    g.fillRect(startX, 3, endX - startX, height - 5);
    if (drawRound) {
        g.drawLine(startX - 1, 4, startX - 1, height - 4);
        g.drawLine(endX, 4, endX, height - 4);
        g.setColor(new Color(100, 100, 100, 50));
        g.drawLine(startX - 1, 4, startX - 1, height - 4);
        g.drawLine(endX, 4, endX, height - 4);
        g.drawLine(startX, 3, endX - 1, 3);
        g.drawLine(startX, height - 3, endX - 1, height - 3);
    }
    config.restore();
}
Also used : RoundRectangle2D(java.awt.geom.RoundRectangle2D) GraphicsConfig(com.intellij.openapi.ui.GraphicsConfig)

Example 38 with GraphicsConfig

use of com.intellij.openapi.ui.GraphicsConfig in project intellij-community by JetBrains.

the class LabelIcon method paintIcon.

private void paintIcon(@NotNull Graphics2D g2) {
    GraphicsConfig config = GraphicsUtil.setupAAPainting(g2);
    float scale = mySize / 8.0f;
    for (int i = myColors.length - 1; i >= 0; i--) {
        if (i != myColors.length - 1) {
            g2.setColor(myBgColor);
            paintTag(g2, scale, scale * 2 * i + 1, 0);
        }
        g2.setColor(myColors[i]);
        paintTag(g2, scale, scale * 2 * i, 0);
    }
    config.restore();
}
Also used : GraphicsConfig(com.intellij.openapi.ui.GraphicsConfig)

Aggregations

GraphicsConfig (com.intellij.openapi.ui.GraphicsConfig)38 JBColor (com.intellij.ui.JBColor)10 Border (javax.swing.border.Border)5 RoundRectangle2D (java.awt.geom.RoundRectangle2D)4 JBGradientPaint (com.intellij.ui.JBGradientPaint)2 Path2D (java.awt.geom.Path2D)2 Rectangle2D (java.awt.geom.Rectangle2D)2 BasicArrowButton (javax.swing.plaf.basic.BasicArrowButton)2 JTextComponent (javax.swing.text.JTextComponent)2 SettingsDialog (com.intellij.openapi.options.newEditor.SettingsDialog)1 DialogWrapper (com.intellij.openapi.ui.DialogWrapper)1 JBInsets (com.intellij.util.ui.JBInsets)1 ActionEvent (java.awt.event.ActionEvent)1 ActionListener (java.awt.event.ActionListener)1 Area (java.awt.geom.Area)1 CompoundBorder (javax.swing.border.CompoundBorder)1 EmptyBorder (javax.swing.border.EmptyBorder)1 DimensionUIResource (javax.swing.plaf.DimensionUIResource)1 UIResource (javax.swing.plaf.UIResource)1 BasicTreeUI (javax.swing.plaf.basic.BasicTreeUI)1