mirror of
https://github.com/jneug/zeichenmaschine.git
synced 2026-04-14 14:43:33 +02:00
AnimationListener
This commit is contained in:
26
src/main/java/schule/ngb/zm/anim/Animation.java
Normal file
26
src/main/java/schule/ngb/zm/anim/Animation.java
Normal file
@@ -0,0 +1,26 @@
|
||||
package schule.ngb.zm.anim;
|
||||
|
||||
import schule.ngb.zm.events.EventDispatcher;
|
||||
|
||||
public class Animation {
|
||||
|
||||
EventDispatcher<Animation, AnimationListener> eventDispatcher;
|
||||
|
||||
private EventDispatcher<Animation, AnimationListener> initializeEventDispatcher() {
|
||||
if( eventDispatcher == null ) {
|
||||
eventDispatcher = new EventDispatcher<>();
|
||||
eventDispatcher.registerEventType("start", ( a, l ) -> l.animationStarted(a));
|
||||
eventDispatcher.registerEventType("stop", ( a, l ) -> l.animationStopped(a));
|
||||
}
|
||||
return eventDispatcher;
|
||||
}
|
||||
|
||||
public void addListener( AnimationListener listener ) {
|
||||
initializeEventDispatcher().addListener(listener);
|
||||
}
|
||||
|
||||
public void removeListener( AnimationListener listener ) {
|
||||
initializeEventDispatcher().removeListener(listener);
|
||||
}
|
||||
|
||||
}
|
||||
11
src/main/java/schule/ngb/zm/anim/AnimationListener.java
Normal file
11
src/main/java/schule/ngb/zm/anim/AnimationListener.java
Normal file
@@ -0,0 +1,11 @@
|
||||
package schule.ngb.zm.anim;
|
||||
|
||||
import schule.ngb.zm.events.Listener;
|
||||
|
||||
public interface AnimationListener extends Listener<Animation> {
|
||||
|
||||
void animationStarted( Animation anim );
|
||||
|
||||
void animationStopped( Animation anim );
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user