Source Code Cross Referenced for CategoryItemEntity.java in  » Chart » jfreechart » org » jfree » chart » entity » Java Source Code / Java DocumentationJava Source Code and Java Documentation

Java Source Code / Java Documentation
1. 6.0 JDK Core
2. 6.0 JDK Modules
3. 6.0 JDK Modules com.sun
4. 6.0 JDK Modules com.sun.java
5. 6.0 JDK Modules sun
6. 6.0 JDK Platform
7. Ajax
8. Apache Harmony Java SE
9. Aspect oriented
10. Authentication Authorization
11. Blogger System
12. Build
13. Byte Code
14. Cache
15. Chart
16. Chat
17. Code Analyzer
18. Collaboration
19. Content Management System
20. Database Client
21. Database DBMS
22. Database JDBC Connection Pool
23. Database ORM
24. Development
25. EJB Server geronimo
26. EJB Server GlassFish
27. EJB Server JBoss 4.2.1
28. EJB Server resin 3.1.5
29. ERP CRM Financial
30. ESB
31. Forum
32. GIS
33. Graphic Library
34. Groupware
35. HTML Parser
36. IDE
37. IDE Eclipse
38. IDE Netbeans
39. Installer
40. Internationalization Localization
41. Inversion of Control
42. Issue Tracking
43. J2EE
44. JBoss
45. JMS
46. JMX
47. Library
48. Mail Clients
49. Net
50. Parser
51. PDF
52. Portal
53. Profiler
54. Project Management
55. Report
56. RSS RDF
57. Rule Engine
58. Science
59. Scripting
60. Search Engine
61. Security
62. Sevlet Container
63. Source Control
64. Swing Library
65. Template Engine
66. Test Coverage
67. Testing
68. UML
69. Web Crawler
70. Web Framework
71. Web Mail
72. Web Server
73. Web Services
74. Web Services apache cxf 2.0.1
75. Web Services AXIS2
76. Wiki Engine
77. Workflow Engines
78. XML
79. XML UI
Java
Java Tutorial
Java Open Source
Jar File Download
Java Articles
Java Products
Java by API
Photoshop Tutorials
Maya Tutorials
Flash Tutorials
3ds-Max Tutorials
Illustrator Tutorials
GIMP Tutorials
C# / C Sharp
C# / CSharp Tutorial
C# / CSharp Open Source
ASP.Net
ASP.NET Tutorial
JavaScript DHTML
JavaScript Tutorial
JavaScript Reference
HTML / CSS
HTML CSS Reference
C / ANSI-C
C Tutorial
C++
C++ Tutorial
Ruby
PHP
Python
Python Tutorial
Python Open Source
SQL Server / T-SQL
SQL Server / T-SQL Tutorial
Oracle PL / SQL
Oracle PL/SQL Tutorial
PostgreSQL
SQL / MySQL
MySQL Tutorial
VB.Net
VB.Net Tutorial
Flash / Flex / ActionScript
VBA / Excel / Access / Word
XML
XML Tutorial
Microsoft Office PowerPoint 2007 Tutorial
Microsoft Office Excel 2007 Tutorial
Microsoft Office Word 2007 Tutorial
Java Source Code / Java Documentation » Chart » jfreechart » org.jfree.chart.entity 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


