01: /*
02: * ComponentEffect.java
03: *
04: * Created on March 31, 2007, 1:12 AM
05: *
06: * Copyright 2006-2007 Nigel Hughes
07: *
08: * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except
09: * in compliance with the License. You may obtain a copy of the License at http://www.apache.org/
10: * licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software
11: * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR
12: * CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language
13: * governing permissions and limitations under the License.
14: */
15:
16: package com.blogofbug.swing.components.effects;
17:
18: import com.blogofbug.utility.ImageUtilities;
19: import java.awt.AlphaComposite;
20: import java.awt.Color;
21: import java.awt.Container;
22: import java.awt.GradientPaint;
23: import java.awt.Graphics2D;
24: import java.awt.event.ComponentEvent;
25: import java.awt.event.ComponentListener;
26: import java.awt.event.ContainerEvent;
27: import java.awt.event.ContainerListener;
28: import java.awt.geom.AffineTransform;
29: import java.awt.geom.Rectangle2D;
30: import java.awt.image.BufferedImage;
31: import javax.swing.JComponent;
32:
33: /**
34: *
35: * @author nigel
36: */
37: public abstract class ComponentEffect implements ContainerEffect,
38: ComponentListener {
39: protected JComponent theComponent;
40:
41: protected Container theContainer;
42:
43: protected EffectContainer effectContainer;
44:
45: /** Creates a new instance of ReflectComponent */
46: public ComponentEffect(Container container, JComponent component,
47: EffectContainer effectContainer) {
48: theContainer = container;
49: theComponent = component;
50: this .effectContainer = effectContainer;
51: theComponent.addComponentListener(this );
52: initializeEffect();
53: }
54:
55: public abstract void initializeEffect();
56:
57: public boolean isLocalEffect() {
58: return true;
59: }
60:
61: public long update() {
62: return EFFECT_INACTIVE;
63: }
64:
65: public void setComponent(JComponent theComponent) {
66: this .theComponent = theComponent;
67: initializeEffect();
68: }
69:
70: public JComponent getComponent(JComponent theComponent) {
71: return theComponent;
72: }
73:
74: public void componentResized(ComponentEvent componentEvent) {
75: if (componentEvent.getComponent().isVisible()) {
76: initializeEffect();
77: }
78: }
79:
80: public void componentMoved(ComponentEvent componentEvent) {
81: }
82:
83: public void componentShown(ComponentEvent componentEvent) {
84: initializeEffect();
85: }
86:
87: public void componentHidden(ComponentEvent componentEvent) {
88: }
89:
90: }
|