Search in sources :

Example 96 with Graphics2D

use of java.awt.Graphics2D in project qrcode by yanbe.

the class J2SEDebugCanvas method drawMatrix.

public void drawMatrix(boolean[][] matrix) {
    if (image == null) {
        image = new BufferedImage(matrix.length, matrix[0].length, BufferedImage.TYPE_INT_ARGB);
        setSize(matrix.length, matrix[0].length);
    }
    Graphics2D g2d = image.createGraphics();
    g2d.setColor(java.awt.Color.WHITE);
    int width = getWidth();
    for (int x = 0; x < matrix.length; x++) {
        g2d.drawLine(x, 0, x, width);
    }
    g2d.setColor(java.awt.Color.BLACK);
    for (int x = 0; x < matrix.length; x++) {
        for (int y = 0; y < matrix[0].length; y++) {
            if (matrix[x][y] == true)
                g2d.drawLine(x, y, x, y);
        }
    }
    repaint();
}
Also used : BufferedImage(java.awt.image.BufferedImage) Point(jp.sourceforge.qrcode.geom.Point) Graphics2D(java.awt.Graphics2D)

Example 97 with Graphics2D

use of java.awt.Graphics2D in project qrcode by yanbe.

the class JMFCanvas method drawPoint.

public void drawPoint(Point point, int color) {
    Graphics2D g2d = image.createGraphics();
    g2d.setColor(new Color(color));
    g2d.drawLine(point.getX(), point.getY(), point.getX(), point.getY());
    repaint();
}
Also used : Color(java.awt.Color) Graphics2D(java.awt.Graphics2D)

Example 98 with Graphics2D

use of java.awt.Graphics2D in project qrcode by yanbe.

the class JMFCanvas method drawLines.

public void drawLines(Line[] lines, int color) {
    Graphics2D g2d = image.createGraphics();
    g2d.setColor(new Color(color));
    for (int i = 0; i < lines.length; i++) {
        g2d.drawLine(lines[i].getP1().getX(), lines[i].getP1().getY(), lines[i].getP2().getX(), lines[i].getP2().getY());
    }
    repaint();
}
Also used : Color(java.awt.Color) Point(jp.sourceforge.qrcode.geom.Point) Graphics2D(java.awt.Graphics2D)

Example 99 with Graphics2D

use of java.awt.Graphics2D in project qrcode by yanbe.

the class J2SEDebugCanvas method drawPoints.

public void drawPoints(Point[] points, int color) {
    Graphics2D g2d = image.createGraphics();
    g2d.setColor(new Color(color));
    for (int i = 0; i < points.length; i++) g2d.drawLine(points[i].getX(), points[i].getY(), points[i].getX(), points[i].getY());
    repaint();
}
Also used : Color(java.awt.Color) Point(jp.sourceforge.qrcode.geom.Point) Graphics2D(java.awt.Graphics2D)

Example 100 with Graphics2D

use of java.awt.Graphics2D in project qrcode by yanbe.

the class J2SEDebugCanvas method drawLine.

public void drawLine(Line line, int color) {
    Graphics2D g2d = image.createGraphics();
    g2d.setColor(new Color(color));
    g2d.drawLine(line.getP1().getX(), line.getP1().getY(), line.getP2().getX(), line.getP2().getY());
    repaint();
}
Also used : Color(java.awt.Color) Graphics2D(java.awt.Graphics2D)

Aggregations

Graphics2D (java.awt.Graphics2D)624 BufferedImage (java.awt.image.BufferedImage)338 Color (java.awt.Color)118 Font (java.awt.Font)58 Rectangle (java.awt.Rectangle)48 BasicStroke (java.awt.BasicStroke)46 AffineTransform (java.awt.geom.AffineTransform)44 Rectangle2D (java.awt.geom.Rectangle2D)41 Point (java.awt.Point)34 FontMetrics (java.awt.FontMetrics)32 Dimension (java.awt.Dimension)31 IOException (java.io.IOException)28 GradientPaint (java.awt.GradientPaint)27 Image (java.awt.Image)27 VolatileImage (java.awt.image.VolatileImage)26 TextLayout (java.awt.font.TextLayout)24 File (java.io.File)23 Graphics (java.awt.Graphics)22 GraphicsConfiguration (java.awt.GraphicsConfiguration)21 GcSnapshot (com.android.layoutlib.bridge.impl.GcSnapshot)20