jfree Chartスタックのヒストグラムのパラメータ設定


package com.iman.nrms.nrmwns.wrm.analyse.domain.util;

import java.awt.Color;
import java.awt.Font;
import java.text.DecimalFormat;

import org.jfree.chart.JFreeChart;
import org.jfree.chart.axis.CategoryAxis;
import org.jfree.chart.axis.NumberAxis;
import org.jfree.chart.axis.ValueAxis;
import org.jfree.chart.labels.StandardCategoryItemLabelGenerator;
import org.jfree.chart.plot.CategoryPlot;
import org.jfree.chart.renderer.category.BarRenderer;

/**
 *     JFreeChart       
 * 
 *   
 * Author : 
 * Date   : Nov 26, 2009
 * Time   : 11:50:41 AM 
 * Version: 1.0
 */
public class FormatPic {
	/**
	 *            
	 * 
	 * @param chart
	 * @returnType: void
	 * @author: 
	 * @data: Nov 26, 2009
	 * @time: 11:51:26 AM
	 */
	public static void setView(JFreeChart chart){
				  //        
				   chart.setTextAntiAlias(false); 
				   chart.setBackgroundPaint(Color.WHITE); 
				   // 2 .2              TextTitle    
				   chart 
					 .setTitle(new TextTitle(chartTitle, new Font("  ", Font.BOLD, 
					   25))); 
				   // 2 .2.1:     
				   // x,y      
				   Font labelFont = new Font("SansSerif", Font.TRUETYPE_FONT, 12); 
				   // 2 .3 Plot    Plot              
				   CategoryPlot plot = chart.getCategoryPlot(); 
				   //         
				   plot.setRangeGridlinesVisible(true); 
				   //      
				   plot.setRangeGridlinePaint(Color.gray); 
				   //       
				   NumberAxis vn = (NumberAxis) plot.getRangeAxis(); 
				   //       1 
				   vn.setUpperBound(1); 
				   //         0   
				   // vn.setAutoRangeIncludesZero(true); 
				   //            
				   DecimalFormat df = new DecimalFormat("0.00%"); 
				   vn.setNumberFormatOverride(df); //              
				   // DomainAxis (   ,    x  ), RangeAxis (   ,    y  ) 
				   CategoryAxis domainAxis = plot.getDomainAxis(); 
				   domainAxis.setLabelFont(labelFont);//     
				   domainAxis.setTickLabelFont(labelFont);//     
				   // x     ,      ,         ,       
				   //   (1)     Lable 45    
				   // domainAxis.setCategoryLabelPositions(CategoryLabelPositions.UP_45); 
				   //   (2)Lable(Math.PI 3.0)    
				   // domainAxis.setCategoryLabelPositions(CategoryLabelPositions 
				   // .createUpRotationLabelPositions(Math.PI / 3.0)); 
				   domainAxis.setMaximumCategoryLabelWidthRatio(0.6f);//      Lable        
				   plot.setDomainAxis(domainAxis); 
				   // y    
				   ValueAxis rangeAxis = plot.getRangeAxis(); 
				   rangeAxis.setLabelFont(labelFont); 
				   rangeAxis.setTickLabelFont(labelFont); 
				   //         Item          
				   rangeAxis.setUpperMargin(0.15); 
				   //         Item          
				   rangeAxis.setLowerMargin(0.15); 
				   plot.setRangeAxis(rangeAxis); 
				   // Renderer            
				   StackedBarRenderer renderer = new StackedBarRenderer(); 
				   //        
				   renderer.setMaximumBarWidth(0.05); 
				   //        
				   renderer.setMinimumBarLength(0.1); 
				   //          
				   renderer.setBaseOutlinePaint(Color.BLACK); 
				   //          
				   renderer.setDrawBarOutline(true); 
				   // //       (       ) 
				   renderer.setSeriesPaint(0, new Color(204, 255, 204)); 
				   renderer.setSeriesPaint(1, new Color(255, 204, 153)); 
				   //                    
				   renderer.setItemMargin(0.4); 
				   plot.setRenderer(renderer); 
				   //        (   3D             ,   2D         ) 
				   // plot.setForegroundAlpha(0.65f); 
	}
}