1
/* ========================================================================
2
* JCommon : a free general purpose class library for the Java(tm) platform
3
* ========================================================================
5
* (C) Copyright 2000-2005, by Object Refinery Limited and Contributors.
7
* Project Info: http://www.jfree.org/jcommon/index.html
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.
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.
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,
24
* [Java is a trademark or registered trademark of Sun Microsystems, Inc.
25
* in the United States and other countries.]
27
* --------------------
28
* TextBlockAnchor.java
29
* --------------------
30
* (C) Copyright 2003-2005, by Object Refinery Limited.
32
* Original Author: David Gilbert (for Object Refinery Limited);
35
* $Id: TextBlockAnchor.java,v 1.4 2005/10/18 13:17:16 mungady Exp $
39
* 06-Nov-2003 : Version 1 (DG);
40
* 22-Mar-2004 : Added readResolve() method (DG);
44
package org.jfree.text;
46
import java.io.ObjectStreamException;
47
import java.io.Serializable;
50
* Used to indicate the position of an anchor point for a text block.
52
* @author David Gilbert
54
public final class TextBlockAnchor implements Serializable {
56
/** For serialization. */
57
private static final long serialVersionUID = -3045058380983401544L;
60
public static final TextBlockAnchor TOP_LEFT
61
= new TextBlockAnchor("TextBlockAnchor.TOP_LEFT");
64
public static final TextBlockAnchor TOP_CENTER = new TextBlockAnchor(
65
"TextBlockAnchor.TOP_CENTER"
69
public static final TextBlockAnchor TOP_RIGHT = new TextBlockAnchor(
70
"TextBlockAnchor.TOP_RIGHT"
74
public static final TextBlockAnchor CENTER_LEFT = new TextBlockAnchor(
75
"TextBlockAnchor.CENTER_LEFT"
79
public static final TextBlockAnchor CENTER
80
= new TextBlockAnchor("TextBlockAnchor.CENTER");
83
public static final TextBlockAnchor CENTER_RIGHT = new TextBlockAnchor(
84
"TextBlockAnchor.CENTER_RIGHT"
88
public static final TextBlockAnchor BOTTOM_LEFT
89
= new TextBlockAnchor("TextBlockAnchor.BOTTOM_LEFT");
92
public static final TextBlockAnchor BOTTOM_CENTER
93
= new TextBlockAnchor("TextBlockAnchor.BOTTOM_CENTER");
96
public static final TextBlockAnchor BOTTOM_RIGHT
97
= new TextBlockAnchor("TextBlockAnchor.BOTTOM_RIGHT");
103
* Private constructor.
105
* @param name the name.
107
private TextBlockAnchor(final String name) {
112
* Returns a string representing the object.
114
* @return The string.
116
public String toString() {
121
* Returns <code>true</code> if this object is equal to the specified
122
* object, and <code>false</code> otherwise.
124
* @param o the other object.
128
public boolean equals(final Object o) {
133
if (!(o instanceof TextBlockAnchor)) {
137
final TextBlockAnchor other = (TextBlockAnchor) o;
138
if (!this.name.equals(other.name)) {
146
* Returns a hash code value for the object.
148
* @return the hashcode
150
public int hashCode() {
151
return this.name.hashCode();
155
* Ensures that serialization returns the unique instances.
157
* @return The object.
159
* @throws ObjectStreamException if there is a problem.
161
private Object readResolve() throws ObjectStreamException {
162
if (this.equals(TextBlockAnchor.TOP_CENTER)) {
163
return TextBlockAnchor.TOP_CENTER;
165
else if (this.equals(TextBlockAnchor.TOP_LEFT)) {
166
return TextBlockAnchor.TOP_LEFT;
168
else if (this.equals(TextBlockAnchor.TOP_RIGHT)) {
169
return TextBlockAnchor.TOP_RIGHT;
171
else if (this.equals(TextBlockAnchor.CENTER)) {
172
return TextBlockAnchor.CENTER;
174
else if (this.equals(TextBlockAnchor.CENTER_LEFT)) {
175
return TextBlockAnchor.CENTER_LEFT;
177
else if (this.equals(TextBlockAnchor.CENTER_RIGHT)) {
178
return TextBlockAnchor.CENTER_RIGHT;
180
else if (this.equals(TextBlockAnchor.BOTTOM_CENTER)) {
181
return TextBlockAnchor.BOTTOM_CENTER;
183
else if (this.equals(TextBlockAnchor.BOTTOM_LEFT)) {
184
return TextBlockAnchor.BOTTOM_LEFT;
186
else if (this.equals(TextBlockAnchor.BOTTOM_RIGHT)) {
187
return TextBlockAnchor.BOTTOM_RIGHT;