首页 新闻 论坛 群组 Blog 文档 下载 读书 Tag 网摘 搜索 .NET Java 游戏 视频 人才 外包 培训 数据库 书店 程序员
中国软件网
欢迎您:游客 | 登录 注册 帮助
  • 关于StandardPieItemLabelGenerator类 [已结贴,结贴人:zr_dixuexiongying]
    进入用户个人空间
    加为好友
    发送私信
    在线聊天
    发表于:2008-05-26 14:28:56 楼主
      请教一下大家!我的程序里面导入了jfeechar的包,可是为什么却没有StandardPieItemLabelGenerator这个类,用开发工具也点不出来这个方法.
      另外我导入
    import org.jfree.chart.labels.StandardPieItemLabelGenerator; 报错,没有这个包,郁闷了


      plot.setLabelGenerator(new StandardPieItemLabelGenerator(StandardPieItemLabelGenerator.DEFAULT_TOOLTIP_FORMAT));    //报错

      plot.setToolTipGenerator(new StandardPieItemLabelGenerator());  //也报错

    报错信息:

    Severity and Description Path Resource Location Creation Time Id
    StandardPieItemLabelGenerator cannot be resolved to a type

    另外请问一下sun有没有这个包!我问我们同事是不是他们自己些的包,他也不清楚,所以只有发帖问了
    import sun.security.krb5.internal.r;

    源代码如下:

    package com.lc.miccs.contract;


    /**
    * <p>Title: sy miccs </p>
    *
    * <p>Description: </p>
    *
    * <p>Copyright: Copyright (c) 2006 </p>
    *
    * <p>Company: lcsoft hust </p>
    *
    * @author hz
    * @version 1.0
    */
    import org.jfree.chart.JFreeChart;
    import org.jfree.chart.plot.*;
    import org.jfree.chart.title.*;
    import org.jfree.chart.servlet.ServletUtilities;
    import com.lc.miccs.db.TableSelect;
    import java.sql.*;
    import java.awt.Font;
    import java.io.IOException;
    import org.jfree.chart.labels.StandardPieItemLabelGenerator;
    import org.jfree.data.general.DefaultPieDataset;
    import org.jfree.chart.urls.StandardPieURLGenerator;
    import org.jfree.chart.entity.StandardEntityCollection;
    import org.jfree.chart.*;
    import java.util.*;
    import com.lc.miccs.db.*;
    public class ContractChart {
      public ContractChart() {
      piedata = new DefaultPieDataset();
      }
      PreparedStatement sql_sta = null;
      Statement sta = null;
      ResultSet sql_res = null;
      connFactory factory=new connFactory();
      DBConnect dbconn = factory.createConnect();
      Connection conn = null;
      public int width = 750;
      public int height = 500;
     
      String title = "2005 搜索引擎市场占有率";//数据为测试数据
     
      DefaultPieDataset piedata = new DefaultPieDataset();
     

      //获取累计图
      public String getSum(String id) {     
          getDatee(id);
          String title="";
          if(id.equals("23"))title="沈阳地铁一号线延伸线 - 合同分类统计图";
          if(id.equals("22"))title="沈阳地铁二号线 - 合同分类统计图";
          if(id.equals("21"))title="沈阳地铁一号线 - 合同分类统计图";
        return getChart(title);
      }

      public String getChart(String title) {
    //   piedata.setValue("Google",30);
    //   piedata.setValue("Baidu",40.3);
    //   piedata.setValue("sohu",19.6);
    //   piedata.setValue("msn",29.6);
     
      //3D饼图
      PiePlot3D plot = new PiePlot3D(piedata);
     
      //设定链接 ("link.jsp","section"));//section为参数,不填写则默认为category
      plot.setURLGenerator(new StandardPieURLGenerator("link.jsp","section"));
     
      //指定图片的透明度
      plot.setForegroundAlpha(0.6f);
     
      //指定显示的饼图上圆形(false)还椭圆形(true)
      plot.setCircular(false);
     
      //显示百分比
      plot.setLabelGenerator(new StandardPieItemLabelGenerator(StandardPieItemLabelGenerator.DEFAULT_TOOLTIP_FORMAT));
      plot.setLegendLabelGenerator(new StandardPieItemLabelGenerator("{0}: ( {2})"));
       
      JFreeChart chart = new JFreeChart("",JFreeChart.DEFAULT_TITLE_FONT, plot, true);
      //设置图片背景色
      chart.setBackgroundPaint(java.awt.Color.white);
     
      //设置图片标题属性
      Font font = new Font("黑体",Font.CENTER_BASELINE,20);
      TextTitle _title = new TextTitle(title);
      _title.setFont(font);
      chart.setTitle(_title);
      plot.setToolTipGenerator(new StandardPieItemLabelGenerator());
      //把生成的图片放到临时目录
      StandardEntityCollection sec = new StandardEntityCollection();
      ChartRenderingInfo info = new ChartRenderingInfo(sec);

      //500是图片长度,300是图片高度,session 为HttpSession对象
      //String filename = ServletUtilities.saveChartAsPNG(chart, 500, 300, info, null);
     
      //PrintWriter pw = new PrintWriter(out);
      //ChartUtilities.writeImageMap(pw, "map0", info, false);
      //String graphURL = request.getContextPath() + "/servlet/DisplayChart?filename=" + filename;

        String fn = "";
        try {
          fn = ServletUtilities.saveChartAsPNG(chart, 500, 300, info, null);
        }
        catch (IOException ex) {
          System.out.println("getChart :" + ex.getMessage());
        }
        return fn;
      }

      //planItemID 计划项ID planTypeID计划类型ID isSum=true累计计划,false时序计划
      private void getDatee(String id) {

        TableSelect ts = new TableSelect();
        String sql ="";
    //    String sql = "select t.* from (select f_ctype,f_ctname,f_count,TO_CHAR(f_sum/10000,'999G999G999G999G999G999G999G999G999G999G999D9999MI') f_sum_wan,"
    // +" case when  nvl(f_sum,0) =0 or nvl(f_all,0)=0 then null when round((f_sum/f_all)*100,2) <1 then  '0' ¦ ¦round((f_sum/f_all)*100,2) ¦ ¦'%'"
    // +" else round((f_sum/f_all)*100,2) ¦ ¦'%' end f_stat "
    // + " from vw_ctrsumbytype where F_MPID=21 )t left join cp_contracttype a on t.f_ctype = a.f_ctcode order by a.f_index";
        if(id.equals(""))
        {
        sql = "select f_ctname,round(f_sum/10000,4) f_sum_wan"
        + " from vw_ctrsumbytype  ";
        }else{
        sql = "select f_ctname,round(f_sum/10000,4) f_sum_wan"
        + " from vw_ctrsumbytype where F_MPID= "+id;
        }
       
        try {
          ResultSet rs = ts.query(sql);
          while (rs.next()) {
    //    System.out.println(sql+":@@@@@@@@@@@@@@@@@@@@");
            String  F_CTNAME  = rs.getString("F_CTNAME");
            double  F_SUM_WAN = rs.getDouble("F_SUM_WAN");       
            piedata.setValue(F_CTNAME,F_SUM_WAN);
          }
        }
        catch (SQLException ex) {

        }
        finally {
          ts.closeQuery();
        }
      }

    }

    20  修改 删除 举报 引用 回复
    进入用户个人空间
    加为好友
    发送私信
    在线聊天
    • skyqiang
    • 等级:
    发表于:2008-05-26 16:15:341楼 得分:6
    不懂...但帮你顶.........
    修改 删除 举报 引用 回复
    进入用户个人空间
    加为好友
    发送私信
    在线聊天
    • AWUSOFT
    • 等级:
    发表于:2008-05-26 16:20:582楼 得分:7
    换一个版本试试吧
    修改 删除 举报 引用 回复
    进入用户个人空间
    加为好友
    发送私信
    在线聊天
    发表于:2008-06-04 22:36:293楼 得分:7
    试试把StandardPieItemLabelGenerator换成StandardPieSectionLabelGenerator。
    修改 删除 举报 引用 回复

    网站简介广告服务网站地图帮助联系方式诚聘英才English 问题报告
    北京创新乐知广告有限公司 版权所有 京 ICP 证 070598 号
    世纪乐知(北京)网络技术有限公司 提供技术支持
    Copyright © 2000-2008, CSDN.NET, All Rights Reserved