Source for org.jfree.chart.labels.ItemLabelAnchor

   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:  * ItemLabelAnchor.java
  29:  * --------------------
  30:  * (C) Copyright 2003-2007, by Object Refinery Limited.
  31:  *
  32:  * Original Author:  David Gilbert (for Object Refinery Limited);
  33:  * Contributor(s):   -;
  34:  *
  35:  * Changes
  36:  * -------
  37:  * 29-Apr-2003 : Version 1 (DG);
  38:  * 19-Feb-2004 : Moved to org.jfree.chart.labels package, added readResolve() 
  39:  *               method (DG);
  40:  * 11-Jan-2005 : Removed deprecated code in preparation for the 1.0.0 
  41:  *               release (DG);
  42:  *
  43:  */
  44: 
  45: package org.jfree.chart.labels;
  46: 
  47: import java.io.ObjectStreamException;
  48: import java.io.Serializable;
  49: 
  50: /**
  51:  * An enumeration of the positions that a value label can take, relative to an 
  52:  * item in a {@link org.jfree.chart.plot.CategoryPlot}.
  53:  */
  54: public final class ItemLabelAnchor implements Serializable {
  55: 
  56:     /** For serialization. */
  57:     private static final long serialVersionUID = -1233101616128695658L;
  58:     
  59:     /** CENTER. */
  60:     public static final ItemLabelAnchor CENTER 
  61:         = new ItemLabelAnchor("ItemLabelAnchor.CENTER");
  62: 
  63:     /** INSIDE1. */
  64:     public static final ItemLabelAnchor INSIDE1 
  65:         = new ItemLabelAnchor("ItemLabelAnchor.INSIDE1");
  66: 
  67:     /** INSIDE2. */
  68:     public static final ItemLabelAnchor INSIDE2 
  69:         = new ItemLabelAnchor("ItemLabelAnchor.INSIDE2");
  70: 
  71:     /** INSIDE3. */
  72:     public static final ItemLabelAnchor INSIDE3 
  73:         = new ItemLabelAnchor("ItemLabelAnchor.INSIDE3");
  74: 
  75:     /** INSIDE4. */
  76:     public static final ItemLabelAnchor INSIDE4 
  77:         = new ItemLabelAnchor("ItemLabelAnchor.INSIDE4");
  78: 
  79:     /** INSIDE5. */
  80:     public static final ItemLabelAnchor INSIDE5 
  81:         = new ItemLabelAnchor("ItemLabelAnchor.INSIDE5");
  82: 
  83:     /** INSIDE6. */
  84:     public static final ItemLabelAnchor INSIDE6 
  85:         = new ItemLabelAnchor("ItemLabelAnchor.INSIDE6");
  86: 
  87:     /** INSIDE7. */
  88:     public static final ItemLabelAnchor INSIDE7 
  89:         = new ItemLabelAnchor("ItemLabelAnchor.INSIDE7");
  90: 
  91:     /** INSIDE8. */
  92:     public static final ItemLabelAnchor INSIDE8 
  93:         = new ItemLabelAnchor("ItemLabelAnchor.INSIDE8");
  94: 
  95:     /** INSIDE9. */
  96:     public static final ItemLabelAnchor INSIDE9 
  97:         = new ItemLabelAnchor("ItemLabelAnchor.INSIDE9");
  98: 
  99:     /** INSIDE10. */
 100:     public static final ItemLabelAnchor INSIDE10 
 101:         = new ItemLabelAnchor("ItemLabelAnchor.INSIDE10");
 102: 
 103:     /** INSIDE11. */
 104:     public static final ItemLabelAnchor INSIDE11 
 105:         = new ItemLabelAnchor("ItemLabelAnchor.INSIDE11");
 106: 
 107:     /** INSIDE12. */
 108:     public static final ItemLabelAnchor INSIDE12 
 109:         = new ItemLabelAnchor("ItemLabelAnchor.INSIDE12");
 110: 
 111:     /** OUTSIDE1. */
 112:     public static final ItemLabelAnchor OUTSIDE1 
 113:         = new ItemLabelAnchor("ItemLabelAnchor.OUTSIDE1");
 114: 
 115:     /** OUTSIDE2. */
 116:     public static final ItemLabelAnchor OUTSIDE2 
 117:         = new ItemLabelAnchor("ItemLabelAnchor.OUTSIDE2");
 118: 
 119:     /** OUTSIDE3. */
 120:     public static final ItemLabelAnchor OUTSIDE3 
 121:         = new ItemLabelAnchor("ItemLabelAnchor.OUTSIDE3");
 122: 
 123:     /** OUTSIDE4. */
 124:     public static final ItemLabelAnchor OUTSIDE4 
 125:         = new ItemLabelAnchor("ItemLabelAnchor.OUTSIDE4");
 126: 
 127:     /** OUTSIDE5. */
 128:     public static final ItemLabelAnchor OUTSIDE5 
 129:         = new ItemLabelAnchor("ItemLabelAnchor.OUTSIDE5");
 130: 
 131:     /** OUTSIDE6. */
 132:     public static final ItemLabelAnchor OUTSIDE6 
 133:         = new ItemLabelAnchor("ItemLabelAnchor.OUTSIDE6");
 134: 
 135:     /** OUTSIDE7. */
 136:     public static final ItemLabelAnchor OUTSIDE7 
 137:         = new ItemLabelAnchor("ItemLabelAnchor.OUTSIDE7");
 138: 
 139:     /** OUTSIDE8. */
 140:     public static final ItemLabelAnchor OUTSIDE8 
 141:         = new ItemLabelAnchor("ItemLabelAnchor.OUTSIDE8");
 142: 
 143:     /** OUTSIDE9. */
 144:     public static final ItemLabelAnchor OUTSIDE9 
 145:         = new ItemLabelAnchor("ItemLabelAnchor.OUTSIDE9");
 146: 
 147:     /** OUTSIDE10. */
 148:     public static final ItemLabelAnchor OUTSIDE10 
 149:         = new ItemLabelAnchor("ItemLabelAnchor.OUTSIDE10");
 150: 
 151:     /** OUTSIDE11. */
 152:     public static final ItemLabelAnchor OUTSIDE11 
 153:         = new ItemLabelAnchor("ItemLabelAnchor.OUTSIDE11");
 154: 
 155:     /** OUTSIDE12. */
 156:     public static final ItemLabelAnchor OUTSIDE12 
 157:         = new ItemLabelAnchor("ItemLabelAnchor.OUTSIDE12");
 158: 
 159:     /** The name. */
 160:     private String name;
 161: 
 162:     /**
 163:      * Private constructor.
 164:      *
 165:      * @param name  the name.
 166:      */
 167:     private ItemLabelAnchor(String name) {
 168:         this.name = name;
 169:     }
 170: 
 171:     /**
 172:      * Returns a string representing the object.
 173:      *
 174:      * @return The string.
 175:      */
 176:     public String toString() {
 177:         return this.name;
 178:     }
 179: 
 180:     /**
 181:      * Returns <code>true</code> if this object is equal to the specified 
 182:      * object, and <code>false</code> otherwise.
 183:      *
 184:      * @param o  the other object.
 185:      *
 186:      * @return A boolean.
 187:      */
 188:     public boolean equals(Object o) {
 189: 
 190:         if (this == o) {
 191:             return true;
 192:         }
 193:         if (!(o instanceof ItemLabelAnchor)) {
 194:             return false;
 195:         }
 196: 
 197:         ItemLabelAnchor order = (ItemLabelAnchor) o;
 198:         if (!this.name.equals(order.toString())) {
 199:             return false;
 200:         }
 201: 
 202:         return true;
 203: 
 204:     }
 205:     
 206:     /**
 207:      * Ensures that serialization returns the unique instances.
 208:      * 
 209:      * @return The object.
 210:      * 
 211:      * @throws ObjectStreamException if there is a problem.
 212:      */
 213:     private Object readResolve() throws ObjectStreamException {
 214:         ItemLabelAnchor result = null;
 215:         if (this.equals(ItemLabelAnchor.CENTER)) {
 216:             result = ItemLabelAnchor.CENTER;
 217:         }
 218:         else if (this.equals(ItemLabelAnchor.INSIDE1)) {
 219:             result = ItemLabelAnchor.INSIDE1;
 220:         }
 221:         else if (this.equals(ItemLabelAnchor.INSIDE2)) {
 222:             result = ItemLabelAnchor.INSIDE2;
 223:         }
 224:         else if (this.equals(ItemLabelAnchor.INSIDE3)) {
 225:             result = ItemLabelAnchor.INSIDE3;
 226:         }
 227:         else if (this.equals(ItemLabelAnchor.INSIDE4)) {
 228:             result = ItemLabelAnchor.INSIDE4;
 229:         }
 230:         else if (this.equals(ItemLabelAnchor.INSIDE5)) {
 231:             result = ItemLabelAnchor.INSIDE5;
 232:         }
 233:         else if (this.equals(ItemLabelAnchor.INSIDE6)) {
 234:             result = ItemLabelAnchor.INSIDE6;
 235:         }
 236:         else if (this.equals(ItemLabelAnchor.INSIDE7)) {
 237:             result = ItemLabelAnchor.INSIDE7;
 238:         }
 239:         else if (this.equals(ItemLabelAnchor.INSIDE8)) {
 240:             result = ItemLabelAnchor.INSIDE8;
 241:         }
 242:         else if (this.equals(ItemLabelAnchor.INSIDE9)) {
 243:             result = ItemLabelAnchor.INSIDE9;
 244:         }
 245:         else if (this.equals(ItemLabelAnchor.INSIDE10)) {
 246:             result = ItemLabelAnchor.INSIDE10;
 247:         }
 248:         else if (this.equals(ItemLabelAnchor.INSIDE11)) {
 249:             result = ItemLabelAnchor.INSIDE11;
 250:         }
 251:         else if (this.equals(ItemLabelAnchor.INSIDE12)) {
 252:             result = ItemLabelAnchor.INSIDE12;
 253:         }
 254:         else if (this.equals(ItemLabelAnchor.OUTSIDE1)) {
 255:             result = ItemLabelAnchor.OUTSIDE1;
 256:         }
 257:         else if (this.equals(ItemLabelAnchor.OUTSIDE2)) {
 258:             result = ItemLabelAnchor.OUTSIDE2;
 259:         }
 260:         else if (this.equals(ItemLabelAnchor.OUTSIDE3)) {
 261:             result = ItemLabelAnchor.OUTSIDE3;
 262:         }
 263:         else if (this.equals(ItemLabelAnchor.OUTSIDE4)) {
 264:             result = ItemLabelAnchor.OUTSIDE4;
 265:         }
 266:         else if (this.equals(ItemLabelAnchor.OUTSIDE5)) {
 267:             result = ItemLabelAnchor.OUTSIDE5;
 268:         }
 269:         else if (this.equals(ItemLabelAnchor.OUTSIDE6)) {
 270:             result = ItemLabelAnchor.OUTSIDE6;
 271:         }
 272:         else if (this.equals(ItemLabelAnchor.OUTSIDE7)) {
 273:             result = ItemLabelAnchor.OUTSIDE7;
 274:         }
 275:         else if (this.equals(ItemLabelAnchor.OUTSIDE8)) {
 276:             result = ItemLabelAnchor.OUTSIDE8;
 277:         }
 278:         else if (this.equals(ItemLabelAnchor.OUTSIDE9)) {
 279:             result = ItemLabelAnchor.OUTSIDE9;
 280:         }
 281:         else if (this.equals(ItemLabelAnchor.OUTSIDE10)) {
 282:             result = ItemLabelAnchor.OUTSIDE10;
 283:         }
 284:         else if (this.equals(ItemLabelAnchor.OUTSIDE11)) {
 285:             result = ItemLabelAnchor.OUTSIDE11;
 286:         }
 287:         else if (this.equals(ItemLabelAnchor.OUTSIDE12)) {
 288:             result = ItemLabelAnchor.OUTSIDE12;
 289:         }
 290:         return result;
 291:     }
 292: 
 293: }