Some fiddling to support a potential wacky project.

git-svn-id: svn+ssh://src.earth.threerings.net/nenya/trunk@104 ed5b42cb-e716-0410-a449-f6a68f950b19
This commit is contained in:
Michael Bayne
2006-12-19 21:45:43 +00:00
parent ae23946af0
commit b44864c506
4 changed files with 18 additions and 7 deletions
@@ -56,11 +56,13 @@ public abstract class AbstractMediaManager
}
/**
* Returns the media panel with which we are coordinating.
* Creates a graphics that can be used to compute metrics or whatever else a media might need.
* The caller should call {@link Graphics2D#dispose} on the returned object when it is done
* with it.
*/
public MediaPanel getMediaPanel ()
public Graphics2D createGraphics ()
{
return _panel;
return (Graphics2D)_panel.getGraphics();
}
/**
@@ -61,7 +61,7 @@ public class FadeLabelAnimation extends FadeAnimation
// if our label is not yet laid out, do the deed
if (!_label.isLaidOut()) {
Graphics2D gfx = (Graphics2D)_mgr.getMediaPanel().getGraphics();
Graphics2D gfx = (Graphics2D)_mgr.createGraphics();
if (gfx != null) {
gfx.setRenderingHint(RenderingHints.KEY_ANTIALIASING,
_antiAliased ?
@@ -254,7 +254,12 @@ public class ButtonSprite extends Sprite
// lay out the label if not already
if (!_label.isLaidOut()) {
_label.layout(_mgr.getMediaPanel());
Graphics2D gfx = _mgr.createGraphics();
try {
_label.layout(gfx);
} finally {
gfx.dispose();
}
}
updateBounds();
@@ -96,13 +96,17 @@ public class LabelSprite extends Sprite
*/
protected void layoutLabel ()
{
Graphics2D gfx = (Graphics2D)_mgr.getMediaPanel().getGraphics();
if (gfx != null) {
Graphics2D gfx = _mgr.createGraphics();
if (gfx == null) {
return;
}
try {
gfx.setRenderingHint(RenderingHints.KEY_ANTIALIASING,
(_antiAliased) ?
RenderingHints.VALUE_ANTIALIAS_ON :
RenderingHints.VALUE_ANTIALIAS_OFF);
_label.layout(gfx);
} finally {
gfx.dispose();
}
}