Class AnimationEngine

  • Direct Known Subclasses:
    SVGAnimationEngine

    public abstract class AnimationEngine
    extends java.lang.Object
    An abstract base class for managing animation in a document.
    Version:
    $Id: AnimationEngine.java 1804130 2017-08-04 14:41:11Z ssteiner $
    • Field Detail

      • document

        protected org.w3c.dom.Document document
        The document this AnimationEngine is managing animation for.
      • timedDocumentRoot

        protected TimedDocumentRoot timedDocumentRoot
        The root time container for the document.
      • pauseTime

        protected long pauseTime
        The time at which the document was paused, or 0 if the document is not paused.
      • targets

        protected java.util.HashMap targets
        Map of AnimationTargets to TargetInfo objects.
      • animations

        protected java.util.HashMap animations
        Map of AbstractAnimations to AnimationInfo objects.
      • targetListener

        protected AnimationEngine.Listener targetListener
        The listener object for animation target base value changes.
      • MAP_ENTRY_ARRAY

        protected static final java.util.Map.Entry[] MAP_ENTRY_ARRAY
    • Constructor Detail

      • AnimationEngine

        public AnimationEngine​(org.w3c.dom.Document doc)
        Creates a new AnimationEngine for the given document.
    • Method Detail

      • dispose

        public void dispose()
        Disposes this animation engine.
      • pause

        public void pause()
        Pauses the animations.
      • unpause

        public void unpause()
        Unpauses the animations.
      • isPaused

        public boolean isPaused()
        Returns whether animations are currently paused.
      • getCurrentTime

        public float getCurrentTime()
        Returns the current document time.
      • setCurrentTime

        public float setCurrentTime​(float t)
        Sets the current document time.
      • addAnimation

        public void addAnimation​(AnimationTarget target,
                                 short type,
                                 java.lang.String ns,
                                 java.lang.String an,
                                 AbstractAnimation anim)
        Adds an animation to the document.
        Parameters:
        target - the target element of the animation
        type - the type of animation (must be one of the ANIM_TYPE_* constants defined in this class
        ns - the namespace URI of the attribute being animated, if type == ANIM_TYPE_XML
        an - the attribute name if type == ANIM_TYPE_XML, the property name if type == ANIM_TYPE_CSS, and the animation type otherwise
        anim - the animation
      • removeAnimation

        public void removeAnimation​(AbstractAnimation anim)
        Removes an animation from the document.
      • getSandwich

        protected AnimationEngine.Sandwich getSandwich​(AnimationTarget target,
                                                       short type,
                                                       java.lang.String ns,
                                                       java.lang.String an)
        Returns the Sandwich for the given animation type/attribute.
      • tick

        protected float tick​(float time,
                             boolean hyperlinking)
        Updates the animations in the document to the given document time.
        Parameters:
        time - the document time to sample at
        hyperlinking - whether the document should be seeked to the given time, as with hyperlinking
      • toActive

        public void toActive​(AbstractAnimation anim,
                             float begin)
        Invoked to indicate an animation became active at the specified time.
        Parameters:
        anim - the animation
        begin - the time the element became active, in document simple time
      • pushDown

        protected void pushDown​(AbstractAnimation anim)
        Moves the animation down the sandwich such that it is in the right position according to begin time and document order.
      • toInactive

        public void toInactive​(AbstractAnimation anim,
                               boolean isFrozen)
        Invoked to indicate that this timed element became inactive.
        Parameters:
        anim - the animation
        isFrozen - whether the element is frozen or not
      • removeFill

        public void removeFill​(AbstractAnimation anim)
        Invoked to indicate that this timed element has had its fill removed.
      • moveToTop

        protected void moveToTop​(AbstractAnimation anim)
        Moves the given animation to the top of the sandwich.
      • moveToBottom

        protected void moveToBottom​(AbstractAnimation anim)
        Moves the given animation to the bottom of the sandwich.
      • sampledAt

        public void sampledAt​(AbstractAnimation anim,
                              float simpleTime,
                              float simpleDur,
                              int repeatIteration)
        Invoked to indicate that this timed element has been sampled at the given time.
        Parameters:
        anim - the animation
        simpleTime - the sample time in local simple time
        simpleDur - the simple duration of the element
        repeatIteration - the repeat iteration during which the element was sampled
      • sampledLastValue

        public void sampledLastValue​(AbstractAnimation anim,
                                     int repeatIteration)
        Invoked to indicate that this timed element has been sampled at the end of its active time, at an integer multiple of the simple duration. This is the "last" value that will be used for filling, which cannot be sampled normally.
      • createDocumentRoot

        protected abstract TimedDocumentRoot createDocumentRoot()
        Creates a new returns a new TimedDocumentRoot object for the document.