Comments and minor debugging additions.
git-svn-id: svn+ssh://src.earth.threerings.net/narya/trunk@61 542714f4-19e9-0310-aa3c-eee0fc999fb1
This commit is contained in:
@@ -1,5 +1,5 @@
|
|||||||
//
|
//
|
||||||
// $Id: IsoSceneView.java,v 1.4 2001/07/16 22:12:01 shaper Exp $
|
// $Id: IsoSceneView.java,v 1.5 2001/07/18 21:19:00 shaper Exp $
|
||||||
|
|
||||||
package com.threerings.cocktail.miso.scene;
|
package com.threerings.cocktail.miso.scene;
|
||||||
|
|
||||||
@@ -89,7 +89,8 @@ public class IsoSceneView implements SceneView
|
|||||||
// TODO: draw layers L1+.
|
// TODO: draw layers L1+.
|
||||||
Tile tile = _scene.tiles[tx][ty][Scene.LAYER_BASE];
|
Tile tile = _scene.tiles[tx][ty][Scene.LAYER_BASE];
|
||||||
|
|
||||||
g2.drawImage(tile.img, screenX, screenY, null);
|
int ypos = screenY - (tile.img.getHeight() - Tile.HEIGHT);
|
||||||
|
g2.drawImage(tile.img, screenX, ypos, null);
|
||||||
|
|
||||||
//paintCoords(g2, tx, ty, screenX, screenY);
|
//paintCoords(g2, tx, ty, screenX, screenY);
|
||||||
|
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
//
|
//
|
||||||
// $Id: ImageManager.java,v 1.4 2001/07/16 22:12:01 shaper Exp $
|
// $Id: ImageManager.java,v 1.5 2001/07/18 21:19:00 shaper Exp $
|
||||||
|
|
||||||
package com.threerings.cocktail.miso.media;
|
package com.threerings.cocktail.miso.media;
|
||||||
|
|
||||||
@@ -9,16 +9,33 @@ import java.awt.*;
|
|||||||
import java.awt.image.*;
|
import java.awt.image.*;
|
||||||
import java.util.Hashtable;
|
import java.util.Hashtable;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The ImageManager class provides a single point of access for image
|
||||||
|
* retrieval and caching.
|
||||||
|
*
|
||||||
|
* <p> <b>Note:</b> The ImageManager must be initialized with a root
|
||||||
|
* AWT component before images can be retrieved, in the interest of
|
||||||
|
* allowing for proper preparation of images for optimal storage and
|
||||||
|
* eventual display.
|
||||||
|
*/
|
||||||
public class ImageManager
|
public class ImageManager
|
||||||
{
|
{
|
||||||
public static Toolkit tk = Toolkit.getDefaultToolkit();
|
public static Toolkit tk = Toolkit.getDefaultToolkit();
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Initialize the ImageManager with a root component to which
|
||||||
|
* images will later be rendered.
|
||||||
|
*/
|
||||||
public static void init (Component root)
|
public static void init (Component root)
|
||||||
{
|
{
|
||||||
_root = root;
|
_root = root;
|
||||||
tk = root.getToolkit();
|
tk = root.getToolkit();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Load the image from the specified filename and cache it for
|
||||||
|
* faster retrieval henceforth.
|
||||||
|
*/
|
||||||
public static Image getImage (String fname)
|
public static Image getImage (String fname)
|
||||||
{
|
{
|
||||||
if (_root == null) {
|
if (_root == null) {
|
||||||
@@ -26,6 +43,12 @@ public class ImageManager
|
|||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// TODO: fix this to properly find the file within the
|
||||||
|
// classpath. getResourceAsStream() returns an InputStream,
|
||||||
|
// but java.awt.Toolkit.createImage() can only take one of a
|
||||||
|
// byte[], String, URL, or ImageProducer.
|
||||||
|
fname = "/home/shaper/workspace/cocktail/" + fname;
|
||||||
|
|
||||||
Image img = (Image)_imgs.get(fname);
|
Image img = (Image)_imgs.get(fname);
|
||||||
if (img != null) {
|
if (img != null) {
|
||||||
Log.info("Retrieved image from cache [fname=" + fname + "].");
|
Log.info("Retrieved image from cache [fname=" + fname + "].");
|
||||||
@@ -55,6 +78,10 @@ public class ImageManager
|
|||||||
return img;
|
return img;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Creates a new image representing the specified rectangular
|
||||||
|
* section cropped from the specified full image object.
|
||||||
|
*/
|
||||||
public static BufferedImage getImageCropped (Image fullImg, int x, int y,
|
public static BufferedImage getImageCropped (Image fullImg, int x, int y,
|
||||||
int width, int height)
|
int width, int height)
|
||||||
{
|
{
|
||||||
|
|||||||
Reference in New Issue
Block a user