Class SVGAnimationElementBridge

java.lang.Object
org.apache.batik.bridge.AbstractSVGBridge
org.apache.batik.bridge.SVGAnimationElementBridge
All Implemented Interfaces:
AnimatableElement, Bridge, BridgeUpdateHandler, GenericBridge, XMLConstants, SVGAnimationContext, SVGContext, CSSConstants, SVGConstants, org.w3c.dom.smil.ElementTimeControl
Direct Known Subclasses:
SVGAnimateElementBridge, SVGSetElementBridge

public abstract class SVGAnimationElementBridge extends AbstractSVGBridge implements GenericBridge, BridgeUpdateHandler, SVGAnimationContext, AnimatableElement
An abstract base class for the SVG animation element bridges.
Version:
$Id: SVGAnimationElementBridge.java 1831630 2018-05-15 12:56:55Z ssteiner $
  • Field Details

    • element

      protected SVGOMElement element
      The animation element.
    • ctx

      protected BridgeContext ctx
      The BridgeContext to be used.
    • eng

      protected SVGAnimationEngine eng
      The AnimationEngine that manages all of the animations in the document.
    • timedElement

      protected TimedElement timedElement
      The TimedElement object that provides the timing for the animation.
    • animation

      protected AbstractAnimation animation
      The animation object that provides the values for the animation.
    • attributeNamespaceURI

      protected String attributeNamespaceURI
      The namespace URI of the attribute being animated.
    • attributeLocalName

      protected String attributeLocalName
      The local name of the attribute or the name of the property being animated.
    • animationType

      protected short animationType
      The animation type. Must be one of the ANIM_TYPE_* constants defined in AnimationEngine.
    • targetElement

      protected SVGOMElement targetElement
      The target element of the animation.
    • animationTarget

      protected AnimationTarget animationTarget
      The AnimationTarget the provides a context to the animation engine.
  • Constructor Details

    • SVGAnimationElementBridge

      public SVGAnimationElementBridge()
  • Method Details

    • getTimedElement

      public TimedElement getTimedElement()
      Returns the TimedElement for the animation.
    • getUnderlyingValue

      public AnimatableValue getUnderlyingValue()
      Returns the underlying value of the animated attribute. Used for composition of additive animations. This should be overridden in descendant classes that are for 'other' animations.
      Specified by:
      getUnderlyingValue in interface AnimatableElement
    • handleElement

      public void handleElement(BridgeContext ctx, Element e)
      Handles this animation element.
      Specified by:
      handleElement in interface GenericBridge
      Parameters:
      ctx - the bridge context to use
      e - the element being handled
    • initializeAnimation

      protected void initializeAnimation()
      Parses the animation element's target attributes and adds it to the document's AnimationEngine.
    • canAnimateType

      protected abstract boolean canAnimateType(int type)
      Returns whether the animation element being handled by this bridge can animate attributes of the specified type.
      Parameters:
      type - one of the TYPE_ constants defined in SVGTypes.
    • checkValueType

      protected boolean checkValueType(AnimatableValue v)
      Returns whether the specified AnimatableValue is of a type allowed by this animation.
    • initializeTimedElement

      protected void initializeTimedElement()
      Parses the animation element's timing attributes and initializes the TimedElement object.
    • createTimedElement

      protected TimedElement createTimedElement()
      Creates a TimedElement for the animation element.
    • createAnimation

      protected abstract AbstractAnimation createAnimation(AnimationTarget t)
      Creates the animation object for the animation element.
    • parseAnimatableValue

      protected AnimatableValue parseAnimatableValue(String an)
      Parses an attribute as an AnimatableValue.
    • initializeTimedElement

      protected void initializeTimedElement(TimedElement timedElement)
      Initializes the timing attributes of the timed element.
    • handleDOMAttrModifiedEvent

      public void handleDOMAttrModifiedEvent(MutationEvent evt)
      Invoked when an MutationEvent of type 'DOMAttrModified' is fired.
      Specified by:
      handleDOMAttrModifiedEvent in interface BridgeUpdateHandler
    • handleDOMNodeInsertedEvent

      public void handleDOMNodeInsertedEvent(MutationEvent evt)
      Invoked when an MutationEvent of type 'DOMNodeInserted' is fired.
      Specified by:
      handleDOMNodeInsertedEvent in interface BridgeUpdateHandler
    • handleDOMNodeRemovedEvent

      public void handleDOMNodeRemovedEvent(MutationEvent evt)
      Invoked when an MutationEvent of type 'DOMNodeRemoved' is fired.
      Specified by:
      handleDOMNodeRemovedEvent in interface BridgeUpdateHandler
    • handleDOMCharacterDataModified

      public void handleDOMCharacterDataModified(MutationEvent evt)
      Invoked when an MutationEvent of type 'DOMCharacterDataModified' is fired.
      Specified by:
      handleDOMCharacterDataModified in interface BridgeUpdateHandler
    • handleCSSEngineEvent

      public void handleCSSEngineEvent(CSSEngineEvent evt)
      Invoked when an CSSEngineEvent is fired.
      Specified by:
      handleCSSEngineEvent in interface BridgeUpdateHandler
    • handleAnimatedAttributeChanged

      public void handleAnimatedAttributeChanged(AnimatedLiveAttributeValue alav)
      Invoked when the animated value of an animatable attribute has changed.
      Specified by:
      handleAnimatedAttributeChanged in interface BridgeUpdateHandler
    • handleOtherAnimationChanged

      public void handleOtherAnimationChanged(String type)
      Invoked when an 'other' animation value has changed.
      Specified by:
      handleOtherAnimationChanged in interface BridgeUpdateHandler
    • dispose

      public void dispose()
      Disposes this BridgeUpdateHandler and releases all resources.
      Specified by:
      dispose in interface BridgeUpdateHandler
    • getPixelUnitToMillimeter

      public float getPixelUnitToMillimeter()
      Returns the size of a px CSS unit in millimeters.
      Specified by:
      getPixelUnitToMillimeter in interface SVGContext
    • getPixelToMM

      public float getPixelToMM()
      Returns the size of a px CSS unit in millimeters. This will be removed after next release.
      Specified by:
      getPixelToMM in interface SVGContext
      See Also:
    • getBBox

      public Rectangle2D getBBox()
      Description copied from interface: SVGContext
      Returns the tight bounding box in current user space (i.e., after application of the transform attribute, if any) on the geometry of all contained graphics elements, exclusive of stroke-width and filter effects).
      Specified by:
      getBBox in interface SVGContext
    • getScreenTransform

      public AffineTransform getScreenTransform()
      Description copied from interface: SVGContext
      Returns the transform from the global transform space to pixels.
      Specified by:
      getScreenTransform in interface SVGContext
    • setScreenTransform

      public void setScreenTransform(AffineTransform at)
      Description copied from interface: SVGContext
      Sets the transform to be used from the global transform space to pixels.
      Specified by:
      setScreenTransform in interface SVGContext
    • getCTM

      public AffineTransform getCTM()
      Description copied from interface: SVGContext
      Returns the transformation matrix from current user units (i.e., after application of the transform attribute, if any) to the viewport coordinate system for the nearestViewportElement.
      Specified by:
      getCTM in interface SVGContext
    • getGlobalTransform

      public AffineTransform getGlobalTransform()
      Description copied from interface: SVGContext
      Returns the global transformation matrix from the current element to the root.
      Specified by:
      getGlobalTransform in interface SVGContext
    • getViewportWidth

      public float getViewportWidth()
      Description copied from interface: SVGContext
      Returns the width of the viewport which directly contains the associated element.
      Specified by:
      getViewportWidth in interface SVGContext
    • getViewportHeight

      public float getViewportHeight()
      Description copied from interface: SVGContext
      Returns the height of the viewport which directly contains the associated element.
      Specified by:
      getViewportHeight in interface SVGContext
    • getFontSize

      public float getFontSize()
      Description copied from interface: SVGContext
      Returns the font-size on the associated element.
      Specified by:
      getFontSize in interface SVGContext
    • svgToUserSpace

      public float svgToUserSpace(float v, int type, int pcInterp)
    • addTargetListener

      public void addTargetListener(String pn, AnimationTargetListener l)
      Adds a listener for changes to the given attribute value.
    • removeTargetListener

      public void removeTargetListener(String pn, AnimationTargetListener l)
      Removes a listener for changes to the given attribute value.
    • getTargetElement

      public org.w3c.dom.svg.SVGElement getTargetElement()
      DOM: Implements SVGAnimationElement.getTargetElement().
      Specified by:
      getTargetElement in interface SVGAnimationContext
    • getStartTime

      public float getStartTime()
      DOM: Implements SVGAnimationElement.getStartTime().
      Specified by:
      getStartTime in interface SVGAnimationContext
    • getCurrentTime

      public float getCurrentTime()
      DOM: Implements SVGAnimationElement.getCurrentTime().
      Specified by:
      getCurrentTime in interface SVGAnimationContext
    • getSimpleDuration

      public float getSimpleDuration()
      DOM: Implements SVGAnimationElement.getSimpleDuration(). With the difference that an indefinite simple duration is returned as TimedElement.INDEFINITE, rather than throwing an exception.
      Specified by:
      getSimpleDuration in interface SVGAnimationContext
    • getHyperlinkBeginTime

      public float getHyperlinkBeginTime()
      Returns the time that the document would seek to if this animation element were hyperlinked to, or NaN if there is no such begin time.
      Specified by:
      getHyperlinkBeginTime in interface SVGAnimationContext
    • beginElement

      public boolean beginElement() throws DOMException
      DOM: Implements ElementTimeControl.beginElement().
      Specified by:
      beginElement in interface org.w3c.dom.smil.ElementTimeControl
      Throws:
      DOMException
    • beginElementAt

      public boolean beginElementAt(float offset) throws DOMException
      DOM: Implements ElementTimeControl.beginElementAt(float).
      Specified by:
      beginElementAt in interface org.w3c.dom.smil.ElementTimeControl
      Throws:
      DOMException
    • endElement

      public boolean endElement() throws DOMException
      DOM: Implements ElementTimeControl.endElement().
      Specified by:
      endElement in interface org.w3c.dom.smil.ElementTimeControl
      Throws:
      DOMException
    • endElementAt

      public boolean endElementAt(float offset) throws DOMException
      DOM: Implements ElementTimeControl.endElementAt(float).
      Specified by:
      endElementAt in interface org.w3c.dom.smil.ElementTimeControl
      Throws:
      DOMException
    • isConstantAnimation

      protected boolean isConstantAnimation()
      Returns whether this is a constant animation (i.e., a 'set' animation).