1 7 8 11 12 package java.awt.font; 13 14 import java.awt.geom.AffineTransform ; 15 16 46 47 public class FontRenderContext { 48 private transient AffineTransform tx; 49 private transient boolean bIsAntiAliased; 50 private transient boolean bUsesFractionalMetrics; 51 52 57 protected FontRenderContext() { 58 } 59 60 73 public FontRenderContext(AffineTransform tx, 74 boolean isAntiAliased, 75 boolean usesFractionalMetrics) { 76 if (tx != null && !tx.isIdentity()) { 77 this.tx = new AffineTransform (tx); 78 } 79 this.bIsAntiAliased = isAntiAliased; 80 this.bUsesFractionalMetrics = usesFractionalMetrics; 81 } 82 83 84 91 public AffineTransform getTransform() { 92 return (tx == null) ? new AffineTransform () : new AffineTransform (tx); 93 } 94 95 102 public boolean isAntiAliased() { 103 return this.bIsAntiAliased; 104 } 105 106 114 public boolean usesFractionalMetrics() { 115 return this.bUsesFractionalMetrics; 116 } 117 118 126 public boolean equals(Object obj) { 127 try { 128 return equals((FontRenderContext )obj); 129 } 130 catch (ClassCastException e) { 131 return false; 132 } 133 } 134 135 143 public boolean equals(FontRenderContext rhs) { 144 if (this == rhs) { 145 return true; 146 } 147 if (rhs != null && 148 rhs.bIsAntiAliased == bIsAntiAliased && 149 rhs.bUsesFractionalMetrics == bUsesFractionalMetrics) { 150 151 return tx == null ? rhs.tx == null : tx.equals(rhs.tx); 152 } 153 return false; 154 } 155 156 159 public int hashCode() { 160 int hash = tx == null ? 0 : tx.hashCode(); 161 if (bIsAntiAliased) { 162 hash ^= 0x1; 163 } 164 if (bUsesFractionalMetrics) { 165 hash ^= 0x2; 166 } 167 return hash; 168 } 169 } 170 | Popular Tags |