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
This commit is contained in:
@@ -77,15 +77,7 @@ public class LabelSprite extends Sprite
|
|||||||
|
|
||||||
// if our label is not yet laid out, do the deed
|
// if our label is not yet laid out, do the deed
|
||||||
if (!_label.isLaidOut()) {
|
if (!_label.isLaidOut()) {
|
||||||
Graphics2D gfx = (Graphics2D)_mgr.getMediaPanel().getGraphics();
|
layoutLabel();
|
||||||
if (gfx != null) {
|
|
||||||
gfx.setRenderingHint(RenderingHints.KEY_ANTIALIASING,
|
|
||||||
(_antiAliased) ?
|
|
||||||
RenderingHints.VALUE_ANTIALIAS_ON :
|
|
||||||
RenderingHints.VALUE_ANTIALIAS_OFF);
|
|
||||||
_label.layout(gfx);
|
|
||||||
gfx.dispose();
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// size the bounds to fit our label
|
// size the bounds to fit our label
|
||||||
@@ -98,6 +90,23 @@ public class LabelSprite extends Sprite
|
|||||||
_label.render(gfx, _bounds.x, _bounds.y);
|
_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. */
|
/** The label associated with this sprite. */
|
||||||
protected Label _label;
|
protected Label _label;
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user