Skip to content
Toggle navigation
Projects
Groups
Snippets
Help
Antti Väyrynen
/
Moya
This project
Loading...
Sign in
Toggle navigation
Go to a project
Project
Repository
Issues
0
Merge Requests
0
Wiki
Settings
Activity
Graph
Charts
Create a new issue
Commits
Issue Boards
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Commit ee74d751
authored
Jun 04, 2013
by
Liv Haapala
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
changed constructPng
1 parent
9c9cb802
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
60 additions
and
16 deletions
code/MoyaBeans/ejbModule/fi/codecrew/moya/beans/CardPrintBean.java
code/MoyaBeans/ejbModule/fi/codecrew/moya/beans/CardPrintBean.java
View file @
ee74d75
package
fi
.
codecrew
.
moya
.
beans
;
package
fi
.
codecrew
.
moya
.
beans
;
import
java.awt.Color
;
import
java.awt.Font
;
import
java.awt.Font
;
import
java.awt.Graphics2D
;
import
java.awt.Graphics2D
;
import
java.awt.Paint
;
import
java.awt.RenderingHints
;
import
java.awt.geom.Point2D
;
import
java.awt.geom.Rectangle2D
;
import
java.awt.image.BufferedImage
;
import
java.awt.image.BufferedImage
;
import
java.awt.image.BufferedImageOp
;
import
java.awt.image.ColorModel
;
import
java.io.ByteArrayInputStream
;
import
java.io.ByteArrayInputStream
;
import
java.io.ByteArrayOutputStream
;
import
java.io.ByteArrayOutputStream
;
import
java.io.IOException
;
import
java.io.IOException
;
...
@@ -66,6 +73,9 @@ public class CardPrintBean implements CardPrintBeanLocal {
...
@@ -66,6 +73,9 @@ public class CardPrintBean implements CardPrintBeanLocal {
private
PrintedCardFacade
printedCardFacade
;
private
PrintedCardFacade
printedCardFacade
;
private
static
final
Logger
logger
=
LoggerFactory
.
getLogger
(
CardPrintBean
.
class
);
private
static
final
Logger
logger
=
LoggerFactory
.
getLogger
(
CardPrintBean
.
class
);
private
int
nick_x
=
0
;
private
int
nick_y
=
0
;
/**
/**
* Default constructor.
* Default constructor.
*/
*/
...
@@ -166,7 +176,8 @@ public class CardPrintBean implements CardPrintBeanLocal {
...
@@ -166,7 +176,8 @@ public class CardPrintBean implements CardPrintBeanLocal {
// Render face image
// Render face image
Image
faceImage
=
new
Image
(
pdf
,
Image
faceImage
=
new
Image
(
pdf
,
convertBufferedImageToPng
(
faceBufferedImage
),
ImageType
.
PNG
);
convertBufferedImageToPng
(
faceBufferedImage
),
ImageType
.
PNG
);
faceImage
.
setPosition
(
15.5
,
67
);
//faceImage.setPosition(15.5, 67);
faceImage
.
setPosition
(
175
,
222
);
// faceImage.scaleBy(0.32);
// faceImage.scaleBy(0.32);
faceImage
.
scaleBy
(((
410.0
*
0.245
)
/
faceImage
.
getHeight
()));
faceImage
.
scaleBy
(((
410.0
*
0.245
)
/
faceImage
.
getHeight
()));
faceImage
.
drawOn
(
page
);
faceImage
.
drawOn
(
page
);
...
@@ -177,6 +188,9 @@ public class CardPrintBean implements CardPrintBeanLocal {
...
@@ -177,6 +188,9 @@ public class CardPrintBean implements CardPrintBeanLocal {
nickFont
.
setSize
(
16.0
);
nickFont
.
setSize
(
16.0
);
// User nick text
// User nick text
TextLine
nickTextLine
=
new
TextLine
(
nickFont
);
TextLine
nickTextLine
=
new
TextLine
(
nickFont
);
nickTextLine
.
setText
(
user
.
getUser
().
getNick
());
nickTextLine
.
setText
(
user
.
getUser
().
getNick
());
nickTextLine
.
setPosition
(
19.0
,
193.0
);
nickTextLine
.
setPosition
(
19.0
,
193.0
);
...
@@ -247,16 +261,31 @@ public class CardPrintBean implements CardPrintBeanLocal {
...
@@ -247,16 +261,31 @@ public class CardPrintBean implements CardPrintBeanLocal {
// g.drawImage(face, AffineTransform.getScaleInstance(0.31, 0.31),
// g.drawImage(face, AffineTransform.getScaleInstance(0.31, 0.31),
// null);
// null);
g
.
drawImage
(
face
,
60
,
300
,
320
,
400
,
null
);
//faceImage.scaleBy(((410.0 * 0.245) / faceImage.getHeight()));
g
.
drawImage
(
face
,
166
,
241
,
318
,
400
,
null
);
g
.
setFont
(
new
Font
(
"Century gothic"
,
Font
.
PLAIN
,
70
));
g
.
setFont
(
new
Font
(
"Century gothic"
,
Font
.
PLAIN
,
70
));
// g.drawString(nick, 595 -
Font
font
=
new
Font
(
"Century gothic"
,
Font
.
PLAIN
,
70
);
// g.getFontMetrics().charsWidth(nick.toCharArray(), 0, nick.length()),
int
nickWidth
=
g
.
getFontMetrics
(
font
).
stringWidth
(
user
.
getUser
().
getNick
());
// 840);
int
nickX
=
(
646
/
2
)
-
(
nickWidth
/
2
);
g
.
drawString
(
user
.
getUser
().
getNick
(),
50
,
810
);
int
nickY
=
750
;
//Color transparentWhite = new Color(255, 255, 255, 140);
//g.setColor(transparentWhite);
//g.fillRect(nickX - 20, nickY - 50, nickWidth + 40, 50);
g
.
setColor
(
Color
.
black
);
g
.
setFont
(
font
);
g
.
drawString
(
user
.
getUser
().
getNick
(),
nickX
,
nickY
);
g
.
setFont
(
new
Font
(
"Century gothic"
,
Font
.
BOLD
,
45
));
g
.
setFont
(
new
Font
(
"Century gothic"
,
Font
.
BOLD
,
45
));
StringBuilder
wholeName
=
new
StringBuilder
();
StringBuilder
wholeName
=
new
StringBuilder
();
wholeName
.
append
(
user
.
getUser
().
getFirstnames
()).
append
(
" "
).
append
(
user
.
getUser
().
getLastname
());
wholeName
.
append
(
user
.
getUser
().
getFirstnames
()).
append
(
" "
).
append
(
user
.
getUser
().
getLastname
());
...
@@ -268,14 +297,29 @@ public class CardPrintBean implements CardPrintBeanLocal {
...
@@ -268,14 +297,29 @@ public class CardPrintBean implements CardPrintBeanLocal {
//
//
// g.drawString(owner.getId().toString(), 60, 948);
// g.drawString(owner.getId().toString(), 60, 948);
g
.
drawString
(
wholeName
.
toString
(),
60
,
865
);
g
.
setFont
(
new
Font
(
"Century gothic"
,
Font
.
BOLD
,
40
));
g
.
drawString
(
card
.
getTemplate
().
getName
(),
60
,
915
);
g
.
drawString
(
wholeName
.
toString
(),
60
,
950
);
//g.drawString(card.getTemplate().getName(), 60, 915);
String
barcodeString
=
String
.
valueOf
(
user
.
getUser
().
getCreated
().
getTime
().
getTime
());
barcodeString
=
barcodeString
.
substring
(
barcodeString
.
length
()
-
12
);
PrintedCard
printedCard
=
cardTemplateBean
.
checkPrintedCard
(
user
);
BufferedImage
image
=
ImageIO
.
read
(
BarcodeUtils
.
getBarcodeEAN
(
barcodeString
));
g
.
drawImage
(
image
,
0
,
base
.
getHeight
()
-
120
,
base
.
getWidth
(),
120
,
null
);
g
.
setFont
(
new
Font
(
"Century gothic"
,
Font
.
PLAIN
,
30
));
g
.
setColor
(
Color
.
white
);
if
(
printedCard
!=
null
)
g
.
drawString
(
barcodeBean
.
getVrAuthCodeForCard
(
printedCard
),
445
,
905
);
BufferedImage
barCodeBufferedImage
=
ImageIO
.
read
(
barcodeBean
.
getCardBarcode
(
printedCard
));
//int barcodeX = (base.getWidth()/2) - (image.getWidth()/2);
int
barcodeX
=
(
base
.
getWidth
()
-
400
)/
2
;
int
barcodeY
=
base
.
getHeight
()
-
50
;
if
(
printedCard
!=
null
)
g
.
drawImage
(
barCodeBufferedImage
,
barcodeX
,
barcodeY
,
400
,
barCodeBufferedImage
.
getHeight
(),
null
);
g
.
setColor
(
Color
.
white
);
g
.
fillRect
(
0
,
base
.
getHeight
()-
20
,
base
.
getWidth
(),
base
.
getHeight
());
g
.
dispose
();
g
.
dispose
();
ByteArrayOutputStream
ostr
=
new
ByteArrayOutputStream
();
ByteArrayOutputStream
ostr
=
new
ByteArrayOutputStream
();
...
...
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