From a70d35cd9a672deb0aed272c8209ddde096f917b Mon Sep 17 00:00:00 2001 From: 喻健 <喻健@Admin> Date: 星期三, 12 十二月 2018 10:25:08 +0800 Subject: [PATCH] 动态商品分享接口修改,添加新接口, 画图调整 --- fanli/src/main/java/com/yeshi/fanli/util/ImageUtil.java | 142 +++++++++++++++++++++++++++++------------------ 1 files changed, 87 insertions(+), 55 deletions(-) diff --git a/fanli/src/main/java/com/yeshi/fanli/util/ImageUtil.java b/fanli/src/main/java/com/yeshi/fanli/util/ImageUtil.java index 402fb29..074b2da 100644 --- a/fanli/src/main/java/com/yeshi/fanli/util/ImageUtil.java +++ b/fanli/src/main/java/com/yeshi/fanli/util/ImageUtil.java @@ -526,7 +526,7 @@ } 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); @@ -572,37 +572,43 @@ 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 { // 璁$畻宸︿笂瑙掑潗鏍� @@ -638,39 +644,46 @@ // 鐢诲埜 - // 鐢诲埜鍙充晶 - 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); + } + } } @@ -698,7 +711,26 @@ // g2d.drawString("杩斿埄鍒告彁閱掓偍", 312, 1118 + 40); g2d.setColor(new Color(102, 102, 102)); - g2d.drawString("闀挎寜璇嗗埆浜岀淮鐮侀鍙栦紭鎯犲埜", 312, 1118 + 77); + g2d.drawString("闀挎寜璇嗗埆浜岀淮鐮佸厤璐归鍒�", 312, 1142); + + g2d.setColor(new Color(102, 102, 102)); + g2d.drawString("鍏�", 1000, 1142); + + + g2d.setColor(new Color(229, 0, 93)); + g2d.drawString(goodsList.size()+"", 1055, 1142); + + + g2d.setColor(new Color(102, 102, 102)); + g2d.drawString("涓晢鍝�", 1090, 1142); + + // 鎻愮ず璇� + BufferedImage tips = ImageIO + .read(ImageUtil.class.getClassLoader().getResourceAsStream("image/share/tips1.png")); + tips = zoomInImage(tips,850, 65); + //g2d.setColor(new Color(255, 250, 250)); + g2d.drawImage(tips, 312,1180, null); + g2d.dispose(); -- Gitblit v1.8.0