01: /*
02: * Effect.java
03: *
04: * Created on March 18, 2007, 7:35 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 java.awt.Graphics2D;
19:
20: /**
21: * Interface to capture an animation effect for the effects panel intended to provide
22: * data back to the core controller as to when to stop, start or refresh an animation.
23: *
24: * @author nigel
25: */
26: public interface Effect {
27: /**
28: * Returned by update() if no further animations are required
29: */
30: public static final long EFFECT_FINISHED = -1;
31:
32: /**
33: * Returned by update() if no further timer based animations are
34: * required
35: */
36: public static final long EFFECT_INACTIVE = -2;
37:
38: /**
39: * This method should return true if the graphics context supplied to the
40: * update method should be protected (a-la paintComponent()), or preserved
41: * (a-la paint()).
42: *
43: * @return True if the context should be protected during this effects update
44: * false if it's fair game.
45: */
46: public boolean isLocalEffect();
47:
48: /**
49: * Causes the effect to be painted, the global context will be preserved
50: * based on the value of the isLocalEffect() call.
51: *
52: * @param graphics The graphics context
53: */
54: public void paintEffect(Graphics2D graphics);
55:
56: /**
57: * Asks the effect to update itself, returning the
58: * delay in milli-seconds before the next required update
59: *
60: * @return The number of milliseconds before the effect would like to update itself again, or
61: * EFFECT_FINISHED if there will be no further updates. To keep the effect being
62: * painted, but not based on timers (instead on repaint trigger only) use EFFECT_INACTIVE (effect will be drawn
63: * when repaint called, but not at other times).
64: */
65: public long update();
66: }
|