diff --git a/PlayWall/src/main/java/de/tobias/playpad/design/ModernDesignAnimator.java b/PlayWall/src/main/java/de/tobias/playpad/design/ModernDesignAnimator.java index ffd70e7b8b949a039aeb21718fdd335de4193f16..08b99ef1e97ccbc31b46fc0622c5a00c119d4f5a 100644 --- a/PlayWall/src/main/java/de/tobias/playpad/design/ModernDesignAnimator.java +++ b/PlayWall/src/main/java/de/tobias/playpad/design/ModernDesignAnimator.java @@ -1,7 +1,7 @@ package de.tobias.playpad.design; import de.tobias.playpad.pad.view.IPadView; -import de.tobias.playpad.pad.viewcontroller.AbstractPadViewController; +import de.tobias.playpad.project.api.IPad; import de.tobias.playpad.util.FadeableColor; import de.tobias.playpad.view.PseudoClasses; import javafx.animation.KeyFrame; @@ -17,22 +17,21 @@ import java.util.HashMap; public class ModernDesignAnimator { - // alles nur static, neine objecte von der Klasse private ModernDesignAnimator() { } - private static HashMap<Integer, Timeline> timelines = new HashMap<>(); + private static final HashMap<Integer, Timeline> timelines = new HashMap<>(); - public static void animateFade(AbstractPadViewController padViewController, FadeableColor startColor, FadeableColor endColor, Duration duration) { + public static void animateFade(IPad pad, IPadView padView, FadeableColor startColor, FadeableColor endColor, Duration duration) { ObjectProperty<FadeableColor> backgroundColor = new SimpleObjectProperty<>(); Timeline timeline = new Timeline(new KeyFrame(Duration.seconds(0), new KeyValue(backgroundColor, startColor)), new KeyFrame(duration, new KeyValue(backgroundColor, endColor))); - animate(padViewController, timeline, backgroundColor); + animate(pad, padView, timeline, backgroundColor); } - public static void animateWarn(AbstractPadViewController padViewController, FadeableColor startColor, FadeableColor endColor, Duration duration) { + public static void animateWarn(IPad pad, IPadView padView, FadeableColor startColor, FadeableColor endColor, Duration duration) { ObjectProperty<FadeableColor> backgroundColor = new SimpleObjectProperty<>(); Timeline timeline = new Timeline(new KeyFrame(Duration.seconds(0), new KeyValue(backgroundColor, startColor)), @@ -42,17 +41,17 @@ public class ModernDesignAnimator { timeline.setAutoReverse(true); timeline.setCycleCount((int) (duration.toSeconds() / 0.625)); - animate(padViewController, timeline, backgroundColor); + animate(pad, padView, timeline, backgroundColor); } - private static void animate(AbstractPadViewController padViewController, Timeline timeline, ObjectProperty<FadeableColor> objectProperty) { - int index = padViewController.getPad().getPosition(); + private static void animate(IPad pad, IPadView padView, Timeline timeline, ObjectProperty<FadeableColor> objectProperty) { + int index = pad.getPosition(); if (timelines.containsKey(index)) { timelines.get(index).stop(); } - ChangeListener<FadeableColor> fadeListener = (observable, oldValue, newValue) -> padViewController.getView().setStyle("-fx-background-color: " + newValue.toString() + ";"); + ChangeListener<FadeableColor> fadeListener = (observable, oldValue, newValue) -> padView.setStyle("-fx-background-color: " + newValue.toString() + ";"); objectProperty.addListener(fadeListener); timeline.playFromStart(); @@ -60,7 +59,7 @@ public class ModernDesignAnimator { timeline.setOnFinished(event -> { objectProperty.removeListener(fadeListener); - padViewController.getView().setStyle(""); + padView.setStyle(""); timelines.remove(index); }); @@ -68,16 +67,15 @@ public class ModernDesignAnimator { timelines.put(index, timeline); } - public static void stopAnimation(AbstractPadViewController controller) { - int index = controller.getPad().getPosition(); + public static void stopAnimation(IPad pad) { + int index = pad.getPosition(); if (timelines.containsKey(index)) { timelines.get(index).stop(); } } - public static void warnFlash(AbstractPadViewController controller) { - final IPadView view = controller.getView(); + public static void warnFlash(IPadView view) { try { while (!Thread.interrupted()) { diff --git a/PlayWall/src/main/java/de/tobias/playpad/pad/listener/PadPositionListener.java b/PlayWall/src/main/java/de/tobias/playpad/pad/listener/PadPositionListener.java index 4feab061bd425d30897b40219658216fcaca8690..d2eee40c01f93808951f6e4039858d88ccdd5349 100644 --- a/PlayWall/src/main/java/de/tobias/playpad/pad/listener/PadPositionListener.java +++ b/PlayWall/src/main/java/de/tobias/playpad/pad/listener/PadPositionListener.java @@ -133,7 +133,7 @@ public class PadPositionListener implements Runnable, IPadPositionListener { final ModernDesignProvider modernDesign = PlayPadMain.getProgramInstance().getModernDesign(); final ModernWarningDesignHandler handler = modernDesign.warning(); - handler.stopWarning(controller); + handler.stopWarning(controller.getPad()); controller.getView().setStyle(""); } } diff --git a/PlayWall/src/main/scala/de/tobias/playpad/design/ModernWarningDesignHandlerImpl.scala b/PlayWall/src/main/scala/de/tobias/playpad/design/ModernWarningDesignHandlerImpl.scala index 30a8c490f5c00a9ae5a5171644f808a78adb8b16..c849a213aa92054184cf902f7c70ed597ab5db4c 100644 --- a/PlayWall/src/main/scala/de/tobias/playpad/design/ModernWarningDesignHandlerImpl.scala +++ b/PlayWall/src/main/scala/de/tobias/playpad/design/ModernWarningDesignHandlerImpl.scala @@ -3,6 +3,7 @@ package de.tobias.playpad.design import de.tobias.playpad.design.modern.ModernWarningDesignHandler import de.tobias.playpad.design.modern.model.ModernGlobalDesign import de.tobias.playpad.pad.viewcontroller.AbstractPadViewController +import de.tobias.playpad.project.api.IPad import de.tobias.playpad.util.FadeableColor import javafx.util.Duration @@ -10,11 +11,11 @@ class ModernWarningDesignHandlerImpl extends ModernWarningDesignHandler { override def performWarning(design: ModernGlobalDesign, fadeStartColor: FadeableColor, fadeStopColor: FadeableColor, controller: AbstractPadViewController, warningDuration: Duration): Unit = { if (design.isWarnAnimation) { - ModernDesignAnimator.animateWarn(controller, fadeStartColor, fadeStopColor, warningDuration) + ModernDesignAnimator.animateWarn(controller.getPad, controller.getView, fadeStartColor, fadeStopColor, warningDuration) } else { - ModernDesignAnimator.warnFlash(controller) + ModernDesignAnimator.warnFlash(controller.getView) } } - override def stopWarning(controller: AbstractPadViewController): Unit = ModernDesignAnimator.stopAnimation(controller) + override def stopWarning(pad: IPad): Unit = ModernDesignAnimator.stopAnimation(pad) } diff --git a/PlayWallCore/src/main/java/de/tobias/playpad/design/modern/ModernWarningDesignHandler.java b/PlayWallCore/src/main/java/de/tobias/playpad/design/modern/ModernWarningDesignHandler.java index aeed4d5a8545b740424eb8db62df65e6a85a8774..405b60e0c3b87a862005bd23501e8ad9d4005643 100644 --- a/PlayWallCore/src/main/java/de/tobias/playpad/design/modern/ModernWarningDesignHandler.java +++ b/PlayWallCore/src/main/java/de/tobias/playpad/design/modern/ModernWarningDesignHandler.java @@ -5,6 +5,7 @@ import de.tobias.playpad.design.modern.model.ModernGlobalDesign; import de.tobias.playpad.pad.Pad; import de.tobias.playpad.pad.content.play.Durationable; import de.tobias.playpad.pad.viewcontroller.AbstractPadViewController; +import de.tobias.playpad.project.api.IPad; import de.tobias.playpad.util.FadeableColor; import javafx.util.Duration; @@ -45,6 +46,6 @@ public interface ModernWarningDesignHandler { */ void performWarning(ModernGlobalDesign design, FadeableColor fadeStartColor, FadeableColor fadeStopColor, AbstractPadViewController controller, Duration duration); - default void stopWarning(AbstractPadViewController controller) { + default void stopWarning(IPad pad) { } }