All Downloads are FREE. Search and download functionalities are using the official Maven repository.

tripleplay.platform.JavaImageOverlay Maven / Gradle / Ivy

There is a newer version: 2.0.8
Show newest version
//
// Triple Play - utilities for use in PlayN-based games
// Copyright (c) 2011-2014, Three Rings Design, Inc. - All rights reserved.
// http://github.com/threerings/tripleplay/blob/master/LICENSE

package tripleplay.platform;

import java.awt.Graphics;

import javax.swing.JComponent;

import playn.core.Image;
import playn.java.JavaImage;

public class JavaImageOverlay extends JavaNativeOverlay
    implements ImageOverlay
{
    public JavaImageOverlay (JavaTPPlatform plat, Image image) {
        super(plat, new ImageComponent((JavaImage)image));
    }

    public Image image () {
        return ((ImageComponent)component).image;
    }

    public void repaint () {
        component.repaint();
    }

    protected static class ImageComponent extends JComponent
    {
        public final JavaImage image;

        public ImageComponent (JavaImage image) {
            this.image = image;
        }

        @Override public void paint (Graphics g) {
            g.drawImage(image.bufferedImage(), 0, 0, null);
        }
    }
}




© 2015 - 2025 Weber Informatics LLC | Privacy Policy