001/* =========================================================== 002 * JFreeChart : a free chart library for the Java(tm) platform 003 * =========================================================== 004 * 005 * (C) Copyright 2000-2013, 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 * [Oracle and Java are registered trademarks of Oracle and/or its affiliates. 025 * Other names may be trademarks of their respective owners.] 026 * 027 * -------------------- 028 * ItemLabelAnchor.java 029 * -------------------- 030 * (C) Copyright 2003-2013, by Object Refinery Limited. 031 * 032 * Original Author: David Gilbert (for Object Refinery Limited); 033 * Contributor(s): -; 034 * 035 * Changes 036 * ------- 037 * 29-Apr-2003 : Version 1 (DG); 038 * 19-Feb-2004 : Moved to org.jfree.chart.labels package, added readResolve() 039 * method (DG); 040 * 11-Jan-2005 : Removed deprecated code in preparation for the 1.0.0 041 * release (DG); 042 * 043 */ 044 045package org.jfree.chart.labels; 046 047import java.io.ObjectStreamException; 048import java.io.Serializable; 049 050/** 051 * An enumeration of the positions that a value label can take, relative to an 052 * item in a {@link org.jfree.chart.plot.CategoryPlot}. 053 */ 054public final class ItemLabelAnchor implements Serializable { 055 056 /** For serialization. */ 057 private static final long serialVersionUID = -1233101616128695658L; 058 059 /** CENTER. */ 060 public static final ItemLabelAnchor CENTER 061 = new ItemLabelAnchor("ItemLabelAnchor.CENTER"); 062 063 /** INSIDE1. */ 064 public static final ItemLabelAnchor INSIDE1 065 = new ItemLabelAnchor("ItemLabelAnchor.INSIDE1"); 066 067 /** INSIDE2. */ 068 public static final ItemLabelAnchor INSIDE2 069 = new ItemLabelAnchor("ItemLabelAnchor.INSIDE2"); 070 071 /** INSIDE3. */ 072 public static final ItemLabelAnchor INSIDE3 073 = new ItemLabelAnchor("ItemLabelAnchor.INSIDE3"); 074 075 /** INSIDE4. */ 076 public static final ItemLabelAnchor INSIDE4 077 = new ItemLabelAnchor("ItemLabelAnchor.INSIDE4"); 078 079 /** INSIDE5. */ 080 public static final ItemLabelAnchor INSIDE5 081 = new ItemLabelAnchor("ItemLabelAnchor.INSIDE5"); 082 083 /** INSIDE6. */ 084 public static final ItemLabelAnchor INSIDE6 085 = new ItemLabelAnchor("ItemLabelAnchor.INSIDE6"); 086 087 /** INSIDE7. */ 088 public static final ItemLabelAnchor INSIDE7 089 = new ItemLabelAnchor("ItemLabelAnchor.INSIDE7"); 090 091 /** INSIDE8. */ 092 public static final ItemLabelAnchor INSIDE8 093 = new ItemLabelAnchor("ItemLabelAnchor.INSIDE8"); 094 095 /** INSIDE9. */ 096 public static final ItemLabelAnchor INSIDE9 097 = new ItemLabelAnchor("ItemLabelAnchor.INSIDE9"); 098 099 /** 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 @Override 177 public String toString() { 178 return this.name; 179 } 180 181 /** 182 * Returns <code>true</code> if this object is equal to the specified 183 * object, and <code>false</code> otherwise. 184 * 185 * @param obj the other object. 186 * 187 * @return A boolean. 188 */ 189 @Override 190 public boolean equals(Object obj) { 191 if (this == obj) { 192 return true; 193 } 194 if (!(obj instanceof ItemLabelAnchor)) { 195 return false; 196 } 197 ItemLabelAnchor that = (ItemLabelAnchor) obj; 198 if (!this.name.equals(that.toString())) { 199 return false; 200 } 201 return true; 202 } 203 204 /** 205 * Ensures that serialization returns the unique instances. 206 * 207 * @return The object. 208 * 209 * @throws ObjectStreamException if there is a problem. 210 */ 211 private Object readResolve() throws ObjectStreamException { 212 ItemLabelAnchor result = null; 213 if (this.equals(ItemLabelAnchor.CENTER)) { 214 result = ItemLabelAnchor.CENTER; 215 } 216 else if (this.equals(ItemLabelAnchor.INSIDE1)) { 217 result = ItemLabelAnchor.INSIDE1; 218 } 219 else if (this.equals(ItemLabelAnchor.INSIDE2)) { 220 result = ItemLabelAnchor.INSIDE2; 221 } 222 else if (this.equals(ItemLabelAnchor.INSIDE3)) { 223 result = ItemLabelAnchor.INSIDE3; 224 } 225 else if (this.equals(ItemLabelAnchor.INSIDE4)) { 226 result = ItemLabelAnchor.INSIDE4; 227 } 228 else if (this.equals(ItemLabelAnchor.INSIDE5)) { 229 result = ItemLabelAnchor.INSIDE5; 230 } 231 else if (this.equals(ItemLabelAnchor.INSIDE6)) { 232 result = ItemLabelAnchor.INSIDE6; 233 } 234 else if (this.equals(ItemLabelAnchor.INSIDE7)) { 235 result = ItemLabelAnchor.INSIDE7; 236 } 237 else if (this.equals(ItemLabelAnchor.INSIDE8)) { 238 result = ItemLabelAnchor.INSIDE8; 239 } 240 else if (this.equals(ItemLabelAnchor.INSIDE9)) { 241 result = ItemLabelAnchor.INSIDE9; 242 } 243 else if (this.equals(ItemLabelAnchor.INSIDE10)) { 244 result = ItemLabelAnchor.INSIDE10; 245 } 246 else if (this.equals(ItemLabelAnchor.INSIDE11)) { 247 result = ItemLabelAnchor.INSIDE11; 248 } 249 else if (this.equals(ItemLabelAnchor.INSIDE12)) { 250 result = ItemLabelAnchor.INSIDE12; 251 } 252 else if (this.equals(ItemLabelAnchor.OUTSIDE1)) { 253 result = ItemLabelAnchor.OUTSIDE1; 254 } 255 else if (this.equals(ItemLabelAnchor.OUTSIDE2)) { 256 result = ItemLabelAnchor.OUTSIDE2; 257 } 258 else if (this.equals(ItemLabelAnchor.OUTSIDE3)) { 259 result = ItemLabelAnchor.OUTSIDE3; 260 } 261 else if (this.equals(ItemLabelAnchor.OUTSIDE4)) { 262 result = ItemLabelAnchor.OUTSIDE4; 263 } 264 else if (this.equals(ItemLabelAnchor.OUTSIDE5)) { 265 result = ItemLabelAnchor.OUTSIDE5; 266 } 267 else if (this.equals(ItemLabelAnchor.OUTSIDE6)) { 268 result = ItemLabelAnchor.OUTSIDE6; 269 } 270 else if (this.equals(ItemLabelAnchor.OUTSIDE7)) { 271 result = ItemLabelAnchor.OUTSIDE7; 272 } 273 else if (this.equals(ItemLabelAnchor.OUTSIDE8)) { 274 result = ItemLabelAnchor.OUTSIDE8; 275 } 276 else if (this.equals(ItemLabelAnchor.OUTSIDE9)) { 277 result = ItemLabelAnchor.OUTSIDE9; 278 } 279 else if (this.equals(ItemLabelAnchor.OUTSIDE10)) { 280 result = ItemLabelAnchor.OUTSIDE10; 281 } 282 else if (this.equals(ItemLabelAnchor.OUTSIDE11)) { 283 result = ItemLabelAnchor.OUTSIDE11; 284 } 285 else if (this.equals(ItemLabelAnchor.OUTSIDE12)) { 286 result = ItemLabelAnchor.OUTSIDE12; 287 } 288 return result; 289 } 290 291}