Search in sources :

Example 86 with Graphics2D

use of java.awt.Graphics2D in project screenbird by adamhub.

the class ResizeHandle method paint.

@Override
public void paint(Graphics g) {
    super.paint(g);
    Graphics2D g2d = (Graphics2D) this.getGraphics();
    g2d.setRenderingHint(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON);
    g2d.setColor(Color.white);
    g2d.fillOval(0, 0, this.getWidth() - 1, this.getHeight() - 1);
    g2d.setColor(STROKE_COLOR);
    g2d.drawOval(0, 0, this.getWidth() - 1, this.getHeight() - 1);
}
Also used : Graphics2D(java.awt.Graphics2D)

Example 87 with Graphics2D

use of java.awt.Graphics2D in project screenbird by adamhub.

the class JRoundBorderSB method paintBorder.

@Override
public void paintBorder(Component c, Graphics g, int x, int y, int width, int height) {
    Graphics2D g2 = (Graphics2D) g.create();
    g2.setRenderingHint(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON);
    int r = height - 1;
    RoundRectangle2D round = new RoundRectangle2D.Float(x, y, width - 1, height - 1, r, r);
    Container parent = c.getParent();
    if (parent != null) {
        g2.setColor(parent.getBackground());
        Area corner = new Area(new Rectangle2D.Float(x, y, width, height));
        corner.subtract(new Area(round));
        g2.fill(corner);
    }
    g2.setColor(Color.lightGray);
    g2.draw(round);
    g2.dispose();
}
Also used : Container(java.awt.Container) Area(java.awt.geom.Area) RoundRectangle2D(java.awt.geom.RoundRectangle2D) Rectangle2D(java.awt.geom.Rectangle2D) RoundRectangle2D(java.awt.geom.RoundRectangle2D) Graphics2D(java.awt.Graphics2D)

Example 88 with Graphics2D

use of java.awt.Graphics2D in project screenbird by adamhub.

the class JRoundedPanel method paintComponent.

//    public JRoundedPanel(CardLayout cardLayout) {
//        super(cardLayout);
//        setOpaque(false);
//        Color backgrnd = new Color(Color.darkGray.getRed(),Color.darkGray.getGreen(), Color.darkGray.getBlue(),180);
//        this.setBackground(backgrnd);
//    }
@Override
protected void paintComponent(Graphics g) {
    super.paintComponent(g);
    int width = getWidth();
    int height = getHeight();
    int shadowGap = this.shadowGap;
    Color shadowColorA = new Color(shadowColor.getRed(), shadowColor.getGreen(), shadowColor.getBlue(), shadowAlpha);
    Graphics2D graphics = (Graphics2D) g;
    //Sets antialiasing if HQ.
    if (highQuality) {
        graphics.setRenderingHint(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON);
    }
    //Draws shadow borders if any.
    if (shady) {
        graphics.setColor(shadowColorA);
        graphics.fillRoundRect(// X position
        shadowOffset, // Y position
        shadowOffset, // width
        width - strokeSize - shadowOffset, // height
        height - strokeSize - shadowOffset, arcs.width, // arc Dimension
        arcs.height);
    } else {
        shadowGap = 1;
    }
    //Draws the rounded opaque panel with borders.
    graphics.setColor(getBackground());
    graphics.fillRoundRect(0, 0, width - shadowGap, height - shadowGap, arcs.width, arcs.height);
    graphics.setColor(getForeground());
    //graphics.setStroke(new BasicStroke(strokeSize));
    //graphics.drawRoundRect(0, 0, width - shadowGap, height - shadowGap, arcs.width, arcs.height);
    //Sets strokes to default, is better.
    graphics.setStroke(new BasicStroke());
}
Also used : BasicStroke(java.awt.BasicStroke) Color(java.awt.Color) Graphics2D(java.awt.Graphics2D)

Example 89 with Graphics2D

use of java.awt.Graphics2D in project LuaViewSDK by alibaba.

