Commit 368f0d40 by Tuomas Riihimäki

Insomnia cardtemplates.

1 parent ce16315e
......@@ -129,11 +129,9 @@ public class CardPrintBean implements CardPrintBeanLocal {
CardTemplate cardTemplate = printedCard.getTemplate();
BufferedImage cardBackground = ImageIO.read(new ByteArrayInputStream(
cardTemplate.getImage()));
BufferedImage cardBackground = ImageIO.read(new ByteArrayInputStream(cardTemplate.getImage()));
BufferedImage faceBufferedImage = ImageIO
.read(new ByteArrayInputStream(user.getCurrentImage().getImageData()));
BufferedImage faceBufferedImage = ImageIO.read(new ByteArrayInputStream(user.getCurrentImage().getImageData()));
/*
* if (faceBufferedImage.getWidth() > 1024 ||
......@@ -141,6 +139,7 @@ public class CardPrintBean implements CardPrintBeanLocal {
* Exception("Image dimensions too large, please take/upload smaller!"
* ); }
*/
// force image aspect ratio.
int originalWidth = faceBufferedImage.getWidth();
int originalHeight = faceBufferedImage.getHeight();
......@@ -160,16 +159,14 @@ public class CardPrintBean implements CardPrintBeanLocal {
Page page = new Page(pdf, new float[] { pagex, pagey });
// Render background image
Image templateImage = new Image(pdf,
convertBufferedImageToPng(cardBackground), ImageType.PNG);
Image templateImage = new Image(pdf, convertBufferedImageToPng(cardBackground), ImageType.PNG);
templateImage.setPosition(0, 0);
templateImage.scaleBy(0.245);
templateImage.drawOn(page);
// Render face image
Image faceImage = new Image(pdf,
convertBufferedImageToPng(faceBufferedImage), ImageType.PNG);
faceImage.setPosition(15.5, 67);
Image faceImage = new Image(pdf, convertBufferedImageToPng(faceBufferedImage), ImageType.PNG);
faceImage.setPosition(55, 75);
//faceImage.setPosition(175, 222);
// faceImage.scaleBy(0.32);
faceImage.scaleBy(((410.0 * 0.245) / faceImage.getHeight()));
......@@ -178,14 +175,15 @@ public class CardPrintBean implements CardPrintBeanLocal {
// Render texts
// Big font for nick
com.pdfjet.Font nickFont = new com.pdfjet.Font(pdf, CoreFont.HELVETICA);
nickFont.setSize(16.0);
nickFont.setSize(17.0);
int[] white = new int[] { 255, 255, 255 };
// User nick text
TextLine nickTextLine = new TextLine(nickFont);
nickTextLine.setText(user.getUser().getNick());
nickTextLine.setPosition(19.0, 193.0);
nickTextLine.setColor(new int[] { 1, 1, 1 });
nickTextLine.setPosition(17.0, 195.0);
nickTextLine.setColor(white);
nickTextLine.drawOn(page);
// Smaller font
......@@ -193,19 +191,18 @@ public class CardPrintBean implements CardPrintBeanLocal {
font.setSize(10.0);
// Full name text
String wholeName = user.getUser().getFirstnames() + " "
+ user.getUser().getLastname();
String wholeName = user.getUser().getFirstnames() + " " + user.getUser().getLastname();
TextLine wholeNameText = new TextLine(font);
wholeNameText.setText(wholeName);
wholeNameText.setPosition(17.0, 212.0);
wholeNameText.setColor(new int[] { 1, 1, 1 });
wholeNameText.setPosition(17.0, 211.0);
wholeNameText.setColor(white);
wholeNameText.drawOn(page);
// Role text
TextLine roleTextLine = new TextLine(font);
roleTextLine.setText(cardTemplate.getName());
roleTextLine.setPosition(17.0, 223.0);
roleTextLine.setColor(new int[] { 1, 1, 1 });
roleTextLine.setPosition(17.0, 224.0);
roleTextLine.setColor(white);
roleTextLine.drawOn(page);
// Barcode
......@@ -215,12 +212,13 @@ public class CardPrintBean implements CardPrintBeanLocal {
// barcodeString = barcodeString.substring(barcodeString.length() -
// 12);
BufferedImage barCodeBufferedImage = ImageIO.read(barcodeBean.getCardBarcode(printedCard));
Image barCodeImage = new Image(pdf, convertBufferedImageToPng(barCodeBufferedImage), ImageType.PNG);
barCodeImage.setPosition(0.0, 230);// 243.5);
barCodeImage.scaleBy(0.7);
barCodeImage.drawOn(page);
// No barcode in insomnia..
/* BufferedImage barCodeBufferedImage = ImageIO.read(barcodeBean.getCardBarcode(printedCard));
Image barCodeImage = new Image(pdf, convertBufferedImageToPng(barCodeBufferedImage), ImageType.PNG);
barCodeImage.setPosition(0.0, 230);// 243.5);
barCodeImage.scaleBy(0.7);
barCodeImage.drawOn(page);
*/
mpr.getAffectedUsers().add(user);
}
pdf.flush();
......@@ -254,24 +252,27 @@ public class CardPrintBean implements CardPrintBeanLocal {
g.drawImage(base, 0, 0, base.getWidth(), base.getHeight(), null);
// g.drawImage(face, AffineTransform.getScaleInstance(0.31, 0.31),
// null);
g.drawImage(face, 174, 237, 301, 410, null);
g.setFont(new Font("Century gothic", Font.PLAIN, 70));
g.drawImage(face, 250, 300, 301, 410, null);
Font nickfont = new Font("Century gothic", Font.BOLD, 65);
Font font = new Font("Century gothic", Font.PLAIN, 70);
int nickWidth = g.getFontMetrics(font).stringWidth(user.getUser().getNick());
Font font = new Font("Century gothic", Font.BOLD, 45);
int nickX = (646 / 2) - (nickWidth / 2);
int nickY = 750;
//int nickWidth = g.getFontMetrics(font).stringWidth(user.getUser().getNick());
//int nickX = (646 / 2) - (nickWidth / 2);
int nickX = 60;
int nickY = 800;
//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.setColor(Color.white);
g.setFont(nickfont);
g.drawString(user.getUser().getNick(), nickX, nickY);
g.setFont(new Font("Century gothic", Font.BOLD, 45));
g.setFont(font);
StringBuilder wholeName = new StringBuilder();
wholeName.append(user.getUser().getFirstnames()).append(" ").append(user.getUser().getLastname());
......@@ -284,25 +285,26 @@ public class CardPrintBean implements CardPrintBeanLocal {
// g.drawString(owner.getId().toString(), 60, 948);
g.setFont(new Font("Century gothic", Font.BOLD, 40));
g.drawString(wholeName.toString(), 60, 950);
//g.drawString(card.getTemplate().getName(), 60, 915);
g.drawString(wholeName.toString(), 60, 865);
g.drawString(card.getTemplate().getName(), 60, 915);
PrintedCard printedCard = cardTemplateBean.checkPrintedCard(user);
g.setFont(new Font("Century gothic", Font.PLAIN, 30));
g.setColor(Color.white);
BufferedImage barCodeBufferedImage = null;
if (printedCard != null) {
int barcodeX = (base.getWidth() - 400) / 2;
int barcodeY = base.getHeight() - 50;
g.drawString(barcodeBean.getVrAuthCodeForCard(printedCard), 445, 905);
barCodeBufferedImage = ImageIO.read(barcodeBean.getCardBarcode(printedCard));
g.drawImage(barCodeBufferedImage, barcodeX, barcodeY, 400, barCodeBufferedImage.getHeight(), null);
g.setColor(Color.white);
}
//g.drawString(card.getTemplate().getName(), 60, 915);
//PrintedCard printedCard = cardTemplateBean.checkPrintedCard(user);
/* Ei insomniassa
g.setFont(new Font("Century gothic", Font.PLAIN, 30));
g.setColor(Color.white);
BufferedImage barCodeBufferedImage = null;
if (printedCard != null) {
int barcodeX = (base.getWidth() - 400) / 2;
int barcodeY = base.getHeight() - 50;
g.drawString(barcodeBean.getVrAuthCodeForCard(printedCard), 445, 905);
barCodeBufferedImage = ImageIO.read(barcodeBean.getCardBarcode(printedCard));
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();
......
Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!