Class ViewBox

java.lang.Object
org.apache.batik.bridge.ViewBox
All Implemented Interfaces:
ErrorConstants, XMLConstants, CSSConstants, SVGConstants

public abstract class ViewBox extends Object implements SVGConstants, ErrorConstants
This class provides convenient methods to handle viewport.
Version:
$Id: ViewBox.java 1733416 2016-03-03 07:07:13Z gadams $
  • Constructor Details

    • ViewBox

      protected ViewBox()
      No instance of this class is required.
  • Method Details

    • getViewTransform

      public static AffineTransform getViewTransform(String ref, Element e, float w, float h, BridgeContext ctx)
      Parses the specified reference (from a URI) and returns the appropriate transform.
      Parameters:
      ref - the reference of the URI that may specify additional attribute values such as the viewBox, preserveAspectRatio or a transform
      e - the element interested in its view transform
      w - the width of the effective viewport
      h - The height of the effective viewport
      ctx - The BridgeContext to use for error information
      Throws:
      BridgeException - if an error occured while computing the preserveAspectRatio transform
    • getClosestAncestorSVGElement

      private static Element getClosestAncestorSVGElement(Element e)
      Returns the closest svg element ancestor of the specified element.
      Parameters:
      e - the element on which to start the svg element lookup
    • getPreserveAspectRatioTransform

      public static AffineTransform getPreserveAspectRatioTransform(Element e, float w, float h)
      Deprecated.
      Replaced by getPreserveAspectRatioTransform(Element,float,float,BridgeContext), which has more accurate error reporting.
      Returns the transformation matrix to apply to initalize a viewport or null if the specified viewBox disables the rendering of the element.
      Parameters:
      e - the element with a viewbox
      w - the width of the effective viewport
      h - The height of the effective viewport
    • getPreserveAspectRatioTransform

      public static AffineTransform getPreserveAspectRatioTransform(Element e, float w, float h, BridgeContext ctx)
      Returns the transformation matrix to apply to initalize a viewport or null if the specified viewBox disables the rendering of the element.
      Parameters:
      e - the element with a viewbox
      w - the width of the effective viewport
      h - The height of the effective viewport
      ctx - The BridgeContext to use for error information
    • getPreserveAspectRatioTransform

      public static AffineTransform getPreserveAspectRatioTransform(Element e, String viewBox, String aspectRatio, float w, float h, BridgeContext ctx)
      Returns the transformation matrix to apply to initalize a viewport or null if the specified viewBox disables the rendering of the element.
      Parameters:
      e - the element with a viewbox
      viewBox - the viewBox definition
      w - the width of the effective viewport
      h - The height of the effective viewport
      ctx - The BridgeContext to use for error information
    • getPreserveAspectRatioTransform

      public static AffineTransform getPreserveAspectRatioTransform(Element e, float[] vb, float w, float h, BridgeContext ctx)
      Returns the transformation matrix to apply to initalize a viewport or null if the specified viewBox disables the rendering of the element.
      Parameters:
      e - the element with a viewbox
      vb - the viewBox definition as float
      w - the width of the effective viewport
      h - The height of the effective viewport
      ctx - The BridgeContext to use for error information
    • getPreserveAspectRatioTransform

      public static AffineTransform getPreserveAspectRatioTransform(Element e, float[] vb, float w, float h, org.w3c.dom.svg.SVGAnimatedPreserveAspectRatio aPAR, BridgeContext ctx)
      Returns the transformation matrix to apply to initalize a viewport or null if the specified viewBox disables the rendering of the element.
      Parameters:
      e - the element with a viewbox
      vb - the viewBox definition as float
      w - the width of the effective viewport
      h - The height of the effective viewport
      aPAR - The animated preserveAspectRatio value
      ctx - The BridgeContext to use for error information
    • getPreserveAspectRatioTransform

      public static AffineTransform getPreserveAspectRatioTransform(Element e, org.w3c.dom.svg.SVGAnimatedRect aViewBox, org.w3c.dom.svg.SVGAnimatedPreserveAspectRatio aPAR, float w, float h, BridgeContext ctx)
      Returns the transformation matrix to apply to initialize a viewport or null if the specified viewBox disables the rendering of the element.
      Parameters:
      e - the element with a viewbox
      aViewBox - the viewBox definition
      aPAR - the preserveAspectRatio definition
      w - the width of the effective viewport
      h - the height of the effective viewport
      ctx - the BridgeContext to use for error information
    • parseViewBoxAttribute

      public static float[] parseViewBoxAttribute(Element e, String value, BridgeContext ctx)
      Parses a viewBox attribute.
      Parameters:
      e - the element whose viewBox attribute value is being parsed
      value - the viewBox
      ctx - the BridgeContext to use for error information
      Returns:
      The 4 viewbox components or null.
    • getPreserveAspectRatioTransform

      public static AffineTransform getPreserveAspectRatioTransform(float[] vb, short align, boolean meet, float w, float h)
      Returns the preserveAspectRatio transform according to the specified parameters.
      Parameters:
      vb - the viewBox definition
      align - the alignment definition
      meet - true means 'meet', false means 'slice'
      w - the width of the region in which the document has to fit into
      h - the height of the region in which the document has to fit into