KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > jfree > chart > labels > StandardCategoryToolTipGenerator


1 /* ===========================================================
2  * JFreeChart : a free chart library for the Java(tm) platform
3  * ===========================================================
4  *
5  * (C) Copyright 2000-2006, by Object Refinery Limited and Contributors.
6  *
7  * Project Info: http://www.jfree.org/jfreechart/index.html
8  *
9  * This library is free software; you can redistribute it and/or modify it
10  * under the terms of the GNU Lesser General Public License as published by
11  * the Free Software Foundation; either version 2.1 of the License, or
12  * (at your option) any later version.
13  *
14  * This library is distributed in the hope that it will be useful, but
15  * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
16  * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public
17  * License for more details.
18  *
19  * You should have received a copy of the GNU Lesser General Public
20  * License along with this library; if not, write to the Free Software
21  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301,
22  * USA.
23  *
24  * [Java is a trademark or registered trademark of Sun Microsystems, Inc.
25  * in the United States and other countries.]
26  *
27  * -------------------------------------
28  * StandardCategoryToolTipGenerator.java
29  * -------------------------------------
30  * (C) Copyright 2004-2006, by Object Refinery Limited.
31  *
32  * Original Author: David Gilbert (for Object Refinery Limited);
33  * Contributor(s): -;
34  *
35  * $Id: StandardCategoryToolTipGenerator.java,v 1.3.2.3 2006/08/04 11:47:49 mungady Exp $
36  *
37  * Changes
38  * -------
39  * 11-May-2004 : Version 1 (DG);
40  * ------------- JFREECHART 1.0.0 ---------------------------------------------
41  * 03-May-2006 : Added equals() method to fix bug 1481087 (DG);
42  *
43  */

44
45 package org.jfree.chart.labels;
46
47 import java.io.Serializable JavaDoc;
48 import java.text.DateFormat JavaDoc;
49 import java.text.NumberFormat JavaDoc;
50
51 import org.jfree.data.category.CategoryDataset;
52
53 /**
54  * A standard tool tip generator that can be used with a
55  * {@link org.jfree.chart.renderer.category.CategoryItemRenderer}.
56  */

57 public class StandardCategoryToolTipGenerator
58     extends AbstractCategoryItemLabelGenerator
59     implements CategoryToolTipGenerator, Serializable JavaDoc {
60
61     /** For serialization. */
62     private static final long serialVersionUID = -6768806592218710764L;
63     
64     /** The default format string. */
65     public static final String JavaDoc DEFAULT_TOOL_TIP_FORMAT_STRING
66         = "({0}, {1}) = {2}";
67     
68     /**
69      * Creates a new generator with a default number formatter.
70      */

71     public StandardCategoryToolTipGenerator() {
72         super(DEFAULT_TOOL_TIP_FORMAT_STRING, NumberFormat.getInstance());
73     }
74
75     /**
76      * Creates a new generator with the specified number formatter.
77      *
78      * @param labelFormat the label format string (<code>null</code> not
79      * permitted).
80      * @param formatter the number formatter (<code>null</code> not permitted).
81      */

82     public StandardCategoryToolTipGenerator(String JavaDoc labelFormat,
83                                             NumberFormat JavaDoc formatter) {
84         super(labelFormat, formatter);
85     }
86     
87     /**
88      * Creates a new generator with the specified date formatter.
89      *
90      * @param labelFormat the label format string (<code>null</code> not
91      * permitted).
92      * @param formatter the date formatter (<code>null</code> not permitted).
93      */

94     public StandardCategoryToolTipGenerator(String JavaDoc labelFormat,
95                                             DateFormat JavaDoc formatter) {
96         super(labelFormat, formatter);
97     }
98     
99     /**
100      * Generates the tool tip text for an item in a dataset. Note: in the
101      * current dataset implementation, each row is a series, and each column
102      * contains values for a particular category.
103      *
104      * @param dataset the dataset (<code>null</code> not permitted).
105      * @param row the row index (zero-based).
106      * @param column the column index (zero-based).
107      *
108      * @return The tooltip text (possibly <code>null</code>).
109      */

110     public String JavaDoc generateToolTip(CategoryDataset dataset,
111                                   int row, int column) {
112         return generateLabelString(dataset, row, column);
113     }
114     
115     /**
116      * Tests this generator for equality with an arbitrary object.
117      *
118      * @param obj the object (<code>null</code> permitted).
119      *
120      * @return A boolean.
121      */

122     public boolean equals(Object JavaDoc obj) {
123         if (obj == this) {
124             return true;
125         }
126         if (!(obj instanceof StandardCategoryToolTipGenerator)) {
127             return false;
128         }
129         return super.equals(obj);
130     }
131
132 }
133
Popular Tags