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

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

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

    賢仁居 George Gong
    It's never too late to learn
    posts - 32,comments - 16,trackbacks - 0

    以下代碼用到了大多數方法(附有注釋):

     private String createBarChart(String[] series,String[] categories,double[][] data,HttpSession session,PrintWriter printWriter){
             
           CategoryDataset dataset 
    = DatasetUtilities.createCategoryDataset(series, categories, data);
      
        JFreeChart chart 
    = ChartFactory.createBarChart3D("預算統計圖""預算科目","實際執行額",
                 dataset,PlotOrientation.VERTICAL,
    true,true,false);
           
           chart.setBackgroundPaint(Color.WHITE);   
    //設定背景色為白色
           
           CategoryPlot categoryPlot 
    = chart.getCategoryPlot();  //獲得 plot:CategoryPlot!!
           
           categoryPlot.setBackgroundPaint(Color.lightGray); 
    //設定圖表數據顯示部分背景色
           
           categoryPlot.setDomainGridlinePaint(Color.white); 
    //橫坐標網格線白色
           categoryPlot.setDomainGridlinesVisible(true); //可見
           
           categoryPlot.setRangeGridlinePaint(Color.white); 
    //縱坐標網格線白色
         
           CategoryAxis domainAxis 
    = categoryPlot.getDomainAxis();
           
           
    //設置 categoryAxis 垂直顯示
         domainAxis.setCategoryLabelPositions(CategoryLabelPositions.createUpRotationLabelPositions(0.4));
         
         
    //設置哼坐標軸的標題字體,此處是“預算科目”
            domainAxis.setLabelFont(new Font("SansSerif",Font.PLAIN,13));
           
           
    //設置距離圖片左端距離,參數為圖片的百分比
           domainAxis.setLowerMargin(0.05);
           
           
    //設置距離圖片右端距離
           domainAxis.setUpperMargin(0.05);
               
           
    //設置橫坐標的坐標值的字體
           domainAxis.setTickLabelFont(new Font("SansSerif",Font.PLAIN,12));
           
           categoryPlot.setDomainAxis(domainAxis); 
                
           ValueAxis rangeAxis 
    = categoryPlot.getRangeAxis();
           
    //設置最高的一個柱與圖片頂端的距離
           rangeAxis.setUpperMargin(0.05);
           
           
    //設置最低的一個柱與圖片底端的距離
           rangeAxis.setLowerMargin(0.05);
           categoryPlot.setRangeAxis(rangeAxis); 
           
           
    //設置豎坐標標簽的旋轉角度
           rangeAxis.setLabelAngle(0.05);
           
           
    //設置豎坐標軸的坐標值字體
    //       rangeAxis.setTickLabelFont(new Font("SansSerif",Font.PLAIN,12));
      
           BarRenderer3D renderer
    =(BarRenderer3D) categoryPlot.getRenderer();
           
           renderer.setBaseOutlinePaint(Color.GREEN);
           
    //設置 Wall 的顏色
           renderer.setWallPaint(Color.PINK);
           
           
    //設置每個柱的顏色     
           GradientPaint gradientpaint = new GradientPaint(0.0F0.0F, Color.blue,
                    
    0.0F0.0Fnew Color(0064)); //設定特定顏色
      GradientPaint gradientpaint1 = new GradientPaint(0.0F0.0F, Color.green,
               
    0.0F0.0Fnew Color(0640));
     
           renderer.setSeriesPaint(
    0, gradientpaint);
           renderer.setSeriesPaint(
    1, gradientpaint1);
           
           
    //設置柱的 Outline 顏色
           renderer.setSeriesOutlinePaint(0, Color.BLACK);
           renderer.setSeriesOutlinePaint(
    1, Color.BLACK);
           
    //設置每個category所包含的平行柱的之間距離
           renderer.setItemMargin(0.1);
        
           
    //顯示每個柱的數值,并修改該數值的字體屬性
           renderer.setItemLabelGenerator(new StandardCategoryItemLabelGenerator());
           
           
    //設置柱子上數值的字體
           renderer.setItemLabelFont(new Font("SansSerif",Font.PLAIN,13));  
           renderer.setItemLabelsVisible(
    true);
         
           
    //設置柱子上數據的顏色
           renderer.setItemLabelPaint(Color.RED);
           
           
    //設置bar的最小寬度,以保證能顯示數值
           renderer.setMinimumBarLength(0.02);
           
           
    //最大寬度
           renderer.setMaximumBarWidth(0.07);
           
           
           
    //設置柱子上顯示的數據旋轉90度,最后一個參數為旋轉的角度值/3.14
           ItemLabelPosition itemLabelPosition= new ItemLabelPosition(
             ItemLabelAnchor.INSIDE12,TextAnchor.CENTER_RIGHT,
             TextAnchor.CENTER_RIGHT,
    -1.57D);
           
           
    //設置不能在柱子上正常顯示的那些數值的顯示方式,將這些數值顯示在柱子外面
           ItemLabelPosition itemLabelPositionFallback=new ItemLabelPosition(
             ItemLabelAnchor.OUTSIDE12,TextAnchor.BASELINE_LEFT,
             TextAnchor.HALF_ASCENT_LEFT,
    -1.57D);
           
           
    //設置正常顯示的柱子label的position
           renderer.setPositiveItemLabelPosition(itemLabelPosition);
           renderer.setNegativeItemLabelPosition(itemLabelPosition);
           
           
    //設置不能正常顯示的柱子label的position
           renderer.setPositiveItemLabelPositionFallback(itemLabelPositionFallback);
           renderer.setNegativeItemLabelPositionFallback(itemLabelPositionFallback);
           
           categoryPlot.setRenderer(renderer);
           
    //設置柱子的透明度
           categoryPlot.setForegroundAlpha(0.8f);
           
           
    //設置地區、銷量的顯示位置
    //       categoryPlot.setDomainAxisLocation(AxisLocation.TOP_OR_RIGHT);
    //       categoryPlot.setRangeAxisLocation(AxisLocation.BOTTOM_OR_RIGHT); 
          
           StandardEntityCollection sec 
    = new StandardEntityCollection(); 
           ChartRenderingInfo info 
    = new ChartRenderingInfo(sec);
                 
           
    try {
             ServletUtilities.setTempFilePrefix(
    "zcz");
             ServletUtilities.setTempOneTimeFilePrefix(
    "zcz-onetime");
            
               filename 
    = ServletUtilities.saveChartAsPNG(chart, 926555, info, session);   
               chartName
    =filename;
               
               System.out.println(
    "圖片的臨時保存路徑:"+System.getProperty("java.io.tmpdir"));
           }
     catch (IOException ex) {
               ex.printStackTrace();
           }

              
               String myMap
    =ChartUtilities.getImageMap(filename, info);
               printWriter.println(myMap);
        
         
    return filename;
        }
    posted @ 2007-07-23 10:47 George Gong 閱讀(1354) | 評論 (2)編輯 收藏

    選取Apache HTTP Server作為前端的負載服務器,后端選取兩個Tomcat作集群,此次選擇的配置方式為Session Sticky(粘性Session),這種方式將同一用戶的請求轉發到特定的Tomcat服務器上,避免了集群中Session的復制,缺點是用戶只跟一種的一臺服務器通信,如果此服務器down掉,那就廢了。
    采用的model為mod_proxy_ajp.so,整個配置在tomcat的配置文件中都有相關的注釋,只需作相應修改就OK。
    我們選取的是Apache HTTP Server2.2.4,Tomcat5.5.16。
    首先安裝Apache HTTP Server,然后修改其配置文件http.conf,首先load三個model,代碼如下:

    LoadModule proxy_module modules/mod_proxy.so
    LoadModule proxy_ajp_module modules
    /mod_proxy_ajp.so
    LoadModule proxy_balancer_module modules
    /mod_proxy_balancer.so
    然后在此配置文件末端加入以下代碼:
    ProxyPass / balancer://tomcatcluster/ lbmethod=byrequests stickysession=JSESSIONID nofailover=Off timeout=5 maxattempts=3  
    ProxyPassReverse / balancer://tomcatcluster/   
      
    <Proxy balancer://tomcatcluster>  
    BalancerMember ajp://localhost:8009 route=a  
    BalancerMember ajp://localhost:9009 route=b
    </Proxy> 

    以上代碼配置了Proxy的相關參數,<Proxy>模塊定義了均衡負載的配置,其中兩個Tomcat Server都配置在同一臺服務器上,端口分別為8009、9009,并配置各自的route,這樣Apache Server就能根據route將請求轉發給特定的Tomcat。
    接下來修改Tomcat的server.xml文件,如下:
    <!-- Define an AJP 1.3 Connector on port 8009 -->
        
    <Connector port="8009" 
                   enableLookups
    ="false" redirectPort="8443" protocol="AJP/1.3" />
    其中的port為前面<Proxy>中設定的端口,還要配置其route,代碼如下:
    <!-- Define the top level container in our container hierarchy -->
        
    <Engine name="Catalina" defaultHost="localhost" jvmRoute="a">
    jvmRoute也須同前面的設置一樣。

    下面用JMeter對配置后的負載均衡做一測試,首先先啟動兩個Tomcat Server,隨后啟動Apache Server,在JMeter中新建測試計劃,在兩個Tomcat Server中的jsp-examples下新建test.jsp(此jsp自己隨便寫兩句就成),然后進行測試,以下是部分取樣器結果:
    HTTP response headers:
    HTTP/1.1 200 OK
    Date: Wed, 11 Jul 2007 02:17:55 GMT
    Set-Cookie: JSESSIONID=AC7EF1CAA8C6B0FEB68E77D7D375E2AF.bPath=/jsp-examples
    Content-Type: text/html;charset=ISO-8859-1
    Content-Length: 3
    Keep-Alive: timeout=5, max=79
    Connection: Keep-Alive
    以上紅色代碼表示用戶的http請求中的JSESSIONID中已經附帶了route后綴,.b表示此請求將轉發到route為b的Tomcat Server上,你將會發現其中的一部分請求的JSESSIONID后綴為.a,也就是轉發給route為a的Tomcat Server上。
    posted @ 2007-07-11 10:08 George Gong 閱讀(8352) | 評論 (0)編輯 收藏
    僅列出標題
    共4頁: 上一頁 1 2 3 4 
    主站蜘蛛池模板: 免费在线观看自拍性爱视频| 亚洲人成网站免费播放| 一个人看的www免费在线视频| 野花高清在线观看免费完整版中文| 91大神亚洲影视在线| 香蕉免费一区二区三区| 亚洲爆乳无码一区二区三区| 伊人久久大香线蕉免费视频| 亚洲七七久久精品中文国产| av电影在线免费看| 亚洲成色www久久网站夜月| 国产一级片免费看| 久久亚洲日韩精品一区二区三区| 99久久国产免费中文无字幕| 亚洲综合一区二区国产精品| 久久www免费人成看片| 亚洲AV成人影视在线观看| 日本一道在线日本一道高清不卡免费| 久久精品国产亚洲AV天海翼 | 美女黄频视频大全免费的| 国产一区二区三区无码免费| 另类小说亚洲色图| 亚洲人成网站在线播放vr| 免费国产污网站在线观看15 | 美国免费高清一级毛片| 老司机亚洲精品影视www| 小草在线看片免费人成视久网| 亚洲成aⅴ人片在线影院八| 成人免费视频试看120秒| 男女污污污超污视频免费在线看| 国产亚洲老熟女视频| 50岁老女人的毛片免费观看| 亚洲第一成年免费网站| 国产亚洲午夜高清国产拍精品| 99re在线免费视频| 女bbbbxxxx另类亚洲| 香蕉视频在线观看亚洲| 成**人免费一级毛片| 免费无码又爽又刺激网站直播| 亚洲天堂2016| 亚洲精品无码成人片久久|