📄 barcode.java
字号:
{
textFont = font;
invalidate();
}
public Font getFont()
{
return textFont;
}
public void setTextFontColor(Color color)
{
fontColor = color;
invalidate();
}
public Color getTextFontColor()
{
return fontColor;
}
public void setForeground(Color color)
{
barColor = color;
invalidate();
}
public Color getForeground()
{
return barColor;
}
public void setUPCESytem(String s)
{
if(s.equals("0"))
UPCESytem = '0';
if(s.equals("1"))
UPCESytem = '1';
invalidate();
}
public String getUPCESytem()
{
String s = "";
if(UPCESytem == '0')
s = "0";
if(UPCESytem == '1')
s = "1";
return s;
}
public void setCODABARStartChar(String s)
{
if(s.equals("B"))
CODABARStartChar = 'B';
if(s.equals("A"))
CODABARStartChar = 'A';
if(s.equals("C"))
CODABARStartChar = 'C';
if(s.equals("D"))
CODABARStartChar = 'D';
invalidate();
}
public String getCODABARStartChar()
{
String s = "";
if(CODABARStartChar == 'B')
s = "B";
if(CODABARStartChar == 'A')
s = "A";
if(CODABARStartChar == 'C')
s = "C";
if(CODABARStartChar == 'D')
s = "D";
return s;
}
public void setCODABARStopChar(String s)
{
if(s.equals("B"))
CODABARStopChar = 'B';
if(s.equals("A"))
CODABARStopChar = 'A';
if(s.equals("C"))
CODABARStopChar = 'C';
if(s.equals("D"))
CODABARStopChar = 'D';
invalidate();
}
public String getCODABARStopChar()
{
String s = "";
if(CODABARStopChar == 'B')
s = "B";
if(CODABARStopChar == 'A')
s = "A";
if(CODABARStopChar == 'C')
s = "C";
if(CODABARStopChar == 'D')
s = "D";
return s;
}
public void setUPCEANSupplement2(boolean flag)
{
UPCEANSupplement2 = flag;
invalidate();
}
public boolean getUPCEANSupplement2()
{
return UPCEANSupplement2;
}
public void setUPCEANSupplement5(boolean flag)
{
UPCEANSupplement5 = flag;
invalidate();
}
public boolean getUPCEANSupplement5()
{
return UPCEANSupplement5;
}
public void setCode128Set(String s)
{
if(s.toUpperCase().equals("B"))
Code128Set = 'B';
if(s.toUpperCase().equals("A"))
Code128Set = 'A';
if(s.toUpperCase().equals("C"))
Code128Set = 'C';
if(s.toUpperCase().equals("AUTO"))
Code128Set = '0';
if(s.toUpperCase().equals("0"))
Code128Set = '0';
invalidate();
}
public String getCode128Set()
{
String s = "";
if(Code128Set == 'B')
s = "B";
if(Code128Set == 'A')
s = "A";
if(Code128Set == 'C')
s = "C";
if(Code128Set == '0')
s = "0";
return s;
}
public void setXDimensionCM(double d1)
{
X = d1;
invalidate();
}
public double getXDimensionCM()
{
return X;
}
public void setNarrowToWideRatio(double d1)
{
N = d1;
invalidate();
}
public double getNarrowToWideRatio()
{
return N;
}
public void setRotationAngle(int i)
{
rotate = i;
invalidate();
}
public int getRotationAngle()
{
return rotate;
}
protected void addBar(Graphics g, int i, boolean flag, int j)
{
if(flag)
{
g.setColor(barColor);
g.fillRect(currentX, topMarginPixels + j, i, (barHeightPixels + extraHeight) - j);
}
currentX += i;
}
protected void paintPostNetChar(Graphics g, String s)
{
int i = (int)(postnetHeightTallBar * (double)resolution);
int j = (int)(postnetHeightShortBar * (double)resolution);
g.setColor(barColor);
for(int k = 0; k < s.length(); k++)
{
char c = s.charAt(k);
if(c == '0')
g.fillRect(currentX, topMarginPixels, narrowBarPixels, j + extraHeight);
if(c == '1')
g.fillRect(currentX, topMarginPixels + (j - i), narrowBarPixels, i + extraHeight);
currentX += narrowBarPixels;
currentX += widthBarPixels;
}
}
protected void paintPOSTNET(Graphics g)
{
boolean flag = false;
int j = 0;
String s2 = code;
paintPostNetChar(g, "1");
for(int k = code.length() - 1; k >= 0; k--)
{
String s = code.charAt(k)+"";
j += findChar(setPOSTNET, s);
}
int l = (int)mod(j, 10D);
if(l != 0)
l = 10 - l;
if(checkCharacter)
s2 = s2 + (new Integer(l)).toString();
for(int i1 = 0; i1 < s2.length(); i1++)
{
String s1 = s2.charAt(i1)+"";
int i = findChar(setPOSTNET, s1);
paintPostNetChar(g, setPOSTNET[i][1]);
}
paintPostNetChar(g, "1");
}
protected int findChar(String as[][], String s)
{
for(int i = 0; i < as.length; i++)
if(s.compareTo(as[i][0]) == 0)
return i;
return -1;
}
protected int findChar(String as[][], char s)
{
for(int i = 0; i < as.length; i++)
if((as[i][0].compareTo(s+"")) == 0)
return i;
return -1;
}
protected void paintPLANET(Graphics g)
{
boolean flag = false;
int j = 0;
String s2 = code;
paintPostNetChar(g, "1");
for(int k = code.length() - 1; k >= 0; k--)
{
String s = code.charAt(k)+"";
j += findChar(setPLANET, s);
}
int l = (int)mod(j, 10D);
if(l != 0)
l = 10 - l;
if(checkCharacter)
s2 = s2 + (new Integer(l)).toString();
for(int i1 = 0; i1 < s2.length(); i1++)
{
String s1 = s2.charAt(i1)+"";
int i = findChar(setPLANET, s1);
paintPostNetChar(g, setPLANET[i][1]);
}
paintPostNetChar(g, "1");
}
protected void paintInterleaved25(Graphics g)
{
boolean flag = false;
boolean flag1 = false;
boolean flag2 = false;
String s3 = code;
paintChar(g, "bwbw", "nnnn");
String s4 = "";
if(mod(code.length(), 2D) == 0.0D && checkCharacter)
s3 = "0" + code;
if(mod(code.length(), 2D) == 1.0D && !checkCharacter)
s3 = "0" + code;
int k = 0;
int l = 0;
boolean flag3 = true;
for(int i1 = s3.length() - 1; i1 >= 0; i1--)
{
String s = String.valueOf(s3.charAt(i1));
if(flag3)
k += findChar(set25, s);
else
l += findChar(set25, s);
flag3 = !flag3;
}
int j1 = k * 3 + l;
j1 = (int)mod(j1, 10D);
if(j1 != 0)
j1 = 10 - j1;
if(checkCharacter)
s3 = s3 + (new Integer(j1)).toString();
for(int k1 = 0; k1 < s3.length(); k1 += 2)
{
String s1 = String.valueOf(s3.charAt(k1));
String s2 = String.valueOf(s3.charAt(k1 + 1));
int i = findChar(set25, s1);
int j = findChar(set25, s2);
for(int l1 = 0; l1 < 5; l1++)
{
paintChar(g, "b", String.valueOf(set25[i][1].charAt(l1)));
paintChar(g, "w", String.valueOf(set25[j][1].charAt(l1)));
}
}
paintChar(g, "bwb", "wnn");
if(checkCharacterInText)
codeText = s3;
else
codeText = code;
}
protected void paintIND25(Graphics g)
{
boolean flag = false;
boolean flag1 = false;
String s2 = code;
paintChar(g, "bwbwbw", "wwwwnw");
int j = 0;
int k = 0;
boolean flag2 = true;
for(int l = s2.length() - 1; l >= 0; l--)
{
String s = String.valueOf(s2.charAt(l));
if(flag2)
j += findChar(set25, s);
else
k += findChar(set25, s);
flag2 = !flag2;
}
int i1 = j * 3 + k;
i1 = (int)mod(i1, 10D);
if(i1 != 0)
i1 = 10 - i1;
if(checkCharacter)
s2 = s2 + (new Integer(i1)).toString();
for(int j1 = 0; j1 < s2.length(); j1++)
{
String s1 = s2.charAt(j1)+"";
int i = findChar(set25, s1);
if(i >= 0)
{
for(int k1 = 0; k1 < set25[i][1].length(); k1++)
{
paintChar(g, "b", set25[i][1].charAt(k1)+"");
paintChar(g, "w", "w");
}
}
}
paintChar(g, "bwbwb", "wwnww");
}
protected String UPCEANCheck(String s)
{
boolean flag = true;
int i = 0;
int j = 0;
int k = 0;
for(int l = s.length() - 1; l >= 0; l--)
{
if(flag)
i += (new Integer(s.charAt(l))).intValue();
else
j += (new Integer(s.charAt(l))).intValue();
flag = !flag;
}
j = i * 3 + j;
k = (int)mod(j, 10D);
if(k != 0)
k = 10 - k;
return k+"";
}
protected void paintUPCA(Graphics g)
{
boolean flag = false;
boolean flag1 = false;
if(code.length() < 11)
return;
if(code.length() == 13)
{
supplement = code.substring(11, 13);
UPCEANSupplement2 = true;
}
if(code.length() == 14)
{
supplement = code.substring(12, 14);
UPCEANSupplement2 = true;
}
if(code.length() == 16)
{
supplement = code.substring(11, 16);
UPCEANSupplement5 = true;
}
if(code.length() == 17)
{
supplement = code.substring(12, 17);
UPCEANSupplement5 = true;
}
code = code.substring(0, 11);
code += UPCEANCheck(code);
paintGuardChar(g, "bwb", "nnn", 0);
leftGuardBar = currentX;
for(int k = 0; k < code.length(); k++)
{
String s = code.charAt(k)+"";
byte byte0 = -1;
if(k <= 5)
{
int i = findChar(setUPCALeft, s);
paintChar(g, "wbwb", setUPCALeft[i][1]);
} else
{
int j = findChar(setUPCARight, s);
paintChar(g, "bwbw", setUPCARight[j][1]);
}
if(k == 5)
{
centerGuardBarStart = currentX;
paintGuardChar(g, "wbwbw", "nnnnn", 0);
centerGuardBarEnd = currentX;
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -