Class SVGImageElementBridge

All Implemented Interfaces:
SVGAnimationTargetContext, Bridge, BridgeUpdateHandler, ErrorConstants, GraphicsNodeBridge, XMLConstants, SVGContext, CSSConstants, SVGConstants
Direct Known Subclasses:
SVGMultiImageElementBridge

public class SVGImageElementBridge extends AbstractGraphicsNodeBridge
Bridge class for the <image> element.
  • Field Details

    • imgDocument

      protected org.w3c.dom.svg.SVGDocument imgDocument
    • listener

      protected EventListener listener
    • subCtx

      protected BridgeContext subCtx
    • hitCheckChildren

      protected boolean hitCheckChildren
  • Constructor Details

    • SVGImageElementBridge

      public SVGImageElementBridge()
      Constructs a new bridge for the <image> element.
  • Method Details

    • getLocalName

      public String getLocalName()
      Returns 'image'.
    • getInstance

      public Bridge getInstance()
      Returns a new instance of this bridge.
      Specified by:
      getInstance in interface Bridge
      Specified by:
      getInstance in interface GraphicsNodeBridge
      Overrides:
      getInstance in class AbstractSVGBridge
    • createGraphicsNode

      public GraphicsNode createGraphicsNode(BridgeContext ctx, Element e)
      Creates a graphics node using the specified BridgeContext and for the specified element.
      Specified by:
      createGraphicsNode in interface GraphicsNodeBridge
      Overrides:
      createGraphicsNode in class AbstractGraphicsNodeBridge
      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
    • buildImageGraphicsNode

      protected GraphicsNode buildImageGraphicsNode(BridgeContext ctx, Element e)
      Create a Graphics node according to the resource pointed by the href : RasterImageNode for bitmaps, CompositeGraphicsNode for svg files.
      Parameters:
      ctx - : the bridge context to use
      e - the element that describes the graphics node to build
      Returns:
      the graphic node that represent the resource pointed by the reference
    • createImageGraphicsNode

      protected GraphicsNode createImageGraphicsNode(BridgeContext ctx, Element e, ParsedURL purl)
    • openStream

      protected SVGImageElementBridge.ProtectedStream openStream(Element e, ParsedURL purl) throws IOException
      Throws:
      IOException
    • instantiateGraphicsNode

      protected GraphicsNode instantiateGraphicsNode()
      Creates an ImageNode.
      Specified by:
      instantiateGraphicsNode in class AbstractGraphicsNodeBridge
    • isComposite

      public boolean isComposite()
      Returns false as image is not a container.
    • initializeDynamicSupport

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

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

      protected void updateImageBounds()
    • rebuildImageNode

      protected void rebuildImageNode()
    • handleCSSPropertyChanged

      protected void handleCSSPropertyChanged(int property)
      Invoked for each CSS property that has changed.
      Overrides:
      handleCSSPropertyChanged in class AbstractGraphicsNodeBridge
    • createRasterImageNode

      protected GraphicsNode createRasterImageNode(BridgeContext ctx, Element e, Filter img, ParsedURL purl)
      Returns a GraphicsNode that represents an raster image in JPEG or PNG format.
      Parameters:
      ctx - the bridge context
      e - the image element
      img - the image to use in creating the graphics node
    • createSVGImageNode

      protected GraphicsNode createSVGImageNode(BridgeContext ctx, Element e, org.w3c.dom.svg.SVGDocument imgDocument)
      Returns a GraphicsNode that represents a svg document as an image.
      Parameters:
      ctx - the bridge context
      e - the image element
      imgDocument - the SVG document that represents the image
    • dispose

      public void dispose()
      Description copied from class: AbstractGraphicsNodeBridge
      Disposes this BridgeUpdateHandler and releases all resources.
      Specified by:
      dispose in interface BridgeUpdateHandler
      Overrides:
      dispose in class AbstractGraphicsNodeBridge
    • initializeViewport

      protected static void initializeViewport(BridgeContext ctx, Element e, GraphicsNode node, float[] vb, Rectangle2D bounds)
      Initializes according to the specified element, the specified graphics node with the specified bounds. This method takes into account the 'viewBox', 'preserveAspectRatio', and 'clip' properties. According to those properties, a AffineTransform and a clip is set.
      Parameters:
      ctx - the bridge context
      e - the image element that defines the properties
      node - the graphics node
      vb - the implicit viewBox definition
      bounds - the bounds of the image element
    • extractColorSpace

      protected static org.apache.xmlgraphics.java2d.color.ICCColorSpaceWithIntent extractColorSpace(Element element, BridgeContext ctx)
      Analyzes the color-profile property and builds an ICCColorSpaceExt object from it.
      Parameters:
      element - the element with the color-profile property
      ctx - the bridge context
    • getImageBounds

      protected static Rectangle2D getImageBounds(BridgeContext ctx, Element element)
      Returns the bounds of the specified image element.
      Parameters:
      ctx - the bridge context
      element - the image element