Search in sources :

Example 1 with Point

use of jp.sourceforge.qrcode.geom.Point in project qrcode by yanbe.

the class QRCodeDecoder method getAdjustPoints.

Point[] getAdjustPoints() {
    // note that adjusts affect dependently
    // i.e. below means (0,0), (2,3), (3,4), (1,2), (2,1), (1,1), (-1,-1)
    //		Point[] adjusts = {new Point(0,0), new Point(2,3), new Point(1,1), 
    //				new Point(-2,-2), new Point(1,-1), new Point(-1,0), new Point(-2,-2)};
    Vector adjustPoints = new Vector();
    for (int d = 0; d < 4; d++) adjustPoints.addElement(new Point(1, 1));
    int lastX = 0, lastY = 0;
    for (int y = 0; y > -4; y--) {
        for (int x = 0; x > -4; x--) {
            if (x != y && ((x + y) % 2 == 0)) {
                adjustPoints.addElement(new Point(x - lastX, y - lastY));
                lastX = x;
                lastY = y;
            }
        }
    }
    Point[] adjusts = new Point[adjustPoints.size()];
    for (int i = 0; i < adjusts.length; i++) adjusts[i] = (Point) adjustPoints.elementAt(i);
    return adjusts;
}
Also used : Point(jp.sourceforge.qrcode.geom.Point) Vector(java.util.Vector) Point(jp.sourceforge.qrcode.geom.Point)

Example 2 with Point

use of jp.sourceforge.qrcode.geom.Point 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 3 with Point

use of jp.sourceforge.qrcode.geom.Point in project qrcode by yanbe.

the class J2SEDebugCanvas method drawPolygon.

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

Example 4 with Point

use of jp.sourceforge.qrcode.geom.Point in project qrcode by yanbe.

the class J2MEImage method drawPoints.

public void drawPoints(Point[] points, int color) {
    Image bufImage = Image.createImage(image.getWidth(), image.getHeight());
    Graphics g = bufImage.getGraphics();
    g.drawImage(image, 0, 0, 0);
    g.setColor(color);
    for (int i = 0; i < points.length - 1; i++) {
        g.drawLine(points[i].getX(), points[i].getY(), points[i].getX() + 1, points[i].getY());
    }
    image = bufImage;
    repaint();
}
Also used : Graphics(javax.microedition.lcdui.Graphics) QRCodeImage(jp.sourceforge.qrcode.data.QRCodeImage) Image(javax.microedition.lcdui.Image) Point(jp.sourceforge.qrcode.geom.Point)

Example 5 with Point

use of jp.sourceforge.qrcode.geom.Point in project qrcode by yanbe.

the class J2MEImage method drawPolygon.

public void drawPolygon(Point[] points, int color) {
    Image bufImage = Image.createImage(image.getWidth(), image.getHeight());
    Graphics g = bufImage.getGraphics();
    g.drawImage(image, 0, 0, 0);
    g.setColor(color);
    int i = 0;
    for (; i < points.length - 1; i++) {
        g.drawLine(points[i].getX(), points[i].getY(), points[i + 1].getX(), points[i + 1].getY());
    }
    g.drawLine(points[i].getX(), points[i].getY(), points[0].getX(), points[0].getY());
    image = bufImage;
    repaint();
}
Also used : Graphics(javax.microedition.lcdui.Graphics) QRCodeImage(jp.sourceforge.qrcode.data.QRCodeImage) Image(javax.microedition.lcdui.Image) Point(jp.sourceforge.qrcode.geom.Point)

Aggregations

Point (jp.sourceforge.qrcode.geom.Point)10 Color (java.awt.Color)4 Graphics2D (java.awt.Graphics2D)4 Vector (java.util.Vector)2 Graphics (javax.microedition.lcdui.Graphics)2 Image (javax.microedition.lcdui.Image)2 QRCodeImage (jp.sourceforge.qrcode.data.QRCodeImage)2 Line (jp.sourceforge.qrcode.geom.Line)2 DecodingFailedException (jp.sourceforge.qrcode.exception.DecodingFailedException)1