|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object | +--org.apache.batik.refimpl.bridge.SVGUtilities
This class contains utility methods for SVG.
Inner Class Summary | |
protected static class |
SVGUtilities.PreserveAspectRatio
To store the preserveAspectRatio attribute values. |
Field Summary | |
static int |
BACKGROUND_ALPHA
Represents 'BackgroundAlpha'. |
static int |
BACKGROUND_IMAGE
Represents 'BackgroundImage'. |
static int |
EMPTY
Represents an empty string attribute. |
static int |
FILL_PAINT
Represents 'FillPaint'. |
static int |
IDENTIFIER
Represents an identifier. |
static int |
OBJECT_BOUNDING_BOX
Represents 'objectBoundingBox'. |
static int |
SOURCE_ALPHA
Represents 'SourceAlpha'. |
static int |
SOURCE_GRAPHIC
Represents 'SourceGraphic'. |
static int |
STROKE_PAINT
Represents 'StrokePaint'. |
static int |
USER_SPACE_ON_USE
Represents 'userSpaceOnUse'. |
Constructor Summary | |
protected |
SVGUtilities()
This class does not need to be instantiated. |
Method Summary | |
static java.lang.Float[] |
buildFloatPair(java.lang.String attrValue)
Parses a Float value pair. |
static java.awt.geom.AffineTransform |
convertAffineTransform(java.awt.geom.AffineTransform at,
GraphicsNode node,
int unitsType)
Creates an AffineTransform with the specified additional transform, in the space of the specified graphics node according to the 'units' coordinate system. |
static java.awt.geom.AffineTransform |
convertAffineTransform(Element e,
java.lang.String attrName,
ParserFactory pf)
Creates an AffineTransform using the element and its specified attribute. |
static java.awt.geom.Rectangle2D |
convertFilterChainRegion(Element filterElement,
Element filteredElement,
GraphicsNode node,
UnitProcessor.Context uctx)
Creates a Rectangle2D for the <filter> element. |
static java.awt.geom.Rectangle2D |
convertFilterPrimitiveRegion(Element filterPrimitiveElement,
Element filteredElement,
java.awt.geom.Rectangle2D defaultRegion,
GraphicsNode node,
UnitProcessor.Context uctx)
Creates a Rectangle2D for the input filter primitive element. |
static float |
convertGradientLength(Element element,
java.lang.String attrLengthName,
java.lang.String lengthStr,
int unitsType,
UnitProcessor.Context uctx)
Creates a float value from the input value in the 'units' coordinate system. |
static java.awt.geom.Point2D |
convertGradientPoint(Element element,
java.lang.String attrXName,
java.lang.String xStr,
java.lang.String attrYName,
java.lang.String yStr,
int unitsType,
UnitProcessor.Context uctx)
Creates a Point2D for the input x and y attribute value in the 'units' coordinate system. |
static java.awt.geom.Rectangle2D |
convertMaskRegion(Element maskElement,
Element maskedElement,
GraphicsNode node,
UnitProcessor.Context uctx)
Creates a Rectangle2D for the input <mask> element. |
static java.awt.geom.Rectangle2D |
convertPatternRegion(Element patternElement,
Element paintedElement,
GraphicsNode node,
UnitProcessor.Context uctx)
Creates a Rectangle2D for the input <pattern> element. |
protected static java.awt.geom.Rectangle2D |
convertRegion(Element filterElement,
Element filteredElement,
GraphicsNode node,
UnitProcessor.Context uctx,
java.lang.String unitsAttr,
java.lang.String unitsDefault,
java.lang.String xDefault,
java.lang.String yDefault,
java.lang.String wDefault,
java.lang.String hDefault)
Creates a Rectangle2D using the specified parameters. |
static int |
convertSVGInteger(java.lang.String attrName,
java.lang.String intStr)
Parses an SVG integer. |
static float |
convertSVGNumber(java.lang.String attrName,
java.lang.String numStr)
Parses an SVG number |
static java.lang.String |
getDescription(SVGElement elt)
Returns the content of the 'desc' child of the given element. |
static java.awt.geom.AffineTransform |
getPreserveAspectRatioTransform(SVGElement elt,
float w,
float h,
ParserFactory pf)
Returns the transformation to apply to initalize a viewport. |
static boolean |
matchUserAgent(Element elt,
UserAgent ua)
Tests whether or not the given element match a user agent. |
protected static boolean |
matchUserLanguage(java.lang.String s,
java.lang.String userLanguages)
Tests whether the given language specification match the user preferences. |
static int |
parseCoordinateSystem(java.lang.String value)
Parse the given specified coordinate system. |
static int |
parseInAttribute(java.lang.String value)
Parses the given 'in' attribute value. |
static float[] |
parseViewBoxAttribute(java.lang.String value)
Parses a viewBox attribute. |
protected static float |
svgToObjectBoundingBox(Element element,
java.lang.String attrName,
java.lang.String valueStr,
UnitProcessor.Context uctx,
short direction)
Returns the float that represents a specified value or percentage. |
static float |
svgToUserSpace(Element element,
java.lang.String attrName,
java.lang.String valueStr,
UnitProcessor.Context uctx,
short direction)
Returns the float that represents a specified value or percentage. |
protected static float |
svgToUserSpaceOnUse(Element element,
java.lang.String attrName,
java.lang.String valueStr,
UnitProcessor.Context uctx,
short direction)
Returns the float that represents a specified value or percentage. |
Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
public static final int EMPTY
public static final int BACKGROUND_ALPHA
public static final int BACKGROUND_IMAGE
public static final int FILL_PAINT
public static final int SOURCE_ALPHA
public static final int SOURCE_GRAPHIC
public static final int STROKE_PAINT
public static final int IDENTIFIER
public static final int OBJECT_BOUNDING_BOX
public static final int USER_SPACE_ON_USE
Constructor Detail |
protected SVGUtilities()
Method Detail |
public static int parseCoordinateSystem(java.lang.String value)
java.lang.IllegalArgumentException
- if the value is not
'objectBoundingBox' or 'userSpaceOnUse'public static int parseInAttribute(java.lang.String value)
public static float[] parseViewBoxAttribute(java.lang.String value)
public static java.awt.geom.AffineTransform getPreserveAspectRatioTransform(SVGElement elt, float w, float h, ParserFactory pf)
elt
- The document node.w
- The effective viewport width.h
- The effective viewport height.public static java.lang.String getDescription(SVGElement elt)
public static boolean matchUserAgent(Element elt, UserAgent ua)
protected static boolean matchUserLanguage(java.lang.String s, java.lang.String userLanguages)
public static int convertSVGInteger(java.lang.String attrName, java.lang.String intStr)
attrName
- the attribute that has the specified valuenumStr
- the integer value to parseIllegalAttributeValueException
- if intStr is not a parsable
integerpublic static float convertSVGNumber(java.lang.String attrName, java.lang.String numStr)
attrName
- the attribute that has the specified valuenumStr
- the float value to parseIllegalAttributeValueException
- if intStr is not a parsable
floatpublic static java.awt.geom.Rectangle2D convertFilterChainRegion(Element filterElement, Element filteredElement, GraphicsNode node, UnitProcessor.Context uctx)
filterElement
- the <filter> elementfilteredElement
- the element to filternode
- the graphics node that represents the element to filteructx
- the context used to compute units and percentagespublic static java.awt.geom.Rectangle2D convertMaskRegion(Element maskElement, Element maskedElement, GraphicsNode node, UnitProcessor.Context uctx)
maskElement
- the <mask> elementmaskedElement
- the element to masknode
- the graphics node that represents the element to maskuctx
- the context used to compute units and percentagespublic static java.awt.geom.Rectangle2D convertPatternRegion(Element patternElement, Element paintedElement, GraphicsNode node, UnitProcessor.Context uctx)
patternElement
- the <pattern> elementpaintedElement
- the element to paintnode
- the graphics node that represents the element to paintuctx
- the context used to compute units and percentagesprotected static java.awt.geom.Rectangle2D convertRegion(Element filterElement, Element filteredElement, GraphicsNode node, UnitProcessor.Context uctx, java.lang.String unitsAttr, java.lang.String unitsDefault, java.lang.String xDefault, java.lang.String yDefault, java.lang.String wDefault, java.lang.String hDefault)
filterElement
- the filter Element or equivalentfilteredElement
- the element which uses the filternode
- the graphics node representing the filtered elementuctx
- the context used to compute units and percentagesunitsAttr
- the units to consider on the specified filter elementunitsDefault
- the default value of the units if not specified on
the filter elementxDefault
- the default value of the x attribute, null means requiredyDefault
- the default value of the x attribute, null means requiredwidthDefault
- the default value of the x attribute, null
means requiredheightDefault
- the default value of the height attribute,
null means requiredpublic static java.awt.geom.Rectangle2D convertFilterPrimitiveRegion(Element filterPrimitiveElement, Element filteredElement, java.awt.geom.Rectangle2D defaultRegion, GraphicsNode node, UnitProcessor.Context uctx)
filterPrimitiveElement
- the primitive filterfilteredElement
- the element which uses the filterdefaultRegion
- the default region to filternode
- the graphics node that represents the element to filteructx
- the context used to compute units and percentagespublic static java.awt.geom.Point2D convertGradientPoint(Element element, java.lang.String attrXName, java.lang.String xStr, java.lang.String attrYName, java.lang.String yStr, int unitsType, UnitProcessor.Context uctx)
element
- the element that defines the specified coordinatesattrXName
- the name of the X attribute (used by error handling)xStr
- the 'x' coordinateattrYName
- the name of the Y attribute (used by error handling)yStr
- the 'y' coordinateunitsType
- the coordinate systemuctx
- the context used to compute units and percentagesIllegalAttributeValueException
- if one of the specified is
not validpublic static float convertGradientLength(Element element, java.lang.String attrLengthName, java.lang.String lengthStr, int unitsType, UnitProcessor.Context uctx)
element
- the element that defines the specified lengthattrLengthName
- the name of the attribute (used by error handling)lengthStr
- the length valueunitsType
- the coordinate systemuctx
- the context used to compute units and percentagesIllegalAttributeValueException
- if the value is not a validpublic static java.awt.geom.AffineTransform convertAffineTransform(Element e, java.lang.String attrName, ParserFactory pf)
the
- e that defines a transformthe
- attribute that defines the transformpf
- the parser factory to usepublic static java.awt.geom.AffineTransform convertAffineTransform(java.awt.geom.AffineTransform at, GraphicsNode node, int unitsType)
at
- the additional transformnode
- the graphics node that defines the coordinate spaceunitsType
- the coordinate systempublic static java.lang.Float[] buildFloatPair(java.lang.String attrValue)
public static float svgToUserSpace(Element element, java.lang.String attrName, java.lang.String valueStr, UnitProcessor.Context uctx, short direction)
element
- the element that defines the specified coordinatesattrName
- the name of the attribute (used by error handling)valueStr
- the value of the coordinateuctx
- the context used to compute units and percentagesdirection
- HORIZONTAL_LENGTH | VERTICAL_LENGTH | OTHER_LENGTHIllegalAttributeValueException
- if the value is not a validprotected static float svgToObjectBoundingBox(Element element, java.lang.String attrName, java.lang.String valueStr, UnitProcessor.Context uctx, short direction)
element
- the element that defines the specified coordinatesattrName
- the name of the attribute (used by error handling)valueStr
- the value of the coordinateuctx
- the context used to compute units and percentagesdirection
- HORIZONTAL_LENGTH | VERTICAL_LENGTH | OTHER_LENGTHIllegalAttributeValueException
- if the value is not a validprotected static float svgToUserSpaceOnUse(Element element, java.lang.String attrName, java.lang.String valueStr, UnitProcessor.Context uctx, short direction)
element
- the element that defines the specified coordinatesattrName
- the name of the attribute (used by error handling)valueStr
- the value of the coordinateuctx
- the context used to compute units and percentagesdirection
- HORIZONTAL_LENGTH | VERTICAL_LENGTH | OTHER_LENGTHIllegalAttributeValueException
- if the value is not a valid
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |