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: * PlotOrientation.java
029: * --------------------
030: * (C) Copyright 2003-2005, by Object Refinery Limited.
031: *
032: * Original Author: David Gilbert (for Object Refinery Limited);
033: * Contributor(s): -;
034: *
035: * $Id: PlotOrientation.java,v 1.4.2.1 2005/10/25 20:52:08 mungady Exp $
036: *
037: * Changes:
038: * --------
039: * 02-May-2003 : Version 1 (DG);
040: * 17-Jul-2003 : Added readResolve() method (DG);
041: *
042: */
043:
044: package org.jfree.chart.plot;
045:
046: import java.io.ObjectStreamException;
047: import java.io.Serializable;
048:
049: /**
050: * Used to indicate the orientation (horizontal or vertical) of a 2D plot.
051: */
052: public final class PlotOrientation implements Serializable {
053:
054: /** For serialization. */
055: private static final long serialVersionUID = -2508771828190337782L;
056:
057: /** For a plot where the range axis is horizontal. */
058: public static final PlotOrientation HORIZONTAL = new PlotOrientation(
059: "PlotOrientation.HORIZONTAL");
060:
061: /** For a plot where the range axis is vertical. */
062: public static final PlotOrientation VERTICAL = new PlotOrientation(
063: "PlotOrientation.VERTICAL");
064:
065: /** The name. */
066: private String name;
067:
068: /**
069: * Private constructor.
070: *
071: * @param name the name.
072: */
073: private PlotOrientation(String name) {
074: this .name = name;
075: }
076:
077: /**
078: * Returns a string representing the object.
079: *
080: * @return The string.
081: */
082: public String toString() {
083: return this .name;
084: }
085:
086: /**
087: * Returns <code>true</code> if this object is equal to the specified
088: * object, and <code>false</code> otherwise.
089: *
090: * @param o the other object.
091: *
092: * @return A boolean.
093: */
094: public boolean equals(Object o) {
095:
096: if (this == o) {
097: return true;
098: }
099: if (!(o instanceof PlotOrientation)) {
100: return false;
101: }
102:
103: PlotOrientation orientation = (PlotOrientation) o;
104: if (!this .name.equals(orientation.toString())) {
105: return false;
106: }
107:
108: return true;
109:
110: }
111:
112: /**
113: * Ensures that serialization returns the unique instances.
114: *
115: * @return The object.
116: *
117: * @throws ObjectStreamException if there is a problem.
118: */
119: private Object readResolve() throws ObjectStreamException {
120: Object result = null;
121: if (this.equals(PlotOrientation.HORIZONTAL)) {
122: result = PlotOrientation.HORIZONTAL;
123: } else if (this.equals(PlotOrientation.VERTICAL)) {
124: result = PlotOrientation.VERTICAL;
125: }
126: return result;
127: }
128:
129: }
|