Class Animator

java.lang.Object
de.rcblum.stream.deck.animation.Animator
All Implemented Interfaces:
StreamKeyListener, Runnable

public class Animator extends Object implements StreamKeyListener, Runnable
Controller that handles the animation of a key. BUGFIX: 2019-01-13 RvW: If the animation had only one frame and mode pingpong, run() would reduce the framePos to -1 finally resulting in a NullPointerException in the run method of SoftStreamDeck.WriterDaemon. Fixed by checking bounds of framePos after calculating the new position.

MIT License

Copyright (c) 2018 Roland von Werden

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
Version:
1.0.0
Author:
Roland von Werden
  • Constructor Details

    • Animator

      public Animator(IStreamDeck streamDeck, int keyIndex, AnimationStack animation)
      Creates an animator for the given stream deck key and AnimationStack
      Parameters:
      streamDeck - Stream Deck with the key
      keyIndex - Index of the key
      animation - AnimationStack that contains framrate trigger loop behavior and frames of the animation
  • Method Details

    • getCurrentIcon

      public SDImage getCurrentIcon()
      Returns the current icon of the animation
      Returns:
      Current frame of the animation
    • onKeyEvent

      public void onKeyEvent(KeyEvent event)
      Checks if the key event should start the animation
      Specified by:
      onKeyEvent in interface StreamKeyListener
      Parameters:
      event -
    • start

      public void start()
      Starts the animation
    • stop

      public void stop(boolean immediate)
      Stops the animation.
      Parameters:
      immediate - true if animation should be stopped immediate, false if the animation should end first. Looped and ping pong animations will not stop with false.
    • run

      public void run()
      Displays one frame of the animation
      Specified by:
      run in interface Runnable
    • isActive

      public boolean isActive()
      Returns boolean if the animation is active
      Returns:
      true if animation is running, false if not
    • addAnimationListener

      public boolean addAnimationListener(AnimationListener listener)
      Adds an animation listener
      Parameters:
      listener - Listener to be added
      Returns:
      true if the listener was added, false if not
    • removeAnimationListener

      public boolean removeAnimationListener(AnimationListener listener)
      Remvoes an animation listener
      Parameters:
      listener - Listener to be removes
      Returns:
      true if the listener was removed, false if not