KickJava   Java API By Example, From Geeks To Geeks.

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


1 /* ===========================================================
2  * JFreeChart : a free chart library for the Java(tm) platform
3  * ===========================================================
4  *
5  * (C) Copyright 2000-2005, 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 License
20  * along with this library; if not, write to the Free Software Foundation,
21  * Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307, USA.
22  *
23  * [Java is a trademark or registered trademark of Sun Microsystems, Inc.
24  * in the United States and other countries.]
25  *
26  * ---------------------------------------
27  * StandardCategoryItemLabelGenerator.java
28  * ---------------------------------------
29  * (C) Copyright 2004, 2005, by Object Refinery Limited.
30  *
31  * Original Author: David Gilbert (for Object Refinery Limited);
32  * Contributor(s): -;
33  *
34  * $Id: StandardCategoryItemLabelGenerator.java,v 1.2 2005/05/19 15:43:00 mungady Exp $
35  *
36  * Changes
37  * -------
38  * 11-May-2004 : Version 1 (DG);
39  * 20-Apr-2005 : Renamed StandardCategoryLabelGenerator
40  * --> StandardCategoryItemLabelGenerator (DG);
41  */

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

56 public class StandardCategoryItemLabelGenerator
57     extends AbstractCategoryItemLabelGenerator
58     implements CategoryItemLabelGenerator, Cloneable JavaDoc, PublicCloneable,
59                Serializable JavaDoc {
60
61     /** For serialization. */
62     private static final long serialVersionUID = 3499701401211412882L;
63     
64     /** The default format string. */
65     public static final String JavaDoc DEFAULT_LABEL_FORMAT_STRING = "{2}";
66     
67     /**
68      * Creates a new generator with a default number formatter.
69      */

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

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

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

109     public String JavaDoc generateLabel(CategoryDataset dataset, int row, int column) {
110         return generateLabelString(dataset, row, column);
111     }
112     
113 }
114
Popular Tags