1/* 2 * ProGuard -- shrinking, optimization, obfuscation, and preverification 3 * of Java bytecode. 4 * 5 * Copyright (c) 2002-2014 Eric Lafortune (eric@graphics.cornell.edu) 6 * 7 * This program is free software; you can redistribute it and/or modify it 8 * under the terms of the GNU General Public License as published by the Free 9 * 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 */ 21package proguard.gui.splash; 22 23import java.awt.*; 24 25/** 26 * This Sprite represents an animated image. 27 * 28 * @author Eric Lafortune 29 */ 30public class ImageSprite implements Sprite 31{ 32 private final Image image; 33 private final VariableInt x; 34 private final VariableInt y; 35 private final VariableDouble scaleX; 36 private final VariableDouble scaleY; 37 38 39 /** 40 * Creates a new ImageSprite. 41 * @param image the Image to be painted. 42 * @param x the variable x-coordinate of the upper-left corner of the image. 43 * @param y the variable y-coordinate of the upper-left corner of the image. 44 * @param scaleX the variable x-scale of the image. 45 * @param scaleY the variable y-scale of the image. 46 */ 47 public ImageSprite(Image image, 48 VariableInt x, 49 VariableInt y, 50 VariableDouble scaleX, 51 VariableDouble scaleY) 52 { 53 this.image = image; 54 this.x = x; 55 this.y = y; 56 this.scaleX = scaleX; 57 this.scaleY = scaleY; 58 } 59 60 61 // Implementation for Sprite. 62 63 public void paint(Graphics graphics, long time) 64 { 65 int xt = x.getInt(time); 66 int yt = y.getInt(time); 67 68 double scale_x = scaleX.getDouble(time); 69 double scale_y = scaleY.getDouble(time); 70 71 int width = (int)(image.getWidth(null) * scale_x); 72 int height = (int)(image.getHeight(null) * scale_y); 73 74 graphics.drawImage(image, xt, yt, width, height, null); 75 } 76} 77