Search in sources :

Example 1 with GraphicsContext

use of com.github.weisj.darklaf.util.graphics.GraphicsContext in project darklaf by weisJ.

the class HoveringPanel method paintComponent.

@Override
protected void paintComponent(final Graphics g) {
    super.paintComponent(g);
    GraphicsContext context = new GraphicsContext(g);
    ((Graphics2D) g).setComposite(PaintUtil.getTransparentComposite());
    g.setColor(color != null ? color : getBackground());
    PaintUtil.fillRoundRect((Graphics2D) g, 0, 0, getWidth(), getHeight(), arc, false);
    context.restore();
}
Also used : GraphicsContext(com.github.weisj.darklaf.util.graphics.GraphicsContext)

Example 2 with GraphicsContext

use of com.github.weisj.darklaf.util.graphics.GraphicsContext in project darklaf by weisJ.

the class BubbleBorder method paintBorder.

public void paintBorder(final Graphics g, final Area strokeArea) {
    final Graphics2D g2 = (Graphics2D) g;
    GraphicsContext config = GraphicsUtil.setupStrokePainting(g);
    g2.setColor(color);
    g2.fill(strokeArea);
    config.restore();
}
Also used : GraphicsContext(com.github.weisj.darklaf.util.graphics.GraphicsContext)

Example 3 with GraphicsContext

use of com.github.weisj.darklaf.util.graphics.GraphicsContext in project darklaf by weisJ.

the class DarkButtonBorder method paintBorder.

@Override
public void paintBorder(final Component c, final Graphics g, final int x, final int y, final int width, final int height) {
    if (ButtonConstants.isBorderlessVariant(c)) {
        paintBorderlessBorder(c, g, x, y, width, height);
        return;
    }
    Graphics2D g2 = (Graphics2D) g;
    g2.translate(x, y);
    int arc = getArc(c);
    int focusArc = getFocusArc(c);
    GraphicsContext config = new GraphicsContext(g);
    AlignmentExt corner = getCornerFlag(c);
    boolean paintShadow = showDropShadow(corner);
    boolean focus = paintFocus(c);
    int shadowHeight = paintShadow ? getShadowSize() : 0;
    int borderSize = getBorderSize();
    Insets insetMask = new Insets(borderSize, borderSize, Math.max(borderSize, shadowHeight), borderSize);
    Insets focusIns = new Insets(0, 0, 0, 0);
    if (corner != null) {
        focusIns = corner.maskInsets(focusIns, -borderSize - focusArc);
        insetMask = corner.maskInsets(insetMask, -arc);
    }
    int bx = insetMask.left;
    int by = insetMask.top;
    int bw = width - insetMask.left - insetMask.right;
    int bh = height - insetMask.top - insetMask.bottom;
    int fx = focusIns.left;
    int fy = focusIns.top;
    int fw = width - focusIns.left - focusIns.right;
    int fh = by + bh + borderSize - focusIns.top - focusIns.bottom;
    if (paintFocus(c)) {
        paintFocusBorder(g2, focusArc, borderSize, fx, fy, fw, fh);
    }
    paintLineBorder(c, g2, arc, focus, bx, by, bw, bh);
    if (corner != null) {
        paintNeighbourFocus(g2, c, width, height);
    }
    config.restore();
}
Also used : GraphicsContext(com.github.weisj.darklaf.util.graphics.GraphicsContext) AlignmentExt(com.github.weisj.darklaf.util.AlignmentExt)

Example 4 with GraphicsContext

use of com.github.weisj.darklaf.util.graphics.GraphicsContext in project darklaf by weisJ.

the class DarkButtonUI method paint.

@Override
public void paint(final Graphics g, final JComponent c) {
    validateLayout();
    GraphicsContext config = new GraphicsContext(g);
    AbstractButton b = (AbstractButton) c;
    try (CleanupTask clean = prepareDelegate(b)) {
        paintButtonBackground(g, c);
        paintIcon(g, b, c);
        config.restoreClip();
        paintText(g, b, displayText);
    }
}
Also used : GraphicsContext(com.github.weisj.darklaf.util.graphics.GraphicsContext) CleanupTask(com.github.weisj.darklaf.util.value.CleanupTask)

Example 5 with GraphicsContext

use of com.github.weisj.darklaf.util.graphics.GraphicsContext in project darklaf by weisJ.

the class DarkTextFieldUI method paintSafely.

@Override
protected void paintSafely(final Graphics g) {
    GraphicsContext context = new GraphicsContext(g);
    super.paintSafely(g);
    context.restore();
    context.setupStrokePainting();
    paintIcons(g);
}
Also used : GraphicsContext(com.github.weisj.darklaf.util.graphics.GraphicsContext)

Aggregations

GraphicsContext (com.github.weisj.darklaf.util.graphics.GraphicsContext)35 Path2D (java.awt.geom.Path2D)2 RoundRectangle2D (java.awt.geom.RoundRectangle2D)2 MenuItemLayoutHelper (com.github.weisj.darklaf.compatibility.MenuItemLayoutHelper)1 DarkTableScrollPaneBorder (com.github.weisj.darklaf.ui.table.DarkTableScrollPaneBorder)1 AlignmentExt (com.github.weisj.darklaf.util.AlignmentExt)1 CleanupTask (com.github.weisj.darklaf.util.value.CleanupTask)1 Color (java.awt.Color)1 Rectangle (java.awt.Rectangle)1 AffineTransform (java.awt.geom.AffineTransform)1 Area (java.awt.geom.Area)1 Ellipse2D (java.awt.geom.Ellipse2D)1 Rectangle2D (java.awt.geom.Rectangle2D)1 BufferedImage (java.awt.image.BufferedImage)1 JMenuItem (javax.swing.JMenuItem)1 TableColumn (javax.swing.table.TableColumn)1 TableColumnModel (javax.swing.table.TableColumnModel)1 JTextComponent (javax.swing.text.JTextComponent)1 View (javax.swing.text.View)1