Automatically lay out our label if it has not already been.
git-svn-id: svn+ssh://src.earth.threerings.net/narya/trunk@3349 542714f4-19e9-0310-aa3c-eee0fc999fb1
This commit is contained in:
@@ -1,5 +1,5 @@
|
|||||||
//
|
//
|
||||||
// $Id: LabelSprite.java,v 1.6 2004/08/27 02:12:41 mdb Exp $
|
// $Id$
|
||||||
//
|
//
|
||||||
// Narya library - tools for developing networked games
|
// Narya library - tools for developing networked games
|
||||||
// Copyright (C) 2002-2004 Three Rings Design, Inc., All Rights Reserved
|
// Copyright (C) 2002-2004 Three Rings Design, Inc., All Rights Reserved
|
||||||
@@ -27,9 +27,10 @@ import java.awt.Graphics2D;
|
|||||||
import com.samskivert.swing.Label;
|
import com.samskivert.swing.Label;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* A sprite that uses a label to render itself. Assumes that the label
|
* A sprite that uses a label to render itself. If the label has not been
|
||||||
* has been previously laid out (see {@link Label#layout}). The label
|
* previously laid out (see {@link Label#layout}) it will be done when the
|
||||||
* should not be altered after the sprite is created.
|
* sprite is added to a media panel. The label should not be altered
|
||||||
|
* after the sprite is created.
|
||||||
*/
|
*/
|
||||||
public class LabelSprite extends Sprite
|
public class LabelSprite extends Sprite
|
||||||
{
|
{
|
||||||
@@ -55,6 +56,11 @@ public class LabelSprite extends Sprite
|
|||||||
{
|
{
|
||||||
super.init();
|
super.init();
|
||||||
|
|
||||||
|
// if our label is not yet laid out, do the deed
|
||||||
|
if (!_label.isLaidOut()) {
|
||||||
|
_label.layout(_mgr.getMediaPanel());
|
||||||
|
}
|
||||||
|
|
||||||
// size the bounds to fit our label
|
// size the bounds to fit our label
|
||||||
Dimension size = _label.getSize();
|
Dimension size = _label.getSize();
|
||||||
_bounds.width = size.width;
|
_bounds.width = size.width;
|
||||||
|
|||||||
Reference in New Issue
Block a user