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);
}
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();
}
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();
}
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);
}
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;
}
Aggregations