分类: Java
2008-04-04 21:02:43
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.
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. |