01: package com.xoetrope.swing.helper;
02:
03: import java.awt.Color;
04:
05: /**
06: *
07: * <p> Copyright (c) Xoetrope Ltd., 2001-2007, This software is licensed under
08: * the GNU Public License (GPL), please see license.txt for more details. If
09: * you make commercial use of this software you must purchase a commercial
10: * license from Xoetrope.</p>
11: * @author luano
12: */
13: public class FadeInHelper extends AnimationHelper {
14: private float[] rgba;
15: private Color originalColor;
16:
17: /** Creates a new instance of FadeInHelper */
18: public FadeInHelper() {
19: }
20:
21: public void init() {
22: if (originalColor == null) {
23: originalColor = targetComp.getForeground();
24: rgba = originalColor.getRGBComponents(null);
25:
26: rgba[0] = 1.0F - rgba[0];
27: rgba[1] = 1.0F - rgba[1];
28: rgba[2] = 1.0F - rgba[2];
29: rgba[3] = 1.0F - rgba[3];
30: }
31:
32: targetComp.setForeground(Color.white);
33: targetComp.repaint(0);
34: }
35:
36: public void updateComponent() {
37: float v = (1.0F - animationValue);
38: Color newColor = new Color(Math.min(1.0F, 1.0F - rgba[0] * v),
39: Math.min(1.0F, 1.0F - rgba[1] * v), Math.min(1.0F, 1.0F
40: - rgba[2] * v), Math.min(1.0F, 1.0F - rgba[3]
41: * v));
42: targetComp.setForeground(newColor);
43: targetComp.repaint(0);
44: }
45: }
|