1b72c5c2e5482cf10117b2b25f642f7616b2326c3Joe Onorato/*
2b72c5c2e5482cf10117b2b25f642f7616b2326c3Joe Onorato * ProGuard -- shrinking, optimization, obfuscation, and preverification
3b72c5c2e5482cf10117b2b25f642f7616b2326c3Joe Onorato *             of Java bytecode.
4b72c5c2e5482cf10117b2b25f642f7616b2326c3Joe Onorato *
5b9cc48a43ed984587c939d02fba5316bf5c0df6eYing Wang * Copyright (c) 2002-2013 Eric Lafortune (eric@graphics.cornell.edu)
6b72c5c2e5482cf10117b2b25f642f7616b2326c3Joe Onorato *
7b72c5c2e5482cf10117b2b25f642f7616b2326c3Joe Onorato * This program is free software; you can redistribute it and/or modify it
8b72c5c2e5482cf10117b2b25f642f7616b2326c3Joe Onorato * under the terms of the GNU General Public License as published by the Free
9b72c5c2e5482cf10117b2b25f642f7616b2326c3Joe Onorato * Software Foundation; either version 2 of the License, or (at your option)
10b72c5c2e5482cf10117b2b25f642f7616b2326c3Joe Onorato * any later version.
11b72c5c2e5482cf10117b2b25f642f7616b2326c3Joe Onorato *
12b72c5c2e5482cf10117b2b25f642f7616b2326c3Joe Onorato * This program is distributed in the hope that it will be useful, but WITHOUT
13b72c5c2e5482cf10117b2b25f642f7616b2326c3Joe Onorato * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
14b72c5c2e5482cf10117b2b25f642f7616b2326c3Joe Onorato * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
15b72c5c2e5482cf10117b2b25f642f7616b2326c3Joe Onorato * more details.
16b72c5c2e5482cf10117b2b25f642f7616b2326c3Joe Onorato *
17b72c5c2e5482cf10117b2b25f642f7616b2326c3Joe Onorato * You should have received a copy of the GNU General Public License along
18b72c5c2e5482cf10117b2b25f642f7616b2326c3Joe Onorato * with this program; if not, write to the Free Software Foundation, Inc.,
19b72c5c2e5482cf10117b2b25f642f7616b2326c3Joe Onorato * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
20b72c5c2e5482cf10117b2b25f642f7616b2326c3Joe Onorato */
21b72c5c2e5482cf10117b2b25f642f7616b2326c3Joe Onoratopackage proguard.gui.splash;
22b72c5c2e5482cf10117b2b25f642f7616b2326c3Joe Onorato
23b72c5c2e5482cf10117b2b25f642f7616b2326c3Joe Onoratoimport java.awt.*;
24b72c5c2e5482cf10117b2b25f642f7616b2326c3Joe Onorato
25b72c5c2e5482cf10117b2b25f642f7616b2326c3Joe Onorato/**
26b72c5c2e5482cf10117b2b25f642f7616b2326c3Joe Onorato * This Sprite represents an animated rounded rectangle. It can optionally be filled.
27b72c5c2e5482cf10117b2b25f642f7616b2326c3Joe Onorato *
28b72c5c2e5482cf10117b2b25f642f7616b2326c3Joe Onorato * @author Eric Lafortune
29b72c5c2e5482cf10117b2b25f642f7616b2326c3Joe Onorato */
30b72c5c2e5482cf10117b2b25f642f7616b2326c3Joe Onoratopublic class RectangleSprite implements Sprite
31b72c5c2e5482cf10117b2b25f642f7616b2326c3Joe Onorato{
32b72c5c2e5482cf10117b2b25f642f7616b2326c3Joe Onorato    private final boolean       filled;
33b72c5c2e5482cf10117b2b25f642f7616b2326c3Joe Onorato    private final VariableColor color;
34b72c5c2e5482cf10117b2b25f642f7616b2326c3Joe Onorato    private final VariableInt   x;
35b72c5c2e5482cf10117b2b25f642f7616b2326c3Joe Onorato    private final VariableInt   y;
36b72c5c2e5482cf10117b2b25f642f7616b2326c3Joe Onorato    private final VariableInt   width;
37b72c5c2e5482cf10117b2b25f642f7616b2326c3Joe Onorato    private final VariableInt   height;
38b72c5c2e5482cf10117b2b25f642f7616b2326c3Joe Onorato    private final VariableInt   arcWidth;
39b72c5c2e5482cf10117b2b25f642f7616b2326c3Joe Onorato    private final VariableInt   arcHeight;
40b72c5c2e5482cf10117b2b25f642f7616b2326c3Joe Onorato
41b72c5c2e5482cf10117b2b25f642f7616b2326c3Joe Onorato
42b72c5c2e5482cf10117b2b25f642f7616b2326c3Joe Onorato    /**
43b72c5c2e5482cf10117b2b25f642f7616b2326c3Joe Onorato     * Creates a new rectangular RectangleSprite.
44b72c5c2e5482cf10117b2b25f642f7616b2326c3Joe Onorato     * @param filled specifies whether the rectangle should be filled.
45b72c5c2e5482cf10117b2b25f642f7616b2326c3Joe Onorato     * @param color  the variable color of the rectangle.
46b72c5c2e5482cf10117b2b25f642f7616b2326c3Joe Onorato     * @param x      the variable x-ordinate of the upper-left corner of the rectangle.
47b72c5c2e5482cf10117b2b25f642f7616b2326c3Joe Onorato     * @param y      the variable y-ordinate of the upper-left corner of the rectangle.
48b72c5c2e5482cf10117b2b25f642f7616b2326c3Joe Onorato     * @param width  the variable width of the rectangle.
49b72c5c2e5482cf10117b2b25f642f7616b2326c3Joe Onorato     * @param height the variable height of the rectangle.
50b72c5c2e5482cf10117b2b25f642f7616b2326c3Joe Onorato     */
51b72c5c2e5482cf10117b2b25f642f7616b2326c3Joe Onorato    public RectangleSprite(boolean       filled,
52b72c5c2e5482cf10117b2b25f642f7616b2326c3Joe Onorato                           VariableColor color,
53b72c5c2e5482cf10117b2b25f642f7616b2326c3Joe Onorato                           VariableInt   x,
54b72c5c2e5482cf10117b2b25f642f7616b2326c3Joe Onorato                           VariableInt   y,
55b72c5c2e5482cf10117b2b25f642f7616b2326c3Joe Onorato                           VariableInt   width,
56b72c5c2e5482cf10117b2b25f642f7616b2326c3Joe Onorato                           VariableInt   height)
57b72c5c2e5482cf10117b2b25f642f7616b2326c3Joe Onorato    {
58b72c5c2e5482cf10117b2b25f642f7616b2326c3Joe Onorato        this(filled, color, x, y, width, height, new ConstantInt(0), new ConstantInt(0));
59b72c5c2e5482cf10117b2b25f642f7616b2326c3Joe Onorato    }
60b72c5c2e5482cf10117b2b25f642f7616b2326c3Joe Onorato
61b72c5c2e5482cf10117b2b25f642f7616b2326c3Joe Onorato
62b72c5c2e5482cf10117b2b25f642f7616b2326c3Joe Onorato    /**
63b72c5c2e5482cf10117b2b25f642f7616b2326c3Joe Onorato     * Creates a new RectangleSprite with rounded corners.
64b72c5c2e5482cf10117b2b25f642f7616b2326c3Joe Onorato     * @param filled specifies whether the rectangle should be filled.
65b72c5c2e5482cf10117b2b25f642f7616b2326c3Joe Onorato     * @param color     the variable color of the rectangle.
66b72c5c2e5482cf10117b2b25f642f7616b2326c3Joe Onorato     * @param x         the variable x-ordinate of the upper-left corner of the rectangle.
67b72c5c2e5482cf10117b2b25f642f7616b2326c3Joe Onorato     * @param y         the variable y-ordinate of the upper-left corner of the rectangle.
68b72c5c2e5482cf10117b2b25f642f7616b2326c3Joe Onorato     * @param width     the variable width of the rectangle.
69b72c5c2e5482cf10117b2b25f642f7616b2326c3Joe Onorato     * @param height    the variable height of the rectangle.
70b72c5c2e5482cf10117b2b25f642f7616b2326c3Joe Onorato     * @param arcWidth  the variable width of the corner arcs.
71b72c5c2e5482cf10117b2b25f642f7616b2326c3Joe Onorato     * @param arcHeight the variable height of the corner arcs.
72b72c5c2e5482cf10117b2b25f642f7616b2326c3Joe Onorato     */
73b72c5c2e5482cf10117b2b25f642f7616b2326c3Joe Onorato    public RectangleSprite(boolean       filled,
74b72c5c2e5482cf10117b2b25f642f7616b2326c3Joe Onorato                           VariableColor color,
75b72c5c2e5482cf10117b2b25f642f7616b2326c3Joe Onorato                           VariableInt   x,
76b72c5c2e5482cf10117b2b25f642f7616b2326c3Joe Onorato                           VariableInt   y,
77b72c5c2e5482cf10117b2b25f642f7616b2326c3Joe Onorato                           VariableInt   width,
78b72c5c2e5482cf10117b2b25f642f7616b2326c3Joe Onorato                           VariableInt   height,
79b72c5c2e5482cf10117b2b25f642f7616b2326c3Joe Onorato                           VariableInt   arcWidth,
80b72c5c2e5482cf10117b2b25f642f7616b2326c3Joe Onorato                           VariableInt   arcHeight)
81b72c5c2e5482cf10117b2b25f642f7616b2326c3Joe Onorato    {
82b72c5c2e5482cf10117b2b25f642f7616b2326c3Joe Onorato        this.filled    = filled;
83b72c5c2e5482cf10117b2b25f642f7616b2326c3Joe Onorato        this.color     = color;
84b72c5c2e5482cf10117b2b25f642f7616b2326c3Joe Onorato        this.x         = x;
85b72c5c2e5482cf10117b2b25f642f7616b2326c3Joe Onorato        this.y         = y;
86b72c5c2e5482cf10117b2b25f642f7616b2326c3Joe Onorato        this.width     = width;
87b72c5c2e5482cf10117b2b25f642f7616b2326c3Joe Onorato        this.height    = height;
88b72c5c2e5482cf10117b2b25f642f7616b2326c3Joe Onorato        this.arcWidth  = arcWidth;
89b72c5c2e5482cf10117b2b25f642f7616b2326c3Joe Onorato        this.arcHeight = arcHeight;
90b72c5c2e5482cf10117b2b25f642f7616b2326c3Joe Onorato    }
91b72c5c2e5482cf10117b2b25f642f7616b2326c3Joe Onorato
92b72c5c2e5482cf10117b2b25f642f7616b2326c3Joe Onorato    // Implementation for Sprite.
93b72c5c2e5482cf10117b2b25f642f7616b2326c3Joe Onorato
94b72c5c2e5482cf10117b2b25f642f7616b2326c3Joe Onorato    public void paint(Graphics graphics, long time)
95b72c5c2e5482cf10117b2b25f642f7616b2326c3Joe Onorato    {
96b72c5c2e5482cf10117b2b25f642f7616b2326c3Joe Onorato        graphics.setColor(color.getColor(time));
97b72c5c2e5482cf10117b2b25f642f7616b2326c3Joe Onorato
98b72c5c2e5482cf10117b2b25f642f7616b2326c3Joe Onorato        int xt = x.getInt(time);
99b72c5c2e5482cf10117b2b25f642f7616b2326c3Joe Onorato        int yt = y.getInt(time);
100b72c5c2e5482cf10117b2b25f642f7616b2326c3Joe Onorato        int w  = width.getInt(time);
101b72c5c2e5482cf10117b2b25f642f7616b2326c3Joe Onorato        int h  = height.getInt(time);
102b72c5c2e5482cf10117b2b25f642f7616b2326c3Joe Onorato        int aw = arcWidth.getInt(time);
103b72c5c2e5482cf10117b2b25f642f7616b2326c3Joe Onorato        int ah = arcHeight.getInt(time);
104b72c5c2e5482cf10117b2b25f642f7616b2326c3Joe Onorato
105b72c5c2e5482cf10117b2b25f642f7616b2326c3Joe Onorato        if (filled)
106b72c5c2e5482cf10117b2b25f642f7616b2326c3Joe Onorato        {
107b72c5c2e5482cf10117b2b25f642f7616b2326c3Joe Onorato            graphics.fillRoundRect(xt, yt, w, h, aw, ah);
108b72c5c2e5482cf10117b2b25f642f7616b2326c3Joe Onorato        }
109b72c5c2e5482cf10117b2b25f642f7616b2326c3Joe Onorato        else
110b72c5c2e5482cf10117b2b25f642f7616b2326c3Joe Onorato        {
111b72c5c2e5482cf10117b2b25f642f7616b2326c3Joe Onorato            graphics.drawRoundRect(xt, yt, w, h, aw, ah);
112b72c5c2e5482cf10117b2b25f642f7616b2326c3Joe Onorato        }
113b72c5c2e5482cf10117b2b25f642f7616b2326c3Joe Onorato    }
114b72c5c2e5482cf10117b2b25f642f7616b2326c3Joe Onorato}
115