01: /*
02: * ProGuard -- shrinking, optimization, obfuscation, and preverification
03: * of Java bytecode.
04: *
05: * Copyright (c) 2002-2007 Eric Lafortune (eric@graphics.cornell.edu)
06: *
07: * This program is free software; you can redistribute it and/or modify it
08: * under the terms of the GNU General Public License as published by the Free
09: * Software Foundation; either version 2 of the License, or (at your option)
10: * any later version.
11: *
12: * This program is distributed in the hope that it will be useful, but WITHOUT
13: * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
14: * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
15: * more details.
16: *
17: * You should have received a copy of the GNU General Public License along
18: * with this program; if not, write to the Free Software Foundation, Inc.,
19: * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
20: */
21: package proguard.gui.splash;
22:
23: import java.awt.*;
24:
25: /**
26: * This Sprite represents an animated image.
27: *
28: * @author Eric Lafortune
29: */
30: public class ImageSprite implements Sprite {
31: private final Image image;
32: private final VariableInt x;
33: private final VariableInt y;
34: private final VariableDouble scaleX;
35: private final VariableDouble scaleY;
36:
37: /**
38: * Creates a new ImageSprite.
39: * @param image the Image to be painted.
40: * @param x the variable x-coordinate of the upper-left corner of the image.
41: * @param y the variable y-coordinate of the upper-left corner of the image.
42: * @param scaleX the variable x-scale of the image.
43: * @param scaleY the variable y-scale of the image.
44: */
45: public ImageSprite(Image image, VariableInt x, VariableInt y,
46: VariableDouble scaleX, VariableDouble scaleY) {
47: this .image = image;
48: this .x = x;
49: this .y = y;
50: this .scaleX = scaleX;
51: this .scaleY = scaleY;
52: }
53:
54: // Implementation for Sprite.
55:
56: public void paint(Graphics graphics, long time) {
57: int xt = x.getInt(time);
58: int yt = y.getInt(time);
59:
60: double scale_x = scaleX.getDouble(time);
61: double scale_y = scaleY.getDouble(time);
62:
63: int width = (int) (image.getWidth(null) * scale_x);
64: int height = (int) (image.getHeight(null) * scale_y);
65:
66: graphics.drawImage(image, xt, yt, width, height, null);
67: }
68: }
|