亚洲精品久久久久久第一页-人妻少妇精彩视品一区二区三区-91国产自拍免费视频-免费一级a在线播放视频正片-少妇天天日天天射天天爽-国产大屁股喷水视频在线观看-操美女骚穴抽插性爱视频-亚洲 欧美 中文字幕 丝袜-成人免费无码片在线观看

java畫圖像表格 java繪圖程序代碼

直接上代碼
畫線的精髓在這        // 字體大小        int fontTitileSize = 12;        // 橫線的行數(shù)        int totalrow = 16;        // 豎線的行數(shù)        int totalcol = 10;        // 圖片寬度        int imageWidth = 700;        // 行高        int rowheight = 38;        // 圖片高度        int imageHeight = totalrow*rowheight+41;        // 起始高度        int startHeight = 70;        // 起始寬度        int startWidth = 0;        // 單元格寬度        int colwidth = 60;// 初始化畫筆 BufferedImage image = new BufferedImage(imageWidth, imageHeight,BufferedImage.TYPE_INT_RGB);Graphics graphics = image.getGraphics();        graphics.setColor(Color.WHITE);        graphics.fillRect(0,0, imageWidth, imageHeight);        graphics.setColor(new Color(220,240,240));        int tmpWidth = 5;        graphics.setColor(Color.black);        graphics.drawLine(startWidth, startHeight, startWidth+10*colwidth, startHeight); //劃線是根據(jù)開始坐標(biāo)和結(jié)束坐標(biāo)兩點畫一條線的 。//縱坐標(biāo)不變畫的是一條橫線// 橫坐標(biāo)不變畫的是一條豎線,如下 graphics.drawLine(startWidth+10*colwidth, startHeight, startWidth+10*colwidth, startHeight+15*rowheight);
畫完線之后,如何寫上文本呢 //設(shè)置字體        Font font = new Font("微軟雅黑",Font.PLAIN,fontTitileSize);        graphics.setFont(font);       graphics.drawString("文本內(nèi)容", 0, 40);//  什么意思呢,即 在(0,40)這個點的位置,寫文本
最后生成圖片調(diào)用 createImage(image, path);public static void createImage(BufferedImage image, String fileLocation) {        FileOutputStream fos = null;        BufferedOutputStream bos = null;            fos = new FileOutputStream(fileLocation);        bos = new BufferedOutputStream(fos);//            JPEGImageEncoder encoder = JPEGCodec.createJPEGEncoder(bos);//            encoder.encode(image);            ImageIO.write(image,"jpg",bos)    }起初,需要用到
com.sum.image.codec.jpeg.JPEGImageEncoder這個類,但是這個是rt.jar包中的sun私有包,涉及到版權(quán)的問題,關(guān)鍵是一些大公司使用的是openjdk,這個openjdk簡單的理解就是開源精簡版,它是沒有sun這個包的,那么就會出現(xiàn)java.lang.NoclassDefFoundError這個錯誤,在openjdk下,建議用


以上關(guān)于本文的內(nèi)容,僅作參考!溫馨提示:如遇健康、疾病相關(guān)的問題,請您及時就醫(yī)或請專業(yè)人士給予相關(guān)指導(dǎo)!

「愛刨根生活網(wǎng)」www.malaban59.cn小編還為您精選了以下內(nèi)容,希望對您有所幫助: