Search in sources :

Example 11 with GraphicsContext

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

the class DarkSliderUI method paintLabels.

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

Example 12 with GraphicsContext

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

the class DarkSliderUI method paintThumb.

@Override
public void paintThumb(final Graphics g2) {
    Graphics2D g = (Graphics2D) g2;
    GraphicsContext context = GraphicsUtil.setupStrokePainting(g);
    if (isPlainThumb()) {
        paintPlainSliderThumb(g);
    } else {
        paintSliderThumb(g);
    }
    context.restore();
}
Also used : GraphicsContext(com.github.weisj.darklaf.util.graphics.GraphicsContext)

Example 13 with GraphicsContext

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

the class DarkNumberingPaneUI method drawNumbering.

protected void drawNumbering(final Graphics g, final int startLine, final int endLine, final int yCur, final Element root, final int descent) {
    GraphicsContext config = GraphicsUtil.setupAntialiasing(g);
    g.setColor(numberingPane.getForeground());
    Font font = getNumberingFont(numberingPane.getTextComponent(), g, numberingPane.getFont());
    g.setFont(font);
    FontMetrics fm = numberingPane.getFontMetrics(font);
    int width = numberingPane.getWidth();
    for (int i = startLine; i <= endLine; i++) {
        int off = root.getElement(i).getStartOffset();
        try {
            String numberStr = String.valueOf(i);
            Rectangle lineRect = textComponent.modelToView(off);
            g.setColor(lineRect.y == yCur ? foregroundHighlight : numberingPane.getForeground());
            g.drawString(numberStr, width - OUTER_PAD - fm.stringWidth(numberStr) - maxIconWidth, lineRect.y + lineRect.height - descent);
        } catch (final BadLocationException e) {
            LOGGER.log(Level.SEVERE, "Painting numbering failed", e);
        }
    }
    config.restore();
}
Also used : GraphicsContext(com.github.weisj.darklaf.util.graphics.GraphicsContext)

Example 14 with GraphicsContext

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

the class DarkLabelUI method paint.

@Override
public void paint(final Graphics g, final JComponent c) {
    GraphicsContext config = new GraphicsContext(g);
    JLabel label = (JLabel) c;
    String text = label.getText();
    Icon icon = getIcon(label);
    paintBackground(g, c);
    if ((icon == null) && (text == null)) {
        return;
    }
    FontMetrics fm = SwingUtil.getFontMetrics(label, g);
    String clippedText = layout(label, fm, c.getWidth(), c.getHeight());
    if (icon != null) {
        icon.paintIcon(c, g, paintIconR.x, paintIconR.y);
        config.restoreClip();
    }
    paintText(g, label, fm, clippedText);
}
Also used : GraphicsContext(com.github.weisj.darklaf.util.graphics.GraphicsContext)

Example 15 with GraphicsContext

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

the class DarkHighlightPainter method paint.

/**
 * Paints a highlight.
 *
 * @param g the graphics context
 * @param offs0 the starting model offset &gt;= 0
 * @param offs1 the ending model offset &gt;= offs1
 * @param bounds the bounding box for the highlight
 * @param c the editor
 */
@Override
public void paint(final Graphics g, final int offs0, final int offs1, final Shape bounds, final JTextComponent c) {
    if (!enabled)
        return;
    Graphics2D g2d = (Graphics2D) g;
    GraphicsContext context = new GraphicsContext(g2d);
    color = c.getSelectedTextColor();
    wrapper.setColor(color);
    wrapper.setCustomForeground(!Objects.equals(color, c.getForeground()));
    if (getAlpha() < 1.0f) {
        g2d.setComposite(getAlphaComposite());
    }
    super.paint(g, offs0, offs1, bounds, c);
    context.restore();
}
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