diff options
-rw-r--r-- | ChangeLog | 6 | ||||
-rw-r--r-- | java/awt/font/TextLayout.java | 15 |
2 files changed, 19 insertions, 2 deletions
@@ -1,5 +1,11 @@ 2006-11-22 Roman Kennke <kennke@aicas.com> + * java/awt/font/TextLayout.java + (hash): New field. Caches the hash code. + (hashCode): Implemented. + +2006-11-22 Roman Kennke <kennke@aicas.com> + * java/awt/image/ImageFilter.java Reformat whole class. (getFilterInstance): Don't touch the consumer field. Don't check diff --git a/java/awt/font/TextLayout.java b/java/awt/font/TextLayout.java index 0362c2687..addf8a417 100644 --- a/java/awt/font/TextLayout.java +++ b/java/awt/font/TextLayout.java @@ -164,6 +164,11 @@ public final class TextLayout implements Cloneable private int[] visualToLogical; /** + * The cached hashCode. + */ + private int hash; + + /** * The default caret policy. */ public static final TextLayout.CaretPolicy DEFAULT_CARET_POLICY = @@ -1091,9 +1096,15 @@ public final class TextLayout implements Cloneable } public int hashCode () - throws NotImplementedException { - throw new Error ("not implemented"); + // This is implemented in sync to equals(). + if (hash == 0 && runs.length > 0) + { + hash = runs.length; + for (int i = 0; i < runs.length; i++) + hash ^= runs[i].glyphVector.hashCode(); + } + return hash; } public String toString () |