免费注册 查看新帖 |

Chinaunix

  平台 论坛 博客 文库
最近访问板块 发新帖
查看: 1762 | 回复: 0
打印 上一主题 下一主题

JFreeChart ToolTips [复制链接]

论坛徽章:
0
跳转到指定楼层
1 [收藏(0)] [报告]
发表于 2008-04-04 21:02 |只看该作者 |倒序浏览

                Overview
JFreeChart includes mechanisms for generating, collecting and displaying tool tips for individual components of a chart.
In this section, I describe:
• how to generate tool tips (including customisation of tool tips);
• how tool tips are collected;
• how to display tool tips;
• how to disable tool tips if you don’t need them;
Generating Tool Tips
  保证tooltip是在绘制chart同时产生的
  If you want to use tool tips, you need to make sure they are generated as your chart is being drawn.
You do this by setting a tool tip generator for your plot or, in many cases, the plot’s item renderer.
  
#以ChartS为例演示tooltip的使用
#PieChart
The PiePlot class generates tool tips using the PieToolTipGenerator interface.A standard implementation (StandardPieToolTipGenerator) is provided, and you are free to create your own implementations.
  To set the tool tip generator, use the following method in the PiePlot class:
public void setToolTipGenerator(  PieToolTipGenerator generator);
  Sets the tool tip generator for the pie chart. If you set this to null, no tool tips will be generated.
#Category Charts
  Category charts—including most of the bar charts generated by JFreeChart—are based on the CategoryPlot class and use a CategoryItemRenderer to draw each data item.   
  The CategoryToolTipGenerator interface specifies the method via which the renderer will obtain tool tips (if required).  To set the tool tip generator for a category plot’s item renderer, use the following method (defined in the AbstractCategoryItemRenderer class):  public void setToolTipGenerator(    CategoryToolTipGenerator generator);
#XY Charts
  XY charts—including scatter plots and all the time series charts generated by JFreeChart—are based on the XYPlot class and use an XYItemRenderer to draw each data item.
  The renderer generates tool tips (if required) using an XYToolTipGenerator.
  To set the tool tip generator for an XY plot’s item renderer, use the following method(defined in the AbstractXYItemRenderer class):
  public void setToolTipGenerator(    XYToolTipGenerator generator);
Collecting Tool Tips
  #设置tooltip generator是不够的
  Tool tips are collected, along with other chart entity information, using the ChartRenderingInfo class. You need to supply an instance of this class to JFreeChart’s draw() method, otherwise no tool tip information will be recorded
  #自动处理
  Fortunately, the ChartPanel class takes care of this automatically, so if you are displaying your
charts using the ChartPanel class you do not need to worry about how tool tips are collected—it is
done for you.
Displaying Tool Tips
  #tooltip的显示同样由ChartPanel处理,可以设置是否显示它。
  Tool tips are automatically displayed by the ChartPanel class, provided that you have set up a tool tip generator for the plot (or the plot’s renderer).
  You can also enable or disable the display of tool tips in the ChartPanel class, using this method:
  public void setDisplayToolTips(boolean flag);
Disabling Tool Tips
  #取消tooltip的最佳方式。
  The most effective way to disable tool tips is to set the tool tip generator to null. This ensures that no tool tip information is even generated, which can save memory and processing time
  
Customising Tool Tips
  You can take full control of the text generated for each tool tip by providing your own implementation of the appropriate tool tip generator interface.
               
               

本文来自ChinaUnix博客,如果查看原文请点:http://blog.chinaunix.net/u2/63463/showart_517485.html
您需要登录后才可以回帖 登录 | 注册

本版积分规则 发表回复

  

北京盛拓优讯信息技术有限公司. 版权所有 京ICP备16024965号-6 北京市公安局海淀分局网监中心备案编号:11010802020122 niuxiaotong@pcpop.com 17352615567
未成年举报专区
中国互联网协会会员  联系我们:huangweiwei@itpub.net
感谢所有关心和支持过ChinaUnix的朋友们 转载本站内容请注明原作者名及出处

清除 Cookies - ChinaUnix - Archiver - WAP - TOP