Moved subimage creation into overridable method.
git-svn-id: svn+ssh://src.earth.threerings.net/narya/trunk@1484 542714f4-19e9-0310-aa3c-eee0fc999fb1
This commit is contained in:
@@ -1,5 +1,5 @@
|
|||||||
//
|
//
|
||||||
// $Id: Tile.java,v 1.21 2002/06/19 00:20:49 mdb Exp $
|
// $Id: Tile.java,v 1.22 2002/06/19 08:26:22 mdb Exp $
|
||||||
|
|
||||||
package com.threerings.media.tile;
|
package com.threerings.media.tile;
|
||||||
|
|
||||||
@@ -30,6 +30,13 @@ public class Tile implements Cloneable
|
|||||||
{
|
{
|
||||||
_image = image;
|
_image = image;
|
||||||
_bounds = bounds;
|
_bounds = bounds;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Called to create our subimage.
|
||||||
|
*/
|
||||||
|
protected void createSubImage ()
|
||||||
|
{
|
||||||
if (_image instanceof BufferedImage) {
|
if (_image instanceof BufferedImage) {
|
||||||
_subimage = ImageUtil.getSubimage(_image, _bounds.x, _bounds.y,
|
_subimage = ImageUtil.getSubimage(_image, _bounds.x, _bounds.y,
|
||||||
_bounds.width, _bounds.height);
|
_bounds.width, _bounds.height);
|
||||||
@@ -61,11 +68,7 @@ public class Tile implements Cloneable
|
|||||||
*/
|
*/
|
||||||
public void paint (Graphics gfx, int x, int y)
|
public void paint (Graphics gfx, int x, int y)
|
||||||
{
|
{
|
||||||
// Shape oclip = gfx.getClip();
|
gfx.drawImage(getImage(), x, y, null);
|
||||||
// gfx.clipRect(x, y, getWidth(), getHeight());
|
|
||||||
// gfx.drawImage(_image, x - _bounds.x, y - _bounds.y, null);
|
|
||||||
// gfx.setClip(oclip);
|
|
||||||
gfx.drawImage(_subimage, x, y, null);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -86,6 +89,9 @@ public class Tile implements Cloneable
|
|||||||
*/
|
*/
|
||||||
public Image getImage ()
|
public Image getImage ()
|
||||||
{
|
{
|
||||||
|
if (_subimage == null) {
|
||||||
|
createSubImage();
|
||||||
|
}
|
||||||
return _subimage;
|
return _subimage;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user