Mir2CachedPictureManager.java :  » Game » easy-game-client » egc » res » mir2 » Java Open Source

Java Open Source » Game » easy game client 
easy game client » egc » res » mir2 » Mir2CachedPictureManager.java
/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package egc.res.mir2;

import easy.egc.common.Cache;
import easy.egc.common.Key;
import egc.res.CachedPictureManager;
import egc.res.PictureManager;
import java.awt.Image;

/**
 * Mir2-> CachedPictureManger
 * @author easy
 */
public class Mir2CachedPictureManager extends CachedPictureManager implements Mir2PictureManager {

    public Mir2CachedPictureManager(Mir2PictureManager mgr, Cache cache) {
        super(mgr, cache);
    }

    public Mir2CachedPictureManager(Mir2PictureManager mgr) {
        super(mgr);
    }

    @Override
    public Mir2ResourceManager getResourceManager() {
        return (Mir2ResourceManager) super.getResourceManager();
    }

    @Override
    public Mir2PictureManager getPictureManager() {
        return (Mir2PictureManager) super.getPictureManager();
    }

    @Override
    public String getName(String name, int fileIndex) {
        return getPictureManager().getName(name, fileIndex);
    }

    @Override
    public Image getImage(String name, int fileIndex, int imageIndex) {
        if (name == null || imageIndex < 0) {
            return null;
        }
        String newName = getName(name, fileIndex);
        Key key = createKey(newName, imageIndex);
        Image img = (Image) getCacheWrapper().get(key);
        if (img == null) {
            img = getPictureManager().getImage(name, fileIndex, imageIndex);
            if (img != null) {
                getCacheWrapper().set(key, img, img.getWidth(null) * img.getHeight(null));
            }
        }
        return img;
    }
}
java2s.com  | Contact Us | Privacy Policy
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.