001: /* ===========================================================
002: * JFreeChart : a free chart library for the Java(tm) platform
003: * ===========================================================
004: *
005: * (C) Copyright 2000-2005, 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: * CategoryTick.java
029: * -----------------
030: * (C) Copyright 2003, 2004, by Object Refinery Limited.
031: *
032: * Original Author: David Gilbert (for Object Refinery Limited);
033: * Contributor(s): -;
034: *
035: * $Id: CategoryTick.java,v 1.4.2.1 2005/10/25 20:37:34 mungady Exp $
036: *
037: * Changes
038: * -------
039: * 07-Nov-2003 : Version 1 (DG);
040: * 13-May-2004 : Added equals() method (DG);
041: *
042: */
043:
044: package org.jfree.chart.axis;
045:
046: import org.jfree.text.TextBlock;
047: import org.jfree.text.TextBlockAnchor;
048: import org.jfree.ui.TextAnchor;
049: import org.jfree.util.ObjectUtilities;
050:
051: /**
052: * A tick for a {@link CategoryAxis}.
053: */
054: public class CategoryTick extends Tick {
055:
056: /** The category. */
057: private Comparable category;
058:
059: /** The label. */
060: private TextBlock label;
061:
062: /** The label anchor. */
063: private TextBlockAnchor labelAnchor;
064:
065: /**
066: * Creates a new tick.
067: *
068: * @param category the category.
069: * @param label the label.
070: * @param labelAnchor the label anchor.
071: * @param rotationAnchor the rotation anchor.
072: * @param angle the rotation angle (in radians).
073: */
074: public CategoryTick(Comparable category, TextBlock label,
075: TextBlockAnchor labelAnchor, TextAnchor rotationAnchor,
076: double angle) {
077:
078: super ("", TextAnchor.CENTER, rotationAnchor, angle);
079: this .category = category;
080: this .label = label;
081: this .labelAnchor = labelAnchor;
082:
083: }
084:
085: /**
086: * Returns the category.
087: *
088: * @return The category.
089: */
090: public Comparable getCategory() {
091: return this .category;
092: }
093:
094: /**
095: * Returns the label.
096: *
097: * @return The label.
098: */
099: public TextBlock getLabel() {
100: return this .label;
101: }
102:
103: /**
104: * Returns the label anchor.
105: *
106: * @return The label anchor.
107: */
108: public TextBlockAnchor getLabelAnchor() {
109: return this .labelAnchor;
110: }
111:
112: /**
113: * Tests this category tick for equality with an arbitrary object.
114: *
115: * @param obj the object (<code>null</code> permitted).
116: *
117: * @return A boolean.
118: */
119: public boolean equals(Object obj) {
120: if (this == obj) {
121: return true;
122: }
123: if (obj instanceof CategoryTick && super .equals(obj)) {
124: CategoryTick that = (CategoryTick) obj;
125: if (!ObjectUtilities.equal(this .category, that.category)) {
126: return false;
127: }
128: if (!ObjectUtilities.equal(this .label, that.label)) {
129: return false;
130: }
131: if (!ObjectUtilities.equal(this .labelAnchor,
132: that.labelAnchor)) {
133: return false;
134: }
135: return true;
136: }
137: return false;
138: }
139:
140: /**
141: * Returns a hash code for this object.
142: *
143: * @return A hash code.
144: */
145: public int hashCode() {
146: int result = 41;
147: result = 37 * result + this .category.hashCode();
148: result = 37 * result + this .label.hashCode();
149: result = 37 * result + this.labelAnchor.hashCode();
150: return result;
151: }
152: }
|