1 43 44 package org.jfree.text; 45 46 import java.io.ObjectStreamException ; 47 import java.io.Serializable ; 48 49 54 public final class TextBlockAnchor implements Serializable { 55 56 57 private static final long serialVersionUID = -3045058380983401544L; 58 59 60 public static final TextBlockAnchor TOP_LEFT 61 = new TextBlockAnchor("TextBlockAnchor.TOP_LEFT"); 62 63 64 public static final TextBlockAnchor TOP_CENTER = new TextBlockAnchor( 65 "TextBlockAnchor.TOP_CENTER" 66 ); 67 68 69 public static final TextBlockAnchor TOP_RIGHT = new TextBlockAnchor( 70 "TextBlockAnchor.TOP_RIGHT" 71 ); 72 73 74 public static final TextBlockAnchor CENTER_LEFT = new TextBlockAnchor( 75 "TextBlockAnchor.CENTER_LEFT" 76 ); 77 78 79 public static final TextBlockAnchor CENTER 80 = new TextBlockAnchor("TextBlockAnchor.CENTER"); 81 82 83 public static final TextBlockAnchor CENTER_RIGHT = new TextBlockAnchor( 84 "TextBlockAnchor.CENTER_RIGHT" 85 ); 86 87 88 public static final TextBlockAnchor BOTTOM_LEFT 89 = new TextBlockAnchor("TextBlockAnchor.BOTTOM_LEFT"); 90 91 92 public static final TextBlockAnchor BOTTOM_CENTER 93 = new TextBlockAnchor("TextBlockAnchor.BOTTOM_CENTER"); 94 95 96 public static final TextBlockAnchor BOTTOM_RIGHT 97 = new TextBlockAnchor("TextBlockAnchor.BOTTOM_RIGHT"); 98 99 100 private String name; 101 102 107 private TextBlockAnchor(final String name) { 108 this.name = name; 109 } 110 111 116 public String toString() { 117 return this.name; 118 } 119 120 128 public boolean equals(final Object o) { 129 130 if (this == o) { 131 return true; 132 } 133 if (!(o instanceof TextBlockAnchor)) { 134 return false; 135 } 136 137 final TextBlockAnchor other = (TextBlockAnchor) o; 138 if (!this.name.equals(other.name)) { 139 return false; 140 } 141 142 return true; 143 } 144 145 150 public int hashCode() { 151 return this.name.hashCode(); 152 } 153 154 161 private Object readResolve() throws ObjectStreamException { 162 if (this.equals(TextBlockAnchor.TOP_CENTER)) { 163 return TextBlockAnchor.TOP_CENTER; 164 } 165 else if (this.equals(TextBlockAnchor.TOP_LEFT)) { 166 return TextBlockAnchor.TOP_LEFT; 167 } 168 else if (this.equals(TextBlockAnchor.TOP_RIGHT)) { 169 return TextBlockAnchor.TOP_RIGHT; 170 } 171 else if (this.equals(TextBlockAnchor.CENTER)) { 172 return TextBlockAnchor.CENTER; 173 } 174 else if (this.equals(TextBlockAnchor.CENTER_LEFT)) { 175 return TextBlockAnchor.CENTER_LEFT; 176 } 177 else if (this.equals(TextBlockAnchor.CENTER_RIGHT)) { 178 return TextBlockAnchor.CENTER_RIGHT; 179 } 180 else if (this.equals(TextBlockAnchor.BOTTOM_CENTER)) { 181 return TextBlockAnchor.BOTTOM_CENTER; 182 } 183 else if (this.equals(TextBlockAnchor.BOTTOM_LEFT)) { 184 return TextBlockAnchor.BOTTOM_LEFT; 185 } 186 else if (this.equals(TextBlockAnchor.BOTTOM_RIGHT)) { 187 return TextBlockAnchor.BOTTOM_RIGHT; 188 } 189 return null; 190 } 191 192 } 193 | Popular Tags |