「java自带的logo」java自带的logger

博主:adminadmin 2022-11-28 20:58:08 60

本篇文章给大家谈谈java自带的logo,以及java自带的logger对应的知识点,希望对各位有所帮助,不要忘了收藏本站喔。

本文目录一览:

用Java绘制百度logo?

//可以通过水印的方法打上去。

 import java.awt.AlphaComposite;

 import java.awt.Color;

 import java.awt.Font;

 import java.awt.Graphics2D;

 import java.awt.Image;

 import java.awt.geom.AffineTransform;

 import java.awt.image.AffineTransformOp;

 import java.awt.image.BufferedImage;

 import java.io.File;

 import java.io.IOException;

 

 import javax.imageio.ImageIO;

 

 /**

  * 图片工具类, 图片水印,文字水印,缩放,补白等

  */

 public final class ImageUtils {

     

     

     /**图片格式:JPG*/

     private static final String PICTRUE_FORMATE_JPG = "jpg";

     

     private ImageUtils(){}

     /**

      * 添加图片水印

      * @param targetImg 目标图片路径,如:C://myPictrue//1.jpg

      * @param waterImg  水印图片路径,如:C://myPictrue//logo.png

      * @param x 水印图片距离目标图片左侧的偏移量,如果x0, 则在正中间

      * @param y 水印图片距离目标图片上侧的偏移量,如果y0, 则在正中间

      * @param alpha 透明度(0.0 -- 1.0, 0.0为完全透明,1.0为完全不透明)

 */

     public final static void pressImage(String targetImg, String waterImg, int x, int y, float alpha) {

             try {

                 File file = new File(targetImg);

                 Image image = ImageIO.read(file);

                 int width = image.getWidth(null);

                 int height = image.getHeight(null);

                 BufferedImage bufferedImage = new BufferedImage(width, height, BufferedImage.TYPE_INT_RGB);

                 Graphics2D g = bufferedImage.createGraphics();

                 g.drawImage(image, 0, 0, width, height, null);

             

                 Image waterImage = ImageIO.read(new File(waterImg));    // 水印文件

                 int width_1 = waterImage.getWidth(null);

                 int height_1 = waterImage.getHeight(null);

                 g.setComposite(AlphaComposite.getInstance(AlphaComposite.SRC_ATOP, alpha));

                 

                 int widthDiff = width - width_1;

                 int heightDiff = height - height_1;

                 if(x  0){

                     x = widthDiff / 2;

                 }else if(x  widthDiff){

                     x = widthDiff;

                 }

                 if(y  0){

                     y = heightDiff / 2;

                 }else if(y  heightDiff){

                     y = heightDiff;

                 }

                 g.drawImage(waterImage, x, y, width_1, height_1, null); // 水印文件结束

                 g.dispose();

                 ImageIO.write(bufferedImage, PICTRUE_FORMATE_JPG, file);

             } catch (IOException e) {

                 e.printStackTrace();

             }

     }

 

     /**

      * 添加文字水印

      * @param targetImg 目标图片路径,如:C://myPictrue//1.jpg

      * @param pressText 水印文字, 如:中国证券网

      * @param fontName 字体名称,    如:宋体

      * @param fontStyle 字体样式,如:粗体和斜体(Font.BOLD|Font.ITALIC)

      * @param fontSize 字体大小,单位为像素

      * @param color 字体颜色

      * @param x 水印文字距离目标图片左侧的偏移量,如果x0, 则在正中间

      * @param y 水印文字距离目标图片上侧的偏移量,如果y0, 则在正中间

      * @param alpha 透明度(0.0 -- 1.0, 0.0为完全透明,1.0为完全不透明)

 */

     public static void pressText(String targetImg, String pressText, String fontName, int fontStyle, int fontSize, Color color, int x, int y, float alpha) {

         try {

             File file = new File(targetImg);

             

             Image image = ImageIO.read(file);

             int width = image.getWidth(null);

             int height = image.getHeight(null);

             BufferedImage bufferedImage = new BufferedImage(width, height, BufferedImage.TYPE_INT_RGB);

             Graphics2D g = bufferedImage.createGraphics();

             g.drawImage(image, 0, 0, width, height, null);

             g.setFont(new Font(fontName, fontStyle, fontSize));

             g.setColor(color);

             g.setComposite(AlphaComposite.getInstance(AlphaComposite.SRC_ATOP, alpha));

             

             int width_1 = fontSize * getLength(pressText);

             int height_1 = fontSize;

             int widthDiff = width - width_1;

             int heightDiff = height - height_1;

             if(x  0){

                 x = widthDiff / 2;

             }else if(x  widthDiff){

                 x = widthDiff;

             }

             if(y  0){

                 y = heightDiff / 2;

             }else if(y  heightDiff){

                 y = heightDiff;

             }

             

             g.drawString(pressText, x, y + height_1);

             g.dispose();

             ImageIO.write(bufferedImage, PICTRUE_FORMATE_JPG, file);

         } catch (Exception e) {

             e.printStackTrace();

         }

     }

     

     /**

      * 获取字符长度,一个汉字作为 1 个字符, 一个英文字母作为 0.5 个字符

      * @param text

      * @return 字符长度,如:text="中国",返回 2;text="test",返回 2;text="中国ABC",返回 4.

 */

     public static int getLength(String text) {

         int textLength = text.length();

         int length = textLength;

         for (int i = 0; i  textLength; i++) {

             if (String.valueOf(text.charAt(i)).getBytes().length  1) {

                 length++;

             }

         }

         return (length % 2 == 0) ? length / 2 : length / 2 + 1;

     }

 

     /**

      * 图片缩放

      * @param filePath 图片路径

      * @param height 高度

      * @param width 宽度

      * @param bb 比例不对时是否需要补白

 */

     public static void resize(String filePath, int height, int width, boolean bb) {

         try {

             double ratio = 0; //缩放比例    

             File f = new File(filePath);   

             BufferedImage bi = ImageIO.read(f);   

             Image itemp = bi.getScaledInstance(width, height, BufferedImage.SCALE_SMOOTH);   

             //计算比例   

             if ((bi.getHeight()  height) || (bi.getWidth()  width)) {   

                 if (bi.getHeight()  bi.getWidth()) {   

                     ratio = (new Integer(height)).doubleValue() / bi.getHeight();   

                 } else {   

                     ratio = (new Integer(width)).doubleValue() / bi.getWidth();   

                 }   

                 AffineTransformOp op = new AffineTransformOp(AffineTransform.getScaleInstance(ratio, ratio), null);   

                 itemp = op.filter(bi, null);   

             }   

             if (bb) {   

                 BufferedImage image = new BufferedImage(width, height, BufferedImage.TYPE_INT_RGB);   

                 Graphics2D g = image.createGraphics();   

                 g.setColor(Color.white);   

                 g.fillRect(0, 0, width, height);   

                 if (width == itemp.getWidth(null))   

                     g.drawImage(itemp, 0, (height - itemp.getHeight(null)) / 2, itemp.getWidth(null), itemp.getHeight(null), Color.white, null);   

                 else  

                     g.drawImage(itemp, (width - itemp.getWidth(null)) / 2, 0, itemp.getWidth(null), itemp.getHeight(null), Color.white, null);   

                 g.dispose();   

                 itemp = image;   

             }

             ImageIO.write((BufferedImage) itemp, "jpg", f);   

         } catch (IOException e) {

             e.printStackTrace();

         }

     }

 

     public static void main(String[] args) throws IOException {

      pressImage("D:/2.jpg", "D:/1.jpg", 0, 0, 1);

       System.out.println("处理完毕!");

     }

     

 }

