suse linux下jfreechart显示方框问题处理

到windows系统下的fonts中找到simsun.ttf这个字体文件,上传到linux服务器下jre的font目录

/usr/java/jdk1.6.0_27/jre/lib/fonts

这里我的jdk就是安装到如上目录中。

原理就是jdk找不到对应字体才这样显示

相关java代码如下:

// 自定义设定背景色  
        // chart.setBackgroundPaint(Color.getHSBColor(23,192,223));  
//        chart.setBackgroundPaint(Color.WHITE);
        
        CategoryPlot plot = (CategoryPlot) chart.getPlot();  
        // 设定图表数据显示部分背景色  
//        plot.setBackgroundPaint(Color.BLACK);  
        // 横坐标网格线  
        plot.setDomainGridlinePaint(Color.RED);  
        // 设置网格线可见  
        plot.setDomainGridlinesVisible(false);  
        // 纵坐标网格线  
//        plot.setRangeGridlinePaint(Color.RED);  
        
        
        CategoryAxis categoryAxis = plot.getDomainAxis();  
//        categoryAxis.setLabelFont(new Font("仿宋", Font.ROMAN_BASELINE, 12));  
        // 重要的类,负责生成各种效果  
        // Renderer 对象是图形的绘制单元
        StackedBarRenderer rd = new StackedBarRenderer();
        // 设置柱子宽度
        rd.setMaximumBarWidth(0.1);
        // 设置柱子高度
        rd.setMinimumBarLength(0.8);
                //设置柱的边框颜色
        rd.setBaseOutlinePaint(Color.LIGHT_GRAY);
        //设置柱的边框可见
        rd.setDrawBarOutline(true);

        // // 设置柱的颜色(可设定也可默认)
//        rd.setSeriesPaint(0, new Color(204, 255, 204));
//        rd.setSeriesPaint(1, new Color(255, 204, 153)); 
//        rd.setSeriesPaint(0, new Color(106, 57, 159));
        rd.setSeriesPaint(1, Color.RED);
        plot.setRenderer(rd);
        
         NumberAxis numberaxis = (NumberAxis) plot.getRangeAxis();  
         // 设置纵坐标的标题字体和大小  
         numberaxis.setLabelFont(new Font("宋体", Font.CENTER_BASELINE, 24));  
         // 设置纵坐标的坐标值的字体颜色  
         numberaxis.setLabelPaint(Color.BLACK);  
         // 设置纵坐标的坐标轴标尺颜色  
         numberaxis.setTickLabelPaint(Color.BLACK);  
         // 坐标轴标尺颜色  
         numberaxis.setTickMarkPaint(Color.BLUE);  
//         // 纵坐标的默认间距值  
         numberaxis.setAutoTickUnitSelection(true);  
//         // 设置纵坐标间距值  
//         numberaxis.setAutoTickUnitSelection(false);  
//         numberaxis.setTickUnit(new NumberTickUnit(150));
        
        // 设置水平底部列表
        categoryAxis.setLabelFont(new Font("宋体", Font.BOLD, 14));
        // 设置水平底部标题
        categoryAxis.setTickLabelFont(new Font("宋体", Font.BOLD, 12));
        categoryAxis.setCategoryLabelPositions(CategoryLabelPositions.createUpRotationLabelPositions(0.8)); 
        // 设置横坐标的坐标值的字体颜色  
        categoryAxis.setTickLabelPaint(new Color(106, 57, 159));
        // 设置垂直标题
        ValueAxis rangeAxis = plot.getRangeAxis();
        rangeAxis.setLabelFont(new Font("宋体", Font.BOLD, 18));
        
        


        // 设置说明的字体
        chart.getLegend().setItemFont(new Font("宋体", Font.BOLD, 18));
        chart.getTitle().setFont(new Font("宋体", Font.BOLD, 20)); 
		
		return chart;
	}
	/**
	 * 我们只是计算指定日期和范围之后的运势图
	 * @param bz 测算人员的八字
	 * @param specdate 指定的开始日期
	 * @param pattern 日期的类型
	 * @param type 0:年内月份的运势图  1:指定日期范围的运势图,一般称为周运势
	 * @param range 从指定日期开始的运势范围
	 * */
    private CategoryDataset createDataSet(BaZi bz,String specdate,String pattern,String type,String range) {  
    	
    	YunShi ys=new YunShi();
    	List<YunshiVO> yvList =new ArrayList<YunshiVO>();
    	if("0".equals(type)){
    		//年内运势,按照月份进行刻画的
    		String year=specdate.substring(0,4);
    		yvList=ys.findYunshiByYearRange(bz, year, 1);
    	}else{
    		//指定日期的周运势
    		yvList=ys.findYunshiByDateRange(bz, specdate, pattern, new Integer(range));
    	}
    	
    	
        DefaultCategoryDataset dataset = new DefaultCategoryDataset();  
  
        for(YunshiVO yv:yvList){
        	double score=new Double(yv.getScore());
        	if("0".equals(type)){
        		//年内运势
            	String d=yv.getDate().substring(0,4);
            	String m=yv.getDate().substring(0, 7);
            	
            	dataset.setValue(score, d+"年运势图",m);
        	}else{
        		//周运势
//            	String d=yv.getDate().substring(0,10);
        		Date d=DateUtils.parseDate(yv.getDate());
            	dataset.setValue(score, "每日运势图", DateUtils.getString(d, "yyyyMMdd"));
        	}

        }



转载于:https://my.oschina.net/abcijkxyz/blog/722338

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值