Skip to content
Toggle navigation
Projects
Groups
Snippets
Help
Codecrew
/
Moya
This project
Loading...
Sign in
Toggle navigation
Go to a project
Project
Repository
Issues
30
Merge Requests
2
Wiki
Snippets
Settings
Activity
Graph
Charts
Create a new issue
Commits
Issue Boards
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Commit c61202ae
authored
Mar 29, 2015
by
Juho Juopperi
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
refactor barcode generation + add code39 function
1 parent
63957df7
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
19 additions
and
26 deletions
code/moya-utils/src/main/java/fi/codecrew/moya/utilities/BarcodeUtils.java
code/moya-utils/src/main/java/fi/codecrew/moya/utilities/BarcodeUtils.java
View file @
c61202a
...
...
@@ -27,46 +27,39 @@ import java.io.InputStream;
import
org.krysalis.barcode4j.BarcodeDimension
;
import
org.krysalis.barcode4j.BarcodeGenerator
;
import
org.krysalis.barcode4j.impl.code128.Code128Bean
;
import
org.krysalis.barcode4j.impl.code39.Code39Bean
;
import
org.krysalis.barcode4j.impl.upcean.EAN13Bean
;
import
org.krysalis.barcode4j.output.bitmap.BitmapCanvasProvider
;
public
class
BarcodeUtils
{
public
static
InputStream
getBarcode
(
String
message
)
throws
IOException
{
// BarcodeGenerator bean = new DataMatrixBean
();
BarcodeGenerator
bean
=
new
Code128Bean
();
ByteArrayOutputStream
out
=
new
ByteArrayOutputStream
();
// System.out.println("created: " + (new Date().getTime() - start)
);
public
static
InputStream
getBarcode
(
BarcodeGenerator
generator
,
String
message
)
throws
IOException
{
ByteArrayOutputStream
out
=
new
ByteArrayOutputStream
();
BitmapCanvasProvider
canvas
=
new
BitmapCanvasProvider
(
out
,
"image/png"
,
150
,
BufferedImage
.
TYPE_BYTE_BINARY
,
false
,
0
);
BitmapCanvasProvider
canvas
=
new
BitmapCanvasProvider
(
out
,
"image/png"
,
150
,
BufferedImage
.
TYPE_BYTE_BINARY
,
false
,
0
);
canvas
.
establishDimensions
(
new
BarcodeDimension
(
200
,
15
));
canvas
.
establishDimensions
(
new
BarcodeDimension
(
200
,
15
));
generator
.
generateBarcode
(
canvas
,
message
);
canvas
.
finish
();
bean
.
generateBarcode
(
canvas
,
message
);
canvas
.
finish
();
ByteArrayInputStream
istream
=
new
ByteArrayInputStream
(
out
.
toByteArray
());
return
istream
;
}
ByteArrayInputStream
istream
=
new
ByteArrayInputStream
(
out
.
toByteArray
());
return
istream
;
public
static
InputStream
getBarcode
(
String
message
)
throws
IOException
{
return
BarcodeUtils
.
getBarcode
(
new
Code128Bean
(),
message
)
;
}
public
static
InputStream
getBarcodeEAN
(
String
message
)
throws
IOException
{
// BarcodeGenerator bean = new DataMatrixBean();
BarcodeGenerator
bean
=
new
EAN13Bean
();
ByteArrayOutputStream
out
=
new
ByteArrayOutputStream
();
// System.out.println("created: " + (new Date().getTime() - start));
BitmapCanvasProvider
canvas
=
new
BitmapCanvasProvider
(
out
,
"image/png"
,
150
,
BufferedImage
.
TYPE_BYTE_BINARY
,
false
,
0
);
canvas
.
establishDimensions
(
new
BarcodeDimension
(
200
,
15
));
return
BarcodeUtils
.
getBarcode
(
new
EAN13Bean
(),
message
);
}
bean
.
generateBarcode
(
canvas
,
message
);
canvas
.
finish
();
public
static
InputStream
getBarcodeCode39
(
String
message
)
throws
IOException
{
return
BarcodeUtils
.
getBarcode
(
new
Code39Bean
(),
message
);
}
ByteArrayInputStream
istream
=
new
ByteArrayInputStream
(
out
.
toByteArray
());
return
istream
;
}
// public void barcode4j() throws FileNotFoundException, Exception {
// long start = new Date().getTime();
//
...
...
Write
Preview
Markdown
is supported
Attach a file
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 post a comment