<rt id="bn8ez"></rt>
<label id="bn8ez"></label>

  • <span id="bn8ez"></span>

    <label id="bn8ez"><meter id="bn8ez"></meter></label>

    Johnny

    表面的激烈是由于內心的單薄,真正的力量如同流水一般沉靜
    隨筆 - 1, 文章 - 5, 評論 - 0, 引用 - 0
    數據加載中……

    2012年11月2日

    迅雷下載開放引擎Demo的 Java版本+注釋版

         摘要: Code highlighting produced by Actipro CodeHighlighter (freeware)http://www.CodeHighlighter.com/-->package skj.thunder;import com.sun.jna.Native;import com.sun.jna.NativeLong;import ...  閱讀全文

    posted @ 2012-11-02 17:44 瓢菝的雨夜| 編輯 收藏

    2012年10月21日

    POI Excel小工具類

      1 package poi.excel;
      2 
      3 import java.awt.Graphics;
      4 import java.awt.Image;
      5 import java.awt.image.BufferedImage;
      6 import java.io.ByteArrayOutputStream;
      7 import java.io.FileInputStream;
      8 import java.io.IOException;
      9 import javax.imageio.ImageIO;
     10 import org.apache.poi.hssf.usermodel.HSSFClientAnchor;
     11 import org.apache.poi.hssf.usermodel.HSSFPatriarch;
     12 import org.apache.poi.hssf.usermodel.HSSFPicture;
     13 import org.apache.poi.hssf.usermodel.HSSFSheet;
     14 import org.apache.poi.hssf.usermodel.HSSFWorkbook;
     15 
     16 /**
     17  * poi HSSF 提取點方法
     18  * @author sikaijian
     19  */
     20 public class Excel03Util {
     21     /**
     22      * 畫圖片
     23      * @param sheet
     24      * @param wb
     25      * @param startCol
     26      * @param startRow
     27      * @param endCol
     28      * @param endRow
     29      * @param pictureIndex 圖片索引號 需要先在workbook中加入圖片資源
     30      * @throws IOException
     31      * @author sikaijian
     32      */
     33     public static void drawPicture(HSSFSheet sheet, HSSFWorkbook wb,
     34             short startCol, int startRow, short endCol, int endRow,
     35             int pictureIndex) throws IOException {
     36         // 圖片容器
     37         HSSFPatriarch patriarch = sheet.createDrawingPatriarch();
     38         
     39         // 錨點 容器下錨位置
     40         HSSFClientAnchor anchor = new HSSFClientAnchor(0, 0, 0, 255, startCol,
     41                 startRow, endCol, endRow);
     42         anchor.setAnchorType(2);
     43         
     44         // 容器下錨,并載入圖片
     45         HSSFPicture picture = patriarch.createPicture(anchor, pictureIndex);
     46 
     47         picture.resize();
     48         picture.setLineStyle(picture.LINESTYLE_DASHDOTGEL);
     49     }
     50 
     51     /**
     52      * 加載圖片
     53      * @param img 圖片對象
     54      * @param wb
     55      * @return 圖片索引號
     56      * @throws IOException
     57      * @author sikaijian
     58      */
     59     public static int loadPicture(Image img, HSSFWorkbook wb)
     60             throws IOException {
     61         int pictureIndex;
     62         ByteArrayOutputStream arrayOut = null;
     63         try {
     64             arrayOut = new ByteArrayOutputStream();
     65             BufferedImage buImage = new BufferedImage(img.getWidth(null), img
     66                     .getHeight(null), BufferedImage.TYPE_INT_RGB);
     67             Graphics g = buImage.getGraphics();
     68             g.drawImage(img, 0, 0, null);
     69             ImageIO.write(buImage, "png", arrayOut);
     70 
     71             byte[] data = arrayOut.toByteArray();
     72 
     73             pictureIndex = wb.addPicture(data, HSSFWorkbook.PICTURE_TYPE_PNG);
     74         } finally {
     75             if (null != arrayOut) {
     76                 arrayOut.close();
     77             }
     78         }
     79 
     80         return pictureIndex;
     81     }
     82 
     83     /**
     84      * 加載圖片
     85      * @param path 圖片路徑
     86      * @param wb
     87      * @return 圖片索引號
     88      * @throws IOException
     89      */
     90     public static int loadPicture(String path, HSSFWorkbook wb)
     91             throws IOException {
     92         int pictureIndex;
     93         FileInputStream fis = null;
     94         ByteArrayOutputStream bos = null;
     95         try {
     96             fis = new FileInputStream(path);
     97             bos = new ByteArrayOutputStream();
     98             int c;
     99             while ((c = fis.read()) != -1)
    100                 bos.write(c);
    101             pictureIndex = wb.addPicture(bos.toByteArray(),
    102                     HSSFWorkbook.PICTURE_TYPE_PNG);
    103         } finally {
    104             if (fis != null)
    105                 fis.close();
    106             if (bos != null)
    107                 bos.close();
    108         }
    109         return pictureIndex;
    110     }
    111 }
    112 

    posted @ 2012-10-21 17:43 瓢菝的雨夜 閱讀(728) | 評論 (0)編輯 收藏

    2012年9月21日

    希爾排序Java代碼

    /**
     * 希爾排序
     * 
    @author sikaijian
     
    */
    public class ShellSort {
        public static void sort(int[] data){
            int d = data.length/2;
            while(d!=0){
                directInsertSort(data, d);
                d/=2;
            }
        }
        
        /**
         * 帶增量的直接插入排序
         * 
    @param data 待排序數組
         * 
    @param d 增量
         
    */
        private static void directInsertSort(int[] data, int d){
            int len = data.length;
            
            for(int i=0; i+d<len; i++){
                int pCurrent = i+d;
                int left = i-1;
                while(pCurrent<len){
                    int front = pCurrent-d;
                    int key = data[pCurrent];
                    while(front>left && data[front]>key){
                        data[front+d] = data[front];
                        front-=d;
                    }
                    data[front+d] = key;
                    
                    pCurrent+=d;
                }
            }
        }
        
        public static void showArray(int[] array){
            for (int t : array) {
                System.out.print(t);
                System.out.print(" ");
            }
        }
        
        /**
         * 測試代碼
         * 
    @param args
         
    */
        public static void main(String[] args) {
            int[] data = new int[] { 49, 23, 65, 13, 38, 96, 12, 33, 88, 123, 22,
                    11, 9, 55, 111, 0 };

            showArray(data);
            System.out.println();
            System.out.println("------------------------------");
            ShellSort.sort(data);

            showArray(data);
        }
    }

    posted @ 2012-09-21 17:30 瓢菝的雨夜 閱讀(171) | 評論 (0)編輯 收藏

    直接插入排序Java代碼

    /**
     * 直接插入排序
     * 
    @author sikaijian
     
    */
    public class DirectInsertSort {
        public static void sort(int[] data){
            int pCurrent = 1;   // 認定第0個數是有序的,從第1個數開始插入排序
            int n = data.length;
            
            while(pCurrent<n){
                int front = pCurrent-1;
                int key = data[pCurrent];
                
                // 當前要插入的數和左邊的有序隊列比較(從右往左比較,比較一次移動一次)
                while(front>-1 && key<data[front]){
                    data[front+1] = data[front];
                    front--;
                }
                
                data[front+1] = key;
                
                pCurrent++;
            }
        }
        
        /**
         * 測試代碼
         * 
    @param args
         
    */
        public static void main(String[] args) {
            int[] data = new int[] { 49, 23, 65, 13, 38, 96, 12, 33, 88, 123, 22,
                    11, 9, 55, 111, 0 };

            for (int t : data) {
                System.out.print(t);
                System.out.print(" ");
            }
            System.out.println();
            System.out.println("------------------------------");
            DirectInsertSort.sort(data);

            for (int t : data) {
                System.out.print(t);
                System.out.print(" ");
            }
        }
    }

    posted @ 2012-09-21 14:23 瓢菝的雨夜 閱讀(209) | 評論 (0)編輯 收藏

    冒泡排序Java代碼


    /**
     * 冒泡排序
     * 
    @author sikaijian
     
    */
    public class BubbleSort {
        public static void sort(int[] data){
            if(data.length<=1) return;
            
            /**
    * 每一趟排序都把最大的數字放到最后
    * 下一趟排序后,最大的數不參加
    * 總共n-1趟(n為數組長度)
    */
            for (int i = data.length-1; i > 0; i--) {
                for (int j = 0; j < i; j++) {
                    if(data[j]>data[j+1]){
                        int temp = data[j];
                        data[j] = data[j+1];
                        data[j+1] = temp;
                    }
                }
            }
        }
        
        /**
         * 測試代碼
         * 
    @param args
         
    */
        public static void main(String[] args) {
            int[] data = new int[] { 49, 23, 65, 13, 38, 96, 12, 33, 88, 123, 22,
                    11, 9, 55, 111, 0 };

            for (int t : data) {
                System.out.print(t);
                System.out.print(" ");
            }
            System.out.println();
            System.out.println("------------------------------");
            BubbleSort.sort(data);

            for (int t : data) {
                System.out.print(t);
                System.out.print(" ");
            }
        }
    }

    posted @ 2012-09-21 13:32 瓢菝的雨夜 閱讀(133) | 評論 (0)編輯 收藏

    快速排序Java代碼

    /**
     * 
    @author sikaijian
     
    */
    public class QuickSort {
        
        /**
         * 快速排序算法實現
         * 
    @param data 待排序數組
         * 
    @param left 左邊界 初始0
         * 
    @param right 右邊界 初始數組長度-1
         * 
    @author sikaijian
         
    */
        public static void sort(int[] data, int left, int right) {
            if (left > right)
                return;
            int pHead = left;  // 頭部指針
            int pTail = right;  // 尾部指針
            int key = data[left];  // 哨兵

            while (pHead < pTail) {
                // 從右往左遍歷,找到比key小的數,放到前面
                while (pHead < pTail && data[pTail] > key) pTail--;
                if (pHead < pTail) data[pHead++] = data[pTail];
                
                // 從左往右遍歷,找到比key大的數,放到后面
                while (pHead < pTail && data[pHead] < key) pHead++;
                if (pHead < pTail) data[pTail--] = data[pHead];
            }
            
            data[pHead] = key; // 歸位
            
            sort(data, left, pHead-1);  // 排序左邊的數組
            sort(data, pHead+1, right);  // 排序右邊的數組
        }
        
        /**
         * 測試代碼
         * 
    @param args
         
    */
        public static void main(String[] args) {
            int[] data = new int[] { 49, 23, 65, 13, 38, 96, 12, 33, 88, 123, 22,
                    11, 9, 55 };

            for (int t : data) {
                System.out.print(t);
                System.out.print(" ");
            }
            System.out.println();
            System.out.println("------------------------------");
            QuickSort.sort(data, 0, data.length - 1);

            for (int t : data) {
                System.out.print(t);
                System.out.print(" ");
            }
        }
    }

    posted @ 2012-09-21 11:01 瓢菝的雨夜 閱讀(214) | 評論 (0)編輯 收藏

    主站蜘蛛池模板: 国产拍拍拍无码视频免费| 成年性羞羞视频免费观看无限| 亚洲香蕉免费有线视频| 在线A级毛片无码免费真人| 亚洲国产免费综合| 亚洲宅男天堂a在线| 亚洲成网777777国产精品| 美丽姑娘免费观看在线观看中文版| 亚洲中文无码永久免费| 国产亚洲一区二区三区在线不卡| 99久久免费国产香蕉麻豆| 男女啪啪免费体验区| 亚洲国产精品yw在线观看| 亚洲成?v人片天堂网无码| 四虎在线免费视频| 免费在线黄色电影| 亚洲AV无码一区二区乱子仑 | 免费在线精品视频| 18观看免费永久视频| 一级**爱片免费视频| 亚洲精品美女久久久久久久| 水蜜桃亚洲一二三四在线 | 中文字幕乱码亚洲精品一区| 国产亚洲高清不卡在线观看| 国产成人无码免费视频97| 日本h在线精品免费观看| 99精品免费视品| 色妞www精品视频免费看| 亚洲a级在线观看| 亚洲精品自产拍在线观看动漫| 亚洲成a人片在线播放| 美女视频黄a视频全免费| 久久99热精品免费观看牛牛| 无码AV动漫精品一区二区免费 | 校园亚洲春色另类小说合集| 亚洲日韩中文字幕| 亚洲嫩模在线观看| 亚洲精品美女久久777777| 亚洲国产成人久久一区WWW| 性做久久久久免费看| 成人免费看吃奶视频网站|