jreeechart

jreeechart虐了,收拾心情,整理一下成果:

 

1、解决Jfreechart  The type org.jfree.util.PublicCloneable cannot be resolved错误

靠了  今天用jfreechart整个报表 NND  老报 The type org.jfree.util.PublicCloneable cannot be resolved. It is indirectly referenced from required .class files。烦躁

整了半天 发现少了个报:

jcommon-1.0.14.jar

在此铭记!

 

2、乱码问题
设置字体就不会出现乱码问题。
/** 
     *
配置字体  
     * @param chart JFreeChart
对象
 
     */ 
    private void configFont(JFreeChart chart){  
        //
配置字体
  
        Font xfont = new Font("
宋体",Font.PLAIN,12) ;// X
  
        Font yfont = new Font("
宋体",Font.PLAIN,12) ;// Y
  
        Font kfont = new Font("
宋体",Font.PLAIN,12) ;// 底部
  
        Font titleFont = new Font("
隶书", Font.BOLD , 25) ; // 图片标题
  
        CategoryPlot plot = chart.getCategoryPlot();//
图形的绘制结构对象
  
          
        //
图片标题
  
        chart.setTitle(new TextTitle(chart.getTitle().getText(),titleFont));  
          
        //
底部
  
        chart.getLegend().setItemFont(kfont);  
          
        // X
  
        CategoryAxis domainAxis = plot.getDomainAxis();     
        domainAxis.setLabelFont(xfont);//
轴标题
  
        domainAxis.setTickLabelFont(xfont);//
轴数值
    
        domainAxis.setTickLabelPaint(Color.BLUE) ; //
字体颜色
  
        domainAxis.setCategoryLabelPositions(CategoryLabelPositions.UP_45); //
横轴上的label斜显示
   
          
        // Y
  
        ValueAxis rangeAxis = plot.getRangeAxis();     
        rangeAxis.setLabelFont(yfont);   
        rangeAxis.setLabelPaint(Color.BLUE) ; //
字体颜色
  
        rangeAxis.setTickLabelFont(yfont);    
          
    } 

 

3、设置不同柱子的颜色
    static class CustomRenderer extends BarRenderer {
        private Paint colors[];

        public Paint getItemPaint(int i, int j) {
          return colors[j % colors.length];
        }

        public CustomRenderer(Paint apaint[]) {
          colors = apaint;
        }
      }
CustomRenderer renderer = new CustomRenderer(new Paint[] { Color.red, Color.blue, Color.green, Color.yellow,
          Color.orange, Color.cyan, Color.magenta, Color.blue });
renderer.setBaseItemLabelGenerator(new StandardCategoryItemLabelGenerator());
        renderer.setBaseItemLabelsVisible(true);


4

public JFreeChart getChart()
{
   chart = ChartFactory.createBarChart3D(
     "
热点讨论投票结果", // 图表标题
     "", //
目录轴的显示标签
     "", //
数值轴的显示标签
     getDataSet(), //
数据集
     //PlotOrientation.HORIZONTAL , //
图表方向:水平
     PlotOrientation.VERTICAL , //
图表方向:垂直
     false, //
是否显示图例(对于简单的柱状图必须是false)
     true, //
是否生成工具

     true //
是否生成URL链接
     );
   //
重新设置图标标题,改变字体
   chart.setTitle(new TextTitle("
热点讨论投票结果", new Font("黑体", Font.ITALIC , 18)));
   //
取得统计图标的第一个图例

   //LegendTitle legend = chart.getLegend(0);
   //
修改图例的字体,必须把显示图例设置为true,否则会报空指针异常
   //legend.setItemFont(new Font("
宋体", Font.BOLD, 14));

   //获得柱状图的Plot对象
   CategoryPlot plot = chart.getCategoryPlot();
   plot.setBackgroundPaint(Color.pink); //
设定图表数据显示部分背景色
   //
取得横轴
   CategoryAxis categoryAxis = plot.getDomainAxis();
   //
设置横轴显示标签的字体
   categoryAxis.setLabelFont(new Font("
宋体" , Font.BOLD , 18));
   //
分类标签以45度角倾斜

   //categoryAxis.setCategoryLabelPositions(CategoryLabelPositions.UP_45);
   categoryAxis.setTickLabelFont(new Font("
宋体" , Font.BOLD , 18));
   //
取得纵轴

   NumberAxis numberAxis = (NumberAxis)plot.getRangeAxis();
   //
设置纵轴显示标签的字体
   numberAxis.setLabelFont(new Font("
宋体" , Font.BOLD , 18));
   //
设置最高的一个柱与图片顶端的距离

   numberAxis.setUpperMargin(0.1);
   //numberAxis.setFixedAutoRange(100);
   //
设置整数显示
   //numberAxis.setStandardTickUnits(NumberAxis.createIntegerTickUnits());
   //numberAxis.setNegativeArrowVisible(true);
 
   //
取最大数Math.max(supportCount, blackballCount)
   numberAxis.setUpperBound(1);
   numberAxis.setLowerBound(0.01);
   //
设置百分比显示

   numberAxis.setNumberFormatOverride(new DecimalFormat("0%"));
   //numberAxis.setNumberFormatOverride(new DecimalFormat("0.00%"));
   //
设置最小显示数,小于的话会显示在中间(正负)
   //numberAxis.setAutoRangeMinimumSize(1);
 
   plot.setNoDataMessage("
没有可供使用的数据!");
   plot.setNoDataMessagePaint(Color.blue);
 
 
   BarRenderer3D renderer = new BarRenderer3D();
   //
设置柱子宽度

   renderer.setMaximumBarWidth(0.1);
   //
设置柱子高度
   renderer.setMinimumBarLength(0.2);
   //
设置柱子的颜色
        renderer.setSeriesPaint(0, new Color(0, 0, 255));
       
        //
设置柱子边框可见
        //renderer.setDrawBarOutline(true);
        //
设置柱子默认的边框颜色,必须设置边框可见才起效
   //renderer.setBaseOutlinePaint(Color.gray);
        //
设置分类柱子的边框色,覆盖默认的边框颜色,必须设置边框可见才起效
        //renderer.setSeriesOutlinePaint(0,Color.red);
        //
设置柱子的纵横背景色
        //renderer.setWallPaint(Color.gray);
        //
设置平行柱的之间距离
        renderer.setItemMargin(0.5);
        //
显示每个柱的数值,并修改该数值的字体属性
        renderer.setIncludeBaseInRange(true);
        //
将修改后的属性值保存到图中,这一步很重要,否则上面对颜色的设置都无效
        plot.setRenderer(renderer);
        
        //
设置柱子的透明度,0.8相当于80%的透明度
        plot.setForegroundAlpha(0.8f);

   return chart;
}

//返回一个CategoryDataset实例
private static CategoryDataset getDataSet()
{
   DefaultCategoryDataset dataset = new DefaultCategoryDataset();
   int total = supportCount+blackballCount;
   if(total < 1) total = 1;
   dataset.addValue((double)supportCount/total, "" , "
正方(" + supportCount + ")");
   dataset.addValue((double)blackballCount/total, "" , "
反方
(" + blackballCount + ")");
   //dataset.addValue(supportCount, "
佛山" , "正方
");
   //dataset.addValue(blackballCount, "
佛山" , "反方
");
   //dataset.addValue(supportCount , "
广州" , "正方
");
   //dataset.addValue(blackballCount , "
广州" , "反方
");
   return dataset;
}

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
城市应急指挥系统是智慧城市建设的重要组成部分,旨在提高城市对突发事件的预防和处置能力。系统背景源于自然灾害和事故灾难频发,如汶川地震和日本大地震等,这些事件造成了巨大的人员伤亡和财产损失。随着城市化进程的加快,应急信息化建设面临信息资源分散、管理标准不统一等问题,需要通过统筹管理和技术创新来解决。 系统的设计思路是通过先进的技术手段,如物联网、射频识别、卫星定位等,构建一个具有强大信息感知和通信能力的网络和平台。这将促进不同部门和层次之间的信息共享、交流和整合,提高城市资源的利用效率,满足城市对各种信息的获取和使用需求。在“十二五”期间,应急信息化工作将依托这些技术,实现动态监控、风险管理、预警以及统一指挥调度。 应急指挥系统的建设目标是实现快速有效的应对各种突发事件,保障人民生命财产安全,减少社会危害和经济损失。系统将包括预测预警、模拟演练、辅助决策、态势分析等功能,以及应急值守、预案管理、GIS应用等基本应用。此外,还包括支撑平台的建设,如接警中心、视频会议、统一通信等基础设施。 系统的实施将涉及到应急网络建设、应急指挥、视频监控、卫星通信等多个方面。通过高度集成的系统,建立统一的信息接收和处理平台,实现多渠道接入和融合指挥调度。此外,还包括应急指挥中心基础平台建设、固定和移动应急指挥通信系统建设,以及应急队伍建设,确保能够迅速响应并有效处置各类突发事件。 项目的意义在于,它不仅是提升灾害监测预报水平和预警能力的重要科技支撑,也是实现预防和减轻重大灾害和事故损失的关键。通过实施城市应急指挥系统,可以加强社会管理和公共服务,构建和谐社会,为打造平安城市提供坚实的基础。
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值