?? datamatrix.java
字號(hào):
package com.idautomation.barcode.datamatrix;
import java.awt.*;
import java.awt.image.MemoryImageSource;
import java.awt.image.PixelGrabber;
import java.io.PrintStream;
import java.io.Serializable;
import java.util.Calendar;
public class DataMatrix extends Canvas
implements Serializable
{
private class charPlacer
{
public int nrow;
public int ncol;
public int array[];
private void utah(int i, int j, int k)
{
module(i - 2, j - 2, k, 1);
module(i - 2, j - 1, k, 2);
module(i - 1, j - 2, k, 3);
module(i - 1, j - 1, k, 4);
module(i - 1, j, k, 5);
module(i, j - 2, k, 6);
module(i, j - 1, k, 7);
module(i, j, k, 8);
}
private void corner1(int i)
{
module(nrow - 1, 0, i, 1);
module(nrow - 1, 1, i, 2);
module(nrow - 1, 2, i, 3);
module(0, ncol - 2, i, 4);
module(0, ncol - 1, i, 5);
module(1, ncol - 1, i, 6);
module(2, ncol - 1, i, 7);
module(3, ncol - 1, i, 8);
}
private void corner2(int i)
{
module(nrow - 3, 0, i, 1);
module(nrow - 2, 0, i, 2);
module(nrow - 1, 0, i, 3);
module(0, ncol - 4, i, 4);
module(0, ncol - 3, i, 5);
module(0, ncol - 2, i, 6);
module(0, ncol - 1, i, 7);
module(1, ncol - 1, i, 8);
}
private void corner3(int i)
{
module(nrow - 3, 0, i, 1);
module(nrow - 2, 0, i, 2);
module(nrow - 1, 0, i, 3);
module(0, ncol - 2, i, 4);
module(0, ncol - 1, i, 5);
module(1, ncol - 1, i, 6);
module(2, ncol - 1, i, 7);
module(3, ncol - 1, i, 8);
}
private void corner4(int i)
{
module(nrow - 1, 0, i, 1);
module(nrow - 1, ncol - 1, i, 2);
module(0, ncol - 3, i, 3);
module(0, ncol - 2, i, 4);
module(0, ncol - 1, i, 5);
module(1, ncol - 3, i, 6);
module(1, ncol - 2, i, 7);
module(1, ncol - 1, i, 8);
}
public void make()
{
int i = 1;
int j = 4;
int k = 0;
for(int l = 0; l < nrow; l++)
{
for(int i1 = 0; i1 < ncol; i1++)
array[l * ncol + i1] = 0;
}
do
{
if(j == nrow && k == 0)
corner1(i++);
if(j == nrow - 2 && k == 0 && ncol % 4 != 0)
corner2(i++);
if(j == nrow - 2 && k == 0 && ncol % 8 == 4)
corner3(i++);
if(j == nrow + 4 && k == 2 && ncol % 8 == 0)
corner4(i++);
do
{
if(j < nrow && k >= 0 && array[j * ncol + k] == 0)
utah(j, k, i++);
j -= 2;
k += 2;
} while(j >= 0 && k < ncol);
j++;
k += 3;
do
{
if(j >= 0 && k < ncol && array[j * ncol + k] == 0)
utah(j, k, i++);
j += 2;
k -= 2;
} while(j < nrow && k >= 0);
j += 3;
k++;
} while(j < nrow || k < ncol);
if(array[nrow * ncol - 1] == 0)
array[nrow * ncol - 1] = array[nrow * ncol - ncol - 2] = 1;
}
private void module(int i, int j, int k, int l)
{
if(i < 0)
{
i += nrow;
j += 4 - (nrow + 4) % 8;
}
if(j < 0)
{
j += ncol;
i += 4 - (ncol + 4) % 8;
}
array[i * ncol + j] = 10 * k + l;
}
private charPlacer()
{
}
charPlacer(_cls1 _pcls1)
{
this();
}
}
public String code;
protected static final int d1 = 3;
public double marginCM;
protected int leftMarginPixels;
protected int topMarginPixels;
private int endOfCode;
private int suplementTopMargin;
public Color backColor;
public String codeText;
protected int narrowBarPixels;
protected int widthBarPixels;
protected double narrowBarCM;
protected double widthBarCM;
public int resolution;
protected int barHeightPixels;
public double N;
public double X;
public int width;
public int height;
public int pWidth;
public int pHeight;
public boolean autoSize;
public Font textFont;
public Color fontColor;
public Color barColor;
public double I;
public double H;
public double L;
public int rotate;
protected int currentX;
protected int currentY;
private int extraHeight;
public int dotPixels;
public int margin;
public boolean processTilde;
public int encoding;
public static int E_AUTO = 5;
public static int E_ASCII = 0;
public static int E_C40 = 1;
public static int E_TEXT = 2;
public static int E_BASE256 = 3;
public static int E_NONE = 4;
public boolean reBuild;
private String internalCode;
private int bitmap[][];
public int preferredFormat;
public static final int C10X10 = 0;
public static final int C12X12 = 1;
public static final int C14X14 = 2;
public static final int C16X16 = 3;
public static final int C18X18 = 4;
public static final int C20X20 = 5;
public static final int C22X22 = 6;
public static final int C24X24 = 7;
public static final int C26X26 = 8;
public static final int C32X32 = 9;
public static final int C36X36 = 10;
public static final int C40X40 = 11;
public static final int C44X44 = 12;
public static final int C48X48 = 13;
public static final int C52X52 = 14;
public static final int C64X64 = 15;
public static final int C72X72 = 16;
public static final int C80X80 = 17;
public static final int C88X88 = 18;
public static final int C96X96 = 19;
public static final int C104X104 = 20;
public static final int C120X120 = 21;
public static final int C132X132 = 22;
public static final int C144X144 = 23;
public static final int C8X18 = 24;
public static final int C8X32 = 25;
public static final int C12X26 = 26;
public static final int C12X36 = 27;
public static final int C16X36 = 28;
public static final int C16X48 = 29;
private int currentEncoding;
private static int C0[][] = {
{
10, 10, 8, 8, 1, 8, 8, 3, 5, 3,
5, 1
}, {
12, 12, 10, 10, 1, 10, 10, 5, 7, 5,
7, 1
}, {
14, 14, 12, 12, 1, 12, 12, 8, 10, 8,
10, 1
}, {
16, 16, 14, 14, 1, 14, 14, 12, 12, 12,
12, 1
}, {
18, 18, 16, 16, 1, 16, 16, 18, 14, 18,
14, 1
}, {
20, 20, 18, 18, 1, 18, 18, 22, 18, 22,
18, 1
}, {
22, 22, 20, 20, 1, 20, 20, 30, 20, 30,
20, 1
}, {
24, 24, 22, 22, 1, 22, 22, 36, 24, 36,
24, 1
}, {
26, 26, 24, 24, 1, 24, 24, 44, 28, 44,
28, 1
}, {
32, 32, 14, 14, 4, 28, 28, 62, 36, 62,
36, 1
}, {
36, 36, 16, 16, 4, 32, 32, 86, 42, 86,
42, 1
}, {
40, 40, 18, 18, 4, 36, 36, 114, 48, 114,
48, 1
}, {
44, 44, 20, 20, 4, 40, 40, 144, 56, 144,
56, 1
}, {
48, 48, 22, 22, 4, 44, 44, 174, 68, 174,
68, 1
}, {
52, 52, 24, 24, 4, 48, 48, 204, 84, 102,
42, 2
}, {
64, 64, 14, 14, 16, 56, 56, 280, 112, 140,
56, 2
}, {
72, 72, 16, 16, 16, 64, 64, 368, 144, 92,
36, 4
}, {
80, 80, 18, 18, 16, 72, 72, 456, 192, 114,
48, 4
}, {
88, 88, 20, 20, 16, 80, 80, 576, 224, 144,
56, 4
}, {
96, 96, 22, 22, 16, 88, 88, 696, 272, 174,
68, 4
}, {
104, 104, 24, 24, 16, 96, 96, 816, 336, 136,
56, 6
}, {
120, 120, 18, 18, 36, 108, 108, 1050, 496, 175,
68, 6
}, {
132, 132, 20, 20, 36, 120, 120, 1304, 496, 163,
62, 8
}, {
144, 144, 22, 22, 36, 132, 132, 1558, 620, 156,
62, 10
}, {
8, 18, 6, 16, 1, 6, 16, 5, 7, 5,
7, 1
}, {
8, 32, 6, 14, 2, 6, 28, 10, 11, 10,
11, 1
}, {
12, 26, 10, 24, 1, 10, 24, 16, 14, 16,
14, 1
}, {
12, 36, 10, 16, 2, 10, 32, 22, 18, 22,
18, 1
}, {
16, 36, 14, 16, 2, 14, 32, 32, 24, 32,
24, 1
}, {
16, 48, 14, 22, 2, 14, 44, 49, 28, 49,
28, 1
}
};
private int rows;
private int cols;
private int datarows;
private int datacols;
private int maprows;
private int mapcols;
private int regions;
private int totaldata;
private int totalerr;
private int reeddata;
private int reederr;
private int reedblocks;
private int C49rest;
private static int C1[][] = {
{
0, 0
}, {
0, 1
}, {
0, 2
}, {
0, 3
}, {
0, 4
}, {
0, 5
}, {
0, 6
}, {
0, 7
}, {
0, 8
}, {
0, 9
}, {
0, 10
}, {
0, 11
}, {
0, 12
}, {
0, 13
}, {
0, 14
}, {
0, 15
}, {
0, 16
}, {
0, 17
}, {
0, 18
}, {
0, 19
}, {
0, 20
}, {
0, 21
}, {
0, 22
}, {
0, 23
}, {
0, 24
}, {
0, 25
}, {
0, 26
}, {
0, 27
}, {
0, 28
}, {
0, 29
}, {
0, 30
}, {
0, 31
}, {
3
}, {
1, 0
}, {
1, 1
}, {
1, 2
}, {
1, 3
}, {
1, 4
}, {
1, 5
}, {
1, 6
}, {
1, 7
}, {
1, 8
}, {
1, 9
}, {
1, 10
}, {
1, 11
}, {
1, 12
}, {
1, 13
}, {
1, 14
}, {
4
}, {
5
}, {
6
}, {
7
}, {
8
}, {
9
}, {
10
}, {
11
}, {
12
}, {
13
}, {
1, 15
}, {
1, 16
}, {
1, 17
}, {
1, 18
}, {
1, 19
}, {
1, 20
}, {
1, 21
}, {
14
}, {
15
}, {
16
}, {
17
}, {
18
}, {
19
}, {
20
}, {
21
}, {
22
}, {
23
}, {
24
}, {
25
}, {
26
}, {
27
}, {
28
}, {
?? 快捷鍵說(shuō)明
復(fù)制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號(hào)
Ctrl + =
減小字號(hào)
Ctrl + -