From d76fc6f518606def8ddc52e0cd4d8a29bd2536fc Mon Sep 17 00:00:00 2001 From: Sven Gothel <sgothel@jausoft.com> Date: Wed, 8 Mar 2023 05:39:56 +0100 Subject: Graph: Font: Add equals() + hash() API doc; GraphUI's Label*.setText(): Only modify values if text and/or font differs, skipping markShapeDirty() saves performance. --- src/jogl/classes/com/jogamp/graph/font/Font.java | 18 ++++++++++++++++++ .../jogamp/graph/font/typecast/TypecastFont.java | 3 +-- 2 files changed, 19 insertions(+), 2 deletions(-) (limited to 'src/jogl') diff --git a/src/jogl/classes/com/jogamp/graph/font/Font.java b/src/jogl/classes/com/jogamp/graph/font/Font.java index f296c77b3..1b5452a45 100644 --- a/src/jogl/classes/com/jogamp/graph/font/Font.java +++ b/src/jogl/classes/com/jogamp/graph/font/Font.java @@ -255,6 +255,24 @@ public interface Font { StringBuilder getAllNames(final StringBuilder string, final String separator); + /** + * Returns the hash code based on {@link #NAME_UNIQUNAME}. + * <p> + * {@inheritDoc} + * </p> + */ + @Override + int hashCode(); + + /** + * Returns true if other instance is of same type and {@link #NAME_UNIQUNAME} is equal. + * <p> + * {@inheritDoc} + * </p> + */ + @Override + boolean equals(final Object o); + /** * Return advance-width of given glyphID in font-units, sourced from `hmtx` table. * @param glyphID diff --git a/src/jogl/classes/jogamp/graph/font/typecast/TypecastFont.java b/src/jogl/classes/jogamp/graph/font/typecast/TypecastFont.java index 003795942..12128f5ad 100644 --- a/src/jogl/classes/jogamp/graph/font/typecast/TypecastFont.java +++ b/src/jogl/classes/jogamp/graph/font/typecast/TypecastFont.java @@ -456,8 +456,7 @@ class TypecastFont implements Font { public final boolean equals(final Object o) { if( this == o ) { return true; } if( o instanceof TypecastFont ) { - final TypecastFont of = (TypecastFont)o; - return of.font.getName(Font.NAME_UNIQUNAME).equals(font.getName(Font.NAME_UNIQUNAME)); + return ((TypecastFont)o).font.getName(Font.NAME_UNIQUNAME).equals(font.getName(Font.NAME_UNIQUNAME)); } return false; } -- cgit v1.2.3