Class Transition

    • Constructor Summary

      Constructors 
      Constructor Description
      Transition​(int durationValue, int rateValue)
      Creates a new non-repeating transition with the given duration, and rate.
      Transition​(int durationValue, int rateValue, boolean repeat)
      Creates a new transition with the given duration, rate, and repeat.
      Transition​(int durationValue, int rateValue, boolean repeat, boolean reverse)
      Creates a new transition with the given duration, rate, and repeat.
    • Method Summary

      All Methods Instance Methods Abstract Methods Concrete Methods 
      Modifier and Type Method Description
      void end()
      "Fast-forward" to the end of the transition, run update() the last time, and fire a TransitionListener.transitionCompleted(Transition) event.
      long getCurrentTime()
      Returns the last time the transition was updated.
      int getDuration()
      Returns the transition duration.
      int getElapsedTime()
      Returns the elapsed time since the transition started.
      int getInterval()
      Returns the transition interval, the number of milliseconds between updates.
      float getPercentComplete()
      Returns the percentage of the transition that has completed.
      int getRate()
      Returns the transition rate.
      long getStartTime()
      Returns the time at which the transition was started.
      boolean isRepeating()
      Is the transition a repeating one?
      boolean isReversed()
      Tests whether the transition is reversed.
      boolean isRunning()
      Tells whether or not the transition is currently running.
      void reverse()
      Reverses the transition.
      void setDuration​(int durationValue)
      Sets the transition duration, the length of time the transition is scheduled to run.
      void setRate​(int rateValue)
      Sets the transition rate, the number of times the transition will be updated within the span of one second.
      void setReversed​(boolean reverse)
      Sets the transition's reversed flag.
      void start()
      Starts the transition.
      void start​(TransitionListener listener)
      Starts the transition.
      void stop()
      Stops the transition running with no final update, and does not fire a TransitionListener.transitionCompleted(Transition) event.
      protected boolean themeHasTransitionEnabled()
      Tell if the theme has transitions enabled.
      Usually this means that (if false) any effect/transition will not be drawn.
      protected abstract void update()
      Called repeatedly while the transition is running to update the transition's state.
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Constructor Detail

      • Transition

        public Transition​(int durationValue,
                          int rateValue)
        Creates a new non-repeating transition with the given duration, and rate.
        Parameters:
        durationValue - Transition duration, in milliseconds.
        rateValue - Transition rate, in frames per second.
      • Transition

        public Transition​(int durationValue,
                          int rateValue,
                          boolean repeat)
        Creates a new transition with the given duration, rate, and repeat.
        Parameters:
        durationValue - Transition duration, in milliseconds.
        rateValue - Transition rate, in frames per second.
        repeat - true if the transition should repeat; false, otherwise.
      • Transition

        public Transition​(int durationValue,
                          int rateValue,
                          boolean repeat,
                          boolean reverse)
        Creates a new transition with the given duration, rate, and repeat. Note that if the current Theme has transitions not enabled, the duration and rate will both be set to zero, so that the final update is called once, in a minimum amount of time after the start.
        Parameters:
        durationValue - Transition duration, in milliseconds.
        rateValue - Transition rate, in frames per second.
        repeat - true if the transition should repeat; false, otherwise.
        reverse - true if the transition should run in reverse; false otherwise.
    • Method Detail

      • getDuration

        public int getDuration()
        Returns the transition duration.
        Returns:
        The duration of the transition, in milliseconds.
        See Also:
        setDuration(int)
      • setDuration

        public void setDuration​(int durationValue)
        Sets the transition duration, the length of time the transition is scheduled to run.
        Parameters:
        durationValue - The duration of the transition, in milliseconds.
      • getRate

        public int getRate()
        Returns the transition rate.
        Returns:
        The rate of the transition, in frames per second.
        See Also:
        setRate(int)
      • setRate

        public void setRate​(int rateValue)
        Sets the transition rate, the number of times the transition will be updated within the span of one second.
        Parameters:
        rateValue - The transition rate, in frames per second.
      • getInterval

        public int getInterval()
        Returns the transition interval, the number of milliseconds between updates.
        Returns:
        The transition interval in milliseconds, or a default minimum value if transitions have been disabled.
      • getStartTime

        public long getStartTime()
        Returns the time at which the transition was started.
        Returns:
        The transition's start time.
      • getCurrentTime

        public long getCurrentTime()
        Returns the last time the transition was updated.
        Returns:
        The most recent update time.
      • getElapsedTime

        public int getElapsedTime()
        Returns the elapsed time since the transition started.
        Returns:
        The amount of time that has passed since the transition was started. If the transition is reversed, this value reflects the amount of time remaining.
      • getPercentComplete

        public float getPercentComplete()
        Returns the percentage of the transition that has completed.
        Returns:
        A value between 0 and 1, inclusive, representing the transition's percent complete. If the transition is reversed, this value reflects the percent remaining.
      • isRunning

        public final boolean isRunning()
        Tells whether or not the transition is currently running.
        Returns:
        true if the transition is currently running; false if it is not
      • start

        public final void start()
        Starts the transition. Calls update() to establish the initial state and starts a time that will repeatedly call update() at the current rate. No TransitionListener will be notified.
        See Also:
        start(TransitionListener)
      • start

        public void start​(TransitionListener listener)
        Starts the transition. Calls update() to establish the initial state and starts a timer that will repeatedly call update() at the current rate. The specified TransitionListener will be notified when the transition completes.
        Parameters:
        listener - The listener to get notified when the transition completes, or null if no notification is necessary.
      • update

        protected abstract void update()
        Called repeatedly while the transition is running to update the transition's state.
      • isRepeating

        public boolean isRepeating()
        Is the transition a repeating one?
        Returns:
        true if the transition should repeat; false if not.
      • isReversed

        public boolean isReversed()
        Tests whether the transition is reversed.
        Returns:
        true if the transition is reversed; false otherwise.
      • setReversed

        public void setReversed​(boolean reverse)
        Sets the transition's reversed flag.
        Parameters:
        reverse - Whether the transition should be reversed.
      • reverse

        public void reverse()
        Reverses the transition. If the transition is running, updates the start time so the reverse duration is the same as the current elapsed time.
      • themeHasTransitionEnabled

        protected boolean themeHasTransitionEnabled()
        Tell if the theme has transitions enabled.
        Usually this means that (if false) any effect/transition will not be drawn.
        Returns:
        true if enabled (default), false otherwise.
        See Also:
        Theme.isTransitionEnabled()