JfreeChart字體設置

  1. /**     
  2.      * 配置字體     
  3.      * @param chart JFreeChart 對象     
  4.      */      
  5.      private void configFont(JFreeChart chart){      
  6.          // 配置字體      
  7.          Font xfont = new Font("宋體",Font.PLAIN,12) ;// X軸      
  8.          Font yfont = new Font("宋體",Font.PLAIN,12) ;// Y軸      
  9.          Font kfont = new Font("宋體",Font.PLAIN,12) ;// 底部      
  10.          Font titleFont = new Font("隸書", Font.BOLD , 25) ; // 圖片標題      
  11.          CategoryPlot plot = chart.getCategoryPlot();// 圖形的繪製結構對象      
  12.               
  13.          // 圖片標題      
  14.          chart.setTitle(new TextTitle(chart.getTitle().getText(),titleFont));      
  15.               
  16.          // 底部      
  17.          chart.getLegend().setItemFont(kfont);      
  18.               
  19.          // X 軸      
  20.          CategoryAxis domainAxis = plot.getDomainAxis();          
  21.          domainAxis.setLabelFont(xfont);// 軸標題      
  22.          domainAxis.setTickLabelFont(xfont);// 軸數值        
  23.          domainAxis.setTickLabelPaint(Color.BLUE) ; // 字體顏色      
  24.          domainAxis.setCategoryLabelPositions(CategoryLabelPositions.UP_45); // 橫軸上的label斜顯示        
  25.               
  26.          // Y 軸      
  27.          ValueAxis rangeAxis = plot.getRangeAxis();          
  28.          rangeAxis.setLabelFont(yfont);        
  29.          rangeAxis.setLabelPaint(Color.BLUE) ; // 字體顏色      
  30.          rangeAxis.setTickLabelFont(yfont);        
  31.               
  32.      }
發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章