Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
W
warehouse
Overview
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
胡懿
warehouse
Commits
8f2d9b23
Commit
8f2d9b23
authored
Jun 07, 2023
by
胡懿
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
调整二维码生成
parent
5240d608
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
37 additions
and
15 deletions
+37
-15
DrawQrcodeUtil.java
...jeeplus/modules/warehouse/qrcode/util/DrawQrcodeUtil.java
+37
-15
No files found.
src/main/java/com/jeeplus/modules/warehouse/qrcode/util/DrawQrcodeUtil.java
View file @
8f2d9b23
...
@@ -252,12 +252,12 @@ public class DrawQrcodeUtil {
...
@@ -252,12 +252,12 @@ public class DrawQrcodeUtil {
,
RenderingHints
.
VALUE_ALPHA_INTERPOLATION_QUALITY
);
,
RenderingHints
.
VALUE_ALPHA_INTERPOLATION_QUALITY
);
g2
.
setRenderingHints
(
rh
);
g2
.
setRenderingHints
(
rh
);
Font
font
=
new
Font
(
"黑体"
,
Font
.
BOLD
,
1
6
*
qRcodeSize
.
getInitfontSize
());
Font
font
=
new
Font
(
"黑体"
,
Font
.
BOLD
,
1
2
*
qRcodeSize
.
getInitfontSize
());
g2
.
setFont
(
font
);
//设置字体:字体、字号、大小
g2
.
setFont
(
font
);
//设置字体:字体、字号、大小
g2
.
setColor
(
qRcodeSize
.
color
);
//设置背景颜色
g2
.
setColor
(
qRcodeSize
.
color
);
//设置背景颜色
// g2.setBackground(c);
// g2.setBackground(c);
int
contentX
=
qRcodeSize
.
getInitContentX
();
int
contentX
=
qRcodeSize
.
getInitContentX
();
int
contentY
=
qRcodeSize
.
getInitContentY
()
+
20
0
;
int
contentY
=
qRcodeSize
.
getInitContentY
()
+
15
0
;
//写二维码
//写二维码
g2
.
drawImage
(
qrcodeImage
,
qRcodeSize
.
getQrcodeX
(),
qRcodeSize
.
getQrcodeY
(),
qRcodeSize
.
getQrcodeWidth
(),
qRcodeSize
.
getQrcodeHeight
(),
null
,
null
);
g2
.
drawImage
(
qrcodeImage
,
qRcodeSize
.
getQrcodeX
(),
qRcodeSize
.
getQrcodeY
(),
qRcodeSize
.
getQrcodeWidth
(),
qRcodeSize
.
getQrcodeHeight
(),
null
,
null
);
...
@@ -273,26 +273,48 @@ public class DrawQrcodeUtil {
...
@@ -273,26 +273,48 @@ public class DrawQrcodeUtil {
//写入货品类型
//写入货品类型
String
contentTitle2
=
"货品类型:"
;
String
contentTitle2
=
"货品类型:"
;
int
contentTitle2Width
=
g2
.
getFontMetrics
().
stringWidth
(
contentTitle2
);
int
contentTitle2Width
=
g2
.
getFontMetrics
().
stringWidth
(
contentTitle2
);
g2
.
drawString
(
contentTitle2
,
contentX
,
contentY
+
200
);
g2
.
drawString
(
contentTitle2
,
contentX
,
contentY
+
150
);
String
typeName
=
formatContent
(
goodsInfo
.
getType
().
getName
(),
10
);
String
typeName
=
goodsInfo
.
getType
().
getName
();
as
=
new
AttributedString
(
typeName
);
if
(
typeName
.
length
()
>
15
)
{
as
.
addAttribute
(
TextAttribute
.
FONT
,
font
);
String
str1
=
typeName
.
substring
(
0
,
9
);
as
.
addAttribute
(
TextAttribute
.
UNDERLINE
,
TextAttribute
.
UNDERLINE_LOW_DASHED
,
0
,
typeName
.
length
());
str1
=
formatContent
(
str1
,
9
);
g2
.
drawString
(
as
.
getIterator
(),
contentX
+
contentTitle2Width
,
contentY
+
200
);
as
=
new
AttributedString
(
str1
);
as
.
addAttribute
(
TextAttribute
.
FONT
,
font
);
as
.
addAttribute
(
TextAttribute
.
UNDERLINE
,
TextAttribute
.
UNDERLINE_LOW_DASHED
,
0
,
str1
.
length
());
g2
.
drawString
(
as
.
getIterator
(),
contentX
+
contentTitle2Width
,
contentY
+
150
);
String
str2
=
typeName
.
substring
(
9
,
typeName
.
length
());
str2
=
formatContent
(
str2
,
9
);
as
=
new
AttributedString
(
str2
);
as
.
addAttribute
(
TextAttribute
.
FONT
,
font
);
as
.
addAttribute
(
TextAttribute
.
UNDERLINE
,
TextAttribute
.
UNDERLINE_LOW_DASHED
,
0
,
str2
.
length
());
g2
.
drawString
(
as
.
getIterator
(),
contentX
+
contentTitle2Width
,
contentY
+
300
);
}
else
{
typeName
=
formatContent
(
goodsInfo
.
getType
().
getName
(),
10
);
as
=
new
AttributedString
(
typeName
);
as
.
addAttribute
(
TextAttribute
.
FONT
,
font
);
as
.
addAttribute
(
TextAttribute
.
UNDERLINE
,
TextAttribute
.
UNDERLINE_LOW_DASHED
,
0
,
typeName
.
length
());
g2
.
drawString
(
as
.
getIterator
(),
contentX
+
contentTitle2Width
,
contentY
+
150
);
}
//写入物资编码
//写入物资编码
String
contentTitle4
=
"物资编码:"
;
String
contentTitle4
=
"物资编码:"
;
int
contentTitle4Width
=
g2
.
getFontMetrics
().
stringWidth
(
contentTitle4
);
int
contentTitle4Width
=
g2
.
getFontMetrics
().
stringWidth
(
contentTitle4
);
g2
.
drawString
(
contentTitle4
,
contentX
,
contentY
+
4
0
0
);
g2
.
drawString
(
contentTitle4
,
contentX
,
contentY
+
4
5
0
);
String
code
=
qrCode
.
getCode
();
String
code
=
qrCode
.
getCode
();
if
(
code
.
length
()
>
1
0
)
{
if
(
code
.
length
()
>
1
5
)
{
String
str1
=
code
.
substring
(
0
,
9
);
String
str1
=
code
.
substring
(
0
,
14
);
str1
=
formatContent
(
str1
,
1
0
);
str1
=
formatContent
(
str1
,
1
5
);
as
=
new
AttributedString
(
str1
);
as
=
new
AttributedString
(
str1
);
as
.
addAttribute
(
TextAttribute
.
FONT
,
font
);
as
.
addAttribute
(
TextAttribute
.
FONT
,
font
);
as
.
addAttribute
(
TextAttribute
.
UNDERLINE
,
TextAttribute
.
UNDERLINE_LOW_DASHED
,
0
,
str1
.
length
());
as
.
addAttribute
(
TextAttribute
.
UNDERLINE
,
TextAttribute
.
UNDERLINE_LOW_DASHED
,
0
,
str1
.
length
());
g2
.
drawString
(
as
.
getIterator
(),
contentX
+
contentTitle4Width
,
contentY
+
4
0
0
);
g2
.
drawString
(
as
.
getIterator
(),
contentX
+
contentTitle4Width
,
contentY
+
4
5
0
);
String
str2
=
code
.
substring
(
9
,
code
.
length
());
String
str2
=
code
.
substring
(
14
,
code
.
length
());
str2
=
formatContent
(
str2
,
1
0
);
str2
=
formatContent
(
str2
,
1
5
);
as
=
new
AttributedString
(
str2
);
as
=
new
AttributedString
(
str2
);
as
.
addAttribute
(
TextAttribute
.
FONT
,
font
);
as
.
addAttribute
(
TextAttribute
.
FONT
,
font
);
as
.
addAttribute
(
TextAttribute
.
UNDERLINE
,
TextAttribute
.
UNDERLINE_LOW_DASHED
,
0
,
str2
.
length
());
as
.
addAttribute
(
TextAttribute
.
UNDERLINE
,
TextAttribute
.
UNDERLINE_LOW_DASHED
,
0
,
str2
.
length
());
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment