Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
M
midjourney-proxy
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
徐少华
midjourney-proxy
Commits
bb661b08
Commit
bb661b08
authored
Jan 29, 2019
by
裴大威
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
调整条形码文字大小
parent
f2092b6c
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
31 additions
and
9 deletions
+31
-9
CopyrightTools.java
.../java/com/pcloud/book/copyright/tools/CopyrightTools.java
+31
-9
No files found.
pcloud-service-book/src/main/java/com/pcloud/book/copyright/tools/CopyrightTools.java
View file @
bb661b08
...
@@ -114,14 +114,14 @@ public class CopyrightTools {
...
@@ -114,14 +114,14 @@ public class CopyrightTools {
String
zipFilePath
=
ZIP_FILE_PATH
+
tempZipName
+
".zip"
;
String
zipFilePath
=
ZIP_FILE_PATH
+
tempZipName
+
".zip"
;
String
fileFolderPath
=
FILE_LOCAL_PATH
+
tempZipName
;
String
fileFolderPath
=
FILE_LOCAL_PATH
+
tempZipName
;
FileUtils
.
isDir
(
fileFolderPath
);
FileUtils
.
isDir
(
fileFolderPath
);
UploadResultInfo
uploadResultInfo
=
null
;
UploadResultInfo
uploadResultInfo
;
try
{
try
{
for
(
BookAuthCode
bookAuthCode
:
bookAuthCodes
)
{
for
(
BookAuthCode
bookAuthCode
:
bookAuthCodes
)
{
BufferedImage
bi
=
null
;
BufferedImage
bi
;
JBarcode
productBarcode
=
new
JBarcode
(
Code128Encoder
.
getInstance
(),
WidthCodedPainter
.
getInstance
(),
EAN13TextPainter
.
getInstance
());
JBarcode
productBarcode
=
new
JBarcode
(
Code128Encoder
.
getInstance
(),
WidthCodedPainter
.
getInstance
(),
EAN13TextPainter
.
getInstance
());
productBarcode
.
setXDimension
(
Double
.
valueOf
(
0.5
)
);
productBarcode
.
setXDimension
(
0.5
);
productBarcode
.
setBarHeight
(
Double
.
valueOf
(
30
)
);
productBarcode
.
setBarHeight
(
30
d
);
productBarcode
.
setWideRatio
(
Double
.
valueOf
(
30.0
D
)
);
productBarcode
.
setWideRatio
(
30.0
D
);
productBarcode
.
setShowText
(
true
);
productBarcode
.
setShowText
(
true
);
productBarcode
.
setTextPainter
(
BaseLineTextPainter
.
getInstance
());
productBarcode
.
setTextPainter
(
BaseLineTextPainter
.
getInstance
());
bi
=
productBarcode
.
createBarcode
(
bookAuthCode
.
getFullCode
());
bi
=
productBarcode
.
createBarcode
(
bookAuthCode
.
getFullCode
());
...
@@ -190,20 +190,42 @@ public class CopyrightTools {
...
@@ -190,20 +190,42 @@ public class CopyrightTools {
}
}
return
last6Months
;
return
last6Months
;
}
}
// public static void paintText(BufferedImage barCodeImage, String text) {
// //绘图
// Graphics g2d = barCodeImage.getGraphics();
// //创建字体
// Font font = new Font("console", Font.PLAIN, 15 );
// g2d.setFont(font);
// FontMetrics fm = g2d.getFontMetrics();
// int height = fm.getHeight();
// int center = (barCodeImage.getWidth() - fm.stringWidth(text)) / 2;
// g2d.setColor(Color.WHITE);
// g2d.fillRect(0, 0, barCodeImage.getWidth(), barCodeImage.getHeight() * 1 / 20);
// g2d.fillRect(0, barCodeImage.getHeight() - (height * 9 / 10), barCodeImage.getWidth(), (height * 9 / 10));
// g2d.setColor(Color.BLACK);
// g2d.drawString(text, center, barCodeImage.getHeight() - (height / 10) - 2);
// }
public
static
void
paintText
(
BufferedImage
barCodeImage
,
String
text
)
{
public
static
void
paintText
(
BufferedImage
barCodeImage
,
String
text
)
{
//绘图
//绘图
Graphics
g2d
=
barCodeImage
.
getGraphics
();
Graphics
g2d
=
barCodeImage
.
getGraphics
();
//创建字体
//创建字体
Font
font
=
new
Font
(
"console"
,
Font
.
PLAIN
,
15
);
Font
font
=
new
Font
(
"console"
,
Font
.
PLAIN
,
25
);
g2d
.
setFont
(
font
);
g2d
.
setFont
(
font
);
FontMetrics
fm
=
g2d
.
getFontMetrics
();
FontMetrics
fm
=
g2d
.
getFontMetrics
();
int
height
=
fm
.
getHeight
();
int
height
=
fm
.
getHeight
();
int
center
=
(
barCodeImage
.
getWidth
()
-
fm
.
stringWidth
(
text
))
/
2
;
//
int center = (barCodeImage.getWidth() - fm.stringWidth(text)) / 2;
g2d
.
setColor
(
Color
.
WHITE
);
g2d
.
setColor
(
Color
.
WHITE
);
g2d
.
fillRect
(
0
,
0
,
barCodeImage
.
getWidth
(),
barCodeImage
.
getHeight
()
*
1
/
20
);
g2d
.
fillRect
(
0
,
0
,
barCodeImage
.
getWidth
(),
barCodeImage
.
getHeight
()
/
20
);
g2d
.
fillRect
(
0
,
barCodeImage
.
getHeight
()
-
(
height
*
9
/
10
),
barCodeImage
.
getWidth
(),
(
height
*
9
/
10
));
g2d
.
fillRect
(
0
,
barCodeImage
.
getHeight
()
-
(
height
*
9
/
10
),
barCodeImage
.
getWidth
(),
(
height
*
9
/
10
));
g2d
.
setColor
(
Color
.
BLACK
);
g2d
.
setColor
(
Color
.
BLACK
);
g2d
.
drawString
(
text
,
center
,
barCodeImage
.
getHeight
()
-
(
height
/
10
)
-
2
);
//g2d.drawString(text, center, barCodeImage.getHeight() - (height / 10) - 2);
int
start
=
17
;
int
length
=
(
barCodeImage
.
getWidth
()
-
2
*
start
)
/
text
.
length
();
for
(
int
i
=
0
;
i
<
text
.
length
();
i
++)
{
g2d
.
drawString
(
text
.
substring
(
i
,
i
+
1
),
start
+
i
*
length
,
barCodeImage
.
getHeight
()
-
(
height
/
10
)
-
2
);
}
}
}
}
}
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