1 43 44 package org.jfree.util; 45 46 import java.io.ObjectStreamException ; 47 import java.io.Serializable ; 48 49 54 public final class Rotation implements Serializable { 55 56 57 private static final long serialVersionUID = -4662815260201591676L; 58 59 60 public static final Rotation CLOCKWISE 61 = new Rotation("Rotation.CLOCKWISE", -1.0); 62 63 64 public static final Rotation ANTICLOCKWISE 65 = new Rotation("Rotation.ANTICLOCKWISE", 1.0); 66 67 68 private String name; 69 70 74 private double factor; 75 76 82 private Rotation(final String name, final double factor) { 83 this.name = name; 84 this.factor = factor; 85 } 86 87 92 public String toString() { 93 return this.name; 94 } 95 96 102 public double getFactor() { 103 return this.factor; 104 } 105 106 114 public boolean equals(final Object o) { 115 if (this == o) { 116 return true; 117 } 118 if (!(o instanceof Rotation)) { 119 return false; 120 } 121 122 final Rotation rotation = (Rotation) o; 123 124 if (this.factor != rotation.factor) { 125 return false; 126 } 127 128 return true; 129 } 130 131 136 public int hashCode() { 137 final long temp = Double.doubleToLongBits(this.factor); 138 return (int) (temp ^ (temp >>> 32)); 139 } 140 141 148 private Object readResolve() throws ObjectStreamException { 149 if (this.equals(Rotation.CLOCKWISE)) { 150 return Rotation.CLOCKWISE; 151 } 152 else if (this.equals(Rotation.ANTICLOCKWISE)) { 153 return Rotation.ANTICLOCKWISE; 154 } 155 return null; 156 } 157 158 } 159 | Popular Tags |