001: /**
002: * ===========================================
003: * JFreeReport : a free Java reporting library
004: * ===========================================
005: *
006: * Project Info: http://reporting.pentaho.org/
007: *
008: * (C) Copyright 2001-2007, by Object Refinery Ltd, Pentaho Corporation and Contributors.
009: *
010: * This library is free software; you can redistribute it and/or modify it under the terms
011: * of the GNU Lesser General Public License as published by the Free Software Foundation;
012: * either version 2.1 of the License, or (at your option) any later version.
013: *
014: * This library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY;
015: * without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
016: * See the GNU Lesser General Public License for more details.
017: *
018: * You should have received a copy of the GNU Lesser General Public License along with this
019: * library; if not, write to the Free Software Foundation, Inc., 59 Temple Place, Suite 330,
020: * Boston, MA 02111-1307, USA.
021: *
022: * [Java is a trademark or registered trademark of Sun Microsystems, Inc.
023: * in the United States and other countries.]
024: *
025: * ------------
026: * VerticalTextAlign.java
027: * ------------
028: * (C) Copyright 2001-2007, by Object Refinery Ltd, Pentaho Corporation and Contributors.
029: */package org.jfree.report.style;
030:
031: import java.io.ObjectStreamException;
032: import java.io.Serializable;
033:
034: import org.jfree.report.util.ObjectStreamResolveException;
035:
036: /**
037: * Creation-Date: 24.11.2005, 17:08:01
038: *
039: * @author Thomas Morgner
040: */
041: public class VerticalTextAlign implements Serializable {
042: public static final VerticalTextAlign USE_SCRIPT = new VerticalTextAlign(
043: "use-script");
044: public static final VerticalTextAlign BASELINE = new VerticalTextAlign(
045: "baseline");
046: public static final VerticalTextAlign SUB = new VerticalTextAlign(
047: "sub");
048: public static final VerticalTextAlign SUPER = new VerticalTextAlign(
049: "super");
050:
051: public static final VerticalTextAlign TOP = new VerticalTextAlign(
052: "top");
053: public static final VerticalTextAlign TEXT_TOP = new VerticalTextAlign(
054: "text-top");
055: public static final VerticalTextAlign CENTRAL = new VerticalTextAlign(
056: "central");
057: public static final VerticalTextAlign MIDDLE = new VerticalTextAlign(
058: "middle");
059: public static final VerticalTextAlign BOTTOM = new VerticalTextAlign(
060: "bottom");
061: public static final VerticalTextAlign TEXT_BOTTOM = new VerticalTextAlign(
062: "text-bottom");
063: private String id;
064:
065: private VerticalTextAlign(final String id) {
066: this .id = id;
067: }
068:
069: /**
070: * Replaces the automatically generated instance with one of the enumeration instances.
071: *
072: * @return the resolved element
073: *
074: * @throws java.io.ObjectStreamException if the element could not be resolved.
075: */
076: protected Object readResolve() throws ObjectStreamException {
077: if (this .id.equals(VerticalTextAlign.USE_SCRIPT.id)) {
078: return VerticalTextAlign.USE_SCRIPT;
079: }
080: if (this .id.equals(VerticalTextAlign.BASELINE.id)) {
081: return VerticalTextAlign.BASELINE;
082: }
083: if (this .id.equals(VerticalTextAlign.SUPER.id)) {
084: return VerticalTextAlign.SUPER;
085: }
086: if (this .id.equals(VerticalTextAlign.SUB.id)) {
087: return VerticalTextAlign.SUB;
088: }
089: if (this .id.equals(VerticalTextAlign.TOP.id)) {
090: return VerticalTextAlign.TOP;
091: }
092: if (this .id.equals(VerticalTextAlign.TEXT_TOP.id)) {
093: return VerticalTextAlign.TEXT_TOP;
094: }
095: if (this .id.equals(VerticalTextAlign.BOTTOM.id)) {
096: return VerticalTextAlign.BOTTOM;
097: }
098: if (this .id.equals(VerticalTextAlign.TEXT_BOTTOM.id)) {
099: return VerticalTextAlign.TEXT_BOTTOM;
100: }
101: if (this .id.equals(VerticalTextAlign.CENTRAL.id)) {
102: return VerticalTextAlign.CENTRAL;
103: }
104: if (this .id.equals(VerticalTextAlign.MIDDLE.id)) {
105: return VerticalTextAlign.MIDDLE;
106: }
107: // unknown element alignment...
108: throw new ObjectStreamResolveException();
109: }
110:
111: public boolean equals(final Object o) {
112: if (this == o) {
113: return true;
114: }
115: if (o == null || getClass() != o.getClass()) {
116: return false;
117: }
118:
119: final VerticalTextAlign that = (VerticalTextAlign) o;
120:
121: if (!id.equals(that.id)) {
122: return false;
123: }
124:
125: return true;
126: }
127:
128: public int hashCode() {
129: return id.hashCode();
130: }
131: }
|