001:        /* ===========================================================
002:         * JFreeChart : a free chart library for the Java(tm) platform
003:         * ===========================================================
004:         *
005:         * (C) Copyright 2000-2007, by Object Refinery Limited and Contributors.
006:         *
007:         * Project Info:  http://www.jfree.org/jfreechart/index.html
008:         *
009:         * This library is free software; you can redistribute it and/or modify it 
010:         * under the terms of the GNU Lesser General Public License as published by 
011:         * the Free Software Foundation; either version 2.1 of the License, or 
012:         * (at your option) any later version.
013:         *
014:         * This library is distributed in the hope that it will be useful, but 
015:         * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY 
016:         * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public 
017:         * License for more details.
018:         *
019:         * You should have received a copy of the GNU Lesser General Public
020:         * License along with this library; if not, write to the Free Software
021:         * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, 
022:         * USA.  
023:         *
024:         * [Java is a trademark or registered trademark of Sun Microsystems, Inc. 
025:         * in the United States and other countries.]
026:         *
027:         * -----------------------
028:         * CategoryItemEntity.java
029:         * -----------------------
030:         * (C) Copyright 2002-2007, by Object Refinery Limited and Contributors.
031:         *
032:         * Original Author:  David Gilbert (for Object Refinery Limited);
033:         * Contributor(s):   Richard Atkinson;
034:         *                   Christian W. Zuckschwerdt;
035:         *
036:         * $Id: CategoryItemEntity.java,v 1.5.2.2 2007/05/18 10:28:19 mungady Exp $
037:         *
038:         * Changes:
039:         * --------
040:         * 23-May-2002 : Version 1 (DG);
041:         * 12-Jun-2002 : Added Javadoc comments (DG);
042:         * 26-Jun-2002 : Added getImageMapAreaTag() method (DG);
043:         * 05-Aug-2002 : Added new constructor to populate URLText
044:         *               Moved getImageMapAreaTag() to ChartEntity (superclass) (RA);
045:         * 03-Oct-2002 : Fixed errors reported by Checkstyle (DG);
046:         * 30-Jul-2003 : Added CategoryDataset reference (CZ);
047:         * 20-May-2004 : Added equals() and clone() methods, and implemented 
048:         *               Serializable (DG);
049:         * 11-Jan-2005 : Removed deprecated code in preparation for 1.0.0 release (DG);
050:         * ------------- JFREECHART 1.0.x ---------------------------------------------
051:         * 18-May-2007 : Updated to use row and column keys to identify item (DG);
052:         *
053:         */
054:
055:        package org.jfree.chart.entity;
056:
057:        import java.awt.Shape;
058:        import java.io.Serializable;
059:
060:        import org.jfree.data.category.CategoryDataset;
061:        import org.jfree.util.ObjectUtilities;
062:
063:        /**
064:         * A chart entity that represents one item within a category plot.
065:         */
066:        public class CategoryItemEntity extends ChartEntity implements 
067:                Cloneable, Serializable {
068:
069:            /** For serialization. */
070:            private static final long serialVersionUID = -8657249457902337349L;
071:
072:            /** The dataset. */
073:            private CategoryDataset dataset;
074:
075:            /** 
076:             * The series (zero-based index). 
077:             * 
078:             * @deprecated As of 1.0.6, this field is redundant as you can derive the
079:             *         index from the <code>rowKey</code> field.
080:             */
081:            private int series;
082:
083:            /** 
084:             * The category.
085:             * 
086:             * @deprecated As of 1.0.6, this field is deprecated in favour of the
087:             *         <code>columnKey</code> field.
088:             */
089:            private Object category;
090:
091:            /** 
092:             * The category index. 
093:             * 
094:             * @deprecated As of 1.0.6, this field is redundant as you can derive the
095:             *         index from the <code>columnKey</code> field.
096:             */
097:            private int categoryIndex;
098:
099:            /**
100:             * The row key.
101:             * 
102:             * @since 1.0.6
103:             */
104:            private Comparable rowKey;
105:
106:            /**
107:             * The column key.
108:             * 
109:             * @since 1.0.6
110:             */
111:            private Comparable columnKey;
112:
113:            /**
114:             * Creates a new category item entity.
115:             *
116:             * @param area  the area (<code>null</code> not permitted).
117:             * @param toolTipText  the tool tip text.
118:             * @param urlText  the URL text for HTML image maps.
119:             * @param dataset  the dataset.
120:             * @param series  the series (zero-based index).
121:             * @param category  the category.
122:             * @param categoryIndex  the category index.
123:             * 
124:             * @deprecated As of 1.0.6, use {@link #CategoryItemEntity(Shape, String, 
125:             *         String, CategoryDataset, Comparable, Comparable)}.
126:             */
127:            public CategoryItemEntity(Shape area, String toolTipText,
128:                    String urlText, CategoryDataset dataset, int series,
129:                    Object category, int categoryIndex) {
130:
131:                super (area, toolTipText, urlText);
132:                if (dataset == null) {
133:                    throw new IllegalArgumentException(
134:                            "Null 'dataset' argument.");
135:                }
136:                this .dataset = dataset;
137:                this .series = series;
138:                this .category = category;
139:                this .categoryIndex = categoryIndex;
140:                this .rowKey = dataset.getRowKey(series);
141:                this .columnKey = dataset.getColumnKey(categoryIndex);
142:            }
143:
144:            /**
145:             * Creates a new entity instance for an item in the specified dataset.
146:             * 
147:             * @param area  the 'hotspot' area (<code>null</code> not permitted).
148:             * @param toolTipText  the tool tip text.
149:             * @param urlText  the URL text.
150:             * @param dataset  the dataset (<code>null</code> not permitted).
151:             * @param rowKey  the row key (<code>null</code> not permitted).
152:             * @param columnKey  the column key (<code>null</code> not permitted).
153:             * 
154:             * @since 1.0.6
155:             */
156:            public CategoryItemEntity(Shape area, String toolTipText,
157:                    String urlText, CategoryDataset dataset, Comparable rowKey,
158:                    Comparable columnKey) {
159:                super (area, toolTipText, urlText);
160:                if (dataset == null) {
161:                    throw new IllegalArgumentException(
162:                            "Null 'dataset' argument.");
163:                }
164:                this .dataset = dataset;
165:                this .rowKey = rowKey;
166:                this .columnKey = columnKey;
167:
168:                // populate the deprecated fields
169:                this .series = dataset.getRowIndex(rowKey);
170:                this .category = columnKey;
171:                this .categoryIndex = dataset.getColumnIndex(columnKey);
172:            }
173:
174:            /**
175:             * Returns the dataset this entity refers to.  This can be used to 
176:             * differentiate between items in a chart that displays more than one
177:             * dataset.
178:             *
179:             * @return The dataset (never <code>null</code>).
180:             * 
181:             * @see #setDataset(CategoryDataset)
182:             */
183:            public CategoryDataset getDataset() {
184:                return this .dataset;
185:            }
186:
187:            /**
188:             * Sets the dataset this entity refers to.
189:             *
190:             * @param dataset  the dataset (<code>null</code> not permitted).
191:             * 
192:             * @see #getDataset()
193:             */
194:            public void setDataset(CategoryDataset dataset) {
195:                if (dataset == null) {
196:                    throw new IllegalArgumentException(
197:                            "Null 'dataset' argument.");
198:                }
199:                this .dataset = dataset;
200:            }
201:
202:            /**
203:             * Returns the row key.
204:             * 
205:             * @return The row key (never <code>null</code>).
206:             * 
207:             * @since 1.0.6
208:             * 
209:             * @see #setRowKey(Comparable)
210:             */
211:            public Comparable getRowKey() {
212:                return this .rowKey;
213:            }
214:
215:            /**
216:             * Sets the row key.
217:             * 
218:             * @param rowKey  the row key (<code>null</code> not permitted).
219:             * 
220:             * @since 1.0.6
221:             * 
222:             * @see #getRowKey()
223:             */
224:            public void setRowKey(Comparable rowKey) {
225:                this .rowKey = rowKey;
226:                // update the deprecated field
227:                this .series = this .dataset.getRowIndex(rowKey);
228:            }
229:
230:            /**
231:             * Returns the column key.
232:             * 
233:             * @return The column key (never <code>null</code>).
234:             * 
235:             * @since 1.0.6
236:             * 
237:             * @see #setColumnKey(Comparable)
238:             */
239:            public Comparable getColumnKey() {
240:                return this .columnKey;
241:            }
242:
243:            /**
244:             * Sets the column key.
245:             * 
246:             * @param columnKey  the column key (<code>null</code> not permitted).
247:             * 
248:             * @since 1.0.6
249:             * 
250:             * @see #getColumnKey()
251:             */
252:            public void setColumnKey(Comparable columnKey) {
253:                this .columnKey = columnKey;
254:                // update the deprecated fields
255:                this .category = columnKey;
256:                this .categoryIndex = this .dataset.getColumnIndex(columnKey);
257:            }
258:
259:            /**
260:             * Returns the series index.
261:             *
262:             * @return The series index.
263:             * 
264:             * @see #setSeries(int)
265:             * 
266:             * @deprecated As of 1.0.6, you can derive this information from the 
267:             *         {@link #getRowKey()} method.
268:             */
269:            public int getSeries() {
270:                return this .series;
271:            }
272:
273:            /**
274:             * Sets the series index.
275:             *
276:             * @param series  the series index (zero-based).
277:             * 
278:             * @see #getSeries()
279:             * 
280:             * @deprecated As of 1.0.6, you should use {@link #setRowKey(Comparable)} 
281:             *         to designate the series.
282:             */
283:            public void setSeries(int series) {
284:                this .series = series;
285:            }
286:
287:            /**
288:             * Returns the category.
289:             *
290:             * @return The category (possibly <code>null</code>).
291:             * 
292:             * @see #setCategory(Object)
293:             * 
294:             * @deprecated The return type for this method should be 
295:             *         <code>Comparable</code>, so it has been deprecated as of 
296:             *         version 1.0.6 and replaced by {@link #getColumnKey()}.
297:             */
298:            public Object getCategory() {
299:                return this .category;
300:            }
301:
302:            /**
303:             * Sets the category.
304:             *
305:             * @param category  the category (<code>null</code> permitted).
306:             * 
307:             * @see #getCategory()
308:             * 
309:             * @deprecated As of version 1.0.6, use {@link #setColumnKey(Comparable)}.
310:             */
311:            public void setCategory(Object category) {
312:                this .category = category;
313:            }
314:
315:            /**
316:             * Returns the category index.
317:             *
318:             * @return The index.
319:             * 
320:             * @see #setCategoryIndex(int)
321:             * 
322:             * @deprecated As of 1.0.6, you can derive this information from the 
323:             *         {@link #getColumnKey()} method.
324:             */
325:            public int getCategoryIndex() {
326:                return this .categoryIndex;
327:            }
328:
329:            /**
330:             * Sets the category index.
331:             *
332:             * @param index  the category index.
333:             * 
334:             * @see #getCategoryIndex()
335:             * 
336:             * @deprecated As of 1.0.6, use {@link #setColumnKey(Comparable)} to 
337:             *         designate the category.
338:             */
339:            public void setCategoryIndex(int index) {
340:                this .categoryIndex = index;
341:            }
342:
343:            /**
344:             * Returns a string representing this object (useful for debugging 
345:             * purposes).
346:             *
347:             * @return A string (never <code>null</code>).
348:             */
349:            public String toString() {
350:                return "CategoryItemEntity: rowKey=" + this .rowKey
351:                        + ", columnKey=" + this .columnKey + ", dataset="
352:                        + this .dataset;
353:            }
354:
355:            /**
356:             * Tests the entity for equality with an arbitrary object.
357:             * 
358:             * @param obj  the object (<code>null</code> permitted).
359:             * 
360:             * @return A boolean.
361:             */
362:            public boolean equals(Object obj) {
363:                if (obj == this ) {
364:                    return true;
365:                }
366:                if (!(obj instanceof  CategoryItemEntity)) {
367:                    return false;
368:                }
369:                CategoryItemEntity that = (CategoryItemEntity) obj;
370:                if (!this .rowKey.equals(that.rowKey)) {
371:                    return false;
372:                }
373:                if (!this .columnKey.equals(that.columnKey)) {
374:                    return false;
375:                }
376:                if (!ObjectUtilities.equal(this .dataset, that.dataset)) {
377:                    return false;
378:                }
379:
380:                // check the deprecated fields
381:                if (this .categoryIndex != that.categoryIndex) {
382:                    return false;
383:                }
384:                if (this .series != that.series) {
385:                    return false;
386:                }
387:                if (!ObjectUtilities.equal(this .category, that.category)) {
388:                    return false;
389:                }
390:                return super.equals(obj);
391:            }
392:
393:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.