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

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

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

    posts - 41, comments - 15, trackbacks - 0, articles - 1
      BlogJava :: 首頁 :: 新隨筆 :: 聯系 :: 聚合  :: 管理

    2014年6月24日

    有時候在客戶端使用svg畫圖,而在服務器端需要同樣的圖片,在服務器端重新畫一遍是非常費事的。這時候我們就可以利用已有的svg直接通過下面的類轉換成png格式。

    使用這個方法需要引用batic相關的包,maven pom文件如下:

    <!-- svg 生成png格式圖片  -->
    <dependency><groupId>batik</groupId><artifactId>batik-svggen</artifactId><version>1.6</version></dependency>        
    <dependency><groupId>batik</groupId><artifactId>batik-awt-util</artifactId><version>1.6</version></dependency>
    <dependency><groupId>batik</groupId><artifactId>batik-bridge</artifactId><version>1.6</version></dependency>
    <dependency><groupId>batik</groupId><artifactId>batik-css</artifactId><version>1.6</version></dependency>
    <dependency><groupId>batik</groupId><artifactId>batik-dom</artifactId><version>1.6</version></dependency>
    <dependency><groupId>batik</groupId><artifactId>batik-gvt</artifactId><version>1.6</version></dependency>
    <dependency><groupId>batik</groupId><artifactId>batik-parser</artifactId><version>1.6</version></dependency>
    <dependency><groupId>batik</groupId><artifactId>batik-script</artifactId><version>1.6</version></dependency>
    <dependency><groupId>batik</groupId><artifactId>batik-svg-dom</artifactId><version>1.6</version></dependency>
    <dependency><groupId>batik</groupId><artifactId>batik-transcoder</artifactId><version>1.6</version></dependency>
    <dependency><groupId>batik</groupId><artifactId>batik-util</artifactId><version>1.6</version></dependency>
    <dependency><groupId>batik</groupId><artifactId>batik-xml</artifactId><version>1.6</version></dependency>
    <!-- 此處不能使用2.9.1版本,使用2.9.1生成png會失敗 -->
    <dependency><groupId>xerces</groupId><artifactId>xercesImpl</artifactId><version>2.5.0</version></dependency>
    <dependency><groupId>xml-apis</groupId><artifactId>xmlParserAPIs</artifactId><version>2.0.2</version></dependency>
    <dependency><groupId>org.axsl.org.w3c.dom.svg</groupId><artifactId>svg-dom-java</artifactId><version>1.1</version></dependency>
    <dependency><groupId>xml-apis</groupId>    <artifactId>xml-apis</artifactId><version>2.0.0</version></dependency>
    <dependency><groupId>org.w3c.css</groupId> <artifactId>sac</artifactId>    <version>1.3</version></dependency>
    <!-- svg 生成png格式圖片結束  -->
    package com.yhb.web.util;
    import java.io.ByteArrayInputStream;
    import java.io.File;
    import java.io.FileOutputStream;
    import java.io.IOException;
    import java.io.InputStream;
    import java.io.OutputStream;
    import java.io.UnsupportedEncodingException;
    import java.net.URL;
    import org.apache.batik.transcoder.TranscoderException;
    import org.apache.batik.transcoder.TranscoderInput;
    import org.apache.batik.transcoder.TranscoderOutput;
    import org.apache.batik.transcoder.image.PNGTranscoder;
    public final class FileUtil {
    /** 
         *@Description: 將svg字符串轉換為png 
         *@Author: 
         *@param svgCode svg代碼 
         *@param pngFilePath  保存的路徑 
         *@throws IOException io異常 
         *@throws TranscoderException svg代碼異常 
        */  
    public static void convertToPng(String svgCode,String pngFilePath) throws IOException,TranscoderException{  
     
            File file = new File (pngFilePath);  
      
            FileOutputStream outputStream = null;  
            try {  
                file.createNewFile ();  
                outputStream = new FileOutputStream (file);  
                convertToPng (svgCode, outputStream);  
            } finally {  
                if (outputStream != null) {  
                    try {  
                        outputStream.close ();  
                    } catch (IOException e) {  
                        e.printStackTrace ();  
                    }  
                }  
            }  
        }  
    /** 
         *@Description: 將svgCode轉換成png文件,直接輸出到流中 
         *@param svgCode svg代碼 
         *@param outputStream 輸出流 
         *@throws TranscoderException 異常 
         *@throws IOException io異常 
         */  
        public static void convertToPng(String svgCode,OutputStream outputStream) throws TranscoderException,IOException{  
            try {  
            byte[] bytes = svgCode.getBytes ("UTF-8");  
                PNGTranscoder t = new PNGTranscoder ();  
                TranscoderInput input = new TranscoderInput (new ByteArrayInputStream (bytes));  
                TranscoderOutput output = new TranscoderOutput (outputStream);  
                t.transcode (input, output);  
                outputStream.flush ();  
            } finally {  
                if (outputStream != null) {  
                    try {  
                        outputStream.close ();  
                    } catch (IOException e) {  
                        e.printStackTrace ();  
                    }  
                }  
            }  
        }  
    }

    posted @ 2015-10-19 15:17 yuhaibo736 閱讀(314) | 評論 (0)編輯 收藏

    方法1: 設定環境變量
    set NLS_SORT=SCHINESE_RADICAL_M ;export NLS_SORT (sh)
    or setenv NLS_SORT SCHINESE_RADICAL_M (csh)
    or regedit 
    HKLC/SOFTWARE/ORACLE/home0/NLS_SORT        (win)

    方法2: 在session中修改
    alter session set NLS_SORT='SCHINESE_RADICAL_M'

    方法3: 直接使用NLSSORT函數 (推薦)
    select name,id from t
    order by NLSSORT(name,'NLS_SORT = SCHINESE_STROKE_M')

    設置NLS_SORT值:

    SCHINESE_RADICAL_M 按照部首(第一順序)、筆劃(第二順序)排序 

    SCHINESE_STROKE_M 按照筆劃(第一順序)、部首(第二順序)排序 

    SCHINESE_PINYIN_M 按照拼音排序

    posted @ 2014-08-29 14:13 yuhaibo736 閱讀(1286) | 評論 (0)編輯 收藏

        在IBATIS中,框架內置了對OSCache的支持,如果我們想使用EHCache,則需要通過我們手工實現來完成二級緩存的功能機制。

        在mybatis中,開發組織只提供了一些默認的二級緩存實現的機制,并沒有直接內置的支持OSCache和EHCache等二級緩存機制,而是作為一個集成jar包來提供二級緩存的實現,在官方網站上我們可以找到mybatis-ehcache-1.0.1-bundle.zip,mybatis-oscache-1.0.1-bundle.zip等ehcache和oscache提供二級緩存的獨立工具包. 這里我就拿oscache在mybatis中的使用來舉例說明:

           1.   將mybatis-oscache-1.0.1-bundle.zip中涉及到的jar包放入到classpath路徑下 
                 maven下可以這樣配置
                   <dependencies>  
                        
    ... 

                        <dependency> 

                            <groupId>org.mybatis.caches</groupId> 

                            <artifactId>mybatis-oscache</artifactId>      
                             <version>1.0.2-SNAPSHOT</version> 

                        </dependency>             

                        <dependency>
                            <groupId>javax.jms</groupId>
                            <artifactId>jms</artifactId>
                            <version>1.1</version>
                        </dependency>

                        <dependency>
                             <groupId>opensymphony</groupId>
                             <artifactId>oscache</artifactId>
                             <version>2.4</version>
                             <exclusions>       
                                   <exclusion>
                                       <groupId>com.sun.jdmk</groupId>
                                       <artifactId>jmxtools</artifactId>
                                   </exclusion>
                               <exclusion>
                               <groupId>com.sun.jmx</groupId>
                               <artifactId>jmxri</artifactId>
                           </exclusion>
                         </exclusions>
                    </dependency>

                        ... 

                    </dependencies>

           2.   在mapper文件中的配置如下:

                 <mapper namespace="org.test.AuthMapper" >         

                     <cache  type="org.mybatis.caches.oscache.OSCache"/>

                 </mapper>
                注意下面兩點
                 (a)在
    <select id="getAuth" parameterType="Map" resultType="Auth"  useCache="false">中使用useCache="false"或useCache="true"來決定是否使用二級緩存。    
                 (b)在增刪改中<insert id="insertAuth" parameterType="Auth"  flushCache="true">使用flushCache="true"或flushCache="flase"來決定對這些進行操作后清空該xml文件中所有查詢語句的二級緩存。 

           3.  在src目錄下創建一個oscache.properties的屬性文件,在里面指定緩存的各種屬性的設置:
                 cache.memory=true             
                 cache.path=c:\\myapp\\cache
                 cache.persistence.class=com.opensymphony.oscache.plugins.diskpersistence.DiskPersistenceListener
                 cache.persistence.overflow.only=true
                 cache.capacity=100000

                

    posted @ 2014-08-11 18:22 yuhaibo736 閱讀(2731) | 評論 (0)編輯 收藏

    import java.awt.Color;
    import java.io.FileOutputStream;

    import com.itextpdf.text.BaseColor;
    import com.itextpdf.text.Document;
    import com.itextpdf.text.Element;
    import com.itextpdf.text.Font;
    import com.itextpdf.text.PageSize;
    import com.itextpdf.text.Phrase;
    import com.itextpdf.text.Rectangle;
    import com.itextpdf.text.pdf.BaseFont;
    import com.itextpdf.text.pdf.PdfPCell;
    import com.itextpdf.text.pdf.PdfPTable;
    import com.itextpdf.text.pdf.PdfWriter;

    public class CellEvents {


     /**
      * @param args
      */
     public static void main(String[] args) {
      Object[] objArr = new Object[]{100,20,300};
      
      Document document = new Document(PageSize.A4.rotate(),50,50,50,50);
      try{
       //bfSongti = BaseFont.createFont("/simsun.ttc,1", BaseFont.IDENTITY_H, BaseFont.NOT_EMBEDDED);
       Font songtiSFivefont = new Font(BaseFont.createFont("/simsun.ttc,1", BaseFont.IDENTITY_H, BaseFont.NOT_EMBEDDED), 9f);//宋體小五號字
             //設置存放位置
             PdfWriter.getInstance(document, new FileOutputStream("D:/test.pdf"));
             document.open();
     
             PdfPTable table = new PdfPTable(5);
       table.setSpacingBefore(10f);
       table.getDefaultCell().setPadding(5);
       //HowbuyBorderPdfPTableEvent event = new HowbuyBorderPdfPTableEvent();
       //table.setTableEvent(event);
       //table.getDefaultCell().setBorder(Rectangle.NO_BORDER);
       table.getDefaultCell().setVerticalAlignment(Element.ALIGN_MIDDLE);
       table.getDefaultCell().setHorizontalAlignment(Element.ALIGN_CENTER);
       PdfPCell cellTitle = new PdfPCell(new Phrase("總資產\n(萬元)",songtiSFivefont));
       cellTitle.setBorderWidth(2f);
       cellTitle.setBackgroundColor(new BaseColor(new Color(153, 51, 0)));
       cellTitle.setBorderColor(new BaseColor(new Color(153, 51, 0)));
       cellTitle.setHorizontalAlignment(Element.ALIGN_CENTER);
       cellTitle.setVerticalAlignment(Element.ALIGN_MIDDLE);
       cellTitle.setMinimumHeight(25);
       table.addCell(cellTitle);
     
       cellTitle = new PdfPCell(new Phrase(""));
       cellTitle.setBorder(Rectangle.NO_BORDER);
       cellTitle.setHorizontalAlignment(Element.ALIGN_CENTER);
       cellTitle.setVerticalAlignment(Element.ALIGN_MIDDLE);
       table.addCell(cellTitle);
       
       cellTitle = new PdfPCell(new Phrase("當前收益\n(萬元)",songtiSFivefont));
       cellTitle.setBorderWidth(2f);
       cellTitle.setBackgroundColor(new BaseColor(new Color(153, 51, 0)));
       cellTitle.setBorderColor(new BaseColor(new Color(153, 51, 0)));
       cellTitle.setHorizontalAlignment(Element.ALIGN_CENTER);
       cellTitle.setVerticalAlignment(Element.ALIGN_MIDDLE);
       table.addCell(cellTitle);
     
       cellTitle = new PdfPCell(new Phrase("",songtiSFivefont));
       cellTitle.setBorder(Rectangle.NO_BORDER);
       cellTitle.setHorizontalAlignment(Element.ALIGN_CENTER);
       cellTitle.setVerticalAlignment(Element.ALIGN_MIDDLE);
       table.addCell(cellTitle);
       
       
       cellTitle = new PdfPCell(new Phrase("累計收益\n(萬元)",songtiSFivefont));
       cellTitle.setBorderWidth(2f);
       cellTitle.setBackgroundColor(new BaseColor(new Color(153, 51, 0)));
       cellTitle.setBorderColor(new BaseColor(new Color(153, 51, 0)));
       cellTitle.setHorizontalAlignment(Element.ALIGN_CENTER);
       cellTitle.setVerticalAlignment(Element.ALIGN_MIDDLE);
       table.addCell(cellTitle);
       
       float[] widths2 = { 24.5f, 12.25f,24.5f,12.25f,24.5f};

       table.setWidths(widths2);
       
       table.setHorizontalAlignment(Element.ALIGN_LEFT);//
       table.setWidthPercentage(70);
       double zzc = objArr[0]==null ? 0:Double.parseDouble(objArr[0].toString());
       double dqsy = objArr[1]==null ? 0:Double.parseDouble(objArr[1].toString());
       double ljsy = objArr[2]==null ? 0:Double.parseDouble(objArr[2].toString());
       PdfPCell cell1 = new PdfPCell(new Phrase(String.valueOf(zzc),songtiSFivefont));
       cell1.setBorderWidth(2f);
       cell1.setBorderColor(new BaseColor(new Color(153, 51, 0)));
       cell1.setHorizontalAlignment(Element.ALIGN_CENTER);
       cell1.setVerticalAlignment(Element.ALIGN_MIDDLE);
       cell1.setMinimumHeight(20);
       table.addCell(cell1);
       
       cell1 = new PdfPCell(new Phrase("",songtiSFivefont));
       cell1.setBorder(Rectangle.NO_BORDER);
       cell1.setHorizontalAlignment(Element.ALIGN_CENTER);
       cell1.setVerticalAlignment(Element.ALIGN_MIDDLE);
       table.addCell(cell1);
       
       cell1 = new PdfPCell(new Phrase(String.valueOf(dqsy),songtiSFivefont));
       cell1.setBorderWidth(2f);
       cell1.setBorderColor(new BaseColor(new Color(153, 51, 0)));
       cell1.setHorizontalAlignment(Element.ALIGN_CENTER);
       cell1.setVerticalAlignment(Element.ALIGN_MIDDLE);
       table.addCell(cell1);
       
       cell1 = new PdfPCell(new Phrase("",songtiSFivefont));
       cell1.setBorder(Rectangle.NO_BORDER);
       cell1.setHorizontalAlignment(Element.ALIGN_CENTER);
       cell1.setVerticalAlignment(Element.ALIGN_MIDDLE);
       table.addCell(cell1);
       
       cell1 = new PdfPCell(new Phrase(String.valueOf(ljsy),songtiSFivefont));
       cell1.setBorderWidth(2f);
       cell1.setBorderColor(new BaseColor(new Color(153, 51, 0)));
       cell1.setHorizontalAlignment(Element.ALIGN_CENTER);
       cell1.setVerticalAlignment(Element.ALIGN_MIDDLE);
       table.addCell(cell1);
       document.add(table);
      }catch(Exception ex){
       ex.printStackTrace();
      }
            document.close();

     }

    }

    posted @ 2014-06-24 16:27 yuhaibo736 閱讀(1463) | 評論 (0)編輯 收藏

    主站蜘蛛池模板: 亚洲AV无码成人专区| 精品亚洲综合久久中文字幕| 成人无码区免费A∨直播| 97se亚洲综合在线| 亚洲精品无码专区2| 西西大胆无码视频免费| 久久精品视频免费看| 有色视频在线观看免费高清在线直播| 亚洲人成毛片线播放| 亚洲三级电影网站| 国产亚洲一区二区精品| 亚洲第一区精品观看| 亚洲区不卡顿区在线观看| 小小影视日本动漫观看免费| 成人特黄a级毛片免费视频| 无人影院手机版在线观看免费 | 亚洲精品V欧洲精品V日韩精品| 免费一看一级毛片全播放| 日本免费一二区在线电影| 免费看美女被靠到爽的视频| 最近最好的中文字幕2019免费 | 在线看片免费不卡人成视频| 成年女人18级毛片毛片免费 | 午夜理伦剧场免费| 久草视频免费在线观看| 欧美a级在线现免费观看| 国产精品成人四虎免费视频| 国产男女猛烈无遮挡免费视频 | 久久激情亚洲精品无码?V| 亚洲AV成人一区二区三区AV| 亚洲精品伊人久久久久| 免费的黄网站男人的天堂| 免费A级毛片在线播放| 黄页免费的网站勿入免费直接进入| 日韩高清在线免费看| 亚洲午夜无码久久久久| 亚洲日韩乱码久久久久久| 青草青草视频2免费观看| 免费看h片的网站| 免费又黄又爽的视频| 亚洲精品人成网在线播放影院|