Class AnimationStack

java.lang.Object
de.rcblum.stream.deck.animation.AnimationStack

public class AnimationStack extends Object
Structure that contains all necessary data to display an animation on a key.
See Animator for actually animating on a stream deck key.

With too many animation at once, there is the possibility to break icon displayed.

MIT License

Copyright (c) 2017 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
  • Field Summary

    Fields
    Modifier and Type
    Field
    Description
    static final int
    Animation should be played at the frame rate of 15 frames per second.
    static final int
    Animation should be played at the frame rate of 30 frames per second.
    static final int
    Deprecated. 
    static final int
    Animation should be looped when reaching the last frame
    static final int
    Animation should stop when reaching the last frame.
    static final int
    Animation should be played in reverse when reaching on end of the frames.
    static final int
    The animation should be playeed as soon as the accosiated item is displayed on a key.
    static final int
    The animation should be played when the associated key is released
    static final int
    The animation should be played when the associated key is pressed down
  • Constructor Summary

    Constructors
    Constructor
    Description
    AnimationStack(int repeatType, boolean endAnimationImmediate, int frameRate, int trigger, SDImage[] frames)
    Creates AnimationStack without text.
    AnimationStack(int repeatType, boolean endAnimationImmediate, int frameRate, int trigger, SDImage[] frames, String text, int textPos)
    Creates AnimationStack with text.
  • Method Summary

    Modifier and Type
    Method
    Description
    boolean
    Returns if the animation should be played as soon as the item is displayed on the stream deck
     
    boolean
     
    getFrame(int frameNo)
    Returns the at the position given by the index
    int
    Returns how many frames this animation has.
    int
    Reutrns the frame rate at which the animation should be played
    int
    Returns the repeat type of the animation
    int
    Returns the trigger for the animation
    getVariant(Dimension targetSize)
     
    boolean
    isTriggered(KeyEvent.Type keyEventType)
    Returns if the animation should be triggered.
    boolean
    Returns if the animation should be looped
    boolean
    Returns if the animation should be reversed ass soon as the last frame in any direction is met
    boolean
    Returns if the animation should be displayed once
    void
     
    void
    setEndAnimationImmediate(boolean endAnimationImmediate)
    Sets if the animation should be stopped immediate after the trigger is not applicable anymore.
    void
    setFrames(SDImage[] frames)
    Sets the frames for the animation
    void
    Sets the text to be displayed on the animation
    void
    setText(String text, int textPos)
    Sets the text to be displayed on the animation
    void
    setTextPos(int textPos)
    Sets the text position of the displayed text
    void
    setTrigger(int trigger)
    Change the trigger for the animations

    Methods inherited from class Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Field Details

    • REPEAT_LOOPING

      public static final int REPEAT_LOOPING
      Animation should be looped when reaching the last frame
      See Also:
    • REPEAT_ONCE

      public static final int REPEAT_ONCE
      Animation should stop when reaching the last frame.
      See Also:
    • REPEAT_PING_PONG

      public static final int REPEAT_PING_PONG
      Animation should be played in reverse when reaching on end of the frames.
      See Also:
    • FRAME_RATE_15

      public static final int FRAME_RATE_15
      Animation should be played at the frame rate of 15 frames per second.
      See Also:
    • FRAME_RATE_30

      public static final int FRAME_RATE_30
      Animation should be played at the frame rate of 30 frames per second.
      See Also:
    • FRAME_RATE_60

      @Deprecated public static final int FRAME_RATE_60
      Deprecated.
      Framerates above 30 FPS are note supported anymore. THe ESD breaks when using a to high framerate. Animation should be played at the
      frame rate of 60 frames per second.
      See Also:
    • TRIGGER_AUTO

      public static final int TRIGGER_AUTO
      The animation should be playeed as soon as the accosiated item is displayed on a key.
      See Also:
    • TRIGGER_PRESSED

      public static final int TRIGGER_PRESSED
      The animation should be played when the associated key is pressed down
      See Also:
    • TRIGGER_CLICKED

      public static final int TRIGGER_CLICKED
      The animation should be played when the associated key is released
      See Also:
  • Constructor Details

    • AnimationStack

      public AnimationStack(int repeatType, boolean endAnimationImmediate, int frameRate, int trigger, SDImage[] frames)
      Creates AnimationStack without text.
      Parameters:
      repeatType - If and how the animation should be repeated.
      endAnimationImmediate - Defines if the animation should be stopped immediate after the trigger expires, e.g. aborting the animation before it finishes
      frameRate - Frame rate the animation should be played at
      trigger - Trigger when the animation should be played
      frames - Frames of the animation. In the stream deck compatible format, see IconHelper.convertImage(java.awt.image.BufferedImage)
    • AnimationStack

      public AnimationStack(int repeatType, boolean endAnimationImmediate, int frameRate, int trigger, SDImage[] frames, String text, int textPos)
      Creates AnimationStack with text.
      Parameters:
      repeatType - If and how the animation should be repeated.
      frameRate - Frame rate the animation should be played at (Max 30 fps).
      trigger - Trigger when the animation should be played
      frames - Frames of the animation. In the stream deck compatible format, see IconHelper.convertImage(java.awt.image.BufferedImage)
      text - Text to be displayed while the animation is running
      textPos - Position of the text on the frames (IconHelper.TEXT_TOP, IconHelper.TEXT_CENTER, IconHelper.TEXT_BOTTOM)
  • Method Details

    • autoPlay

      public boolean autoPlay()
      Returns if the animation should be played as soon as the item is displayed on the stream deck
      Returns:
      true if animation should start immediate as the item is displayed on the stream deck
    • endAnimationImmediate

      public boolean endAnimationImmediate()
    • getFrame

      public SDImage getFrame(int frameNo)
      Returns the at the position given by the index
      Parameters:
      frameNo - Frame number to be returned
      Returns:
      Frame for the given frameNo.
    • getFrameCount

      public int getFrameCount()
      Returns how many frames this animation has.
      Returns:
      Amount of frames
    • getFrameRate

      public int getFrameRate()
      Reutrns the frame rate at which the animation should be played
      Returns:
    • getRepeatType

      public int getRepeatType()
      Returns the repeat type of the animation
      Returns:
      int value of the repeat type
    • getTrigger

      public int getTrigger()
      Returns the trigger for the animation
      Returns:
      int value of the trigger for the animation
    • setTrigger

      public void setTrigger(int trigger)
      Change the trigger for the animations
    • isTriggered

      public boolean isTriggered(KeyEvent.Type keyEventType)
      Returns if the animation should be triggered.
      Parameters:
      keyEventType - Key event sent by the stream deck
      Returns:
      true if the animation should be triggered, false if not
    • loop

      public boolean loop()
      Returns if the animation should be looped
      Returns:
      true if the animation should be looped indefinatly, false if not
    • pingPong

      public boolean pingPong()
      Returns if the animation should be reversed ass soon as the last frame in any direction is met
      Returns:
      true if the animation should ping pong between the last and the first frame, false if not
    • playOnce

      public boolean playOnce()
      Returns if the animation should be displayed once
      Returns:
      true if the animation should only be displayed once, false if not
    • setAnimationTrigger

      public void setAnimationTrigger(AnimationTrigger animationTrigger)
    • setEndAnimationImmediate

      public void setEndAnimationImmediate(boolean endAnimationImmediate)
      Sets if the animation should be stopped immediate after the trigger is not applicable anymore.
      Parameters:
      endAnimationImmediate -
    • setFrames

      public void setFrames(SDImage[] frames)
      Sets the frames for the animation
      Parameters:
      frames - frames of the animation
    • setText

      public void setText(String text)
      Sets the text to be displayed on the animation
      Parameters:
      text -
    • setText

      public void setText(String text, int textPos)
      Sets the text to be displayed on the animation
      Parameters:
      text -
    • setTextPos

      public void setTextPos(int textPos)
      Sets the text position of the displayed text
      Parameters:
      textPos -
    • copy

      public AnimationStack copy()
    • getVariant

      public AnimationStack getVariant(Dimension targetSize)