the class EclipseTabbedPaneUI method paintText.

/**
	 * Selected labels have a white color.
	 */
@Override
protected void paintText(Graphics tempG, int tabPlacement, Font font, FontMetrics metrics, int tabIndex, String title, Rectangle textRect, boolean isSelected) {
    Graphics2D g = (Graphics2D) tempG;
    g.setRenderingHint(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON);
    if (isSelected && tabPlacement == TOP) {
        g.setColor(Color.BLACK);
    } else {
        g.setColor(Color.BLACK);
    }
    g.drawString(title, textRect.x, textRect.y + metrics.getAscent());
}
Also used : Graphics2D(java.awt.Graphics2D)

Example 90 with Graphics2D

use of java.awt.Graphics2D in project LuaViewSDK by alibaba.

the class SrcCodeScrollPanel method paint.

public void paint(Graphics tempG) {
    if (tempG instanceof Graphics2D == false) {
        return;
    }
    Graphics2D g = (Graphics2D) tempG;
    g.setRenderingHint(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON);
    g.setFont(font);
    if (nextY >= 0) {
        zeroPoint.y = nextY;
        nextY = -1;
    }
    screenW = getWidth();
    screenH = getHeight();
    max_w = max_w < screenW ? screenW : max_w;
    max_h = max_h < screenH ? screenH : max_h;
    if (zeroPoint.x < 0) {
        zeroPoint.x = 0;
    } else if (zeroPoint.x > max_w - screenW) {
        zeroPoint.x = max_w - screenW;
    }
    if (zeroPoint.y < 0) {
        zeroPoint.y = 0;
    } else if (zeroPoint.y > max_h - screenH) {
        zeroPoint.y = max_h - screenH;
    }
    g.setColor(Color.white);
    g.fillRect(0, 0, screenW, screenH);
    // 显示位置
    g.setClip(0, 0, screenW - bar_w, screenH);
    g.translate(-zeroPoint.x, -zeroPoint.y);
    // //////////////////////
    myPaint(g);
    g.translate(zeroPoint.x, zeroPoint.y);
    // bar
    int bar_X = screenW - bar_w;
    int bar_Y = zeroPoint.y * screenH / max_h;
    int bar_W = bar_w;
    int bar_H = screenH * screenH / max_h;
    if (bar_H > screenH - 1) {
        bar_H = screenH - 1;
    }
    g.setClip(0, 0, screenW, screenH);
    g.setColor(new Color(250, 250, 250));
    g.fillRect(screenW - bar_w, -1, bar_w + 1, screenH + 2);
    g.setColor(new Color(232, 232, 232));
    g.drawRect(screenW - bar_w, -1, bar_w + 8, screenH + 2);
    fillBar(g, bar_X, bar_Y, bar_W, bar_H);
    if (m_repaint) {
        m_repaint = false;
        if (updateUI)
            updateUI();
    }
}
Also used : Color(java.awt.Color) Point(java.awt.Point) Graphics2D(java.awt.Graphics2D)

Aggregations

Graphics2D (java.awt.Graphics2D)777 BufferedImage (java.awt.image.BufferedImage)379 Color (java.awt.Color)180 Font (java.awt.Font)77 BasicStroke (java.awt.BasicStroke)75 Rectangle (java.awt.Rectangle)65 Point (java.awt.Point)63 Rectangle2D (java.awt.geom.Rectangle2D)59 AffineTransform (java.awt.geom.AffineTransform)55 GradientPaint (java.awt.GradientPaint)48 Dimension (java.awt.Dimension)46 Paint (java.awt.Paint)44 FontMetrics (java.awt.FontMetrics)35 IOException (java.io.IOException)33 Graphics (java.awt.Graphics)31 Stroke (java.awt.Stroke)30 Image (java.awt.Image)29 RadialGradientPaint (java.awt.RadialGradientPaint)26 VolatileImage (java.awt.image.VolatileImage)26 File (java.io.File)26