diff --git a/LICENSE.txt b/LICENSE.txt old mode 100644 new mode 100755 diff --git a/README.md b/README.md old mode 100644 new mode 100755 diff --git a/assets/linux-icon.png b/assets/linux-icon.png old mode 100644 new mode 100755 diff --git a/assets/macos-icon.icns b/assets/macos-icon.icns old mode 100644 new mode 100755 diff --git a/assets/windows-icon.ico b/assets/windows-icon.ico old mode 100644 new mode 100755 diff --git a/pom.xml b/pom.xml old mode 100644 new mode 100755 diff --git a/src/android/AndroidManifest.xml b/src/android/AndroidManifest.xml old mode 100644 new mode 100755 diff --git a/src/android/mods/MainActivity.java b/src/android/mods/MainActivity.java old mode 100644 new mode 100755 diff --git a/src/android/res/mipmap-hdpi/ic_launcher.png b/src/android/res/mipmap-hdpi/ic_launcher.png old mode 100644 new mode 100755 diff --git a/src/android/res/mipmap-mdpi/ic_launcher.png b/src/android/res/mipmap-mdpi/ic_launcher.png old mode 100644 new mode 100755 diff --git a/src/android/res/mipmap-xhdpi/ic_launcher.png b/src/android/res/mipmap-xhdpi/ic_launcher.png old mode 100644 new mode 100755 diff --git a/src/android/res/mipmap-xxhdpi/ic_launcher.png b/src/android/res/mipmap-xxhdpi/ic_launcher.png old mode 100644 new mode 100755 diff --git a/src/android/res/mipmap-xxxhdpi/ic_launcher.png b/src/android/res/mipmap-xxxhdpi/ic_launcher.png old mode 100644 new mode 100755 diff --git a/src/ios/assets/Assets.xcassets/AppIcon.appiconset/100.png b/src/ios/assets/Assets.xcassets/AppIcon.appiconset/100.png old mode 100644 new mode 100755 diff --git a/src/ios/assets/Assets.xcassets/AppIcon.appiconset/1024.png b/src/ios/assets/Assets.xcassets/AppIcon.appiconset/1024.png old mode 100644 new mode 100755 diff --git a/src/ios/assets/Assets.xcassets/AppIcon.appiconset/114.png b/src/ios/assets/Assets.xcassets/AppIcon.appiconset/114.png old mode 100644 new mode 100755 diff --git a/src/ios/assets/Assets.xcassets/AppIcon.appiconset/120.png b/src/ios/assets/Assets.xcassets/AppIcon.appiconset/120.png old mode 100644 new mode 100755 diff --git a/src/ios/assets/Assets.xcassets/AppIcon.appiconset/144.png b/src/ios/assets/Assets.xcassets/AppIcon.appiconset/144.png old mode 100644 new mode 100755 diff --git a/src/ios/assets/Assets.xcassets/AppIcon.appiconset/152.png b/src/ios/assets/Assets.xcassets/AppIcon.appiconset/152.png old mode 100644 new mode 100755 diff --git a/src/ios/assets/Assets.xcassets/AppIcon.appiconset/167.png b/src/ios/assets/Assets.xcassets/AppIcon.appiconset/167.png old mode 100644 new mode 100755 diff --git a/src/ios/assets/Assets.xcassets/AppIcon.appiconset/180.png b/src/ios/assets/Assets.xcassets/AppIcon.appiconset/180.png old mode 100644 new mode 100755 diff --git a/src/ios/assets/Assets.xcassets/AppIcon.appiconset/20.png b/src/ios/assets/Assets.xcassets/AppIcon.appiconset/20.png old mode 100644 new mode 100755 diff --git a/src/ios/assets/Assets.xcassets/AppIcon.appiconset/29.png b/src/ios/assets/Assets.xcassets/AppIcon.appiconset/29.png old mode 100644 new mode 100755 diff --git a/src/ios/assets/Assets.xcassets/AppIcon.appiconset/40.png b/src/ios/assets/Assets.xcassets/AppIcon.appiconset/40.png old mode 100644 new mode 100755 diff --git a/src/ios/assets/Assets.xcassets/AppIcon.appiconset/50.png b/src/ios/assets/Assets.xcassets/AppIcon.appiconset/50.png old mode 100644 new mode 100755 diff --git a/src/ios/assets/Assets.xcassets/AppIcon.appiconset/57.png b/src/ios/assets/Assets.xcassets/AppIcon.appiconset/57.png old mode 100644 new mode 100755 diff --git a/src/ios/assets/Assets.xcassets/AppIcon.appiconset/58.png b/src/ios/assets/Assets.xcassets/AppIcon.appiconset/58.png old mode 100644 new mode 100755 diff --git a/src/ios/assets/Assets.xcassets/AppIcon.appiconset/60.png b/src/ios/assets/Assets.xcassets/AppIcon.appiconset/60.png old mode 100644 new mode 100755 diff --git a/src/ios/assets/Assets.xcassets/AppIcon.appiconset/72.png b/src/ios/assets/Assets.xcassets/AppIcon.appiconset/72.png old mode 100644 new mode 100755 diff --git a/src/ios/assets/Assets.xcassets/AppIcon.appiconset/76.png b/src/ios/assets/Assets.xcassets/AppIcon.appiconset/76.png old mode 100644 new mode 100755 diff --git a/src/ios/assets/Assets.xcassets/AppIcon.appiconset/80.png b/src/ios/assets/Assets.xcassets/AppIcon.appiconset/80.png old mode 100644 new mode 100755 diff --git a/src/ios/assets/Assets.xcassets/AppIcon.appiconset/87.png b/src/ios/assets/Assets.xcassets/AppIcon.appiconset/87.png old mode 100644 new mode 100755 diff --git a/src/ios/assets/Assets.xcassets/AppIcon.appiconset/Contents.json b/src/ios/assets/Assets.xcassets/AppIcon.appiconset/Contents.json old mode 100644 new mode 100755 diff --git a/src/ios/assets/Assets.xcassets/Contents.json b/src/ios/assets/Assets.xcassets/Contents.json old mode 100644 new mode 100755 diff --git a/src/ios/assets/Base.lproj/LaunchScreen.storyboard b/src/ios/assets/Base.lproj/LaunchScreen.storyboard old mode 100644 new mode 100755 diff --git a/src/ios/assets/Base.lproj/MainScreen.storyboard b/src/ios/assets/Base.lproj/MainScreen.storyboard old mode 100644 new mode 100755 diff --git a/src/ios/assets/Default-375w-667h@2x~iphone.png b/src/ios/assets/Default-375w-667h@2x~iphone.png old mode 100644 new mode 100755 diff --git a/src/ios/assets/Default-375w-812h-landscape@3x~iphone.png b/src/ios/assets/Default-375w-812h-landscape@3x~iphone.png old mode 100644 new mode 100755 diff --git a/src/ios/assets/Default-375w-812h@3x~iphone.png b/src/ios/assets/Default-375w-812h@3x~iphone.png old mode 100644 new mode 100755 diff --git a/src/ios/assets/Default-414w-736h-landscape@3x~iphone.png b/src/ios/assets/Default-414w-736h-landscape@3x~iphone.png old mode 100644 new mode 100755 diff --git a/src/ios/assets/Default-414w-736h@3x~iphone.png b/src/ios/assets/Default-414w-736h@3x~iphone.png old mode 100644 new mode 100755 diff --git a/src/ios/assets/Default-414w-896h-landscape@3x~iphone.png b/src/ios/assets/Default-414w-896h-landscape@3x~iphone.png old mode 100644 new mode 100755 diff --git a/src/ios/assets/Default-414w-896h@3x~iphone.png b/src/ios/assets/Default-414w-896h@3x~iphone.png old mode 100644 new mode 100755 diff --git a/src/ios/assets/Default-568h@2x~iphone.png b/src/ios/assets/Default-568h@2x~iphone.png old mode 100644 new mode 100755 diff --git a/src/ios/assets/Default-landscape@2x~ipad.png b/src/ios/assets/Default-landscape@2x~ipad.png old mode 100644 new mode 100755 diff --git a/src/ios/assets/Default-landscape~ipad.png b/src/ios/assets/Default-landscape~ipad.png old mode 100644 new mode 100755 diff --git a/src/ios/assets/Default-portrait@2x~ipad.png b/src/ios/assets/Default-portrait@2x~ipad.png old mode 100644 new mode 100755 diff --git a/src/ios/assets/Default-portrait~ipad.png b/src/ios/assets/Default-portrait~ipad.png old mode 100644 new mode 100755 diff --git a/src/ios/assets/Default@2x~iphone.png b/src/ios/assets/Default@2x~iphone.png old mode 100644 new mode 100755 diff --git a/src/ios/assets/iTunesArtwork.png b/src/ios/assets/iTunesArtwork.png old mode 100644 new mode 100755 diff --git a/src/ios/assets/iTunesArtwork@2x.png b/src/ios/assets/iTunesArtwork@2x.png old mode 100644 new mode 100755 diff --git a/src/main/java/com/stream_pi/client/Main.java b/src/main/java/com/stream_pi/client/Main.java old mode 100644 new mode 100755 diff --git a/src/main/java/com/stream_pi/client/animations/AnimateFXInterpolator.java b/src/main/java/com/stream_pi/client/animations/AnimateFXInterpolator.java new file mode 100755 index 00000000..df910c10 --- /dev/null +++ b/src/main/java/com/stream_pi/client/animations/AnimateFXInterpolator.java @@ -0,0 +1,13 @@ +package com.stream_pi.client.animations; + +import javafx.animation.Interpolator; + +public final class AnimateFXInterpolator { + + private AnimateFXInterpolator() { + throw new IllegalStateException("AnimateFX Interpolator"); + } + + public static final Interpolator EASE = Interpolator.SPLINE(0.25, 0.1, 0.25, 1); + +} diff --git a/src/main/java/com/stream_pi/client/animations/AnimationFX.java b/src/main/java/com/stream_pi/client/animations/AnimationFX.java new file mode 100755 index 00000000..faa54c7b --- /dev/null +++ b/src/main/java/com/stream_pi/client/animations/AnimationFX.java @@ -0,0 +1,204 @@ +package com.stream_pi.client.animations; + +import javafx.animation.Animation; +import javafx.animation.Timeline; +import javafx.event.ActionEvent; +import javafx.event.EventHandler; +import javafx.scene.Node; +import javafx.util.Duration; + + +/** + * @author Loïc Sculier aka typhon0 + */ +public abstract class AnimationFX { + + /** + * Used to specify an animation that repeats indefinitely, until the + * {@code stop()} method is called. + */ + public static final int INDEFINITE = -1; + private Timeline timeline; + private boolean reset; + private Node node; + private AnimationFX nextAnimation; + private boolean hasNextAnimation; + + /** + * Create a new animation + * + * @param node the node to affect + */ + public AnimationFX(Node node) { + super(); + setNode(node); + + } + + /** + * Default constructor + */ + public AnimationFX() { + hasNextAnimation = false; + this.reset = false; + } + + /** + * Handle when the animation is finished + * + * @return + */ + private AnimationFX onFinished() { + if (reset) { + resetNode(); + } + if (this.nextAnimation != null) { + this.nextAnimation.play(); + } + return this; + } + + /** + * Set the next animation to play + * + * @param animation + * @return + */ + public AnimationFX playOnFinished(AnimationFX animation) { + setNextAnimation(animation); + return this; + + } + + /** + * Function to reset the node or not when the animation is finished + * + * @param reset + * @return + */ + public AnimationFX setResetOnFinished(boolean reset) { + this.reset = reset; + return this; + } + + /** + * Play the animation + */ + public void play() { + timeline.play(); + } + + /** + * Stop the animation + * + * @return + */ + public AnimationFX stop() { + timeline.stop(); + return this; + } + + /** + * Function the reset the node to original state + * + * @return + */ + abstract AnimationFX resetNode(); + + /** + * Function to initialize the timeline + */ + abstract void initTimeline(); + + + public Timeline getTimeline() { + return timeline; + } + + public void setTimeline(Timeline timeline) { + this.timeline = timeline; + } + + public boolean isResetOnFinished() { + return reset; + } + + protected void setReset(boolean reset) { + this.reset = reset; + } + + public Node getNode() { + return node; + } + + public void setNode(Node node) { + this.node = node; + initTimeline(); + timeline.statusProperty().addListener((observable, oldValue, newValue) -> { + if (newValue.equals(Animation.Status.STOPPED)) { + onFinished(); + } + + }); + } + + public AnimationFX getNextAnimation() { + return nextAnimation; + } + + protected void setNextAnimation(AnimationFX nextAnimation) { + hasNextAnimation = true; + this.nextAnimation = nextAnimation; + } + + public boolean hasNextAnimation() { + return hasNextAnimation; + } + + protected void setHasNextAnimation(boolean hasNextAnimation) { + this.hasNextAnimation = hasNextAnimation; + } + + /** + * Define the number of cycles in this animation + * + * @param value + * @return + */ + public AnimationFX setCycleCount(int value) { + this.timeline.setCycleCount(value); + return this; + } + + /** + * Set the speed factor of the animation + * + * @param value + * @return + */ + public AnimationFX setSpeed(double value) { + this.timeline.setRate(value); + return this; + } + + /** + * Delays the start of an animation + * + * @param value + * @return + */ + public AnimationFX setDelay(Duration value) { + this.timeline.setDelay(value); + return this; + } + + /** + * Set event when the animation ended. + * + * @param value + */ + public final void setOnFinished(EventHandler value) { + this.timeline.setOnFinished(value); + } + +} diff --git a/src/main/java/com/stream_pi/client/animations/Bounce.java b/src/main/java/com/stream_pi/client/animations/Bounce.java new file mode 100755 index 00000000..a10090b3 --- /dev/null +++ b/src/main/java/com/stream_pi/client/animations/Bounce.java @@ -0,0 +1,66 @@ +package com.stream_pi.client.animations; + +import javafx.animation.Interpolator; +import javafx.animation.KeyFrame; +import javafx.animation.KeyValue; +import javafx.animation.Timeline; +import javafx.scene.Node; +import javafx.util.Duration; + + +/** + * @author Loïc Sculier aka typhon0 + */ +public class Bounce extends AnimationFX { + + + /** + * Create new Bounce + * + * @param node The node to affect + */ + public Bounce(Node node) { + super(node); + } + + public Bounce() { + super(); + } + + @Override + public AnimationFX resetNode() { + getNode().setTranslateY(0); + return this; + } + + @Override + void initTimeline() { + setTimeline( + new Timeline( + + new KeyFrame(Duration.millis(0), + new KeyValue(getNode().translateYProperty(), 0, Interpolator.SPLINE(0.215, 0.610, 0.355, 1.000)) + ), + new KeyFrame(Duration.millis(400), + new KeyValue(getNode().translateYProperty(), -30, Interpolator.SPLINE(0.755, 0.050, 0.855, 0.060)) + ), + new KeyFrame(Duration.millis(550), + new KeyValue(getNode().translateYProperty(), 0, Interpolator.SPLINE(0.215, 0.610, 0.355, 1.000)) + ), + new KeyFrame(Duration.millis(700), + new KeyValue(getNode().translateYProperty(), -15, Interpolator.SPLINE(0.755, 0.050, 0.855, 0.060)) + ), + new KeyFrame(Duration.millis(800), + new KeyValue(getNode().translateYProperty(), 0, Interpolator.SPLINE(0.215, 0.610, 0.355, 1.000)) + ), + new KeyFrame(Duration.millis(900), + new KeyValue(getNode().translateYProperty(), -5, Interpolator.SPLINE(0.755, 0.050, 0.855, 0.060)) + ), + new KeyFrame(Duration.millis(1000), + new KeyValue(getNode().translateYProperty(), 0, Interpolator.SPLINE(0.215, 0.610, 0.355, 1.000)) + ) + + )); + } +} + diff --git a/src/main/java/com/stream_pi/client/animations/BounceIn.java b/src/main/java/com/stream_pi/client/animations/BounceIn.java new file mode 100755 index 00000000..38263d1e --- /dev/null +++ b/src/main/java/com/stream_pi/client/animations/BounceIn.java @@ -0,0 +1,72 @@ +package com.stream_pi.client.animations; + +import javafx.animation.Interpolator; +import javafx.animation.KeyFrame; +import javafx.animation.KeyValue; +import javafx.animation.Timeline; +import javafx.scene.Node; +import javafx.util.Duration; + +/** + * @author Loïc Sculier aka typhon0 + */ +public class BounceIn extends AnimationFX { + + + /** + * Create new BounceIn + * + * @param node The node to affect + */ + public BounceIn(Node node) { + super(node); + + } + + public BounceIn() { + super(); + } + + @Override + AnimationFX resetNode() { + getNode().setOpacity(1); + getNode().setScaleX(1); + getNode().setScaleY(1); + return this; + } + + @Override + void initTimeline() { + setTimeline(new Timeline( + new KeyFrame(Duration.millis(0), + new KeyValue(getNode().opacityProperty(), 0, Interpolator.SPLINE(0.215, 0.610, 0.355, 1.000)), + new KeyValue(getNode().scaleXProperty(), 0.3, Interpolator.SPLINE(0.215, 0.610, 0.355, 1.000)), + new KeyValue(getNode().scaleYProperty(), 0.3, Interpolator.SPLINE(0.215, 0.610, 0.355, 1.000)) + ), + new KeyFrame(Duration.millis(200), + new KeyValue(getNode().scaleXProperty(), 1.1, Interpolator.SPLINE(0.215, 0.610, 0.355, 1.000)), + new KeyValue(getNode().scaleYProperty(), 1.1, Interpolator.SPLINE(0.215, 0.610, 0.355, 1.000)) + ), + new KeyFrame(Duration.millis(400), + new KeyValue(getNode().scaleXProperty(), 0.9, Interpolator.SPLINE(0.215, 0.610, 0.355, 1.000)), + new KeyValue(getNode().scaleYProperty(), 0.9, Interpolator.SPLINE(0.215, 0.610, 0.355, 1.000)) + ), + new KeyFrame(Duration.millis(600), + new KeyValue(getNode().opacityProperty(), 1, Interpolator.SPLINE(0.215, 0.610, 0.355, 1.000)), + new KeyValue(getNode().scaleXProperty(), 1.03, Interpolator.SPLINE(0.215, 0.610, 0.355, 1.000)), + new KeyValue(getNode().scaleYProperty(), 1.03, Interpolator.SPLINE(0.215, 0.610, 0.355, 1.000)) + ), + new KeyFrame(Duration.millis(800), + new KeyValue(getNode().scaleXProperty(), 0.97, Interpolator.SPLINE(0.215, 0.610, 0.355, 1.000)), + new KeyValue(getNode().scaleYProperty(), 0.97, Interpolator.SPLINE(0.215, 0.610, 0.355, 1.000)) + ), + new KeyFrame(Duration.millis(1000), + new KeyValue(getNode().opacityProperty(), 1, Interpolator.SPLINE(0.215, 0.610, 0.355, 1.000)), + new KeyValue(getNode().scaleXProperty(), 1, Interpolator.SPLINE(0.215, 0.610, 0.355, 1.000)), + new KeyValue(getNode().scaleYProperty(), 1, Interpolator.SPLINE(0.215, 0.610, 0.355, 1.000)) + ) + + )); + + } +} diff --git a/src/main/java/com/stream_pi/client/animations/BounceOut.java b/src/main/java/com/stream_pi/client/animations/BounceOut.java new file mode 100755 index 00000000..b9ff2ec8 --- /dev/null +++ b/src/main/java/com/stream_pi/client/animations/BounceOut.java @@ -0,0 +1,61 @@ +package com.stream_pi.client.animations; + +import javafx.animation.KeyFrame; +import javafx.animation.KeyValue; +import javafx.animation.Timeline; +import javafx.scene.Node; +import javafx.util.Duration; + +/** + * @author Loïc Sculier aka typhon0 + */ +public class BounceOut extends AnimationFX { + + /** + * Create new BounceOut animation + * + * @param node The node to affect + */ + public BounceOut(final Node node) { + super(node); + } + + public BounceOut() { + } + + @Override + AnimationFX resetNode() { + getNode().setOpacity(1); + getNode().setScaleX(1); + getNode().setScaleY(1); + return this; + } + + @Override + void initTimeline() { + setTimeline(new Timeline( + + new KeyFrame(Duration.millis(0), + new KeyValue(getNode().scaleXProperty(), 1, AnimateFXInterpolator.EASE), + new KeyValue(getNode().scaleYProperty(), 1, AnimateFXInterpolator.EASE) + ), + new KeyFrame(Duration.millis(50), + new KeyValue(getNode().scaleXProperty(), 0.9, AnimateFXInterpolator.EASE), + new KeyValue(getNode().scaleYProperty(), 0.9, AnimateFXInterpolator.EASE) + ), + new KeyFrame(Duration.millis(112), + new KeyValue(getNode().opacityProperty(), 1, AnimateFXInterpolator.EASE), + new KeyValue(getNode().scaleXProperty(), 1.1, AnimateFXInterpolator.EASE), + new KeyValue(getNode().scaleYProperty(), 1.1, AnimateFXInterpolator.EASE) + ), + new KeyFrame(Duration.millis(225), + new KeyValue(getNode().opacityProperty(), 0, AnimateFXInterpolator.EASE), + new KeyValue(getNode().scaleXProperty(), 0.3, AnimateFXInterpolator.EASE), + new KeyValue(getNode().scaleYProperty(), 0.3, AnimateFXInterpolator.EASE) + ) + + )); + } + + +} diff --git a/src/main/java/com/stream_pi/client/animations/FadeIn.java b/src/main/java/com/stream_pi/client/animations/FadeIn.java new file mode 100755 index 00000000..208afa3a --- /dev/null +++ b/src/main/java/com/stream_pi/client/animations/FadeIn.java @@ -0,0 +1,46 @@ +package com.stream_pi.client.animations; + +import javafx.animation.KeyFrame; +import javafx.animation.KeyValue; +import javafx.animation.Timeline; +import javafx.scene.Node; +import javafx.util.Duration; + +/** + * @author Loïc Sculier aka typhon0 + */ + +public class FadeIn extends AnimationFX { + + /** + * Create a new FadeIn animation + * + * @param node the node to affect + */ + public FadeIn(Node node) { + super(node); + } + + public FadeIn() { + } + + @Override + AnimationFX resetNode() { + getNode().setOpacity(1); + return this; + } + + @Override + void initTimeline() { + setTimeline(new Timeline( + new KeyFrame(Duration.millis(0), + new KeyValue(getNode().opacityProperty(), 0, AnimateFXInterpolator.EASE) + ), + new KeyFrame(Duration.millis(1000), + new KeyValue(getNode().opacityProperty(), 1, AnimateFXInterpolator.EASE) + ) + + )); + } +} + diff --git a/src/main/java/com/stream_pi/client/animations/FadeOut.java b/src/main/java/com/stream_pi/client/animations/FadeOut.java new file mode 100755 index 00000000..3045437c --- /dev/null +++ b/src/main/java/com/stream_pi/client/animations/FadeOut.java @@ -0,0 +1,41 @@ +package com.stream_pi.client.animations; + +import javafx.animation.KeyFrame; +import javafx.animation.KeyValue; +import javafx.animation.Timeline; +import javafx.scene.Node; +import javafx.util.Duration; + +/** + * @author Loïc Sculier aka typhon0 + */ +public class FadeOut extends AnimationFX { + /** + * Create a new FadeOut animation + * @param node the node to affect + */ + public FadeOut(Node node) { + super(node); + } + + public FadeOut() { + } + + @Override + AnimationFX resetNode() { + getNode().setOpacity(1); + return this; + } + + @Override + void initTimeline() { + setTimeline(new Timeline( + new KeyFrame(Duration.millis(0), + new KeyValue(getNode().opacityProperty(), 1, AnimateFXInterpolator.EASE) + ), + new KeyFrame(Duration.millis(50), + new KeyValue(getNode().opacityProperty(), 0, AnimateFXInterpolator.EASE) + ) + )); + } +} diff --git a/src/main/java/com/stream_pi/client/animations/Flash.java b/src/main/java/com/stream_pi/client/animations/Flash.java new file mode 100755 index 00000000..8bb9a7a0 --- /dev/null +++ b/src/main/java/com/stream_pi/client/animations/Flash.java @@ -0,0 +1,57 @@ +package com.stream_pi.client.animations; + +import javafx.animation.KeyFrame; +import javafx.animation.KeyValue; +import javafx.animation.Timeline; +import javafx.scene.Node; +import javafx.util.Duration; + + +/** + * @author Loïc Sculier aka typhon0 + */ +public class Flash extends AnimationFX { + + /** + * Create new Flash + * + * @param node The node to affect + */ + public Flash(Node node) { + super(node); + } + + public Flash() { + } + + @Override + AnimationFX resetNode() { + getNode().setOpacity(1); + return this; + } + + @Override + void initTimeline() { + setTimeline(new Timeline( + + new KeyFrame(Duration.millis(0), + new KeyValue(getNode().opacityProperty(), 1, AnimateFXInterpolator.EASE) + ), + new KeyFrame(Duration.millis(250), + new KeyValue(getNode().opacityProperty(), 0, AnimateFXInterpolator.EASE) + ), + new KeyFrame(Duration.millis(500), + new KeyValue(getNode().opacityProperty(), 1, AnimateFXInterpolator.EASE) + ), + new KeyFrame(Duration.millis(750), + new KeyValue(getNode().opacityProperty(), 0, AnimateFXInterpolator.EASE) + ), + new KeyFrame(Duration.millis(1000), + new KeyValue(getNode().opacityProperty(), 1, AnimateFXInterpolator.EASE) + ) + + )); + } + +} + diff --git a/src/main/java/com/stream_pi/client/animations/Flip.java b/src/main/java/com/stream_pi/client/animations/Flip.java new file mode 100755 index 00000000..4a9aa993 --- /dev/null +++ b/src/main/java/com/stream_pi/client/animations/Flip.java @@ -0,0 +1,77 @@ +package com.stream_pi.client.animations; + +import javafx.animation.Interpolator; +import javafx.animation.KeyFrame; +import javafx.animation.KeyValue; +import javafx.animation.Timeline; +import javafx.scene.Node; +import javafx.scene.ParallelCamera; +import javafx.scene.PerspectiveCamera; +import javafx.util.Duration; + +import static javafx.scene.transform.Rotate.Y_AXIS; + + +/** + * @author Loïc Sculier aka typhon0 + */ +public class Flip extends AnimationFX { + + /** + * Create new Flip + * + * @param node The node to affect + */ + public Flip(Node node) { + super(node); + } + + public Flip() { + } + + @Override + AnimationFX resetNode() { + getNode().setRotate(0); + getNode().setScaleX(1); + getNode().setScaleY(1); + getNode().setScaleZ(1); + getNode().setTranslateZ(0); + return this; + } + + @Override + void initTimeline() { + getNode().getScene().setCamera(new PerspectiveCamera()); + getNode().setRotationAxis(Y_AXIS); + setTimeline(new Timeline( + new KeyFrame(Duration.millis(0), + new KeyValue(getNode().rotateProperty(), 360, Interpolator.EASE_OUT) + ), + new KeyFrame(Duration.millis(400), + new KeyValue(getNode().rotateProperty(), 190, Interpolator.EASE_OUT), + new KeyValue(getNode().translateZProperty(), -150, Interpolator.EASE_OUT) + ), + new KeyFrame(Duration.millis(500), + new KeyValue(getNode().rotateProperty(), 170, Interpolator.EASE_IN), + new KeyValue(getNode().translateZProperty(), -150, Interpolator.EASE_IN) + ), + new KeyFrame(Duration.millis(800), + new KeyValue(getNode().scaleXProperty(), 0.95, Interpolator.EASE_IN), + new KeyValue(getNode().scaleYProperty(), 0.95, Interpolator.EASE_IN), + new KeyValue(getNode().scaleZProperty(), 0.95, Interpolator.EASE_IN) + ), + new KeyFrame(Duration.millis(1000), + new KeyValue(getNode().rotateProperty(), 0, Interpolator.EASE_IN), + new KeyValue(getNode().scaleXProperty(), 1, Interpolator.EASE_IN), + new KeyValue(getNode().scaleYProperty(), 1, Interpolator.EASE_IN), + new KeyValue(getNode().scaleZProperty(), 1, Interpolator.EASE_IN), + new KeyValue(getNode().translateZProperty(), 0, Interpolator.EASE_IN) + ) + )); + //TODO + getTimeline().setOnFinished(event -> getNode().getScene().setCamera(new ParallelCamera())); + + } + +} + diff --git a/src/main/java/com/stream_pi/client/animations/JackInTheBox.java b/src/main/java/com/stream_pi/client/animations/JackInTheBox.java new file mode 100755 index 00000000..202427e5 --- /dev/null +++ b/src/main/java/com/stream_pi/client/animations/JackInTheBox.java @@ -0,0 +1,65 @@ +package com.stream_pi.client.animations; + +import javafx.animation.KeyFrame; +import javafx.animation.KeyValue; +import javafx.animation.Timeline; +import javafx.scene.Node; +import javafx.scene.transform.Rotate; +import javafx.util.Duration; + +/** + * @author Loïc Sculier aka typhon0 + */ +public class JackInTheBox extends AnimationFX { + + /** + * Create new JackInTheBox animation + * + * @param node The node to affect + */ + public JackInTheBox(Node node) { + super(node); + + } + + public JackInTheBox() { + } + + private Rotate rotate; + + @Override + AnimationFX resetNode() { + getNode().setScaleX(1); + getNode().setScaleZ(1); + getNode().setScaleY(1); + getNode().setOpacity(1); + rotate.setAngle(0); + return this; + } + + @Override + void initTimeline() { + rotate = new Rotate(30, getNode().getBoundsInParent().getWidth() / 2, getNode().getBoundsInParent().getHeight()); + getNode().getTransforms().add(rotate); + setTimeline(new Timeline( + new KeyFrame(Duration.millis(0), + new KeyValue(rotate.angleProperty(), 30, AnimateFXInterpolator.EASE), + new KeyValue(getNode().scaleXProperty(), 0.1, AnimateFXInterpolator.EASE), + new KeyValue(getNode().scaleYProperty(), 0.1, AnimateFXInterpolator.EASE), + new KeyValue(getNode().opacityProperty(), 0, AnimateFXInterpolator.EASE) + ), + new KeyFrame(Duration.millis(500), + new KeyValue(rotate.angleProperty(), -10, AnimateFXInterpolator.EASE) + ), + new KeyFrame(Duration.millis(700), + new KeyValue(rotate.angleProperty(), 3, AnimateFXInterpolator.EASE) + ), + new KeyFrame(Duration.millis(1000), + new KeyValue(getNode().scaleXProperty(), 1, AnimateFXInterpolator.EASE), + new KeyValue(getNode().scaleYProperty(), 1, AnimateFXInterpolator.EASE), + new KeyValue(rotate.angleProperty(), 0, AnimateFXInterpolator.EASE), + new KeyValue(getNode().opacityProperty(), 1, AnimateFXInterpolator.EASE) + ) + )); + } +} diff --git a/src/main/java/com/stream_pi/client/animations/Jello.java b/src/main/java/com/stream_pi/client/animations/Jello.java new file mode 100755 index 00000000..629aee72 --- /dev/null +++ b/src/main/java/com/stream_pi/client/animations/Jello.java @@ -0,0 +1,74 @@ +package com.stream_pi.client.animations; + +import javafx.animation.KeyFrame; +import javafx.animation.KeyValue; +import javafx.animation.Timeline; +import javafx.geometry.Bounds; +import javafx.scene.Node; +import javafx.scene.transform.Shear; +import javafx.util.Duration; + +/** + * @author Remi Lenoir + */ + +public class Jello extends AnimationFX { + /** + * Create new Jello + * + * @param node The node to affect + */ + public Jello(Node node) { + super(node); + } + + public Jello() { + } + + @Override + AnimationFX resetNode() { + shear.setX(0); + shear.setY(0); + return this; + } + + private Shear shear; + + @Override + void initTimeline() { + shear = new Shear(); + Bounds bounds = getNode().getLayoutBounds(); + shear.setPivotX(bounds.getWidth() / 2); + shear.setPivotY(bounds.getHeight() / 2); + getNode().getTransforms().add(shear); + setTimeline(new Timeline( + new KeyFrame(Duration.millis(0), + new KeyValue(shear.xProperty(), 0), + new KeyValue(shear.yProperty(), 0)), + new KeyFrame(Duration.millis(111), + new KeyValue(shear.xProperty(), 0.125), + new KeyValue(shear.yProperty(), 0.125)), + new KeyFrame(Duration.millis(222), + new KeyValue(shear.xProperty(), -0.625), + new KeyValue(shear.yProperty(), -0.625)), + new KeyFrame(Duration.millis(333), + new KeyValue(shear.xProperty(), 0.3125), + new KeyValue(shear.yProperty(), 0.3125)), + new KeyFrame(Duration.millis(444), + new KeyValue(shear.xProperty(), -0.15625), + new KeyValue(shear.yProperty(), -0.15625)), + new KeyFrame(Duration.millis(555), + new KeyValue(shear.xProperty(), 0.078125), + new KeyValue(shear.yProperty(), 0.078125)), + new KeyFrame(Duration.millis(666), + new KeyValue(shear.xProperty(), -0.0390625), + new KeyValue(shear.yProperty(), -0.0390625)), + new KeyFrame(Duration.millis(777), + new KeyValue(shear.xProperty(), 0.01953125), + new KeyValue(shear.yProperty(), 0.01953125)), + new KeyFrame(Duration.millis(888), + new KeyValue(shear.xProperty(), 0), + new KeyValue(shear.yProperty(), 0)))); + } + +} diff --git a/src/main/java/com/stream_pi/client/animations/Pulse.java b/src/main/java/com/stream_pi/client/animations/Pulse.java new file mode 100755 index 00000000..7d2116f2 --- /dev/null +++ b/src/main/java/com/stream_pi/client/animations/Pulse.java @@ -0,0 +1,57 @@ +package com.stream_pi.client.animations; + +import javafx.animation.KeyFrame; +import javafx.animation.KeyValue; +import javafx.animation.Timeline; +import javafx.scene.Node; +import javafx.util.Duration; + + +/** + * @author Loïc Sculier + */ +public class Pulse extends AnimationFX { + + /** + * Create new Pulse + * + * @param node The node to affect + */ + public Pulse(Node node) { + super(node); + } + + public Pulse() { + } + + + @Override + AnimationFX resetNode() { + getNode().setScaleX(1); + getNode().setScaleY(1); + getNode().setScaleZ(1); + return this; + } + + @Override + void initTimeline() { + setTimeline(new Timeline( + new KeyFrame(Duration.millis(0), + new KeyValue(getNode().scaleXProperty(), 1, AnimateFXInterpolator.EASE), + new KeyValue(getNode().scaleYProperty(), 1, AnimateFXInterpolator.EASE), + new KeyValue(getNode().scaleZProperty(), 1, AnimateFXInterpolator.EASE) + ), + new KeyFrame(Duration.millis(500), + new KeyValue(getNode().scaleXProperty(), 1.05, AnimateFXInterpolator.EASE), + new KeyValue(getNode().scaleYProperty(), 1.05, AnimateFXInterpolator.EASE), + new KeyValue(getNode().scaleZProperty(), 1.05, AnimateFXInterpolator.EASE) + ), + new KeyFrame(Duration.millis(1000), + new KeyValue(getNode().scaleXProperty(), 1, AnimateFXInterpolator.EASE), + new KeyValue(getNode().scaleYProperty(), 1, AnimateFXInterpolator.EASE), + new KeyValue(getNode().scaleZProperty(), 1, AnimateFXInterpolator.EASE) + ) + )); + } +} + diff --git a/src/main/java/com/stream_pi/client/animations/RollIn.java b/src/main/java/com/stream_pi/client/animations/RollIn.java new file mode 100755 index 00000000..afef776e --- /dev/null +++ b/src/main/java/com/stream_pi/client/animations/RollIn.java @@ -0,0 +1,53 @@ +package com.stream_pi.client.animations; + +import javafx.animation.KeyFrame; +import javafx.animation.KeyValue; +import javafx.animation.Timeline; +import javafx.scene.Node; +import javafx.util.Duration; + + +/** + * @author Loïc Sculier aka typhon0 + */ +public class RollIn extends AnimationFX { + + /** + * Create new RollIn + * + * @param node The node to affect + */ + public RollIn(Node node) { + super(node); + } + + public RollIn() { + } + + @Override + AnimationFX resetNode() { + getNode().setOpacity(1); + getNode().setTranslateX(0); + getNode().setRotate(0); + return this; + } + + @Override + void initTimeline() { + setTimeline(new Timeline( + new KeyFrame(Duration.millis(0), + new KeyValue(getNode().opacityProperty(), 0, AnimateFXInterpolator.EASE), + new KeyValue(getNode().translateXProperty(), -getNode().getBoundsInLocal().getWidth(), AnimateFXInterpolator.EASE), + new KeyValue(getNode().rotateProperty(), -120, AnimateFXInterpolator.EASE) + ), + new KeyFrame(Duration.millis(1000), + new KeyValue(getNode().opacityProperty(), 1, AnimateFXInterpolator.EASE), + new KeyValue(getNode().translateXProperty(), 0, AnimateFXInterpolator.EASE), + new KeyValue(getNode().rotateProperty(), 0, AnimateFXInterpolator.EASE) + ) + )); + } + + +} + diff --git a/src/main/java/com/stream_pi/client/animations/RollOut.java b/src/main/java/com/stream_pi/client/animations/RollOut.java new file mode 100755 index 00000000..018ed4f1 --- /dev/null +++ b/src/main/java/com/stream_pi/client/animations/RollOut.java @@ -0,0 +1,53 @@ +package com.stream_pi.client.animations; + +import javafx.animation.KeyFrame; +import javafx.animation.KeyValue; +import javafx.animation.Timeline; +import javafx.scene.Node; +import javafx.util.Duration; + + +/** + * @author Loïc Sculier aka typhon0 + */ +public class RollOut extends AnimationFX { + + /** + * Create new RollOut + * + * @param node The node to affect + */ + public RollOut(Node node) { + super(node); + } + + public RollOut() { + } + + @Override + AnimationFX resetNode() { + getNode().setOpacity(1); + getNode().setTranslateX(0); + getNode().setRotate(0); + return this; + } + + @Override + void initTimeline() { + setTimeline(new Timeline( + new KeyFrame(Duration.millis(0), + new KeyValue(getNode().opacityProperty(), 1, AnimateFXInterpolator.EASE), + new KeyValue(getNode().translateXProperty(), 0, AnimateFXInterpolator.EASE), + new KeyValue(getNode().rotateProperty(), 0, AnimateFXInterpolator.EASE) + ), + new KeyFrame(Duration.millis(1000), + new KeyValue(getNode().opacityProperty(), 0, AnimateFXInterpolator.EASE), + new KeyValue(getNode().translateXProperty(), getNode().getBoundsInLocal().getWidth(), AnimateFXInterpolator.EASE), + new KeyValue(getNode().rotateProperty(), 120, AnimateFXInterpolator.EASE) + ) + )); + } + + +} + diff --git a/src/main/java/com/stream_pi/client/animations/RotateIn.java b/src/main/java/com/stream_pi/client/animations/RotateIn.java new file mode 100755 index 00000000..5450bd40 --- /dev/null +++ b/src/main/java/com/stream_pi/client/animations/RotateIn.java @@ -0,0 +1,50 @@ +package com.stream_pi.client.animations; + +import javafx.animation.KeyFrame; +import javafx.animation.KeyValue; +import javafx.animation.Timeline; +import javafx.scene.Node; +import javafx.scene.transform.Rotate; +import javafx.util.Duration; + +/** + * @author Loïc Sculier aka typhon0 + */ +public class RotateIn extends AnimationFX { + + /** + * Create new RotateIn + * + * @param node The node to affect + */ + public RotateIn(Node node) { + super(node); + } + + public RotateIn() { + } + + @Override + AnimationFX resetNode() { + getNode().setRotate(0); + getNode().setOpacity(1); + return this; + } + + @Override + void initTimeline() { + getNode().setRotationAxis(Rotate.Z_AXIS); + setTimeline(new Timeline( + new KeyFrame(Duration.millis(0), + new KeyValue(getNode().rotateProperty(), -200, AnimateFXInterpolator.EASE), + new KeyValue(getNode().opacityProperty(), 0, AnimateFXInterpolator.EASE) + ), + new KeyFrame(Duration.millis(1000), + new KeyValue(getNode().rotateProperty(), 0, AnimateFXInterpolator.EASE), + new KeyValue(getNode().opacityProperty(), 1, AnimateFXInterpolator.EASE) + ) + )); + } + + +} diff --git a/src/main/java/com/stream_pi/client/animations/RotateOut.java b/src/main/java/com/stream_pi/client/animations/RotateOut.java new file mode 100755 index 00000000..db59e620 --- /dev/null +++ b/src/main/java/com/stream_pi/client/animations/RotateOut.java @@ -0,0 +1,48 @@ +package com.stream_pi.client.animations; + +import javafx.animation.KeyFrame; +import javafx.animation.KeyValue; +import javafx.animation.Timeline; +import javafx.scene.Node; +import javafx.scene.transform.Rotate; +import javafx.util.Duration; + +/** + * @author Loïc Sculier aka typhon0 + */ +public class RotateOut extends AnimationFX { + + /** + * Create new RotateOut + * + * @param node The node to affect + */ + public RotateOut(Node node) { + super(node); + } + + public RotateOut() { + } + + @Override + AnimationFX resetNode() { + getNode().setOpacity(1); + getNode().setRotate(0); + return this; + } + + @Override + void initTimeline() { + getNode().setRotationAxis(Rotate.Z_AXIS); + setTimeline(new Timeline( + new KeyFrame(Duration.millis(0), + new KeyValue(getNode().rotateProperty(), 0, AnimateFXInterpolator.EASE), + new KeyValue(getNode().opacityProperty(), 1, AnimateFXInterpolator.EASE) + ), + new KeyFrame(Duration.millis(1000), + new KeyValue(getNode().rotateProperty(), 200, AnimateFXInterpolator.EASE), + new KeyValue(getNode().opacityProperty(), 0, AnimateFXInterpolator.EASE) + ) + )); + } +} diff --git a/src/main/java/com/stream_pi/client/animations/RubberBand.java b/src/main/java/com/stream_pi/client/animations/RubberBand.java new file mode 100755 index 00000000..251665ae --- /dev/null +++ b/src/main/java/com/stream_pi/client/animations/RubberBand.java @@ -0,0 +1,80 @@ +package com.stream_pi.client.animations; + + +import javafx.animation.KeyFrame; +import javafx.animation.KeyValue; +import javafx.animation.Timeline; +import javafx.scene.Node; +import javafx.util.Duration; + + +/** + * @author Loïc Sculier aka typhon0 + */ +public class RubberBand extends AnimationFX { + + /** + * Create new RubberBand + * + * @param node The node to affect + */ + public RubberBand(Node node) { + super(node); + } + + public RubberBand() { + } + + @Override + AnimationFX resetNode() { + getNode().setScaleX(1); + getNode().setScaleY(1); + getNode().setScaleZ(1); + return this; + } + + @Override + void initTimeline() { + setTimeline(new Timeline( + new KeyFrame(Duration.millis(0), + new KeyValue(getNode().scaleXProperty(), 1, AnimateFXInterpolator.EASE), + new KeyValue(getNode().scaleYProperty(), 1, AnimateFXInterpolator.EASE), + new KeyValue(getNode().scaleZProperty(), 1, AnimateFXInterpolator.EASE) + ), + new KeyFrame(Duration.millis(300), + new KeyValue(getNode().scaleXProperty(), 1.25, AnimateFXInterpolator.EASE), + new KeyValue(getNode().scaleYProperty(), 0.75, AnimateFXInterpolator.EASE), + new KeyValue(getNode().scaleZProperty(), 1, AnimateFXInterpolator.EASE) + ), + new KeyFrame(Duration.millis(400), + new KeyValue(getNode().scaleXProperty(), 0.75, AnimateFXInterpolator.EASE), + new KeyValue(getNode().scaleYProperty(), 1.25, AnimateFXInterpolator.EASE), + new KeyValue(getNode().scaleZProperty(), 1, AnimateFXInterpolator.EASE) + ), + new KeyFrame(Duration.millis(500), + new KeyValue(getNode().scaleXProperty(), 1.15, AnimateFXInterpolator.EASE), + new KeyValue(getNode().scaleYProperty(), 0.85, AnimateFXInterpolator.EASE), + new KeyValue(getNode().scaleZProperty(), 1, AnimateFXInterpolator.EASE) + ), + new KeyFrame(Duration.millis(650), + new KeyValue(getNode().scaleXProperty(), 0.95, AnimateFXInterpolator.EASE), + new KeyValue(getNode().scaleYProperty(), 1.05, AnimateFXInterpolator.EASE), + new KeyValue(getNode().scaleZProperty(), 1, AnimateFXInterpolator.EASE) + ), + new KeyFrame(Duration.millis(750), + new KeyValue(getNode().scaleXProperty(), 1.05, AnimateFXInterpolator.EASE), + new KeyValue(getNode().scaleYProperty(), 0.95, AnimateFXInterpolator.EASE), + new KeyValue(getNode().scaleZProperty(), 1, AnimateFXInterpolator.EASE) + ), + new KeyFrame(Duration.millis(1000), + new KeyValue(getNode().scaleXProperty(), 1, AnimateFXInterpolator.EASE), + new KeyValue(getNode().scaleYProperty(), 1, AnimateFXInterpolator.EASE), + new KeyValue(getNode().scaleZProperty(), 1, AnimateFXInterpolator.EASE) + ) + )); + } + +} + + + diff --git a/src/main/java/com/stream_pi/client/animations/Shake.java b/src/main/java/com/stream_pi/client/animations/Shake.java new file mode 100755 index 00000000..3869f3de --- /dev/null +++ b/src/main/java/com/stream_pi/client/animations/Shake.java @@ -0,0 +1,75 @@ +package com.stream_pi.client.animations; + +import javafx.animation.KeyFrame; +import javafx.animation.KeyValue; +import javafx.animation.Timeline; +import javafx.scene.Node; +import javafx.util.Duration; + + +/** + * @author Loïc Sculier aka typhon0 + */ +public class Shake extends AnimationFX { + + /** + * Create new Shake + * + * @param node The node to affect + */ + public Shake(Node node) { + super(node); + } + + public Shake() { + } + + @Override + AnimationFX resetNode() { + + getNode().setTranslateX(0); + return this; + } + + @Override + void initTimeline() { + setTimeline(new Timeline( + new KeyFrame(Duration.millis(0), + new KeyValue(getNode().translateXProperty(), 0, AnimateFXInterpolator.EASE) + ), + new KeyFrame(Duration.millis(100), + new KeyValue(getNode().translateXProperty(), -10, AnimateFXInterpolator.EASE) + ), + new KeyFrame(Duration.millis(200), + new KeyValue(getNode().translateXProperty(), 10, AnimateFXInterpolator.EASE) + ), + new KeyFrame(Duration.millis(300), + new KeyValue(getNode().translateXProperty(), -10, AnimateFXInterpolator.EASE) + ), + new KeyFrame(Duration.millis(400), + new KeyValue(getNode().translateXProperty(), 10, AnimateFXInterpolator.EASE) + ), + new KeyFrame(Duration.millis(500), + new KeyValue(getNode().translateXProperty(), -10, AnimateFXInterpolator.EASE) + ), + new KeyFrame(Duration.millis(600), + new KeyValue(getNode().translateXProperty(), 10, AnimateFXInterpolator.EASE) + ), + new KeyFrame(Duration.millis(700), + new KeyValue(getNode().translateXProperty(), -10, AnimateFXInterpolator.EASE) + ), + new KeyFrame(Duration.millis(800), + new KeyValue(getNode().translateXProperty(), 10, AnimateFXInterpolator.EASE) + ), + new KeyFrame(Duration.millis(900), + new KeyValue(getNode().translateXProperty(), -10, AnimateFXInterpolator.EASE) + ), + new KeyFrame(Duration.millis(1000), + new KeyValue(getNode().translateXProperty(), 0, AnimateFXInterpolator.EASE) + ) + )); + } +} + + + diff --git a/src/main/java/com/stream_pi/client/animations/ShakeUpDown.java b/src/main/java/com/stream_pi/client/animations/ShakeUpDown.java new file mode 100755 index 00000000..98c32dd1 --- /dev/null +++ b/src/main/java/com/stream_pi/client/animations/ShakeUpDown.java @@ -0,0 +1,75 @@ +package com.stream_pi.client.animations; + +import javafx.animation.KeyFrame; +import javafx.animation.KeyValue; +import javafx.animation.Timeline; +import javafx.scene.Node; +import javafx.util.Duration; + + +/** + * @author Loïc Sculier aka typhon0 + */ +public class ShakeUpDown extends AnimationFX { + + /** + * Create new Shake + * + * @param node The node to affect + */ + public ShakeUpDown(Node node) { + super(node); + } + + public ShakeUpDown() { + } + + @Override + AnimationFX resetNode() { + + getNode().setTranslateX(0); + return this; + } + + @Override + void initTimeline() { + setTimeline(new Timeline( + new KeyFrame(Duration.millis(0), + new KeyValue(getNode().translateYProperty(), 0, AnimateFXInterpolator.EASE) + ), + new KeyFrame(Duration.millis(100), + new KeyValue(getNode().translateYProperty(), -10, AnimateFXInterpolator.EASE) + ), + new KeyFrame(Duration.millis(200), + new KeyValue(getNode().translateYProperty(), 10, AnimateFXInterpolator.EASE) + ), + new KeyFrame(Duration.millis(300), + new KeyValue(getNode().translateYProperty(), -10, AnimateFXInterpolator.EASE) + ), + new KeyFrame(Duration.millis(400), + new KeyValue(getNode().translateYProperty(), 10, AnimateFXInterpolator.EASE) + ), + new KeyFrame(Duration.millis(500), + new KeyValue(getNode().translateYProperty(), -10, AnimateFXInterpolator.EASE) + ), + new KeyFrame(Duration.millis(600), + new KeyValue(getNode().translateYProperty(), 10, AnimateFXInterpolator.EASE) + ), + new KeyFrame(Duration.millis(700), + new KeyValue(getNode().translateYProperty(), -10, AnimateFXInterpolator.EASE) + ), + new KeyFrame(Duration.millis(800), + new KeyValue(getNode().translateYProperty(), 10, AnimateFXInterpolator.EASE) + ), + new KeyFrame(Duration.millis(900), + new KeyValue(getNode().translateYProperty(), -10, AnimateFXInterpolator.EASE) + ), + new KeyFrame(Duration.millis(1000), + new KeyValue(getNode().translateYProperty(), 0, AnimateFXInterpolator.EASE) + ) + )); + } +} + + + diff --git a/src/main/java/com/stream_pi/client/animations/Swing.java b/src/main/java/com/stream_pi/client/animations/Swing.java new file mode 100755 index 00000000..7cefb590 --- /dev/null +++ b/src/main/java/com/stream_pi/client/animations/Swing.java @@ -0,0 +1,63 @@ +package com.stream_pi.client.animations; + +import javafx.animation.KeyFrame; +import javafx.animation.KeyValue; +import javafx.animation.Timeline; +import javafx.scene.Node; +import javafx.scene.transform.Rotate; +import javafx.util.Duration; + +/** + * @author Loïc Sculier aka typhon0 + */ +public class Swing extends AnimationFX { + + /** + * Create new Swing + * + * @param node The node to affect + */ + public Swing(Node node) { + super(node); + } + + public Swing() { + } + + private Rotate rotation; + + @Override + AnimationFX resetNode() { + rotation.setAngle(0); + return this; + } + + @Override + void initTimeline() { + rotation = new Rotate(); + rotation.setPivotX(getNode().getLayoutBounds().getWidth() / 2.0); + rotation.setPivotY(-getNode().getLayoutBounds().getHeight()); + getNode().getTransforms().add(rotation); + setTimeline(new Timeline( + new KeyFrame(Duration.millis(0), + new KeyValue(rotation.angleProperty(), 0, AnimateFXInterpolator.EASE) + ), + new KeyFrame(Duration.millis(200), + new KeyValue(rotation.angleProperty(), 15, AnimateFXInterpolator.EASE) + ), + new KeyFrame(Duration.millis(400), + new KeyValue(rotation.angleProperty(), -10, AnimateFXInterpolator.EASE) + ), + new KeyFrame(Duration.millis(600), + new KeyValue(rotation.angleProperty(), 5, AnimateFXInterpolator.EASE) + ), + new KeyFrame(Duration.millis(800), + new KeyValue(rotation.angleProperty(), -5, AnimateFXInterpolator.EASE) + ), + new KeyFrame(Duration.millis(1000), + new KeyValue(rotation.angleProperty(), 0, AnimateFXInterpolator.EASE) + ) + )); + } +} + diff --git a/src/main/java/com/stream_pi/client/animations/Tada.java b/src/main/java/com/stream_pi/client/animations/Tada.java new file mode 100755 index 00000000..c981d52d --- /dev/null +++ b/src/main/java/com/stream_pi/client/animations/Tada.java @@ -0,0 +1,110 @@ +package com.stream_pi.client.animations; + +import javafx.animation.KeyFrame; +import javafx.animation.KeyValue; +import javafx.animation.Timeline; +import javafx.scene.Node; +import javafx.scene.transform.Rotate; +import javafx.util.Duration; + +/** + * @author Loïc Sculier aka typhon0 + */ +public class Tada extends AnimationFX { + + /** + * Create new Swing + * + * @param node The node to affect + */ + public Tada(Node node) { + super(node); + } + + public Tada() { + } + + @Override + AnimationFX resetNode() { + getNode().setScaleX(1); + getNode().setScaleY(1); + getNode().setScaleZ(1); + getNode().setRotate(0); + return this; + } + + @Override + void initTimeline() { + getNode().setRotationAxis(Rotate.Z_AXIS); + setTimeline(new Timeline( + new KeyFrame(Duration.millis(0), + new KeyValue(getNode().scaleXProperty(), 1, AnimateFXInterpolator.EASE), + new KeyValue(getNode().scaleYProperty(), 1, AnimateFXInterpolator.EASE), + new KeyValue(getNode().scaleZProperty(), 1, AnimateFXInterpolator.EASE), + new KeyValue(getNode().rotateProperty(), 0, AnimateFXInterpolator.EASE) + + ), + new KeyFrame(Duration.millis(100), + new KeyValue(getNode().scaleXProperty(), 0.9, AnimateFXInterpolator.EASE), + new KeyValue(getNode().scaleYProperty(), 0.9, AnimateFXInterpolator.EASE), + new KeyValue(getNode().scaleZProperty(), 0.9, AnimateFXInterpolator.EASE), + new KeyValue(getNode().rotateProperty(), -3, AnimateFXInterpolator.EASE) + ), + new KeyFrame(Duration.millis(200), + new KeyValue(getNode().scaleXProperty(), 0.9, AnimateFXInterpolator.EASE), + new KeyValue(getNode().scaleYProperty(), 0.9, AnimateFXInterpolator.EASE), + new KeyValue(getNode().scaleZProperty(), 0.9, AnimateFXInterpolator.EASE), + new KeyValue(getNode().rotateProperty(), -3, AnimateFXInterpolator.EASE) + ), + new KeyFrame(Duration.millis(300), + new KeyValue(getNode().scaleXProperty(), 1.1, AnimateFXInterpolator.EASE), + new KeyValue(getNode().scaleYProperty(), 1.1, AnimateFXInterpolator.EASE), + new KeyValue(getNode().scaleZProperty(), 1.1, AnimateFXInterpolator.EASE), + new KeyValue(getNode().rotateProperty(), 3, AnimateFXInterpolator.EASE) + ), + new KeyFrame(Duration.millis(400), + new KeyValue(getNode().scaleXProperty(), 1.1, AnimateFXInterpolator.EASE), + new KeyValue(getNode().scaleYProperty(), 1.1, AnimateFXInterpolator.EASE), + new KeyValue(getNode().scaleZProperty(), 1.1, AnimateFXInterpolator.EASE), + new KeyValue(getNode().rotateProperty(), -3, AnimateFXInterpolator.EASE) + ), + new KeyFrame(Duration.millis(500), + new KeyValue(getNode().scaleXProperty(), 1.1, AnimateFXInterpolator.EASE), + new KeyValue(getNode().scaleYProperty(), 1.1, AnimateFXInterpolator.EASE), + new KeyValue(getNode().scaleZProperty(), 1.1, AnimateFXInterpolator.EASE), + new KeyValue(getNode().rotateProperty(), 3, AnimateFXInterpolator.EASE) + ), + new KeyFrame(Duration.millis(600), + new KeyValue(getNode().scaleXProperty(), 1.1, AnimateFXInterpolator.EASE), + new KeyValue(getNode().scaleYProperty(), 1.1, AnimateFXInterpolator.EASE), + new KeyValue(getNode().scaleZProperty(), 1.1, AnimateFXInterpolator.EASE), + new KeyValue(getNode().rotateProperty(), -3, AnimateFXInterpolator.EASE) + ), + new KeyFrame(Duration.millis(700), + new KeyValue(getNode().scaleXProperty(), 1.1, AnimateFXInterpolator.EASE), + new KeyValue(getNode().scaleYProperty(), 1.1, AnimateFXInterpolator.EASE), + new KeyValue(getNode().scaleZProperty(), 1.1, AnimateFXInterpolator.EASE), + new KeyValue(getNode().rotateProperty(), 3, AnimateFXInterpolator.EASE) + ), + new KeyFrame(Duration.millis(800), + new KeyValue(getNode().scaleXProperty(), 1.1, AnimateFXInterpolator.EASE), + new KeyValue(getNode().scaleYProperty(), 1.1, AnimateFXInterpolator.EASE), + new KeyValue(getNode().scaleZProperty(), 1.1, AnimateFXInterpolator.EASE), + new KeyValue(getNode().rotateProperty(), -3, AnimateFXInterpolator.EASE) + ), + new KeyFrame(Duration.millis(900), + new KeyValue(getNode().scaleXProperty(), 1.1, AnimateFXInterpolator.EASE), + new KeyValue(getNode().scaleYProperty(), 1.1, AnimateFXInterpolator.EASE), + new KeyValue(getNode().scaleZProperty(), 1.1, AnimateFXInterpolator.EASE), + new KeyValue(getNode().rotateProperty(), 3, AnimateFXInterpolator.EASE) + ), + new KeyFrame(Duration.millis(1000), + new KeyValue(getNode().scaleXProperty(), 1, AnimateFXInterpolator.EASE), + new KeyValue(getNode().scaleYProperty(), 1, AnimateFXInterpolator.EASE), + new KeyValue(getNode().scaleZProperty(), 1, AnimateFXInterpolator.EASE), + new KeyValue(getNode().rotateProperty(), 0, AnimateFXInterpolator.EASE) + ) + )); + } +} + diff --git a/src/main/java/com/stream_pi/client/animations/Wobble.java b/src/main/java/com/stream_pi/client/animations/Wobble.java new file mode 100755 index 00000000..71b18372 --- /dev/null +++ b/src/main/java/com/stream_pi/client/animations/Wobble.java @@ -0,0 +1,66 @@ +package com.stream_pi.client.animations; + +import javafx.animation.KeyFrame; +import javafx.animation.KeyValue; +import javafx.animation.Timeline; +import javafx.scene.Node; +import javafx.util.Duration; + +/** + * @author Loïc Sculier aka typhon0 + */ +public class Wobble extends AnimationFX { + + /** + * Create new Wobble + * + * @param node The node to affect + */ + public Wobble(Node node) { + super(node); + } + + public Wobble() { + } + + @Override + AnimationFX resetNode() { + getNode().setTranslateX(0); + getNode().setRotate(0); + return this; + } + + @Override + void initTimeline() { + setTimeline(new Timeline( + new KeyFrame(Duration.millis(0), + new KeyValue(getNode().translateXProperty(), 0, AnimateFXInterpolator.EASE), + new KeyValue(getNode().rotateProperty(), -0, AnimateFXInterpolator.EASE) + ), + new KeyFrame(Duration.millis(150), + new KeyValue(getNode().translateXProperty(), -0.25 * getNode().getBoundsInParent().getWidth(), AnimateFXInterpolator.EASE), + new KeyValue(getNode().rotateProperty(), -5, AnimateFXInterpolator.EASE) + ), + new KeyFrame(Duration.millis(300), + new KeyValue(getNode().translateXProperty(), 0.2 * getNode().getBoundsInParent().getWidth(), AnimateFXInterpolator.EASE), + new KeyValue(getNode().rotateProperty(), 3, AnimateFXInterpolator.EASE) + ), + new KeyFrame(Duration.millis(450), + new KeyValue(getNode().translateXProperty(), -0.15 * getNode().getBoundsInParent().getWidth(), AnimateFXInterpolator.EASE), + new KeyValue(getNode().rotateProperty(), -3, AnimateFXInterpolator.EASE) + ), + new KeyFrame(Duration.millis(600), + new KeyValue(getNode().translateXProperty(), 0.1 * getNode().getBoundsInParent().getWidth(), AnimateFXInterpolator.EASE), + new KeyValue(getNode().rotateProperty(), 2, AnimateFXInterpolator.EASE) + ), + new KeyFrame(Duration.millis(750), + new KeyValue(getNode().translateXProperty(), -0.05 * getNode().getBoundsInParent().getWidth(), AnimateFXInterpolator.EASE), + new KeyValue(getNode().rotateProperty(), -1, AnimateFXInterpolator.EASE) + ), + new KeyFrame(Duration.millis(1000), + new KeyValue(getNode().translateXProperty(), 0, AnimateFXInterpolator.EASE), + new KeyValue(getNode().rotateProperty(), 0, AnimateFXInterpolator.EASE) + ) + )); + } +} diff --git a/src/main/java/com/stream_pi/client/animations/ZoomIn.java b/src/main/java/com/stream_pi/client/animations/ZoomIn.java new file mode 100755 index 00000000..f0346955 --- /dev/null +++ b/src/main/java/com/stream_pi/client/animations/ZoomIn.java @@ -0,0 +1,54 @@ +package com.stream_pi.client.animations; + +import javafx.animation.KeyFrame; +import javafx.animation.KeyValue; +import javafx.animation.Timeline; +import javafx.scene.Node; +import javafx.util.Duration; + + +/** + * @author Loïc Sculier aka typhon0 + */ +public class ZoomIn extends AnimationFX { + + /** + * Create new ZoomIn + * + * @param node The node to affect + */ + public ZoomIn(Node node) { + super(node); + } + + public ZoomIn() { + } + + @Override + AnimationFX resetNode() { + getNode().setOpacity(1); + getNode().setScaleX(1); + getNode().setScaleY(1); + getNode().setScaleZ(1); + return this; + } + + @Override + void initTimeline() { + setTimeline(new Timeline( + new KeyFrame(Duration.millis(0), + new KeyValue(getNode().opacityProperty(), 0, AnimateFXInterpolator.EASE), + new KeyValue(getNode().scaleXProperty(), 0.3, AnimateFXInterpolator.EASE), + new KeyValue(getNode().scaleYProperty(), 0.3, AnimateFXInterpolator.EASE), + new KeyValue(getNode().scaleZProperty(), 0.3, AnimateFXInterpolator.EASE) + ), + new KeyFrame(Duration.millis(1000), + new KeyValue(getNode().opacityProperty(), 1, AnimateFXInterpolator.EASE), + new KeyValue(getNode().scaleXProperty(), 1, AnimateFXInterpolator.EASE), + new KeyValue(getNode().scaleYProperty(), 1, AnimateFXInterpolator.EASE), + new KeyValue(getNode().scaleZProperty(), 1, AnimateFXInterpolator.EASE) + ) + )); + } +} + diff --git a/src/main/java/com/stream_pi/client/animations/ZoomOut.java b/src/main/java/com/stream_pi/client/animations/ZoomOut.java new file mode 100755 index 00000000..e67bbfed --- /dev/null +++ b/src/main/java/com/stream_pi/client/animations/ZoomOut.java @@ -0,0 +1,57 @@ +package com.stream_pi.client.animations; + +import javafx.animation.KeyFrame; +import javafx.animation.KeyValue; +import javafx.animation.Timeline; +import javafx.scene.Node; +import javafx.util.Duration; + + +/** + * @author Loïc Sculier aka typhon0 + */ +public class ZoomOut extends AnimationFX { + + /** + * Create new ZoomOut + * + * @param node The node to affect + */ + public ZoomOut(Node node) { + super(node); + } + + public ZoomOut() { + } + + @Override + AnimationFX resetNode() { + getNode().setOpacity(1); + getNode().setScaleX(1); + getNode().setScaleY(1); + getNode().setScaleZ(1); + return this; + } + + @Override + void initTimeline() { + setTimeline(new Timeline( + new KeyFrame(Duration.millis(0), + new KeyValue(getNode().opacityProperty(), 1, AnimateFXInterpolator.EASE), + new KeyValue(getNode().scaleXProperty(), 1, AnimateFXInterpolator.EASE), + new KeyValue(getNode().scaleYProperty(), 1, AnimateFXInterpolator.EASE), + new KeyValue(getNode().scaleZProperty(), 0.3, AnimateFXInterpolator.EASE) + ), + new KeyFrame(Duration.millis(500), + new KeyValue(getNode().opacityProperty(), 0, AnimateFXInterpolator.EASE), + new KeyValue(getNode().scaleXProperty(), 0.3, AnimateFXInterpolator.EASE), + new KeyValue(getNode().scaleYProperty(), 0.3, AnimateFXInterpolator.EASE), + new KeyValue(getNode().scaleZProperty(), 0.3, AnimateFXInterpolator.EASE) + ), + new KeyFrame(Duration.millis(1000), + new KeyValue(getNode().opacityProperty(), 0, AnimateFXInterpolator.EASE) + ) + )); + } +} + diff --git a/src/main/java/com/stream_pi/client/connection/Client.java b/src/main/java/com/stream_pi/client/connection/Client.java old mode 100644 new mode 100755 diff --git a/src/main/java/com/stream_pi/client/controller/ClientListener.java b/src/main/java/com/stream_pi/client/controller/ClientListener.java old mode 100644 new mode 100755 diff --git a/src/main/java/com/stream_pi/client/controller/Controller.java b/src/main/java/com/stream_pi/client/controller/Controller.java old mode 100644 new mode 100755 diff --git a/src/main/java/com/stream_pi/client/controller/ScreenMover.java b/src/main/java/com/stream_pi/client/controller/ScreenMover.java old mode 100644 new mode 100755 diff --git a/src/main/java/com/stream_pi/client/controller/ScreenSaver.java b/src/main/java/com/stream_pi/client/controller/ScreenSaver.java old mode 100644 new mode 100755 diff --git a/src/main/java/com/stream_pi/client/info/ClientInfo.java b/src/main/java/com/stream_pi/client/info/ClientInfo.java old mode 100644 new mode 100755 diff --git a/src/main/java/com/stream_pi/client/info/License.java b/src/main/java/com/stream_pi/client/info/License.java old mode 100644 new mode 100755 diff --git a/src/main/java/com/stream_pi/client/info/StartupFlags.java b/src/main/java/com/stream_pi/client/info/StartupFlags.java old mode 100644 new mode 100755 diff --git a/src/main/java/com/stream_pi/client/io/Config.java b/src/main/java/com/stream_pi/client/io/Config.java old mode 100644 new mode 100755 index df04a419..1ec2c822 --- a/src/main/java/com/stream_pi/client/io/Config.java +++ b/src/main/java/com/stream_pi/client/io/Config.java @@ -1,538 +1,551 @@ -/* -Config.java - -Contributor(s) : Debayan Sutradhar (@rnayabed) - -handler for config.xml - */ - -package com.stream_pi.client.io; - -import java.io.File; -import java.util.Objects; - -import javax.xml.parsers.DocumentBuilder; -import javax.xml.parsers.DocumentBuilderFactory; -import javax.xml.transform.Result; -import javax.xml.transform.Source; -import javax.xml.transform.Transformer; -import javax.xml.transform.TransformerFactory; -import javax.xml.transform.dom.DOMSource; -import javax.xml.transform.stream.StreamResult; - -import com.stream_pi.client.Main; -import com.stream_pi.client.info.ClientInfo; -import com.stream_pi.client.info.StartupFlags; -import com.stream_pi.util.exception.SevereException; -import com.stream_pi.util.iohelper.IOHelper; -import com.stream_pi.util.platform.Platform; -import com.stream_pi.util.xmlconfighelper.XMLConfigHelper; - -import org.w3c.dom.Document; -import org.w3c.dom.Element; - -public class Config -{ - private static Config instance = null; - - private final File configFile; - - private Document document; - - private Config() throws SevereException - { - try - { - configFile = new File(ClientInfo.getInstance().getPrePath()+"config.xml"); - DocumentBuilderFactory docFactory = DocumentBuilderFactory.newInstance(); - DocumentBuilder docBuilder = docFactory.newDocumentBuilder(); - document = docBuilder.parse(configFile); - } - catch (Exception e) - { - e.printStackTrace(); - throw new SevereException("Config", "unable to read config.xml\n"+e.getMessage()); - } - } - - public static synchronized Config getInstance() throws SevereException - { - if(instance == null) - instance = new Config(); - - return instance; - } - - public static void nullify() - { - instance = null; - } - - public static void unzipToDefaultPrePath() throws Exception - { - IOHelper.unzip(Objects.requireNonNull(Main.class.getResourceAsStream("Default.zip")), ClientInfo.getInstance().getPrePath()); - Config.getInstance().setThemesPath(ClientInfo.getInstance().getPrePath()+"Themes/"); - Config.getInstance().setIconsPath(ClientInfo.getInstance().getPrePath()+"Icons/"); - Config.getInstance().setProfilesPath(ClientInfo.getInstance().getPrePath()+"Profiles/"); - - Config.getInstance().setIsFullScreenMode(StartupFlags.DEFAULT_FULLSCREEN_MODE); - - Config.getInstance().save(); - } - - public void save() throws SevereException - { - try - { - Transformer transformer = TransformerFactory.newInstance().newTransformer(); - Result output = new StreamResult(configFile); - Source input = new DOMSource(document); - - transformer.transform(input, output); - } - catch (Exception e) - { - throw new SevereException("Config", "unable to save config.xml"); - } - } - - - //Client Element - - //Default Values - public String getDefaultClientNickName() - { - return "Stream-Pi Client"; - } - - public String getDefaultStartupProfileID() - { - return "default"; - } - - public String getDefaultCurrentThemeFullName() - { - return "com.stream_pi.defaultlight"; - } - - public String getDefaultThemesPath() - { - return ClientInfo.getInstance().getPrePath()+"Themes/"; - } - - public String getDefaultProfilesPath() - { - return ClientInfo.getInstance().getPrePath()+"Profiles/"; - } - - public String getDefaultIconsPath() - { - return ClientInfo.getInstance().getPrePath()+"Icons/"; - } - - //Getters - - public String getClientNickName() - { - return XMLConfigHelper.getStringProperty(document, "nickname", getDefaultClientNickName(), false, true, document, configFile); - } - - public String getStartupProfileID() - { - return XMLConfigHelper.getStringProperty(document, "startup-profile", getDefaultStartupProfileID(), false, true, document, configFile); - } - - public String getCurrentThemeFullName() - { - return XMLConfigHelper.getStringProperty(document, "current-theme-full-name", getDefaultCurrentThemeFullName(), false, true, document, configFile); - } - - public String getThemesPath() - { - Platform platform = ClientInfo.getInstance().getPlatform(); - if(platform != Platform.ANDROID && - platform != Platform.IOS) - return ClientInfo.getInstance().getPrePath() + "Themes/"; - - return XMLConfigHelper.getStringProperty(document, "themes-path", getDefaultThemesPath(), false, true, document, configFile); - } - - public String getProfilesPath() - { - Platform platform = ClientInfo.getInstance().getPlatform(); - if(platform != Platform.ANDROID && - platform != Platform.IOS) - return ClientInfo.getInstance().getPrePath() + "Profiles/"; - - return XMLConfigHelper.getStringProperty(document, "profiles-path", getDefaultProfilesPath(), false, true, document, configFile); - } - - public String getIconsPath() - { - Platform platform = ClientInfo.getInstance().getPlatform(); - if(platform != Platform.ANDROID && - platform != Platform.IOS) - return ClientInfo.getInstance().getPrePath() + "Icons/"; - - return XMLConfigHelper.getStringProperty(document, "icons-path", getDefaultIconsPath(), false, true, document, configFile); - } - - - - //Setters - - public void setNickName(String nickName) - { - document.getElementsByTagName("nickname").item(0).setTextContent(nickName); - } - - public void setStartupProfileID(String id) - { - document.getElementsByTagName("startup-profile").item(0).setTextContent(id); - } - - public void setCurrentThemeFullName(String name) - { - document.getElementsByTagName("current-theme-full-name").item(0).setTextContent(name); - } - - public void setProfilesPath(String profilesPath) - { - document.getElementsByTagName("profiles-path").item(0).setTextContent(profilesPath); - } - - public void setIconsPath(String iconsPath) - { - document.getElementsByTagName("icons-path").item(0).setTextContent(iconsPath); - } - - public void setThemesPath(String themesPath) - { - document.getElementsByTagName("themes-path").item(0).setTextContent(themesPath); - } - - - //comms-server - public Element getCommsServerElement() - { - return (Element) document.getElementsByTagName("comms-server").item(0); - } - - public String getDefaultSavedServerHostNameOrIP() - { - return "127.0.0.1"; - } - - public int getDefaultSavedServerPort() - { - return -1; - } - - - public String getSavedServerHostNameOrIP() - { - return XMLConfigHelper.getStringProperty(getCommsServerElement(), "hostname-ip", getDefaultSavedServerHostNameOrIP(), false, true, document, configFile); - } - - public int getSavedServerPort() - { - return XMLConfigHelper.getIntProperty(getCommsServerElement(), "port", getDefaultSavedServerPort(), false, true, document, configFile); - } - - public void setServerHostNameOrIP(String hostNameOrIP) - { - getCommsServerElement().getElementsByTagName("hostname-ip").item(0).setTextContent(hostNameOrIP); - } - - public void setServerPort(int port) - { - getCommsServerElement().getElementsByTagName("port").item(0).setTextContent(port+""); - } - - - - - - //screen-mover - public Element getScreenMoverElement() - { - return (Element) document.getElementsByTagName("screen-mover").item(0); - } - - - //others - public Element getOthersElement() - { - return (Element) document.getElementsByTagName("others").item(0); - } - - //others-default - - public boolean getDefaultStartOnBoot() - { - return false; - } - - public boolean getDefaultIsShowCursor() - { - return true; - } - - public boolean getDefaultFirstTimeUse() - { - return true; - } - - - - public boolean isShowCursor() - { - return XMLConfigHelper.getBooleanProperty(getOthersElement(), "show-cursor", getDefaultIsShowCursor(), false, true, document, configFile); - } - - - public boolean isStartOnBoot() - { - return XMLConfigHelper.getBooleanProperty(getOthersElement(), "start-on-boot", getDefaultStartOnBoot(), false, true, document, configFile); - } - - - public boolean isFirstTimeUse() - { - return XMLConfigHelper.getBooleanProperty(getOthersElement(), "first-time-use", true, false, true, document, configFile); - } - - public boolean isVibrateOnActionClicked() - { - return XMLConfigHelper.getBooleanProperty(getOthersElement(), "vibrate-on-action-clicked", false, false, true, document, configFile); - } - - public boolean isConnectOnStartup() - { - return XMLConfigHelper.getBooleanProperty(getOthersElement(), "connect-on-startup", false, false, true, document, configFile); - } - - public boolean getIsFullScreenMode() - { - return XMLConfigHelper.getBooleanProperty(getOthersElement(), "full-screen-mode", false, false, true, document, configFile); - } - - - public void setStartOnBoot(boolean value) - { - getOthersElement().getElementsByTagName("start-on-boot").item(0).setTextContent(value+""); - } - - public void setShowCursor(boolean value) - { - getOthersElement().getElementsByTagName("show-cursor").item(0).setTextContent(value+""); - } - - public void setFullscreen(boolean value) - { - getOthersElement().getElementsByTagName("fullscreen").item(0).setTextContent(value+""); - } - - public void setFirstTimeUse(boolean value) - { - getOthersElement().getElementsByTagName("first-time-use").item(0).setTextContent(value+""); - } - - public void setVibrateOnActionClicked(boolean value) - { - getOthersElement().getElementsByTagName("vibrate-on-action-clicked").item(0).setTextContent(value+""); - } - - public void setConnectOnStartup(boolean value) - { - getOthersElement().getElementsByTagName("connect-on-startup").item(0).setTextContent(value+""); - } - - public void setIsFullScreenMode(boolean value) - { - getOthersElement().getElementsByTagName("full-screen-mode").item(0).setTextContent(value+""); - } - - - - private Element getStartupWindowSizeElement() - { - return (Element) document.getElementsByTagName("startup-window-size").item(0); - } - - public double getStartupWindowWidth() - { - return XMLConfigHelper.getDoubleProperty(getStartupWindowSizeElement(), "width", - getDefaultStartupWindowWidth(), false, true, document, configFile); - } - - public double getStartupWindowHeight() - { - return XMLConfigHelper.getDoubleProperty(getStartupWindowSizeElement(), "height", - getDefaultStartupWindowHeight(), false, true, document, configFile); - } - - - public int getDefaultStartupWindowWidth() - { - return 800; - } - - public int getDefaultStartupWindowHeight() - { - return 400; - } - - public void setStartupWindowSize(double width, double height) - { - setStartupWindowWidth(width); - setStartupWindowHeight(height); - } - - public void setStartupWindowWidth(double width) - { - getStartupWindowSizeElement().getElementsByTagName("width").item(0).setTextContent(width+""); - } - - public void setStartupWindowHeight(double height) - { - getStartupWindowSizeElement().getElementsByTagName("height").item(0).setTextContent(height+""); - } - - public void setStartupIsXMode(boolean value) - { - getOthersElement().getElementsByTagName("start-on-boot-x-mode").item(0).setTextContent(value+""); - } - - public boolean getDefaultIsStartupXMode() - { - return false; - } - - public boolean isStartupXMode() - { - return XMLConfigHelper.getBooleanProperty(getOthersElement(), "start-on-boot-x-mode", getDefaultIsStartupXMode(), false, true, document, configFile); - } - - - public boolean getDefaultIsTryConnectingWhenActionClicked() - { - return false; - } - - public boolean isTryConnectingWhenActionClicked() - { - return XMLConfigHelper.getBooleanProperty(getOthersElement(), "try-connecting-when-action-clicked", getDefaultIsTryConnectingWhenActionClicked(), false, true, document, configFile); - } - - public void setTryConnectingWhenActionClicked(boolean value) - { - getOthersElement().getElementsByTagName("try-connecting-when-action-clicked").item(0).setTextContent(value+""); - } - - - public boolean getDefaultScreenSaverEnabled() - { - return false; - } - - public boolean isScreenSaverEnabled() - { - return XMLConfigHelper.getBooleanProperty(getOthersElement(), "screen-saver", getDefaultScreenSaverEnabled(), false, true, document, configFile); - } - - public void setScreenSaverEnabled(boolean value) - { - getOthersElement().getElementsByTagName("screen-saver").item(0).setTextContent(value+""); - } - - public int getDefaultScreenSaverTimeout() - { - return 60; - } - - public int getScreenSaverTimeout() - { - return XMLConfigHelper.getIntProperty(getOthersElement(), "screen-saver-timeout-seconds", getDefaultScreenSaverTimeout(), false, true, document, configFile); - } - - public void setScreenSaverTimeout(String value) - { - getOthersElement().getElementsByTagName("screen-saver-timeout-seconds").item(0).setTextContent(value); - } - - public int getDefaultScreenMoverInterval() - { - return 120000; - } - - public int getScreenMoverInterval() - { - return XMLConfigHelper.getIntProperty(getScreenMoverElement(), "interval", getDefaultScreenMoverInterval(), false, true, document, configFile); - } - - public void setScreenMoverInterval(String value) - { - getScreenMoverElement().getElementsByTagName("interval").item(0).setTextContent(value); - } - - public int getDefaultScreenMoverXChange() - { - return 5; - } - - public int getScreenMoverXChange() - { - return XMLConfigHelper.getIntProperty(getScreenMoverElement(), "x-change", getDefaultScreenMoverXChange(), false, true, document, configFile); - } - - public void setScreenMoverXChange(String value) - { - getScreenMoverElement().getElementsByTagName("x-change").item(0).setTextContent(value); - } - - public int getDefaultScreenMoverYChange() - { - return 5; - } - - public int getScreenMoverYChange() - { - return XMLConfigHelper.getIntProperty(getScreenMoverElement(), "y-change", getDefaultScreenMoverYChange(), false, true, document, configFile); - } - - public void setScreenMoverYChange(String value) - { - getScreenMoverElement().getElementsByTagName("y-change").item(0).setTextContent(value); - } - - public boolean getDefaultScreenMoverEnabled() - { - return false; - } - - public boolean isScreenMoverEnabled() - { - return XMLConfigHelper.getBooleanProperty(getScreenMoverElement(), "status", getDefaultScreenMoverEnabled(), false, true, document, configFile); - } - - public void setScreenMoverEnabled(boolean value) - { - getScreenMoverElement().getElementsByTagName("status").item(0).setTextContent(value+""); - } - - public boolean getDefaultInvertRowsColsOnDeviceRotate() - { - return true; - } - - public boolean isInvertRowsColsOnDeviceRotate() - { - return XMLConfigHelper.getBooleanProperty(getOthersElement(), "invert-rows-cols-on-device-rotate", getDefaultInvertRowsColsOnDeviceRotate(), false, true, document, configFile); - } - - public void setInvertRowsColsOnDeviceRotate(boolean value) - { - getOthersElement().getElementsByTagName("invert-rows-cols-on-device-rotate").item(0).setTextContent(value+""); - } -} +/* +Config.java + +Contributor(s) : Debayan Sutradhar (@rnayabed) + +handler for config.xml + */ + +package com.stream_pi.client.io; + +import java.io.File; +import java.util.Objects; + +import javax.xml.parsers.DocumentBuilder; +import javax.xml.parsers.DocumentBuilderFactory; +import javax.xml.transform.Result; +import javax.xml.transform.Source; +import javax.xml.transform.Transformer; +import javax.xml.transform.TransformerFactory; +import javax.xml.transform.dom.DOMSource; +import javax.xml.transform.stream.StreamResult; + +import com.stream_pi.client.Main; +import com.stream_pi.client.info.ClientInfo; +import com.stream_pi.client.info.StartupFlags; +import com.stream_pi.util.exception.SevereException; +import com.stream_pi.util.iohelper.IOHelper; +import com.stream_pi.util.platform.Platform; +import com.stream_pi.util.xmlconfighelper.XMLConfigHelper; + +import org.w3c.dom.Document; +import org.w3c.dom.Element; + +public class Config +{ + private static Config instance = null; + + private final File configFile; + + private Document document; + + private Config() throws SevereException + { + try + { + configFile = new File(ClientInfo.getInstance().getPrePath()+"config.xml"); + DocumentBuilderFactory docFactory = DocumentBuilderFactory.newInstance(); + DocumentBuilder docBuilder = docFactory.newDocumentBuilder(); + document = docBuilder.parse(configFile); + } + catch (Exception e) + { + e.printStackTrace(); + throw new SevereException("Config", "unable to read config.xml\n"+e.getMessage()); + } + } + + public static synchronized Config getInstance() throws SevereException + { + if(instance == null) + instance = new Config(); + + return instance; + } + + public static void nullify() + { + instance = null; + } + + public static void unzipToDefaultPrePath() throws Exception + { + IOHelper.unzip(Objects.requireNonNull(Main.class.getResourceAsStream("Default.zip")), ClientInfo.getInstance().getPrePath()); + Config.getInstance().setThemesPath(ClientInfo.getInstance().getPrePath()+"Themes/"); + Config.getInstance().setIconsPath(ClientInfo.getInstance().getPrePath()+"Icons/"); + Config.getInstance().setProfilesPath(ClientInfo.getInstance().getPrePath()+"Profiles/"); + + Config.getInstance().setIsFullScreenMode(StartupFlags.DEFAULT_FULLSCREEN_MODE); + + Config.getInstance().save(); + } + + public void save() throws SevereException + { + try + { + Transformer transformer = TransformerFactory.newInstance().newTransformer(); + Result output = new StreamResult(configFile); + Source input = new DOMSource(document); + + transformer.transform(input, output); + } + catch (Exception e) + { + throw new SevereException("Config", "unable to save config.xml"); + } + } + + + //Client Element + + //Default Values + public String getDefaultClientNickName() + { + return "Stream-Pi Client"; + } + + public String getDefaultStartupProfileID() + { + return "default"; + } + + public String getDefaultCurrentAnimationName() + { + return "None"; + } + + public String getDefaultCurrentThemeFullName() + { + return "com.stream_pi.defaultlight"; + } + + public String getDefaultThemesPath() + { + return ClientInfo.getInstance().getPrePath()+"Themes/"; + } + + public String getDefaultProfilesPath() + { + return ClientInfo.getInstance().getPrePath()+"Profiles/"; + } + + public String getDefaultIconsPath() + { + return ClientInfo.getInstance().getPrePath()+"Icons/"; + } + + //Getters + + public String getClientNickName() + { + return XMLConfigHelper.getStringProperty(document, "nickname", getDefaultClientNickName(), false, true, document, configFile); + } + + public String getStartupProfileID() + { + return XMLConfigHelper.getStringProperty(document, "startup-profile", getDefaultStartupProfileID(), false, true, document, configFile); + } + + public String getCurrentThemeFullName() + { + return XMLConfigHelper.getStringProperty(document, "current-theme-full-name", getDefaultCurrentThemeFullName(), false, true, document, configFile); + } + + public String getCurrentAnimationName() { + return XMLConfigHelper.getStringProperty(this.document, "current-animation-name", getDefaultCurrentAnimationName(), false, true, this.document, this.configFile); + } + + public String getThemesPath() + { + Platform platform = ClientInfo.getInstance().getPlatform(); + if(platform != Platform.ANDROID && + platform != Platform.IOS) + return ClientInfo.getInstance().getPrePath() + "Themes/"; + + return XMLConfigHelper.getStringProperty(document, "themes-path", getDefaultThemesPath(), false, true, document, configFile); + } + + public String getProfilesPath() + { + Platform platform = ClientInfo.getInstance().getPlatform(); + if(platform != Platform.ANDROID && + platform != Platform.IOS) + return ClientInfo.getInstance().getPrePath() + "Profiles/"; + + return XMLConfigHelper.getStringProperty(document, "profiles-path", getDefaultProfilesPath(), false, true, document, configFile); + } + + public String getIconsPath() + { + Platform platform = ClientInfo.getInstance().getPlatform(); + if(platform != Platform.ANDROID && + platform != Platform.IOS) + return ClientInfo.getInstance().getPrePath() + "Icons/"; + + return XMLConfigHelper.getStringProperty(document, "icons-path", getDefaultIconsPath(), false, true, document, configFile); + } + + + + //Setters + + public void setNickName(String nickName) + { + document.getElementsByTagName("nickname").item(0).setTextContent(nickName); + } + + public void setStartupProfileID(String id) + { + document.getElementsByTagName("startup-profile").item(0).setTextContent(id); + } + + public void setCurrentThemeFullName(String name) + { + document.getElementsByTagName("current-theme-full-name").item(0).setTextContent(name); + } + + public void setCurrentAnimationName(String name) { + this.document.getElementsByTagName("current-animation-name").item(0).setTextContent(name); + } + + public void setProfilesPath(String profilesPath) + { + document.getElementsByTagName("profiles-path").item(0).setTextContent(profilesPath); + } + + public void setIconsPath(String iconsPath) + { + document.getElementsByTagName("icons-path").item(0).setTextContent(iconsPath); + } + + public void setThemesPath(String themesPath) + { + document.getElementsByTagName("themes-path").item(0).setTextContent(themesPath); + } + + + //comms-server + public Element getCommsServerElement() + { + return (Element) document.getElementsByTagName("comms-server").item(0); + } + + public String getDefaultSavedServerHostNameOrIP() + { + return "127.0.0.1"; + } + + public int getDefaultSavedServerPort() + { + return -1; + } + + + public String getSavedServerHostNameOrIP() + { + return XMLConfigHelper.getStringProperty(getCommsServerElement(), "hostname-ip", getDefaultSavedServerHostNameOrIP(), false, true, document, configFile); + } + + public int getSavedServerPort() + { + return XMLConfigHelper.getIntProperty(getCommsServerElement(), "port", getDefaultSavedServerPort(), false, true, document, configFile); + } + + public void setServerHostNameOrIP(String hostNameOrIP) + { + getCommsServerElement().getElementsByTagName("hostname-ip").item(0).setTextContent(hostNameOrIP); + } + + public void setServerPort(int port) + { + getCommsServerElement().getElementsByTagName("port").item(0).setTextContent(port+""); + } + + + + + + //screen-mover + public Element getScreenMoverElement() + { + return (Element) document.getElementsByTagName("screen-mover").item(0); + } + + + //others + public Element getOthersElement() + { + return (Element) document.getElementsByTagName("others").item(0); + } + + //others-default + + public boolean getDefaultStartOnBoot() + { + return false; + } + + public boolean getDefaultIsShowCursor() + { + return true; + } + + public boolean getDefaultFirstTimeUse() + { + return true; + } + + + + public boolean isShowCursor() + { + return XMLConfigHelper.getBooleanProperty(getOthersElement(), "show-cursor", getDefaultIsShowCursor(), false, true, document, configFile); + } + + + public boolean isStartOnBoot() + { + return XMLConfigHelper.getBooleanProperty(getOthersElement(), "start-on-boot", getDefaultStartOnBoot(), false, true, document, configFile); + } + + + public boolean isFirstTimeUse() + { + return XMLConfigHelper.getBooleanProperty(getOthersElement(), "first-time-use", true, false, true, document, configFile); + } + + public boolean isVibrateOnActionClicked() + { + return XMLConfigHelper.getBooleanProperty(getOthersElement(), "vibrate-on-action-clicked", false, false, true, document, configFile); + } + + public boolean isConnectOnStartup() + { + return XMLConfigHelper.getBooleanProperty(getOthersElement(), "connect-on-startup", false, false, true, document, configFile); + } + + public boolean getIsFullScreenMode() + { + return XMLConfigHelper.getBooleanProperty(getOthersElement(), "full-screen-mode", false, false, true, document, configFile); + } + + + public void setStartOnBoot(boolean value) + { + getOthersElement().getElementsByTagName("start-on-boot").item(0).setTextContent(value+""); + } + + public void setShowCursor(boolean value) + { + getOthersElement().getElementsByTagName("show-cursor").item(0).setTextContent(value+""); + } + + public void setFullscreen(boolean value) + { + getOthersElement().getElementsByTagName("fullscreen").item(0).setTextContent(value+""); + } + + public void setFirstTimeUse(boolean value) + { + getOthersElement().getElementsByTagName("first-time-use").item(0).setTextContent(value+""); + } + + public void setVibrateOnActionClicked(boolean value) + { + getOthersElement().getElementsByTagName("vibrate-on-action-clicked").item(0).setTextContent(value+""); + } + + public void setConnectOnStartup(boolean value) + { + getOthersElement().getElementsByTagName("connect-on-startup").item(0).setTextContent(value+""); + } + + public void setIsFullScreenMode(boolean value) + { + getOthersElement().getElementsByTagName("full-screen-mode").item(0).setTextContent(value+""); + } + + + + private Element getStartupWindowSizeElement() + { + return (Element) document.getElementsByTagName("startup-window-size").item(0); + } + + public double getStartupWindowWidth() + { + return XMLConfigHelper.getDoubleProperty(getStartupWindowSizeElement(), "width", + getDefaultStartupWindowWidth(), false, true, document, configFile); + } + + public double getStartupWindowHeight() + { + return XMLConfigHelper.getDoubleProperty(getStartupWindowSizeElement(), "height", + getDefaultStartupWindowHeight(), false, true, document, configFile); + } + + + public int getDefaultStartupWindowWidth() + { + return 800; + } + + public int getDefaultStartupWindowHeight() + { + return 400; + } + + public void setStartupWindowSize(double width, double height) + { + setStartupWindowWidth(width); + setStartupWindowHeight(height); + } + + public void setStartupWindowWidth(double width) + { + getStartupWindowSizeElement().getElementsByTagName("width").item(0).setTextContent(width+""); + } + + public void setStartupWindowHeight(double height) + { + getStartupWindowSizeElement().getElementsByTagName("height").item(0).setTextContent(height+""); + } + + public void setStartupIsXMode(boolean value) + { + getOthersElement().getElementsByTagName("start-on-boot-x-mode").item(0).setTextContent(value+""); + } + + public boolean getDefaultIsStartupXMode() + { + return false; + } + + public boolean isStartupXMode() + { + return XMLConfigHelper.getBooleanProperty(getOthersElement(), "start-on-boot-x-mode", getDefaultIsStartupXMode(), false, true, document, configFile); + } + + + public boolean getDefaultIsTryConnectingWhenActionClicked() + { + return false; + } + + public boolean isTryConnectingWhenActionClicked() + { + return XMLConfigHelper.getBooleanProperty(getOthersElement(), "try-connecting-when-action-clicked", getDefaultIsTryConnectingWhenActionClicked(), false, true, document, configFile); + } + + public void setTryConnectingWhenActionClicked(boolean value) + { + getOthersElement().getElementsByTagName("try-connecting-when-action-clicked").item(0).setTextContent(value+""); + } + + + public boolean getDefaultScreenSaverEnabled() + { + return false; + } + + public boolean isScreenSaverEnabled() + { + return XMLConfigHelper.getBooleanProperty(getOthersElement(), "screen-saver", getDefaultScreenSaverEnabled(), false, true, document, configFile); + } + + public void setScreenSaverEnabled(boolean value) + { + getOthersElement().getElementsByTagName("screen-saver").item(0).setTextContent(value+""); + } + + public int getDefaultScreenSaverTimeout() + { + return 60; + } + + public int getScreenSaverTimeout() + { + return XMLConfigHelper.getIntProperty(getOthersElement(), "screen-saver-timeout-seconds", getDefaultScreenSaverTimeout(), false, true, document, configFile); + } + + public void setScreenSaverTimeout(String value) + { + getOthersElement().getElementsByTagName("screen-saver-timeout-seconds").item(0).setTextContent(value); + } + + public int getDefaultScreenMoverInterval() + { + return 120000; + } + + public int getScreenMoverInterval() + { + return XMLConfigHelper.getIntProperty(getScreenMoverElement(), "interval", getDefaultScreenMoverInterval(), false, true, document, configFile); + } + + public void setScreenMoverInterval(String value) + { + getScreenMoverElement().getElementsByTagName("interval").item(0).setTextContent(value); + } + + public int getDefaultScreenMoverXChange() + { + return 5; + } + + public int getScreenMoverXChange() + { + return XMLConfigHelper.getIntProperty(getScreenMoverElement(), "x-change", getDefaultScreenMoverXChange(), false, true, document, configFile); + } + + public void setScreenMoverXChange(String value) + { + getScreenMoverElement().getElementsByTagName("x-change").item(0).setTextContent(value); + } + + public int getDefaultScreenMoverYChange() + { + return 5; + } + + public int getScreenMoverYChange() + { + return XMLConfigHelper.getIntProperty(getScreenMoverElement(), "y-change", getDefaultScreenMoverYChange(), false, true, document, configFile); + } + + public void setScreenMoverYChange(String value) + { + getScreenMoverElement().getElementsByTagName("y-change").item(0).setTextContent(value); + } + + public boolean getDefaultScreenMoverEnabled() + { + return false; + } + + public boolean isScreenMoverEnabled() + { + return XMLConfigHelper.getBooleanProperty(getScreenMoverElement(), "status", getDefaultScreenMoverEnabled(), false, true, document, configFile); + } + + public void setScreenMoverEnabled(boolean value) + { + getScreenMoverElement().getElementsByTagName("status").item(0).setTextContent(value+""); + } + + public boolean getDefaultInvertRowsColsOnDeviceRotate() + { + return true; + } + + public boolean isInvertRowsColsOnDeviceRotate() + { + return XMLConfigHelper.getBooleanProperty(getOthersElement(), "invert-rows-cols-on-device-rotate", getDefaultInvertRowsColsOnDeviceRotate(), false, true, document, configFile); + } + + public void setInvertRowsColsOnDeviceRotate(boolean value) + { + getOthersElement().getElementsByTagName("invert-rows-cols-on-device-rotate").item(0).setTextContent(value+""); + } +} diff --git a/src/main/java/com/stream_pi/client/profile/ClientProfile.java b/src/main/java/com/stream_pi/client/profile/ClientProfile.java old mode 100644 new mode 100755 diff --git a/src/main/java/com/stream_pi/client/profile/ClientProfiles.java b/src/main/java/com/stream_pi/client/profile/ClientProfiles.java old mode 100644 new mode 100755 diff --git a/src/main/java/com/stream_pi/client/window/Base.java b/src/main/java/com/stream_pi/client/window/Base.java old mode 100644 new mode 100755 diff --git a/src/main/java/com/stream_pi/client/window/ExceptionAndAlertHandler.java b/src/main/java/com/stream_pi/client/window/ExceptionAndAlertHandler.java old mode 100644 new mode 100755 diff --git a/src/main/java/com/stream_pi/client/window/dashboard/DashboardBase.java b/src/main/java/com/stream_pi/client/window/dashboard/DashboardBase.java old mode 100644 new mode 100755 diff --git a/src/main/java/com/stream_pi/client/window/dashboard/actiongridpane/ActionBox.java b/src/main/java/com/stream_pi/client/window/dashboard/actiongridpane/ActionBox.java old mode 100644 new mode 100755 index ab71a778..f0e828ee --- a/src/main/java/com/stream_pi/client/window/dashboard/actiongridpane/ActionBox.java +++ b/src/main/java/com/stream_pi/client/window/dashboard/actiongridpane/ActionBox.java @@ -1,484 +1,548 @@ -package com.stream_pi.client.window.dashboard.actiongridpane; - -import com.stream_pi.action_api.action.Action; -import com.stream_pi.action_api.action.ActionType; -import com.stream_pi.action_api.action.DisplayTextAlignment; -import com.stream_pi.client.controller.ClientListener; -import com.stream_pi.client.io.Config; -import com.stream_pi.client.window.ExceptionAndAlertHandler; -import com.stream_pi.util.alert.StreamPiAlertType; -import com.stream_pi.util.exception.MinorException; -import com.stream_pi.util.exception.SevereException; -import javafx.animation.Interpolator; -import javafx.animation.KeyFrame; -import javafx.animation.KeyValue; -import javafx.animation.Timeline; -import javafx.geometry.Pos; -import javafx.scene.CacheHint; -import javafx.scene.control.Label; -import javafx.scene.image.Image; -import javafx.scene.layout.Background; -import javafx.scene.layout.BackgroundImage; -import javafx.scene.layout.BackgroundPosition; -import javafx.scene.layout.BackgroundRepeat; -import javafx.scene.layout.BackgroundSize; -import javafx.scene.layout.StackPane; -import javafx.scene.text.Font; -import javafx.scene.text.TextAlignment; -import javafx.util.Duration; -import org.kordamp.ikonli.javafx.FontIcon; - -import java.io.ByteArrayInputStream; -import java.util.logging.Logger; - -public class ActionBox extends StackPane -{ - - private Label displayTextLabel; - - private int row; - private int col; - - public int getRow() { - return row; - } - - public int getCol() { - return col; - } - - private Logger logger; - - - - public void clear() - { - setStyle(null); - setAction(null); - setCurrentToggleStatus(false); - getStyleClass().clear(); - setBackground(Background.EMPTY); - removeFontIcon(); - getChildren().clear(); - baseInit(); - } - - private FontIcon statusIcon; - - public void baseInit() - { - displayTextLabel = new Label(); - displayTextLabel.setWrapText(true); - displayTextLabel.setTextAlignment(TextAlignment.CENTER); - displayTextLabel.getStyleClass().add("action_box_display_text_label"); - - displayTextLabel.prefHeightProperty().bind(heightProperty()); - displayTextLabel.prefWidthProperty().bind(widthProperty()); - - - statusIcon = new FontIcon("fas-exclamation-triangle"); - statusIcon.getStyleClass().add("action_box_error_icon"); - statusIcon.setOpacity(0); - statusIcon.setCache(true); - statusIcon.setCacheHint(CacheHint.SPEED); - statusIcon.setIconSize(size - 30); - - - getChildren().addAll(statusIcon, displayTextLabel); - - setMinSize(size, size); - setMaxSize(size, size); - - getStyleClass().clear(); - getStyleClass().add("action_box"); - getStyleClass().add("action_box_"+row+"_"+col); - - setIcon(null); - - setOnMouseClicked(touchEvent -> actionClicked()); - - setOnMousePressed(TouchEvent -> { - if(action != null) - { - getStyleClass().add("action_box_onclick"); - } - }); - setOnMouseReleased(TouchEvent ->{ - if(action != null) - { - getStyleClass().remove("action_box_onclick"); - } - }); - - statusIconAnimation = new Timeline( - new KeyFrame( - Duration.millis(0.0D), - new KeyValue(statusIcon.opacityProperty(), 0.0D, Interpolator.EASE_IN)), - new KeyFrame( - Duration.millis(100.0D), - new KeyValue(statusIcon.opacityProperty(), 1.0D, Interpolator.EASE_IN)), - new KeyFrame( - Duration.millis(600.0D), - new KeyValue(statusIcon.opacityProperty(), 1.0D, Interpolator.EASE_OUT)), - new KeyFrame( - Duration.millis(700.0D), - new KeyValue(statusIcon.opacityProperty(), 0.0D, Interpolator.EASE_OUT)) - ); - - statusIconAnimation.setOnFinished(event -> { - statusIcon.toBack(); - }); - - setCache(true); - setCacheHint(CacheHint.QUALITY); - } - - public void actionClicked() - { - if(action!=null) - { - if(action.getActionType() == ActionType.FOLDER) - { - getActionGridPaneListener().renderFolder(action.getID()); - } - else - { - if(!getActionGridPaneListener().isConnected()) - { - try - { - if(Config.getInstance().isTryConnectingWhenActionClicked()) - { - clientListener.setupClientConnection(this::actionClicked); - } - else - { - exceptionAndAlertHandler.handleMinorException(new MinorException("Not Connected", "Not Connected to any Server")); - } - return; - } - catch (SevereException e) - { - exceptionAndAlertHandler.handleSevereException(e); - } - } - - if(action.getActionType() == ActionType.COMBINE || action.getActionType() == ActionType.NORMAL) - { - getActionGridPaneListener().normalOrCombineActionClicked(action.getID()); - } - else if(action.getActionType() == ActionType.TOGGLE) - { - toggle(); - getActionGridPaneListener().toggleActionClicked(action.getID(), getCurrentToggleStatus()); - } - } - } - } - - private Timeline statusIconAnimation; - - public Timeline getStatusIconAnimation() { - return statusIconAnimation; - } - - public ActionGridPaneListener getActionGridPaneListener() { - return actionGridPaneListener; - } - - private int size; - private ActionGridPaneListener actionGridPaneListener; - private ClientListener clientListener; - - public ActionBox(int size, ExceptionAndAlertHandler exceptionAndAlertHandler, - ClientListener clientListener, ActionGridPaneListener actionGridPaneListener, int row, int col) - { - this.actionGridPaneListener = actionGridPaneListener; - this.exceptionAndAlertHandler = exceptionAndAlertHandler; - this.size = size; - this.row = row; - this.col = col; - this.clientListener = clientListener; - this.logger = Logger.getLogger(""); - - baseInit(); - } - - public Logger getLogger() - { - return logger; - } - - public void setIcon(byte[] iconByteArray) - { - removeFontIcon(); - - if(iconByteArray == null) - { - getStyleClass().remove("action_box_icon_present"); - getStyleClass().add("action_box_icon_not_present"); - setBackground(null); - } - else - { - getStyleClass().add("action_box_icon_present"); - getStyleClass().remove("action_box_icon_not_present"); - - - setBackground( - new Background( - new BackgroundImage(new Image( - new ByteArrayInputStream(iconByteArray), size, size, false, true - ), BackgroundRepeat.NO_REPEAT, BackgroundRepeat.NO_REPEAT, BackgroundPosition.CENTER, - - new BackgroundSize(100, 100, true, true, true, false)) - ) - ); - } - } - - private Action action = null; - - public Action getAction() { - return action; - } - - private ExceptionAndAlertHandler exceptionAndAlertHandler; - - private String parent; - - public String getStreamPiParent() { - return parent; - } - - public void setStreamPiParent(String parent) { - this.parent = parent; - } - - public void setAction(Action action) - { - this.action = action; - } - - public void init() - { - setBackground(null); - setStyle(null); - displayTextLabel.setStyle(null); - - - if(getAction().isShowDisplayText()) - { - setDisplayTextAlignment(action.getDisplayTextAlignment()); - setDisplayTextFontColourAndSize(action.getDisplayTextFontColourHex()); - setDisplayTextLabel(getAction().getDisplayText()); - } - else - setDisplayTextLabel(""); - - setBackgroundColour(action.getBgColourHex()); - - try - { - if(action.getActionType() == ActionType.TOGGLE) - { - toggle(getCurrentToggleStatus()); - } - else - { - if(action.isHasIcon()) - { - if(!action.getCurrentIconState().isBlank()) - { - setIcon(action.getCurrentIcon()); - } - } - else - { - setIcon(null); - } - } - } - catch (Exception e) - { - e.printStackTrace(); - } - } - - - public void setCurrentToggleStatus(boolean currentToggleStatus) - { - if(getAction() != null) - getAction().setCurrentToggleStatus(currentToggleStatus); - } - - public boolean getCurrentToggleStatus() - { - if(getAction() == null) - return false; - - return getAction().getCurrentToggleStatus(); - } - - public void toggle() - { - setCurrentToggleStatus(!getCurrentToggleStatus()); - - toggle(getCurrentToggleStatus()); - } - - public void toggle(boolean isON) - { - String[] toggleStatesHiddenStatus = action.getCurrentIconState().split("__"); - - boolean isToggleOffHidden = toggleStatesHiddenStatus[0].equals("true"); - boolean isToggleOnHidden = toggleStatesHiddenStatus[1].equals("true"); - - if(isON) // ON - { - if(action.isHasIcon()) - { - boolean isToggleOnPresent = action.getIcons().containsKey("toggle_on"); - - if(isToggleOnPresent) - { - if(isToggleOnHidden) - { - setDefaultToggleIcon(true); - } - else - { - setIcon(action.getIcons().get("toggle_on")); - } - } - else - { - setDefaultToggleIcon(true); - } - } - else - { - setDefaultToggleIcon(true); - } - } - else // OFF - { - if(action.isHasIcon()) - { - boolean isToggleOffPresent = action.getIcons().containsKey("toggle_off"); - - if(isToggleOffPresent) - { - if(isToggleOffHidden) - { - setDefaultToggleIcon(false); - } - else - { - setIcon(action.getIcons().get("toggle_off")); - } - } - else - { - setDefaultToggleIcon(false); - } - } - else - { - setDefaultToggleIcon(false); - } - } - } - - - public void setDefaultToggleIcon(boolean isToggleOn) - { - String styleClass; - - if(isToggleOn) - { - styleClass = "action_box_toggle_on"; - } - else - { - styleClass = "action_box_toggle_off"; - } - - - setBackground(null); - - - if(fontIcon!=null) - { - fontIcon.getStyleClass().removeIf(s -> s.equals("action_box_toggle_off") || s.equals("action_box_toggle_on")); - } - else - { - fontIcon = new FontIcon(); - fontIcon.setIconSize((int) (size * 0.8)); - getChildren().add(fontIcon); - } - - fontIcon.getStyleClass().add(styleClass); - - fontIcon.toBack(); - } - - public void removeFontIcon() - { - if(fontIcon!=null) - { - getChildren().remove(fontIcon); - fontIcon = null; - } - } - - FontIcon fontIcon = null; - - public void animateStatus() - { - statusIcon.toFront(); - statusIconAnimation.play(); - } - - public void setDisplayTextLabel(String text) - { - displayTextLabel.setText(text); - } - - public void setDisplayTextAlignment(DisplayTextAlignment displayTextAlignment) - { - if(displayTextAlignment == DisplayTextAlignment.CENTER) - displayTextLabel.setAlignment(Pos.CENTER); - else if (displayTextAlignment == DisplayTextAlignment.BOTTOM) - displayTextLabel.setAlignment(Pos.BOTTOM_CENTER); - else if (displayTextAlignment == DisplayTextAlignment.TOP) - displayTextLabel.setAlignment(Pos.TOP_CENTER); - } - - public void setDisplayTextFontColourAndSize(String colour) - { - String totalStyle = ""; - if(!colour.isEmpty()) - { - totalStyle+="-fx-text-fill : "+colour+";"; - } - - if(getAction().getNameFontSize() > -1) - { - totalStyle+="-fx-font-size: "+getAction().getNameFontSize()+";"; - } - - if(!totalStyle.isBlank()) - { - displayTextLabel.setStyle(totalStyle); - } - } - - - public void setBackgroundColour(String colour) - { - if(!colour.isEmpty()) - setStyle("-fx-background-color : "+colour); - } -} +package com.stream_pi.client.window.dashboard.actiongridpane; + +import com.stream_pi.action_api.action.Action; +import com.stream_pi.action_api.action.ActionType; +import com.stream_pi.action_api.action.DisplayTextAlignment; +import com.stream_pi.client.animations.*; +import com.stream_pi.client.controller.ClientListener; +import com.stream_pi.client.io.Config; +import com.stream_pi.client.window.ExceptionAndAlertHandler; +import com.stream_pi.util.alert.StreamPiAlertType; +import com.stream_pi.util.exception.MinorException; +import com.stream_pi.util.exception.SevereException; +import javafx.animation.Interpolator; +import javafx.animation.KeyFrame; +import javafx.animation.KeyValue; +import javafx.animation.Timeline; +import javafx.geometry.Pos; +import javafx.scene.CacheHint; +import javafx.scene.control.Label; +import javafx.scene.image.Image; +import javafx.scene.layout.Background; +import javafx.scene.layout.BackgroundImage; +import javafx.scene.layout.BackgroundPosition; +import javafx.scene.layout.BackgroundRepeat; +import javafx.scene.layout.BackgroundSize; +import javafx.scene.layout.StackPane; +import javafx.scene.text.Font; +import javafx.scene.text.TextAlignment; +import javafx.util.Duration; +import org.kordamp.ikonli.javafx.FontIcon; + +import java.io.ByteArrayInputStream; +import java.util.logging.Logger; + +public class ActionBox extends StackPane +{ + + private Label displayTextLabel; + + private int row; + private int col; + + public int getRow() { + return row; + } + + public int getCol() { + return col; + } + + private Logger logger; + + + + public void clear() + { + setStyle(null); + setAction(null); + setCurrentToggleStatus(false); + getStyleClass().clear(); + setBackground(Background.EMPTY); + removeFontIcon(); + getChildren().clear(); + baseInit(); + } + + private FontIcon statusIcon; + + public void baseInit() + { + displayTextLabel = new Label(); + displayTextLabel.setWrapText(true); + displayTextLabel.setTextAlignment(TextAlignment.CENTER); + displayTextLabel.getStyleClass().add("action_box_display_text_label"); + + displayTextLabel.prefHeightProperty().bind(heightProperty()); + displayTextLabel.prefWidthProperty().bind(widthProperty()); + + + statusIcon = new FontIcon("fas-exclamation-triangle"); + statusIcon.getStyleClass().add("action_box_error_icon"); + statusIcon.setOpacity(0); + statusIcon.setCache(true); + statusIcon.setCacheHint(CacheHint.SPEED); + statusIcon.setIconSize(size - 30); + + + getChildren().addAll(statusIcon, displayTextLabel); + + setMinSize(size, size); + setMaxSize(size, size); + + getStyleClass().clear(); + getStyleClass().add("action_box"); + getStyleClass().add("action_box_"+row+"_"+col); + + setIcon(null); + + setOnMouseClicked(touchEvent -> actionClicked()); + + setOnMousePressed(TouchEvent -> { + if(action != null) + { + getStyleClass().add("action_box_onclick"); + } + }); + setOnMouseReleased(TouchEvent ->{ + if(action != null) + { + getStyleClass().remove("action_box_onclick"); + } + }); + + statusIconAnimation = new Timeline( + new KeyFrame( + Duration.millis(0.0D), + new KeyValue(statusIcon.opacityProperty(), 0.0D, Interpolator.EASE_IN)), + new KeyFrame( + Duration.millis(100.0D), + new KeyValue(statusIcon.opacityProperty(), 1.0D, Interpolator.EASE_IN)), + new KeyFrame( + Duration.millis(600.0D), + new KeyValue(statusIcon.opacityProperty(), 1.0D, Interpolator.EASE_OUT)), + new KeyFrame( + Duration.millis(700.0D), + new KeyValue(statusIcon.opacityProperty(), 0.0D, Interpolator.EASE_OUT)) + ); + + statusIconAnimation.setOnFinished(event -> { + statusIcon.toBack(); + }); + + setCache(true); + setCacheHint(CacheHint.QUALITY); + } + + public void actionClicked() + { + if(action!=null) + { + if(action.getActionType() == ActionType.FOLDER) + { + getActionGridPaneListener().renderFolder(action.getID()); + } + else + { + if(!getActionGridPaneListener().isConnected()) + { + try + { + if(Config.getInstance().isTryConnectingWhenActionClicked()) + { + clientListener.setupClientConnection(this::actionClicked); + } + else + { + exceptionAndAlertHandler.handleMinorException(new MinorException("Not Connected", "Not Connected to any Server")); + } + return; + } + catch (SevereException e) + { + exceptionAndAlertHandler.handleSevereException(e); + } + } + + if(action.getActionType() == ActionType.COMBINE || action.getActionType() == ActionType.NORMAL) + { + getActionGridPaneListener().normalOrCombineActionClicked(action.getID()); + } + else if(action.getActionType() == ActionType.TOGGLE) + { + toggle(); + getActionGridPaneListener().toggleActionClicked(action.getID(), getCurrentToggleStatus()); + } + } + try { + playActionAnimation(); + } catch (SevereException e) { + Logger.getLogger("").warning(e.getMessage()); + } + } + } + + private Timeline statusIconAnimation; + + public Timeline getStatusIconAnimation() { + return statusIconAnimation; + } + + public ActionGridPaneListener getActionGridPaneListener() { + return actionGridPaneListener; + } + + private int size; + private ActionGridPaneListener actionGridPaneListener; + private ClientListener clientListener; + + public ActionBox(int size, ExceptionAndAlertHandler exceptionAndAlertHandler, + ClientListener clientListener, ActionGridPaneListener actionGridPaneListener, int row, int col) + { + this.actionGridPaneListener = actionGridPaneListener; + this.exceptionAndAlertHandler = exceptionAndAlertHandler; + this.size = size; + this.row = row; + this.col = col; + this.clientListener = clientListener; + this.logger = Logger.getLogger(""); + + baseInit(); + } + + public Logger getLogger() + { + return logger; + } + + public void setIcon(byte[] iconByteArray) + { + removeFontIcon(); + + if(iconByteArray == null) + { + getStyleClass().remove("action_box_icon_present"); + getStyleClass().add("action_box_icon_not_present"); + setBackground(null); + } + else + { + getStyleClass().add("action_box_icon_present"); + getStyleClass().remove("action_box_icon_not_present"); + + + setBackground( + new Background( + new BackgroundImage(new Image( + new ByteArrayInputStream(iconByteArray), size, size, false, true + ), BackgroundRepeat.NO_REPEAT, BackgroundRepeat.NO_REPEAT, BackgroundPosition.CENTER, + + new BackgroundSize(100, 100, true, true, true, false)) + ) + ); + } + } + + private Action action = null; + + public Action getAction() { + return action; + } + + private ExceptionAndAlertHandler exceptionAndAlertHandler; + + private String parent; + + public String getStreamPiParent() { + return parent; + } + + public void setStreamPiParent(String parent) { + this.parent = parent; + } + + public void setAction(Action action) + { + this.action = action; + } + + public void playActionAnimation() throws SevereException { + Config config = Config.getInstance(); + + switch (config.getCurrentAnimationName()) { + case "None": + return; + case "Flip": + new Flip(getChildren().get(1).getParent()).play(); + case "Bounce": + new Bounce(getChildren().get(1).getParent()).play(); + break; + case "Bounce In/Out": + new BounceOut(getChildren().get(1).getParent()).playOnFinished(new BounceIn(getChildren().get(1).getParent())).play(); + break; + case "Fade In/Out": + new FadeOut(getChildren().get(1).getParent()).playOnFinished(new FadeIn(getChildren().get(1).getParent())).play(); + break; + case "Roll In/Out": + new RollOut(getChildren().get(1).getParent()).playOnFinished(new RollIn(getChildren().get(1).getParent())).play(); + break; + case "Rotate In/Out": + new RotateOut(getChildren().get(1).getParent()).playOnFinished(new RotateIn(getChildren().get(1).getParent())).play(); + break; + case "Zoom In/Out": + new ZoomOut(getChildren().get(1).getParent()).playOnFinished(new ZoomIn(getChildren().get(1).getParent())).play(); + break; + case "Jack In The Box": + new JackInTheBox(getChildren().get(1).getParent()).play(); + break; + case "Swing": + new Swing(getChildren().get(1).getParent()).play(); + break; + case "Jello": + new Jello(getChildren().get(1).getParent()).play(); + break; + case "Pulse": + new Pulse(getChildren().get(1).getParent()).play(); + break; + case "RubberBand": + new RubberBand(getChildren().get(1).getParent()).play(); + break; + case "Shake Left/Right": + new Shake(getChildren().get(1).getParent()).play(); + break; + case "Shake Up/Down": + new ShakeUpDown(getChildren().get(1).getParent()).play(); + break; + case "Tada": + new Tada(getChildren().get(1).getParent()).play(); + break; + case "Wobble": + new Wobble(getChildren().get(1).getParent()).play(); + break; + default: + Logger.getLogger("").warning("Invalid Option/n Please contact quimodotcom to solve this error!"); + } + } + + public void init() + { + setBackground(null); + setStyle(null); + displayTextLabel.setStyle(null); + + + if(getAction().isShowDisplayText()) + { + setDisplayTextAlignment(action.getDisplayTextAlignment()); + setDisplayTextFontColourAndSize(action.getDisplayTextFontColourHex()); + setDisplayTextLabel(getAction().getDisplayText()); + } + else + setDisplayTextLabel(""); + + setBackgroundColour(action.getBgColourHex()); + + try + { + if(action.getActionType() == ActionType.TOGGLE) + { + toggle(getCurrentToggleStatus()); + } + else + { + if(action.isHasIcon()) + { + if(!action.getCurrentIconState().isBlank()) + { + setIcon(action.getCurrentIcon()); + } + } + else + { + setIcon(null); + } + } + } + catch (Exception e) + { + e.printStackTrace(); + } + } + + + public void setCurrentToggleStatus(boolean currentToggleStatus) + { + if(getAction() != null) + getAction().setCurrentToggleStatus(currentToggleStatus); + } + + public boolean getCurrentToggleStatus() + { + if(getAction() == null) + return false; + + return getAction().getCurrentToggleStatus(); + } + + public void toggle() + { + setCurrentToggleStatus(!getCurrentToggleStatus()); + + toggle(getCurrentToggleStatus()); + } + + public void toggle(boolean isON) + { + String[] toggleStatesHiddenStatus = action.getCurrentIconState().split("__"); + + boolean isToggleOffHidden = toggleStatesHiddenStatus[0].equals("true"); + boolean isToggleOnHidden = toggleStatesHiddenStatus[1].equals("true"); + + if(isON) // ON + { + if(action.isHasIcon()) + { + boolean isToggleOnPresent = action.getIcons().containsKey("toggle_on"); + + if(isToggleOnPresent) + { + if(isToggleOnHidden) + { + setDefaultToggleIcon(true); + } + else + { + setIcon(action.getIcons().get("toggle_on")); + } + } + else + { + setDefaultToggleIcon(true); + } + } + else + { + setDefaultToggleIcon(true); + } + } + else // OFF + { + if(action.isHasIcon()) + { + boolean isToggleOffPresent = action.getIcons().containsKey("toggle_off"); + + if(isToggleOffPresent) + { + if(isToggleOffHidden) + { + setDefaultToggleIcon(false); + } + else + { + setIcon(action.getIcons().get("toggle_off")); + } + } + else + { + setDefaultToggleIcon(false); + } + } + else + { + setDefaultToggleIcon(false); + } + } + } + + + public void setDefaultToggleIcon(boolean isToggleOn) + { + String styleClass; + + if(isToggleOn) + { + styleClass = "action_box_toggle_on"; + } + else + { + styleClass = "action_box_toggle_off"; + } + + + setBackground(null); + + + if(fontIcon!=null) + { + fontIcon.getStyleClass().removeIf(s -> s.equals("action_box_toggle_off") || s.equals("action_box_toggle_on")); + } + else + { + fontIcon = new FontIcon(); + fontIcon.setIconSize((int) (size * 0.8)); + getChildren().add(fontIcon); + } + + fontIcon.getStyleClass().add(styleClass); + + fontIcon.toBack(); + } + + public void removeFontIcon() + { + if(fontIcon!=null) + { + getChildren().remove(fontIcon); + fontIcon = null; + } + } + + FontIcon fontIcon = null; + + public void animateStatus() + { + statusIcon.toFront(); + statusIconAnimation.play(); + } + + public void setDisplayTextLabel(String text) + { + displayTextLabel.setText(text); + } + + public void setDisplayTextAlignment(DisplayTextAlignment displayTextAlignment) + { + if(displayTextAlignment == DisplayTextAlignment.CENTER) + displayTextLabel.setAlignment(Pos.CENTER); + else if (displayTextAlignment == DisplayTextAlignment.BOTTOM) + displayTextLabel.setAlignment(Pos.BOTTOM_CENTER); + else if (displayTextAlignment == DisplayTextAlignment.TOP) + displayTextLabel.setAlignment(Pos.TOP_CENTER); + } + + public void setDisplayTextFontColourAndSize(String colour) + { + String totalStyle = ""; + if(!colour.isEmpty()) + { + totalStyle+="-fx-text-fill : "+colour+";"; + } + + if(getAction().getNameFontSize() > -1) + { + totalStyle+="-fx-font-size: "+getAction().getNameFontSize()+";"; + } + + if(!totalStyle.isBlank()) + { + displayTextLabel.setStyle(totalStyle); + } + } + + + public void setBackgroundColour(String colour) + { + if(!colour.isEmpty()) + setStyle("-fx-background-color : "+colour); + } +} diff --git a/src/main/java/com/stream_pi/client/window/dashboard/actiongridpane/ActionGridPane.java b/src/main/java/com/stream_pi/client/window/dashboard/actiongridpane/ActionGridPane.java old mode 100644 new mode 100755 index 1eafe151..e1034d07 --- a/src/main/java/com/stream_pi/client/window/dashboard/actiongridpane/ActionGridPane.java +++ b/src/main/java/com/stream_pi/client/window/dashboard/actiongridpane/ActionGridPane.java @@ -1,459 +1,459 @@ -package com.stream_pi.client.window.dashboard.actiongridpane; - -import java.util.logging.Logger; - -import com.stream_pi.action_api.action.Action; -import com.stream_pi.action_api.action.ActionType; -import com.stream_pi.action_api.action.Location; -import com.stream_pi.client.controller.ClientListener; -import com.stream_pi.client.info.ClientInfo; -import com.stream_pi.client.info.StartupFlags; -import com.stream_pi.client.io.Config; -import com.stream_pi.client.profile.ClientProfile; -import com.stream_pi.client.window.ExceptionAndAlertHandler; -import com.stream_pi.util.exception.MinorException; -import com.stream_pi.util.exception.SevereException; -import javafx.concurrent.Task; -import javafx.geometry.Insets; -import javafx.geometry.Orientation; -import javafx.geometry.Pos; -import javafx.scene.CacheHint; -import javafx.scene.Node; -import javafx.scene.control.ScrollPane; -import javafx.scene.layout.GridPane; -import javafx.scene.layout.Priority; -import javafx.scene.layout.StackPane; -import javafx.scene.layout.VBox; -import org.kordamp.ikonli.javafx.FontIcon; - -public class ActionGridPane extends ScrollPane implements ActionGridPaneListener -{ - - private ExceptionAndAlertHandler exceptionAndAlertHandler; - - private ClientListener clientListener; - - private ActionBox[][] actionBoxes; - - private GridPane actionsGridPane; - - public ActionGridPane(ExceptionAndAlertHandler exceptionAndAlertHandler, ClientListener clientListener) - { - this.clientListener = clientListener; - - logger = Logger.getLogger(ActionGridPane.class.getName()); - this.exceptionAndAlertHandler = exceptionAndAlertHandler; - - getStyleClass().add("action_grid_pane_parent"); - - actionsGridPane = new GridPane(); - actionsGridPane.setPadding(new Insets(5.0)); - actionsGridPane.getStyleClass().add("action_grid_pane"); - actionsGridPane.prefWidthProperty().bind(widthProperty().subtract(20)); - actionsGridPane.prefHeightProperty().bind(heightProperty().subtract(20)); - - setContent(actionsGridPane); - - actionsGridPane.setAlignment(Pos.CENTER); - - - VBox.setVgrow(this, Priority.ALWAYS); - - setCache(true); - setCacheHint(CacheHint.SPEED); - } - - private String currentParent; - - public void setCurrentParent(String currentParent) { - this.currentParent = currentParent; - } - - public ClientProfile getClientProfile() { - return clientProfile; - } - - private int rows, cols; - - private ClientProfile clientProfile; - - public void setClientProfile(ClientProfile clientProfile) - { - this.clientProfile = clientProfile; - - setCurrentParent("root"); - setRows(clientProfile.getRows()); - setCols(clientProfile.getCols()); - } - - public void actionFailed(String profileID, String actionID) - { - if(getClientProfile().getID().equals(profileID)) - { - Action action = getClientProfile().getActionFromID(actionID); - if(action != null) - { - if(currentParent.equals(action.getParent())) - { - failShow(action); - } - else - { - if(action.getLocation().getCol() == -1) - { - failShow(getClientProfile().getActionFromID(action.getParent())); - } - } - } - } - } - - public void failShow(Action action) - { - actionBoxes[action.getLocation().getCol()][action.getLocation().getRow()].animateStatus(); - } - - - public String getCurrentParent() { - return currentParent; - } - - public StackPane getFolderBackButton() - { - StackPane stackPane = new StackPane(); - stackPane.getStyleClass().add("action_box"); - stackPane.getStyleClass().add("action_box_valid"); - - stackPane.setPrefSize( - getClientProfile().getActionSize(), - getClientProfile().getActionSize() - ); - - FontIcon fontIcon = new FontIcon("fas-chevron-left"); - fontIcon.getStyleClass().add("folder_action_back_button_icon"); - fontIcon.setIconSize(getClientProfile().getActionSize() - 30); - - stackPane.setAlignment(Pos.CENTER); - stackPane.getChildren().add(fontIcon); - - stackPane.setOnMouseClicked(e->returnToPreviousParent()); - - return stackPane; - } - - private boolean isFreshRender = true; - private Node folderBackButton = null; - public void renderGrid() - { - actionsGridPane.setHgap(getClientProfile().getActionGap()); - actionsGridPane.setVgap(getClientProfile().getActionGap()); - - if(isFreshRender) - { - clear(); - actionBoxes = new ActionBox[cols][rows]; - } - - boolean isFolder = false; - - if(getCurrentParent().equals("root")) - { - if(folderBackButton != null) - { - actionsGridPane.getChildren().remove(folderBackButton); - folderBackButton = null; - - actionBoxes[0][0] = addBlankActionBox(0,0); - } - } - else - { - isFolder = true; - - if(folderBackButton != null) - { - actionsGridPane.getChildren().remove(folderBackButton); - folderBackButton = null; - } - else - { - actionsGridPane.getChildren().remove(actionBoxes[0][0]); - } - - folderBackButton = getFolderBackButton(); - actionsGridPane.add(folderBackButton, 0,0); - } - - for(int row = 0; row= rows || action.getLocation().getCol() >= cols) - { - throw new MinorException("Action "+action.getDisplayText()+" ("+action.getID()+") falls outside bounds.\n" + - " Consider increasing rows/cols from client settings and relocating/deleting it."); - } - - - Location location = action.getLocation(); - - if( getClientProfile().getCols() < location.getCol() || getClientProfile().getRows() < location.getRow()) - return; - - ActionBox actionBox = actionBoxes[location.getCol()][location.getRow()]; - - if(actionBox.getAction()!=null) - { - if(!actionBox.getAction().getID().equals(action.getID())) - { - actionBox.clear(); - } - } - else - { - actionBox.clear(); - } - - - boolean oldToggleStatus = action.getCurrentToggleStatus(); - - - actionBox.setAction(action); - - - actionBox.setCurrentToggleStatus(oldToggleStatus); - - - actionBox.setStreamPiParent(currentParent); - actionBox.init(); - - /*ActionBox actionBox = new ActionBox(getClientProfile().getActionSize(), action, exceptionAndAlertHandler, this, location.getRow(), location.getCol()); - - actionBox.setStreamPiParent(currentParent); - - clearActionBox(location.getCol(), location.getRow()); - - System.out.println(location.getCol()+","+location.getRow()); - add(actionBox, location.getRow(), location.getCol()); - - actionBoxes[location.getCol()][location.getRow()] = actionBox;*/ - } - - public void setRows(int rows) - { - this.rows = rows; - } - - public void setCols(int cols) - { - this.cols = cols; - } - - public int getRows() - { - return rows; - } - - public int getCols() - { - return cols; - } - - private String previousParent; - - public void setPreviousParent(String previousParent) { - this.previousParent = previousParent; - } - - public String getPreviousParent() { - return previousParent; - } - - @Override - public void renderFolder(String actionID) { - setCurrentParent(clientProfile.getActionFromID(actionID).getID()); - setPreviousParent(clientProfile.getActionFromID(actionID).getParent()); - renderGrid(); - renderActions(); - } - - @Override - public void normalOrCombineActionClicked(String ID) - { - clientListener.onActionClicked(getClientProfile().getID(), ID, false); - } - - @Override - public void toggleActionClicked(String ID, boolean toggleState) - { - clientListener.onActionClicked(getClientProfile().getID(), ID, toggleState); - } - - @Override - public ActionBox getActionBoxByLocation(Location location) - { - return getActionBox(location.getCol(), location.getRow()); - } - - - @Override - public boolean isConnected() - { - return clientListener.isConnected(); - } - - - public void returnToPreviousParent() - { - setCurrentParent(getPreviousParent()); - - if(!getPreviousParent().equals("root")) - { - System.out.println("parent : "+getPreviousParent()); - setPreviousParent(getClientProfile().getActionFromID( - getPreviousParent() - ).getParent()); - } - - renderGrid(); - renderActions(); - } -} +package com.stream_pi.client.window.dashboard.actiongridpane; + +import java.util.logging.Logger; + +import com.stream_pi.action_api.action.Action; +import com.stream_pi.action_api.action.ActionType; +import com.stream_pi.action_api.action.Location; +import com.stream_pi.client.controller.ClientListener; +import com.stream_pi.client.info.ClientInfo; +import com.stream_pi.client.info.StartupFlags; +import com.stream_pi.client.io.Config; +import com.stream_pi.client.profile.ClientProfile; +import com.stream_pi.client.window.ExceptionAndAlertHandler; +import com.stream_pi.util.exception.MinorException; +import com.stream_pi.util.exception.SevereException; +import javafx.concurrent.Task; +import javafx.geometry.Insets; +import javafx.geometry.Orientation; +import javafx.geometry.Pos; +import javafx.scene.CacheHint; +import javafx.scene.Node; +import javafx.scene.control.ScrollPane; +import javafx.scene.layout.GridPane; +import javafx.scene.layout.Priority; +import javafx.scene.layout.StackPane; +import javafx.scene.layout.VBox; +import org.kordamp.ikonli.javafx.FontIcon; + +public class ActionGridPane extends ScrollPane implements ActionGridPaneListener +{ + + private ExceptionAndAlertHandler exceptionAndAlertHandler; + + private ClientListener clientListener; + + private ActionBox[][] actionBoxes; + + private GridPane actionsGridPane; + + public ActionGridPane(ExceptionAndAlertHandler exceptionAndAlertHandler, ClientListener clientListener) + { + this.clientListener = clientListener; + + logger = Logger.getLogger(ActionGridPane.class.getName()); + this.exceptionAndAlertHandler = exceptionAndAlertHandler; + + getStyleClass().add("action_grid_pane_parent"); + + actionsGridPane = new GridPane(); + actionsGridPane.setPadding(new Insets(5.0)); + actionsGridPane.getStyleClass().add("action_grid_pane"); + actionsGridPane.prefWidthProperty().bind(widthProperty().subtract(20)); + actionsGridPane.prefHeightProperty().bind(heightProperty().subtract(20)); + + setContent(actionsGridPane); + + actionsGridPane.setAlignment(Pos.CENTER); + + + VBox.setVgrow(this, Priority.ALWAYS); + + setCache(true); + setCacheHint(CacheHint.SPEED); + } + + private String currentParent; + + public void setCurrentParent(String currentParent) { + this.currentParent = currentParent; + } + + public ClientProfile getClientProfile() { + return clientProfile; + } + + private int rows, cols; + + private ClientProfile clientProfile; + + public void setClientProfile(ClientProfile clientProfile) + { + this.clientProfile = clientProfile; + + setCurrentParent("root"); + setRows(clientProfile.getRows()); + setCols(clientProfile.getCols()); + } + + public void actionFailed(String profileID, String actionID) + { + if(getClientProfile().getID().equals(profileID)) + { + Action action = getClientProfile().getActionFromID(actionID); + if(action != null) + { + if(currentParent.equals(action.getParent())) + { + failShow(action); + } + else + { + if(action.getLocation().getCol() == -1) + { + failShow(getClientProfile().getActionFromID(action.getParent())); + } + } + } + } + } + + public void failShow(Action action) + { + actionBoxes[action.getLocation().getCol()][action.getLocation().getRow()].animateStatus(); + } + + + public String getCurrentParent() { + return currentParent; + } + + public StackPane getFolderBackButton() + { + StackPane stackPane = new StackPane(); + stackPane.getStyleClass().add("action_box"); + stackPane.getStyleClass().add("action_box_valid"); + + stackPane.setPrefSize( + getClientProfile().getActionSize(), + getClientProfile().getActionSize() + ); + + FontIcon fontIcon = new FontIcon("fas-chevron-left"); + fontIcon.getStyleClass().add("folder_action_back_button_icon"); + fontIcon.setIconSize(getClientProfile().getActionSize() - 30); + + stackPane.setAlignment(Pos.CENTER); + stackPane.getChildren().add(fontIcon); + + stackPane.setOnMouseClicked(e->returnToPreviousParent()); + + return stackPane; + } + + private boolean isFreshRender = true; + private Node folderBackButton = null; + public void renderGrid() + { + actionsGridPane.setHgap(getClientProfile().getActionGap()); + actionsGridPane.setVgap(getClientProfile().getActionGap()); + + if(isFreshRender) + { + clear(); + actionBoxes = new ActionBox[cols][rows]; + } + + boolean isFolder = false; + + if(getCurrentParent().equals("root")) + { + if(folderBackButton != null) + { + actionsGridPane.getChildren().remove(folderBackButton); + folderBackButton = null; + + actionBoxes[0][0] = addBlankActionBox(0,0); + } + } + else + { + isFolder = true; + + if(folderBackButton != null) + { + actionsGridPane.getChildren().remove(folderBackButton); + folderBackButton = null; + } + else + { + actionsGridPane.getChildren().remove(actionBoxes[0][0]); + } + + folderBackButton = getFolderBackButton(); + actionsGridPane.add(folderBackButton, 0,0); + } + + for(int row = 0; row= rows || action.getLocation().getCol() >= cols) + { + throw new MinorException("Action "+action.getDisplayText()+" ("+action.getID()+") falls outside bounds.\n" + + " Consider increasing rows/cols from client settings and relocating/deleting it."); + } + + + Location location = action.getLocation(); + + if( getClientProfile().getCols() < location.getCol() || getClientProfile().getRows() < location.getRow()) + return; + + ActionBox actionBox = actionBoxes[location.getCol()][location.getRow()]; + + if(actionBox.getAction()!=null) + { + if(!actionBox.getAction().getID().equals(action.getID())) + { + actionBox.clear(); + } + } + else + { + actionBox.clear(); + } + + + boolean oldToggleStatus = action.getCurrentToggleStatus(); + + + actionBox.setAction(action); + + + actionBox.setCurrentToggleStatus(oldToggleStatus); + + + actionBox.setStreamPiParent(currentParent); + actionBox.init(); + + /*ActionBox actionBox = new ActionBox(getClientProfile().getActionSize(), action, exceptionAndAlertHandler, this, location.getRow(), location.getCol()); + + actionBox.setStreamPiParent(currentParent); + + clearActionBox(location.getCol(), location.getRow()); + + System.out.println(location.getCol()+","+location.getRow()); + add(actionBox, location.getRow(), location.getCol()); + + actionBoxes[location.getCol()][location.getRow()] = actionBox;*/ + } + + public void setRows(int rows) + { + this.rows = rows; + } + + public void setCols(int cols) + { + this.cols = cols; + } + + public int getRows() + { + return rows; + } + + public int getCols() + { + return cols; + } + + private String previousParent; + + public void setPreviousParent(String previousParent) { + this.previousParent = previousParent; + } + + public String getPreviousParent() { + return previousParent; + } + + @Override + public void renderFolder(String actionID) { + setCurrentParent(clientProfile.getActionFromID(actionID).getID()); + setPreviousParent(clientProfile.getActionFromID(actionID).getParent()); + renderGrid(); + renderActions(); + } + + @Override + public void normalOrCombineActionClicked(String ID) + { + clientListener.onActionClicked(getClientProfile().getID(), ID, false); + } + + @Override + public void toggleActionClicked(String ID, boolean toggleState) + { + clientListener.onActionClicked(getClientProfile().getID(), ID, toggleState); + } + + @Override + public ActionBox getActionBoxByLocation(Location location) + { + return getActionBox(location.getCol(), location.getRow()); + } + + + @Override + public boolean isConnected() + { + return clientListener.isConnected(); + } + + + public void returnToPreviousParent() + { + setCurrentParent(getPreviousParent()); + + if(!getPreviousParent().equals("root")) + { + System.out.println("parent : "+getPreviousParent()); + setPreviousParent(getClientProfile().getActionFromID( + getPreviousParent() + ).getParent()); + } + + renderGrid(); + renderActions(); + } +} diff --git a/src/main/java/com/stream_pi/client/window/dashboard/actiongridpane/ActionGridPaneListener.java b/src/main/java/com/stream_pi/client/window/dashboard/actiongridpane/ActionGridPaneListener.java old mode 100644 new mode 100755 index a8290f4c..4023a4c1 --- a/src/main/java/com/stream_pi/client/window/dashboard/actiongridpane/ActionGridPaneListener.java +++ b/src/main/java/com/stream_pi/client/window/dashboard/actiongridpane/ActionGridPaneListener.java @@ -1,17 +1,17 @@ -package com.stream_pi.client.window.dashboard.actiongridpane; - -import com.stream_pi.action_api.action.Action; -import com.stream_pi.action_api.action.Location; -import com.stream_pi.action_api.otheractions.FolderAction; - -public interface ActionGridPaneListener -{ - void renderFolder(String ID); - - void normalOrCombineActionClicked(String ID); - void toggleActionClicked(String ID, boolean toggleState); - - ActionBox getActionBoxByLocation(Location location); - - boolean isConnected(); -} +package com.stream_pi.client.window.dashboard.actiongridpane; + +import com.stream_pi.action_api.action.Action; +import com.stream_pi.action_api.action.Location; +import com.stream_pi.action_api.otheractions.FolderAction; + +public interface ActionGridPaneListener +{ + void renderFolder(String ID); + + void normalOrCombineActionClicked(String ID); + void toggleActionClicked(String ID, boolean toggleState); + + ActionBox getActionBoxByLocation(Location location); + + boolean isConnected(); +} diff --git a/src/main/java/com/stream_pi/client/window/firsttimeuse/FinalConfigPane.java b/src/main/java/com/stream_pi/client/window/firsttimeuse/FinalConfigPane.java old mode 100644 new mode 100755 diff --git a/src/main/java/com/stream_pi/client/window/firsttimeuse/FirstTimeUse.java b/src/main/java/com/stream_pi/client/window/firsttimeuse/FirstTimeUse.java old mode 100644 new mode 100755 diff --git a/src/main/java/com/stream_pi/client/window/firsttimeuse/LicensePane.java b/src/main/java/com/stream_pi/client/window/firsttimeuse/LicensePane.java old mode 100644 new mode 100755 diff --git a/src/main/java/com/stream_pi/client/window/firsttimeuse/WelcomePane.java b/src/main/java/com/stream_pi/client/window/firsttimeuse/WelcomePane.java old mode 100644 new mode 100755 diff --git a/src/main/java/com/stream_pi/client/window/firsttimeuse/WindowName.java b/src/main/java/com/stream_pi/client/window/firsttimeuse/WindowName.java old mode 100644 new mode 100755 diff --git a/src/main/java/com/stream_pi/client/window/settings/About/AboutTab.java b/src/main/java/com/stream_pi/client/window/settings/About/AboutTab.java old mode 100644 new mode 100755 diff --git a/src/main/java/com/stream_pi/client/window/settings/About/ContactTab.java b/src/main/java/com/stream_pi/client/window/settings/About/ContactTab.java old mode 100644 new mode 100755 diff --git a/src/main/java/com/stream_pi/client/window/settings/About/Contributor.java b/src/main/java/com/stream_pi/client/window/settings/About/Contributor.java old mode 100644 new mode 100755 diff --git a/src/main/java/com/stream_pi/client/window/settings/About/ContributorsTab.java b/src/main/java/com/stream_pi/client/window/settings/About/ContributorsTab.java old mode 100644 new mode 100755 diff --git a/src/main/java/com/stream_pi/client/window/settings/About/LicenseTab.java b/src/main/java/com/stream_pi/client/window/settings/About/LicenseTab.java old mode 100644 new mode 100755 diff --git a/src/main/java/com/stream_pi/client/window/settings/GeneralTab.java b/src/main/java/com/stream_pi/client/window/settings/GeneralTab.java old mode 100644 new mode 100755 index 5100fd89..a06ee685 --- a/src/main/java/com/stream_pi/client/window/settings/GeneralTab.java +++ b/src/main/java/com/stream_pi/client/window/settings/GeneralTab.java @@ -37,6 +37,8 @@ import org.controlsfx.control.ToggleSwitch; import java.io.File; +import java.util.List; +import java.util.Arrays; import java.net.URISyntaxException; import java.util.logging.Logger; @@ -53,6 +55,7 @@ public class GeneralTab extends VBox private StreamPiComboBox clientProfileComboBox; private StreamPiComboBox themeComboBox; + private StreamPiComboBox animationComboBox; private TextField nickNameTextField; @@ -134,7 +137,16 @@ public void onNewItemSelected(ClientProfile selectedItem) clientListener.renderProfile(selectedItem, true); } }); - + + animationComboBox = new StreamPiComboBox<>(); + animationComboBox.setStreamPiComboBoxFactory(new StreamPiComboBoxFactory() + { + @Override + public String getOptionDisplayText(String object) + { + return object; + } + }); themeComboBox = new StreamPiComboBox<>(); themeComboBox.setStreamPiComboBoxFactory(new StreamPiComboBoxFactory() @@ -243,6 +255,11 @@ public String getOptionDisplayText(Theme object) SpaceFiller.horizontal(), themeComboBox ), + new HBox( + new Label("Action Animation"), + SpaceFiller.horizontal(), + animationComboBox + ), generateSubHeading("Others"), themesPathInputBox, iconsPathInputBox, @@ -479,8 +496,23 @@ public void loadData() throws SevereException break; } } + + List animationList = Arrays.asList("None", "Bounce", "Bounce In/Out", "Fade In/Out", "Flash", "Flip", "Jack In The Box", "Jello", "Pulse", "Roll In/Out", "Rotate In/Out", "RubberBand", "Shake Left/Right", "Shake Up/Down", "Swing", "Tada", "Wobble", "Zoom In/Out"); + + animationComboBox.setOptions(animationList); + + int ind3 = 0; + for(int i = 0;i 65535) exceptionAndAlertHandler.handleSevereException(e); } } + + if(!config.getCurrentThemeFullName().equals(animationComboBox.getCurrentSelectedItem())) + { + syncWithServer = true; + + config.setCurrentAnimationName(animationComboBox.getCurrentSelectedItem()); + } if(!config.getClientNickName().equals(nickNameTextField.getText())) { diff --git a/src/main/java/com/stream_pi/client/window/settings/SettingsBase.java b/src/main/java/com/stream_pi/client/window/settings/SettingsBase.java old mode 100644 new mode 100755 diff --git a/src/main/java/module-info.java b/src/main/java/module-info.java old mode 100644 new mode 100755 diff --git a/src/main/resources/META-INF/native-image/resource-config.json b/src/main/resources/META-INF/native-image/resource-config.json old mode 100644 new mode 100755 diff --git a/src/main/resources/META-INF/native-image/serialization-config.json b/src/main/resources/META-INF/native-image/serialization-config.json old mode 100644 new mode 100755 diff --git a/src/main/resources/com/stream_pi/client/Default.zip b/src/main/resources/com/stream_pi/client/Default.zip old mode 100644 new mode 100755 index 748677d1..971db6b7 Binary files a/src/main/resources/com/stream_pi/client/Default.zip and b/src/main/resources/com/stream_pi/client/Default.zip differ diff --git a/src/main/resources/com/stream_pi/client/Roboto.ttf b/src/main/resources/com/stream_pi/client/Roboto.ttf old mode 100644 new mode 100755 diff --git a/src/main/resources/com/stream_pi/client/app_icon.png b/src/main/resources/com/stream_pi/client/app_icon.png old mode 100644 new mode 100755 diff --git a/src/main/resources/com/stream_pi/client/default_icons.css b/src/main/resources/com/stream_pi/client/default_icons.css old mode 100644 new mode 100755 diff --git a/src/main/resources/com/stream_pi/client/icon16x16.png b/src/main/resources/com/stream_pi/client/icon16x16.png old mode 100644 new mode 100755 diff --git a/src/main/resources/com/stream_pi/client/icon24x24.png b/src/main/resources/com/stream_pi/client/icon24x24.png old mode 100644 new mode 100755 diff --git a/src/main/resources/com/stream_pi/client/icon256x256.png b/src/main/resources/com/stream_pi/client/icon256x256.png old mode 100644 new mode 100755 diff --git a/src/main/resources/com/stream_pi/client/icon32x32.png b/src/main/resources/com/stream_pi/client/icon32x32.png old mode 100644 new mode 100755 diff --git a/src/main/resources/com/stream_pi/client/icon48x48.png b/src/main/resources/com/stream_pi/client/icon48x48.png old mode 100644 new mode 100755 diff --git a/src/main/resources/com/stream_pi/client/style.css b/src/main/resources/com/stream_pi/client/style.css old mode 100644 new mode 100755 diff --git a/style_classes.txt b/style_classes.txt old mode 100644 new mode 100755