Class AbstractSVGGradientElementBridge

All Implemented Interfaces:
SVGAnimationTargetContext, Bridge, BridgeUpdateHandler, ErrorConstants, GenericBridge, PaintBridge, XMLConstants, SVGContext, CSSConstants, SVGConstants
Direct Known Subclasses:
SVGLinearGradientElementBridge, SVGRadialGradientElementBridge

public abstract class AbstractSVGGradientElementBridge extends AnimatableGenericSVGBridge implements PaintBridge, ErrorConstants
Bridge class for vending gradients.
Version:
$Id: AbstractSVGGradientElementBridge.java 1831635 2018-05-15 13:33:47Z ssteiner $
  • Constructor Details

    • AbstractSVGGradientElementBridge

      protected AbstractSVGGradientElementBridge()
      Constructs a new AbstractSVGGradientElementBridge.
  • Method Details

    • createPaint

      public Paint createPaint(BridgeContext ctx, Element paintElement, Element paintedElement, GraphicsNode paintedNode, float opacity)
      Creates a Paint according to the specified parameters.
      Specified by:
      createPaint in interface PaintBridge
      Parameters:
      ctx - the bridge context to use
      paintElement - the element that defines a Paint
      paintedElement - the element referencing the paint
      paintedNode - the graphics node on which the Paint will be applied
      opacity - the opacity of the Paint to create
    • buildGradient

      protected abstract Paint buildGradient(Element paintElement, Element paintedElement, GraphicsNode paintedNode, MultipleGradientPaint.CycleMethodEnum spreadMethod, MultipleGradientPaint.ColorSpaceEnum colorSpace, AffineTransform transform, Color[] colors, float[] offsets, BridgeContext ctx)
      Builds a concrete gradient according to the specified parameters.
      Parameters:
      paintElement - the element that defines a Paint
      paintedElement - the element referencing the paint
      paintedNode - the graphics node on which the Paint will be applied
      spreadMethod - the spread method
      colorSpace - the color space (sRGB | LinearRGB)
      transform - the gradient transform
      colors - the colors of the gradient
      offsets - the offsets
      ctx - the bridge context to use
    • convertSpreadMethod

      protected static MultipleGradientPaint.CycleMethodEnum convertSpreadMethod(Element paintElement, String s, BridgeContext ctx)
      Converts the spreadMethod attribute.
      Parameters:
      paintElement - the paint Element with a spreadMethod
      s - the spread method
      ctx - the BridgeContext to use for error information
    • extractStop

      protected static List extractStop(Element paintElement, float opacity, BridgeContext ctx)
      Returns the stops elements of the specified gradient element. Stops can be children of the gradients or defined on one of its 'ancestor' (linked with the xlink:href attribute).
      Parameters:
      paintElement - the gradient element
      opacity - the opacity
      ctx - the bridge context to use
    • extractLocalStop

      protected static List extractLocalStop(Element gradientElement, float opacity, BridgeContext ctx)
      Returns a list of Stop elements, children of the specified paintElement can have or null if any.
      Parameters:
      gradientElement - the paint element
      opacity - the opacity
      ctx - the bridge context
    • contains

      private static boolean contains(List urls, ParsedURL key)
      Returns true if the specified list of URLs contains the specified url.
      Parameters:
      urls - the list of URLs
      key - the url to search for