原文:

Java为什么是一个咖啡标志?

1.第一个版本

2000年度的JavaOne国际会议大厅热闹非凡,一阵阵浓郁的咖啡味儿香气扑鼻。从世界各地汇集到旧金山参加会议的Java精英们兴奋异常,排着长队,等待得到一杯由Java语言控制的咖啡机煮制的免费咖啡。这是一个特殊设计的全透明咖啡机。当您按下按钮时,咖啡豆从玻璃管输送到研磨器。磨制后的咖啡粉由另一个玻璃管送到煮制机。沸腾的水滴入咖啡粉中,一杯醇香四溢的咖啡传送到您的手中…由此可见JAVA和咖啡有着不解之缘。

2.第二个版本

最初这个为TV机顶盒所设计的语言在公司内部一直称为Green项目。“我们的新语言需要一个名字。” 简姆斯.古斯林一直在考虑这个问题。 有一天,简姆斯·古斯林注意到自己办公室外一棵茂密的橡树Oak,这是一种在硅谷很常见的树。所以他将这个新语言命名为Oak。但Oak是另外一个注册公司的名字。这个名字不可能再用了。如果通过正式程序来注册产品的名称将既费时又费钱。简姆斯·古斯林决定通过市场部门,请来了一个命名顾问,召开命名征集会。当时,因为没有一个合适的名字,他们不得不延后这个语言的面世。在命名征集会上,大家提出了很多名字。最后按大家的评选次序,将十几个名字排列成表,上报给商标律师。排在第一位的是Silk(丝绸)。尽管大家都喜欢这个名字,但遭到简姆斯·古斯林的坚决反对而作罢。排在第二和第三的都没有通过律师这一关。简姆斯·古斯林最喜欢的就是排在第三位的Lyric(抒情诗)。只有排在第四位的名字、得到了所有人的认可和律师的通过。这个名字就是Java。

3.第三个版本

还有一种说法是马克·奥颇门一家咖啡店与同事品尝咖啡时得到灵感的。Java是印度尼西亚爪哇岛的英文名称,因盛产咖啡而闻名。国外的许多咖啡店用Java来命名或宣传,以彰显其咖啡的品质。

Java语言中的许多库类名称,多与咖啡有关。JavaBeans(咖啡豆)、NetBeans(网络豆)以及ObjectBeans (对象豆)等等。从此一个即好听又好记、具有强大的生命力的编程语言Java诞生了。

哪种版本更能说服你呢?如今Java在行业中依然拥有巨大的潜力,让我们一起学习,一起交流,一起成长,共同努力发展壮大这个功能强大的编程语言。

java的品牌来源

JAVA(中文名佳沃)最初源自设计师名字的组合:JACOPOGOSLING(雅科波·高斯林)Andrea.WILIER(安德列亚·威廉)VITTORIO(维托里奥)ALBERTO.BARIN(阿尔伯特·博瑞),JAVA意大利设计团队的努力,同时这个名字也是出于JAVA团队对咖啡的喜爱,所以以Java咖啡来命名。JAVA是印度尼西亚爪哇岛的英文名称,因盛产咖啡而著名。JAVA自行车中的许多车类名称多与咖啡有关。如DECAF(去咖啡因的咖啡),ESPRESSO(浓缩咖啡)以及MOKA(摩卡)等等,同时JAVA的LOGO也正如一杯冒着热气的咖啡。

java自带的logo的介绍就聊到这里吧,感谢你花时间阅读本站内容,更多关于java自带的logger、java自带的logo的信息别忘了在本站进行查找喔。

The End

发布于:2022-11-28,除非注明,否则均为首码项目网原创文章,转载请注明出处。