Frames | No Frames |
1: /* =========================================================== 2: * JFreeChart : a free chart library for the Java(tm) platform 3: * =========================================================== 4: * 5: * (C) Copyright 2000-2007, by Object Refinery Limited and Contributors. 6: * 7: * Project Info: http://www.jfree.org/jfreechart/index.html 8: * 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. 13: * 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. 18: * 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, 22: * USA. 23: * 24: * [Java is a trademark or registered trademark of Sun Microsystems, Inc. 25: * in the United States and other countries.] 26: * 27: * ------------------------ 28: * AreaRendererEndType.java 29: * ------------------------ 30: * (C) Copyright 2004-2007, by Object Refinery Limited. 31: * 32: * Original Author: David Gilbert (for Object Refinery Limited); 33: * Contributor(s): -; 34: * 35: * Changes: 36: * -------- 37: * 29-April-2004 : Version 1 (DG); 38: * 39: */ 40: 41: package org.jfree.chart.renderer; 42: 43: import java.io.ObjectStreamException; 44: import java.io.Serializable; 45: 46: /** 47: * An enumeration of the 'end types' for an area renderer. 48: */ 49: public final class AreaRendererEndType implements Serializable { 50: 51: /** For serialization. */ 52: private static final long serialVersionUID = -1774146392916359839L; 53: 54: /** 55: * The area tapers from the first or last value down to zero. 56: */ 57: public static final AreaRendererEndType TAPER = new AreaRendererEndType( 58: "AreaRendererEndType.TAPER" 59: ); 60: 61: /** 62: * The area is truncated at the first or last value. 63: */ 64: public static final AreaRendererEndType TRUNCATE = new AreaRendererEndType( 65: "AreaRendererEndType.TRUNCATE" 66: ); 67: 68: /** 69: * The area is levelled at the first or last value. 70: */ 71: public static final AreaRendererEndType LEVEL = new AreaRendererEndType( 72: "AreaRendererEndType.LEVEL" 73: ); 74: 75: /** The name. */ 76: private String name; 77: 78: /** 79: * Private constructor. 80: * 81: * @param name the name. 82: */ 83: private AreaRendererEndType(String name) { 84: this.name = name; 85: } 86: 87: /** 88: * Returns a string representing the object. 89: * 90: * @return The string. 91: */ 92: public String toString() { 93: return this.name; 94: } 95: 96: /** 97: * Returns <code>true</code> if this object is equal to the specified 98: * object, and <code>false</code> otherwise. 99: * 100: * @param o the other object. 101: * 102: * @return A boolean. 103: */ 104: public boolean equals(Object o) { 105: 106: if (this == o) { 107: return true; 108: } 109: if (!(o instanceof AreaRendererEndType)) { 110: return false; 111: } 112: 113: AreaRendererEndType t = (AreaRendererEndType) o; 114: if (!this.name.equals(t.toString())) { 115: return false; 116: } 117: 118: return true; 119: 120: } 121: 122: /** 123: * Ensures that serialization returns the unique instances. 124: * 125: * @return The object. 126: * 127: * @throws ObjectStreamException if there is a problem. 128: */ 129: private Object readResolve() throws ObjectStreamException { 130: Object result = null; 131: if (this.equals(AreaRendererEndType.LEVEL)) { 132: result = AreaRendererEndType.LEVEL; 133: } 134: else if (this.equals(AreaRendererEndType.TAPER)) { 135: result = AreaRendererEndType.TAPER; 136: } 137: else if (this.equals(AreaRendererEndType.TRUNCATE)) { 138: result = AreaRendererEndType.TRUNCATE; 139: } 140: return result; 141: } 142: 143: }