From 35c3458cd10dfa50511a831d0dc61b68a08edcef Mon Sep 17 00:00:00 2001 From: Michael Bayne Date: Fri, 6 May 2005 03:01:43 +0000 Subject: [PATCH] Pulled layoutLabel() into a method so we can call it again if we want to change our text. git-svn-id: svn+ssh://src.earth.threerings.net/narya/trunk@3542 542714f4-19e9-0310-aa3c-eee0fc999fb1 --- .../threerings/media/sprite/LabelSprite.java | 27 ++++++++++++------- 1 file changed, 18 insertions(+), 9 deletions(-) diff --git a/src/java/com/threerings/media/sprite/LabelSprite.java b/src/java/com/threerings/media/sprite/LabelSprite.java index e27ad7fdc..905927e9c 100644 --- a/src/java/com/threerings/media/sprite/LabelSprite.java +++ b/src/java/com/threerings/media/sprite/LabelSprite.java @@ -77,15 +77,7 @@ public class LabelSprite extends Sprite // if our label is not yet laid out, do the deed if (!_label.isLaidOut()) { - Graphics2D gfx = (Graphics2D)_mgr.getMediaPanel().getGraphics(); - if (gfx != null) { - gfx.setRenderingHint(RenderingHints.KEY_ANTIALIASING, - (_antiAliased) ? - RenderingHints.VALUE_ANTIALIAS_ON : - RenderingHints.VALUE_ANTIALIAS_OFF); - _label.layout(gfx); - gfx.dispose(); - } + layoutLabel(); } // size the bounds to fit our label @@ -98,6 +90,23 @@ public class LabelSprite extends Sprite _label.render(gfx, _bounds.x, _bounds.y); } + /** + * Lays out our underlying label which must be done if the text is + * changed. + */ + protected void layoutLabel () + { + Graphics2D gfx = (Graphics2D)_mgr.getMediaPanel().getGraphics(); + if (gfx != null) { + gfx.setRenderingHint(RenderingHints.KEY_ANTIALIASING, + (_antiAliased) ? + RenderingHints.VALUE_ANTIALIAS_ON : + RenderingHints.VALUE_ANTIALIAS_OFF); + _label.layout(gfx); + gfx.dispose(); + } + } + /** The label associated with this sprite. */ protected Label _label;