Search in sources :

Example 21 with GraphicsContext

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

the class DarkToggleButtonUI method paint.

@Override
public void paint(final Graphics g, final JComponent c) {
    if (ToggleButtonConstants.isSlider(c)) {
        GraphicsContext config = GraphicsUtil.setupStrokePainting(g);
        paintSlider((Graphics2D) g, (AbstractButton) c);
        config.restoreClip();
    }
    super.paint(g, c);
}
Also used : GraphicsContext(com.github.weisj.darklaf.util.graphics.GraphicsContext)

Example 22 with GraphicsContext

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

the class DarkTextBorder method paintBorder.

@Override
public void paintBorder(final Component c, final Graphics g2, final int x, final int y, final int width, final int height) {
    boolean editable = !(c instanceof JTextComponent) || ((JTextComponent) c).isEditable();
    boolean focus = DarkUIUtil.hasFocus(c);
    boolean error = hasError(c);
    boolean warning = !error && hasWarning(c);
    Graphics2D g = (Graphics2D) g2;
    g.translate(x, y);
    GraphicsContext config = GraphicsUtil.setupStrokePainting(g);
    int arcSize = getArcSize(c);
    int focusArcSize = getFocusArcSize(c);
    paintFocus(g, c, width, height, editable, error, warning, focusArcSize);
    g.setColor(getBorderColor(focus, error, warning, editable, c.isEnabled()));
    PaintUtil.paintLineBorder(g, borderSize, borderSize, width - 2 * borderSize, height - 2 * borderSize, arcSize);
    g.translate(-x, -y);
    config.restore();
}
Also used : GraphicsContext(com.github.weisj.darklaf.util.graphics.GraphicsContext) JTextComponent(javax.swing.text.JTextComponent)

Example 23 with GraphicsContext

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

the class DarkTextUI method paintSafely.

@Override
protected void paintSafely(final Graphics g) {
    GraphicsContext config = GraphicsUtil.setupAntialiasing(g);
    super.paintSafely(g);
    config.restoreClip();
    paintDefaultText(g);
    config.restore();
}
Also used : GraphicsContext(com.github.weisj.darklaf.util.graphics.GraphicsContext)

Example 24 with GraphicsContext

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

the class ColorTriangle method paint.

@Override
public void paint(final Graphics g) {
    GraphicsContext context = GraphicsUtil.setupStrokePainting(g);
    Graphics2D g2d = (Graphics2D) g;
    final Dimension dim = getSize();
    int size = Math.min(dim.width, dim.height);
    size = Math.min(size, 600);
    float x = (float) ((dim.width - size) / 2.0);
    float y = (float) ((dim.height - size) / 2.0);
    centerX = x + size / 2.0;
    centerY = y + size / 2.0;
    if (invalid || circleShape == null || triangleShape == null || outerIndicator == null) {
        createShapes(x, y, size);
    }
    g2d.setComposite(COMPOSITE.derive((float) opacity));
    g2d.setPaint(new InnerPaint());
    g2d.fill(triangleShape);
    g2d.setPaint(new OuterPaint());
    g2d.fill(circleShape);
    context.restoreComposite();
    drawIndicator(g2d, outerIndicator);
    drawIndicator(g2d, innerIndicator);
}
Also used : GraphicsContext(com.github.weisj.darklaf.util.graphics.GraphicsContext)

Example 25 with GraphicsContext

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

the class DarkPreviewPanel method paintText.

private int paintText(final Graphics g, final int offsetX) {
    GraphicsContext config = GraphicsUtil.setupAntialiasing(g);
    g.setFont(getFont());
    JComponent host = getColorChooser();
    if (host == null) {
        host = this;
    }
    FontMetrics fm = SwingUtil.getFontMetrics(host, g);
    int ascent = fm.getAscent();
    int height = fm.getHeight();
    int width = SwingUtil.stringWidth(host, fm, getSampleText());
    int textXOffset = offsetX + TEXT_GAP;
    Color color = getForeground();
    g.setColor(color);
    SwingUtil.drawString(host, g, getSampleText(), textXOffset + (TEXT_GAP / 2), ascent);
    g.fillRect(textXOffset, height + TEXT_GAP, width + TEXT_GAP, height + 2);
    g.setColor(Color.black);
    SwingUtil.drawString(host, g, getSampleText(), textXOffset + (TEXT_GAP / 2), height + ascent + TEXT_GAP + 2);
    g.setColor(Color.white);
    g.fillRect(textXOffset, (height + TEXT_GAP) * 2, width + TEXT_GAP, height + 2);
    g.setColor(color);
    SwingUtil.drawString(host, g, getSampleText(), textXOffset + (TEXT_GAP / 2), ((height + TEXT_GAP) * 2) + ascent + 2);
    config.restore();
    return width + TEXT_GAP * 3;
}
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