diff --git a/src/main/java/schule/ngb/zm/anim/Animation.java b/src/main/java/schule/ngb/zm/anim/Animation.java new file mode 100644 index 0000000..793f352 --- /dev/null +++ b/src/main/java/schule/ngb/zm/anim/Animation.java @@ -0,0 +1,26 @@ +package schule.ngb.zm.anim; + +import schule.ngb.zm.events.EventDispatcher; + +public class Animation { + + EventDispatcher eventDispatcher; + + private EventDispatcher 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); + } + +} diff --git a/src/main/java/schule/ngb/zm/anim/AnimationListener.java b/src/main/java/schule/ngb/zm/anim/AnimationListener.java new file mode 100644 index 0000000..13e62da --- /dev/null +++ b/src/main/java/schule/ngb/zm/anim/AnimationListener.java @@ -0,0 +1,11 @@ +package schule.ngb.zm.anim; + +import schule.ngb.zm.events.Listener; + +public interface AnimationListener extends Listener { + + void animationStarted( Animation anim ); + + void animationStopped( Animation anim ); + +}