001/* =========================================================== 002 * JFreeChart : a free chart library for the Java(tm) platform 003 * =========================================================== 004 * 005 * (C) Copyright 2000-2020, 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-2020, by Object Refinery Limited. 031 * 032 * Original Author: David Gilbert (for Object Refinery Limited); 033 * Contributor(s): -; 034 * 035 */ 036 037package org.jfree.chart.labels; 038 039import java.io.ObjectStreamException; 040import java.io.Serializable; 041 042/** 043 * An enumeration of the positions that a value label can take, relative to an 044 * item in a {@link org.jfree.chart.plot.CategoryPlot}. 045 */ 046public final class ItemLabelAnchor implements Serializable { 047 048 /** For serialization. */ 049 private static final long serialVersionUID = -1233101616128695658L; 050 051 /** CENTER. */ 052 public static final ItemLabelAnchor CENTER 053 = new ItemLabelAnchor("ItemLabelAnchor.CENTER"); 054 055 /** INSIDE1. */ 056 public static final ItemLabelAnchor INSIDE1 057 = new ItemLabelAnchor("ItemLabelAnchor.INSIDE1"); 058 059 /** INSIDE2. */ 060 public static final ItemLabelAnchor INSIDE2 061 = new ItemLabelAnchor("ItemLabelAnchor.INSIDE2"); 062 063 /** INSIDE3. */ 064 public static final ItemLabelAnchor INSIDE3 065 = new ItemLabelAnchor("ItemLabelAnchor.INSIDE3"); 066 067 /** INSIDE4. */ 068 public static final ItemLabelAnchor INSIDE4 069 = new ItemLabelAnchor("ItemLabelAnchor.INSIDE4"); 070 071 /** INSIDE5. */ 072 public static final ItemLabelAnchor INSIDE5 073 = new ItemLabelAnchor("ItemLabelAnchor.INSIDE5"); 074 075 /** INSIDE6. */ 076 public static final ItemLabelAnchor INSIDE6 077 = new ItemLabelAnchor("ItemLabelAnchor.INSIDE6"); 078 079 /** INSIDE7. */ 080 public static final ItemLabelAnchor INSIDE7 081 = new ItemLabelAnchor("ItemLabelAnchor.INSIDE7"); 082 083 /** INSIDE8. */ 084 public static final ItemLabelAnchor INSIDE8 085 = new ItemLabelAnchor("ItemLabelAnchor.INSIDE8"); 086 087 /** INSIDE9. */ 088 public static final ItemLabelAnchor INSIDE9 089 = new ItemLabelAnchor("ItemLabelAnchor.INSIDE9"); 090 091 /** INSIDE10. */ 092 public static final ItemLabelAnchor INSIDE10 093 = new ItemLabelAnchor("ItemLabelAnchor.INSIDE10"); 094 095 /** INSIDE11. */ 096 public static final ItemLabelAnchor INSIDE11 097 = new ItemLabelAnchor("ItemLabelAnchor.INSIDE11"); 098 099 /** INSIDE12. */ 100 public static final ItemLabelAnchor INSIDE12 101 = new ItemLabelAnchor("ItemLabelAnchor.INSIDE12"); 102 103 /** OUTSIDE1. */ 104 public static final ItemLabelAnchor OUTSIDE1 105 = new ItemLabelAnchor("ItemLabelAnchor.OUTSIDE1"); 106 107 /** OUTSIDE2. */ 108 public static final ItemLabelAnchor OUTSIDE2 109 = new ItemLabelAnchor("ItemLabelAnchor.OUTSIDE2"); 110 111 /** OUTSIDE3. */ 112 public static final ItemLabelAnchor OUTSIDE3 113 = new ItemLabelAnchor("ItemLabelAnchor.OUTSIDE3"); 114 115 /** OUTSIDE4. */ 116 public static final ItemLabelAnchor OUTSIDE4 117 = new ItemLabelAnchor("ItemLabelAnchor.OUTSIDE4"); 118 119 /** OUTSIDE5. */ 120 public static final ItemLabelAnchor OUTSIDE5 121 = new ItemLabelAnchor("ItemLabelAnchor.OUTSIDE5"); 122 123 /** OUTSIDE6. */ 124 public static final ItemLabelAnchor OUTSIDE6 125 = new ItemLabelAnchor("ItemLabelAnchor.OUTSIDE6"); 126 127 /** OUTSIDE7. */ 128 public static final ItemLabelAnchor OUTSIDE7 129 = new ItemLabelAnchor("ItemLabelAnchor.OUTSIDE7"); 130 131 /** OUTSIDE8. */ 132 public static final ItemLabelAnchor OUTSIDE8 133 = new ItemLabelAnchor("ItemLabelAnchor.OUTSIDE8"); 134 135 /** OUTSIDE9. */ 136 public static final ItemLabelAnchor OUTSIDE9 137 = new ItemLabelAnchor("ItemLabelAnchor.OUTSIDE9"); 138 139 /** OUTSIDE10. */ 140 public static final ItemLabelAnchor OUTSIDE10 141 = new ItemLabelAnchor("ItemLabelAnchor.OUTSIDE10"); 142 143 /** OUTSIDE11. */ 144 public static final ItemLabelAnchor OUTSIDE11 145 = new ItemLabelAnchor("ItemLabelAnchor.OUTSIDE11"); 146 147 /** OUTSIDE12. */ 148 public static final ItemLabelAnchor OUTSIDE12 149 = new ItemLabelAnchor("ItemLabelAnchor.OUTSIDE12"); 150 151 /** The name. */ 152 private String name; 153 154 /** 155 * Private constructor. 156 * 157 * @param name the name. 158 */ 159 private ItemLabelAnchor(String name) { 160 this.name = name; 161 } 162 163 /** 164 * Returns a string representing the object. 165 * 166 * @return The string. 167 */ 168 @Override 169 public String toString() { 170 return this.name; 171 } 172 173 /** 174 * Returns {@code true} if this object is equal to the specified 175 * object, and {@code false} otherwise. 176 * 177 * @param obj the other object. 178 * 179 * @return A boolean. 180 */ 181 @Override 182 public boolean equals(Object obj) { 183 if (this == obj) { 184 return true; 185 } 186 if (!(obj instanceof ItemLabelAnchor)) { 187 return false; 188 } 189 ItemLabelAnchor that = (ItemLabelAnchor) obj; 190 if (!this.name.equals(that.toString())) { 191 return false; 192 } 193 return true; 194 } 195 196 /** 197 * Ensures that serialization returns the unique instances. 198 * 199 * @return The object. 200 * 201 * @throws ObjectStreamException if there is a problem. 202 */ 203 private Object readResolve() throws ObjectStreamException { 204 ItemLabelAnchor result = null; 205 if (this.equals(ItemLabelAnchor.CENTER)) { 206 result = ItemLabelAnchor.CENTER; 207 } 208 else if (this.equals(ItemLabelAnchor.INSIDE1)) { 209 result = ItemLabelAnchor.INSIDE1; 210 } 211 else if (this.equals(ItemLabelAnchor.INSIDE2)) { 212 result = ItemLabelAnchor.INSIDE2; 213 } 214 else if (this.equals(ItemLabelAnchor.INSIDE3)) { 215 result = ItemLabelAnchor.INSIDE3; 216 } 217 else if (this.equals(ItemLabelAnchor.INSIDE4)) { 218 result = ItemLabelAnchor.INSIDE4; 219 } 220 else if (this.equals(ItemLabelAnchor.INSIDE5)) { 221 result = ItemLabelAnchor.INSIDE5; 222 } 223 else if (this.equals(ItemLabelAnchor.INSIDE6)) { 224 result = ItemLabelAnchor.INSIDE6; 225 } 226 else if (this.equals(ItemLabelAnchor.INSIDE7)) { 227 result = ItemLabelAnchor.INSIDE7; 228 } 229 else if (this.equals(ItemLabelAnchor.INSIDE8)) { 230 result = ItemLabelAnchor.INSIDE8; 231 } 232 else if (this.equals(ItemLabelAnchor.INSIDE9)) { 233 result = ItemLabelAnchor.INSIDE9; 234 } 235 else if (this.equals(ItemLabelAnchor.INSIDE10)) { 236 result = ItemLabelAnchor.INSIDE10; 237 } 238 else if (this.equals(ItemLabelAnchor.INSIDE11)) { 239 result = ItemLabelAnchor.INSIDE11; 240 } 241 else if (this.equals(ItemLabelAnchor.INSIDE12)) { 242 result = ItemLabelAnchor.INSIDE12; 243 } 244 else if (this.equals(ItemLabelAnchor.OUTSIDE1)) { 245 result = ItemLabelAnchor.OUTSIDE1; 246 } 247 else if (this.equals(ItemLabelAnchor.OUTSIDE2)) { 248 result = ItemLabelAnchor.OUTSIDE2; 249 } 250 else if (this.equals(ItemLabelAnchor.OUTSIDE3)) { 251 result = ItemLabelAnchor.OUTSIDE3; 252 } 253 else if (this.equals(ItemLabelAnchor.OUTSIDE4)) { 254 result = ItemLabelAnchor.OUTSIDE4; 255 } 256 else if (this.equals(ItemLabelAnchor.OUTSIDE5)) { 257 result = ItemLabelAnchor.OUTSIDE5; 258 } 259 else if (this.equals(ItemLabelAnchor.OUTSIDE6)) { 260 result = ItemLabelAnchor.OUTSIDE6; 261 } 262 else if (this.equals(ItemLabelAnchor.OUTSIDE7)) { 263 result = ItemLabelAnchor.OUTSIDE7; 264 } 265 else if (this.equals(ItemLabelAnchor.OUTSIDE8)) { 266 result = ItemLabelAnchor.OUTSIDE8; 267 } 268 else if (this.equals(ItemLabelAnchor.OUTSIDE9)) { 269 result = ItemLabelAnchor.OUTSIDE9; 270 } 271 else if (this.equals(ItemLabelAnchor.OUTSIDE10)) { 272 result = ItemLabelAnchor.OUTSIDE10; 273 } 274 else if (this.equals(ItemLabelAnchor.OUTSIDE11)) { 275 result = ItemLabelAnchor.OUTSIDE11; 276 } 277 else if (this.equals(ItemLabelAnchor.OUTSIDE12)) { 278 result = ItemLabelAnchor.OUTSIDE12; 279 } 280 return result; 281 } 282 283}