| | |
| | | }
|
| | | g2d.setFont(font);
|
| | | try {
|
| | | g2d.setColor(new Color(153, 153, 153));
|
| | | // g2d.setColor(new Color(153, 153, 153));
|
| | | // 画第一张
|
| | | for (int i = 0; i < goodsList.size(); i++) {
|
| | | TaoBaoGoodsBrief goods = goodsList.get(i);
|
| | |
| | | g2d.setStroke(new BasicStroke(2.0f));
|
| | | g2d.drawLine(70 + 20, 674, 90 + 10 + textLength, 674);
|
| | |
|
| | | // 画券右侧
|
| | | BufferedImage quanRight = ImageIO
|
| | | .read(ImageUtil.class.getClassLoader().getResourceAsStream("image/fanli_quan_right.png"));
|
| | | quanRight = zoomInImage(quanRight, 12, 60);
|
| | | g2d.setColor(new Color(241, 66, 66));
|
| | | g2d.drawImage(quanRight, topX + 630 - quanRight.getWidth(), topY + 630 - quanRight.getHeight(),
|
| | | null);
|
| | | String quanString = "";
|
| | | BigDecimal withNoZera = MoneyBigDecimalUtil.getWithNoZera(goods.getCouponAmount());
|
| | | |
| | | if (!withNoZera.toString().endsWith("0")) {
|
| | | |
| | | // 画券右侧
|
| | | BufferedImage quanRight = ImageIO
|
| | | .read(ImageUtil.class.getClassLoader().getResourceAsStream("image/fanli_quan_right.png"));
|
| | | quanRight = zoomInImage(quanRight, 12, 60);
|
| | | g2d.setColor(new Color(241, 66, 66));
|
| | | g2d.drawImage(quanRight, topX + 630 - quanRight.getWidth(), topY + 630 - quanRight.getHeight(),
|
| | | null);
|
| | |
|
| | | // 画券的内容
|
| | | g2d.setColor(new Color(229, 0, 93));
|
| | | // 画券的内容
|
| | | g2d.setColor(new Color(229, 0, 93));
|
| | |
|
| | | String quanString = " " + MoneyBigDecimalUtil.getWithNoZera(goods.getCouponAmount()) + "元券 ";
|
| | | quanString = " " + withNoZera + "元券 ";
|
| | |
|
| | | font = font.deriveFont(36.0f);
|
| | | g2d.setFont(font);
|
| | | fm = g2d.getFontMetrics(font);
|
| | | textLength = fm.stringWidth(quanString);
|
| | | font = font.deriveFont(36.0f);
|
| | | g2d.setFont(font);
|
| | | fm = g2d.getFontMetrics(font);
|
| | | textLength = fm.stringWidth(quanString);
|
| | |
|
| | | g2d.fillRect(topX + 630 - quanRight.getWidth() - textLength, topY + 630 - quanRight.getHeight(),
|
| | | textLength, quanRight.getHeight());
|
| | | g2d.fillRect(topX + 630 - quanRight.getWidth() - textLength, topY + 630 - quanRight.getHeight(),
|
| | | textLength, quanRight.getHeight());
|
| | |
|
| | | g2d.setColor(Color.WHITE);
|
| | | g2d.drawString(quanString, topX + 630 - quanRight.getWidth() - textLength,
|
| | | topY + 630 + 42 - quanRight.getHeight());
|
| | | g2d.setColor(Color.WHITE);
|
| | | g2d.drawString(quanString, topX + 630 - quanRight.getWidth() - textLength,
|
| | | topY + 630 + 42 - quanRight.getHeight());
|
| | |
|
| | | // 画券左侧
|
| | | BufferedImage quanLeft = ImageIO
|
| | | .read(ImageUtil.class.getClassLoader().getResourceAsStream("image/fanli_quan_left.png"));
|
| | | quanLeft = zoomInImage(quanLeft, 12, 60);
|
| | | g2d.drawImage(quanLeft, topX + 630 - quanRight.getWidth() - textLength - quanLeft.getWidth(),
|
| | | topY + 630 - quanRight.getHeight(), null);
|
| | | // 画券左侧
|
| | | BufferedImage quanLeft = ImageIO
|
| | | .read(ImageUtil.class.getClassLoader().getResourceAsStream("image/fanli_quan_left.png"));
|
| | | quanLeft = zoomInImage(quanLeft, 12, 60);
|
| | | g2d.drawImage(quanLeft, topX + 630 - quanRight.getWidth() - textLength - quanLeft.getWidth(),
|
| | | topY + 630 - quanRight.getHeight(), null);
|
| | | }
|
| | |
|
| | | } else {
|
| | | // 计算左上角坐标
|
| | |
| | |
|
| | | // 画券
|
| | |
|
| | | // 画券右侧
|
| | | BufferedImage quanRight = ImageIO
|
| | | .read(ImageUtil.class.getClassLoader().getResourceAsStream("image/fanli_quan_right.png"));
|
| | | quanRight = zoomInImage(quanRight, 8, 40);
|
| | | g2d.setColor(new Color(241, 66, 66));
|
| | | g2d.drawImage(quanRight, topX + 315 - quanRight.getWidth(), topY + 315 - quanRight.getHeight(),
|
| | | null);
|
| | | String quanString = "";
|
| | | BigDecimal withNoZera = MoneyBigDecimalUtil.getWithNoZera(goods.getCouponAmount());
|
| | | |
| | | if (!withNoZera.toString().endsWith("0")) {
|
| | | |
| | | // 画券右侧
|
| | | BufferedImage quanRight = ImageIO
|
| | | .read(ImageUtil.class.getClassLoader().getResourceAsStream("image/fanli_quan_right.png"));
|
| | | quanRight = zoomInImage(quanRight, 8, 40);
|
| | | g2d.setColor(new Color(241, 66, 66));
|
| | | g2d.drawImage(quanRight, topX + 315 - quanRight.getWidth(), topY + 315 - quanRight.getHeight(),
|
| | | null);
|
| | |
|
| | | // 画券的内容
|
| | | g2d.setColor(new Color(229, 0, 93));
|
| | | // 画券的内容
|
| | | g2d.setColor(new Color(229, 0, 93));
|
| | | |
| | | quanString = " " + withNoZera + "元券 ";
|
| | | |
| | | font = font.deriveFont(24.0f);
|
| | | g2d.setFont(font);
|
| | | FontMetrics fm = g2d.getFontMetrics(font);
|
| | | int textLength = fm.stringWidth(quanString);
|
| | |
|
| | | String quanString = " " + MoneyBigDecimalUtil.getWithNoZera(goods.getCouponAmount()) + "元券 ";
|
| | | g2d.fillRect(topX + 315 - quanRight.getWidth() - textLength, topY + 315 - quanRight.getHeight(),
|
| | | textLength, quanRight.getHeight());
|
| | |
|
| | | font = font.deriveFont(24.0f);
|
| | | g2d.setFont(font);
|
| | | FontMetrics fm = g2d.getFontMetrics(font);
|
| | | int textLength = fm.stringWidth(quanString);
|
| | | g2d.setColor(Color.WHITE);
|
| | |
|
| | | g2d.fillRect(topX + 315 - quanRight.getWidth() - textLength, topY + 315 - quanRight.getHeight(),
|
| | | textLength, quanRight.getHeight());
|
| | | g2d.setFont(font);
|
| | | g2d.drawString(quanString, topX + 315 - quanRight.getWidth() - textLength,
|
| | | topY + 315 + 28 - quanRight.getHeight());
|
| | |
|
| | | g2d.setColor(Color.WHITE);
|
| | |
|
| | | g2d.setFont(font);
|
| | | g2d.drawString(quanString, topX + 315 - quanRight.getWidth() - textLength,
|
| | | topY + 315 + 28 - quanRight.getHeight());
|
| | |
|
| | | // 画券左侧
|
| | | BufferedImage quanLeft = ImageIO
|
| | | .read(ImageUtil.class.getClassLoader().getResourceAsStream("image/fanli_quan_left.png"));
|
| | | quanLeft = zoomInImage(quanLeft, 8, 40);
|
| | | g2d.drawImage(quanLeft, topX + 315 - quanRight.getWidth() - textLength - quanLeft.getWidth(),
|
| | | topY + 315 - quanRight.getHeight(), null);
|
| | | // 画券左侧
|
| | | BufferedImage quanLeft = ImageIO
|
| | | .read(ImageUtil.class.getClassLoader().getResourceAsStream("image/fanli_quan_left.png"));
|
| | | quanLeft = zoomInImage(quanLeft, 8, 40);
|
| | | g2d.drawImage(quanLeft, topX + 315 - quanRight.getWidth() - textLength - quanLeft.getWidth(),
|
| | | topY + 315 - quanRight.getHeight(), null);
|
| | | }
|
| | | |
| | | }
|
| | | }
|
| | |
|
| | |
| | | // g2d.drawString("返利券提醒您", 312, 1118 + 40);
|
| | |
|
| | | g2d.setColor(new Color(102, 102, 102));
|
| | | g2d.drawString("长按识别二维码领取优惠券", 312, 1118 + 77);
|
| | | g2d.drawString("长按识别二维码免费领券", 312, 1150);
|
| | | |
| | | g2d.setColor(new Color(102, 102, 102));
|
| | | g2d.drawString("共", 1000, 1150);
|
| | | |
| | | |
| | | g2d.setColor(new Color(229, 0, 93));
|
| | | g2d.drawString(goodsList.size()+"", 1055, 1150);
|
| | | |
| | | |
| | | g2d.setColor(new Color(102, 102, 102));
|
| | | g2d.drawString("个商品", 1090, 1150);
|
| | | |
| | | // 提示语
|
| | | BufferedImage tips = ImageIO
|
| | | .read(ImageUtil.class.getClassLoader().getResourceAsStream("image/share/tips1.png"));
|
| | | tips = zoomInImage(tips,850, 65);
|
| | | g2d.drawImage(tips, 312,1190, null);
|
| | |
|
| | | g2d.dispose();
|
| | |
|
| | | // OutputStream out = new ByteArrayOutputStream(); new
|
| | | // FileOutputStream(new File(targetPath));
|
| | | // ImageIO.write(targetImg, "JPEG", out);
|
| | | // out.flush();
|
| | | // out.close();
|
| | | ByteArrayOutputStream aos = new ByteArrayOutputStream();
|
| | | ImageIO.write(targetImg, "JPEG", aos);
|
| | | InputStream is = new ByteArrayInputStream(aos.toByteArray());
|