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:
@@ -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 our label is not yet laid out, do the deed
|
||||||
if (!_label.isLaidOut()) {
|
if (!_label.isLaidOut()) {
|
||||||
Graphics2D gfx = (Graphics2D)_mgr.getMediaPanel().getGraphics();
|
Graphics2D gfx = (Graphics2D)_mgr.createGraphics();
|
||||||
if (gfx != null) {
|
if (gfx != null) {
|
||||||
gfx.setRenderingHint(RenderingHints.KEY_ANTIALIASING,
|
gfx.setRenderingHint(RenderingHints.KEY_ANTIALIASING,
|
||||||
_antiAliased ?
|
_antiAliased ?
|
||||||
|
|||||||
@@ -254,7 +254,12 @@ public class ButtonSprite extends Sprite
|
|||||||
|
|
||||||
// lay out the label if not already
|
// lay out the label if not already
|
||||||
if (!_label.isLaidOut()) {
|
if (!_label.isLaidOut()) {
|
||||||
_label.layout(_mgr.getMediaPanel());
|
Graphics2D gfx = _mgr.createGraphics();
|
||||||
|
try {
|
||||||
|
_label.layout(gfx);
|
||||||
|
} finally {
|
||||||
|
gfx.dispose();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
updateBounds();
|
updateBounds();
|
||||||
|
|||||||
@@ -96,13 +96,17 @@ public class LabelSprite extends Sprite
|
|||||||
*/
|
*/
|
||||||
protected void layoutLabel ()
|
protected void layoutLabel ()
|
||||||
{
|
{
|
||||||
Graphics2D gfx = (Graphics2D)_mgr.getMediaPanel().getGraphics();
|
Graphics2D gfx = _mgr.createGraphics();
|
||||||
if (gfx != null) {
|
if (gfx == null) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
try {
|
||||||
gfx.setRenderingHint(RenderingHints.KEY_ANTIALIASING,
|
gfx.setRenderingHint(RenderingHints.KEY_ANTIALIASING,
|
||||||
(_antiAliased) ?
|
(_antiAliased) ?
|
||||||
RenderingHints.VALUE_ANTIALIAS_ON :
|
RenderingHints.VALUE_ANTIALIAS_ON :
|
||||||
RenderingHints.VALUE_ANTIALIAS_OFF);
|
RenderingHints.VALUE_ANTIALIAS_OFF);
|
||||||
_label.layout(gfx);
|
_label.layout(gfx);
|
||||||
|
} finally {
|
||||||
gfx.dispose();
|
gfx.dispose();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user