Class AbstractGraphicsNodeBridge

All Implemented Interfaces:
SVGAnimationTargetContext, Bridge, BridgeUpdateHandler, ErrorConstants, GraphicsNodeBridge, XMLConstants, SVGContext, CSSConstants, SVGConstants
Direct Known Subclasses:
BindableElementBridge, SVGGElementBridge, SVGImageElementBridge, SVGShapeElementBridge, SVGTextElementBridge, SVGUseElementBridge, XBLContentElementBridge, XBLShadowTreeElementBridge

public abstract class AbstractGraphicsNodeBridge extends AnimatableSVGBridge implements SVGContext, BridgeUpdateHandler, GraphicsNodeBridge, ErrorConstants
The base bridge class for SVG graphics node. By default, the namespace URI is the SVG namespace. Override the getNamespaceURI if you want to add custom GraphicsNode with a custom namespace.

This class handles various attributes that are defined on most of the SVG graphic elements as described in the SVG specification.

  • clip-path
  • filter
  • mask
  • opacity
  • transform
  • visibility
Version:
$Id: AbstractGraphicsNodeBridge.java 1804130 2017-08-04 14:41:11Z ssteiner $
  • Field Details

    • node

      protected GraphicsNode node
      The graphics node constructed by this bridge.
    • isSVG12

      protected boolean isSVG12
      Whether the document is an SVG 1.2 document.
    • unitContext

      protected UnitProcessor.Context unitContext
      The unit context for length conversions.
    • bboxShape

      protected SoftReference bboxShape
    • bbox

      protected Rectangle2D bbox
  • Constructor Details

    • AbstractGraphicsNodeBridge

      protected AbstractGraphicsNodeBridge()
      Constructs a new abstract bridge.
  • Method Details

    • createGraphicsNode

      public GraphicsNode createGraphicsNode(BridgeContext ctx, Element e)
      Creates a GraphicsNode according to the specified parameters.
      Specified by:
      createGraphicsNode in interface GraphicsNodeBridge
      Parameters:
      ctx - the bridge context to use
      e - the element that describes the graphics node to build
      Returns:
      a graphics node that represents the specified element
    • instantiateGraphicsNode

      protected abstract GraphicsNode instantiateGraphicsNode()
      Creates the GraphicsNode depending on the GraphicsNodeBridge implementation.
    • buildGraphicsNode

      public void buildGraphicsNode(BridgeContext ctx, Element e, GraphicsNode node)
      Builds using the specified BridgeContext and element, the specified graphics node.
      Specified by:
      buildGraphicsNode in interface GraphicsNodeBridge
      Parameters:
      ctx - the bridge context to use
      e - the element that describes the graphics node to build
      node - the graphics node to build
    • getDisplay

      public boolean getDisplay(Element e)
      Returns true if the graphics node has to be displayed, false otherwise.
      Specified by:
      getDisplay in interface GraphicsNodeBridge
    • computeTransform

      protected AffineTransform computeTransform(org.w3c.dom.svg.SVGTransformable te, BridgeContext ctx)
      Returns an AffineTransform that is the transformation to be applied to the node.
    • setTransform

      protected void setTransform(GraphicsNode n, Element e, BridgeContext ctx)
      Sets the graphics node's transform to the current animated transform value.
    • associateSVGContext

      protected void associateSVGContext(BridgeContext ctx, Element e, GraphicsNode node)
      Associates the SVGContext with the element. This method should be called even for static documents, since some bridges will need to access animated attribute values even during the first build.
    • initializeDynamicSupport

      protected void initializeDynamicSupport(BridgeContext ctx, Element e, GraphicsNode node)
      This method is invoked during the build phase if the document is dynamic. The responsibility of this method is to ensure that any dynamic modifications of the element this bridge is dedicated to, happen on its associated GVT product.
    • handleDOMAttrModifiedEvent

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

      protected void handleGeometryChanged()
      Invoked when the geometry of a graphical element has changed.
    • fireShapeChangeEvent

      protected void fireShapeChangeEvent()
      Fires a ShapeChange event on the element this bridge is managing.
    • 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
    • dispose

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

      protected static void disposeTree(Node node)
      Disposes all resources related to the specified node and its subtree.
    • disposeTree

      protected static void disposeTree(Node node, boolean removeContext)
      Disposes all resources related to the specified node and its subtree, and optionally removes the nodes' SVGContext.
    • handleCSSEngineEvent

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

      protected void handleCSSPropertyChanged(int property)
      Invoked for each CSS property that has changed.
    • 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
    • checkBBoxChange

      protected void checkBBoxChange()
      Checks if the bounding box of the node has changed, and if so, fires a bboxchange event on the element.
    • fireBBoxChangeEvent

      protected void fireBBoxChangeEvent()
      Fires an svg:bboxchange event on the element.
    • 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()
      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
    • getCTM

      public AffineTransform getCTM()
      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
    • getScreenTransform

      public AffineTransform getScreenTransform()
      Returns the display transform.
      Specified by:
      getScreenTransform in interface SVGContext
    • setScreenTransform

      public void setScreenTransform(AffineTransform at)
      Sets the display transform.
      Specified by:
      setScreenTransform in interface SVGContext
    • getGlobalTransform

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

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

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

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