Source for org.jfree.chart.renderer.AreaRendererEndType

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