|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object | +--org.apache.batik.bridge.SVGUtilities
A collection of utility methods for SVG.
Field Summary | |
static short |
OBJECT_BOUNDING_BOX
The objectBoundingBox coordinate system constants. |
static short |
STROKE_WIDTH
The strokeWidth coordinate system constants. |
static short |
USER_SPACE_ON_USE
The userSpaceOnUse coordinate system constants. |
Fields inherited from interface org.apache.batik.bridge.ErrorConstants |
ERR_ATTRIBUTE_MISSING, ERR_ATTRIBUTE_VALUE_MALFORMED, ERR_CSS_LENGTH_NEGATIVE, ERR_CSS_URI_BAD_TARGET, ERR_LENGTH_NEGATIVE, ERR_URI_BAD_TARGET, ERR_URI_IMAGE_INVALID, ERR_URI_IO, ERR_URI_MALFORMED, ERR_URI_REFERENCE_A_DOCUMENT, ERR_URI_UNSECURE, ERR_XLINK_HREF_CIRCULAR_DEPENDENCIES, MSG_BROKEN_LINK_TITLE |
Constructor Summary | |
protected |
SVGUtilities()
No instance of this class is required. |
Method Summary | |
static void |
bridgeChildren(BridgeContext ctx,
org.w3c.dom.Element elt)
Scans the children of the input e element and invokes any registered bridge found for the children. |
static java.awt.geom.Rectangle2D |
convertFilterChainRegion(org.w3c.dom.Element filterElement,
org.w3c.dom.Element filteredElement,
GraphicsNode filteredNode,
BridgeContext ctx)
Returns the filter region according to the x, y, width, height, dx, dy, dw, dh and filterUnits attributes. |
static java.awt.geom.Rectangle2D |
convertFilterPrimitiveRegion(org.w3c.dom.Element filterPrimitiveElement,
org.w3c.dom.Element filteredElement,
GraphicsNode filteredNode,
java.awt.geom.Rectangle2D defaultRegion,
java.awt.geom.Rectangle2D filterRegion,
BridgeContext ctx)
Returns the filter primitive region according to the x, y, width, height, and filterUnits attributes. |
static float[] |
convertFilterRes(org.w3c.dom.Element filterElement,
BridgeContext ctx)
Returns an array of 2 float numbers that describes the filter resolution of the specified filter element. |
static float |
convertLength(java.lang.String length,
java.lang.String attr,
short unitsType,
UnitProcessor.Context uctx)
Returns a float in user units according to the specified parameters. |
static java.awt.geom.Rectangle2D |
convertMaskRegion(org.w3c.dom.Element maskElement,
org.w3c.dom.Element maskedElement,
GraphicsNode maskedNode,
BridgeContext ctx)
Returns the mask region according to the x, y, width, height, and maskUnits attributes. |
static java.awt.geom.Rectangle2D |
convertPatternRegion(org.w3c.dom.Element patternElement,
org.w3c.dom.Element paintedElement,
GraphicsNode paintedNode,
BridgeContext ctx)
Returns the pattern region according to the x, y, width, height, and patternUnits attributes. |
static java.awt.geom.Point2D |
convertPoint(java.lang.String xStr,
java.lang.String xAttr,
java.lang.String yStr,
java.lang.String yAttr,
short unitsType,
UnitProcessor.Context uctx)
Returns a Point2D in user units according to the specified parameters. |
static float |
convertRatio(java.lang.String v)
Converts the specified ratio to float number. |
protected static java.awt.geom.Rectangle2D |
convertRegion(java.lang.String xStr,
java.lang.String yStr,
java.lang.String wStr,
java.lang.String hStr,
short unitsType,
GraphicsNode targetNode,
UnitProcessor.Context uctx)
Returns a rectangle that represents the region defined by the specified coordinates. |
static int |
convertSVGInteger(java.lang.String s)
Converts a string into an integer. |
static float |
convertSVGNumber(java.lang.String s)
Converts a string into a float. |
static float[] |
convertSVGNumberList(SVGNumberList l)
Converts an SVGNumberList into a float array. |
static java.lang.Float[] |
convertSVGNumberOptionalNumber(org.w3c.dom.Element elem,
java.lang.String attrName,
java.lang.String attrValue)
This function parses attrValue for a number followed by an optional second Number. |
static java.awt.geom.AffineTransform |
convertTransform(org.w3c.dom.Element e,
java.lang.String attr,
java.lang.String transform)
Returns an AffineTransform according to the specified parameters. |
protected static java.awt.geom.Rectangle2D |
extendRegion(java.lang.String dxStr,
java.lang.String dyStr,
java.lang.String dwStr,
java.lang.String dhStr,
short unitsType,
GraphicsNode filteredNode,
java.awt.geom.Rectangle2D region,
UnitProcessor.Context uctx)
Returns a rectangle that represents the region extended by the specified differential coordinates. |
static java.lang.String |
getChainableAttributeNS(org.w3c.dom.Element element,
java.lang.String namespaceURI,
java.lang.String attrName,
BridgeContext ctx)
Returns the value of the specified attribute specified on the specified element or one of its ancestor. |
static java.lang.String |
getDescription(SVGElement elt)
Returns the content of the 'desc' child of the given element. |
static org.w3c.dom.Node |
getImportedChild(org.w3c.dom.Node n)
Returns the node imported by the given node, or null. |
static org.w3c.dom.Element |
getParentElement(org.w3c.dom.Element elt)
Returns the logical parent element of the given element. |
static boolean |
matchUserAgent(org.w3c.dom.Element elt,
UserAgent ua)
Tests whether or not the given element match a specified user agent. |
protected static boolean |
matchUserLanguage(java.lang.String s,
java.lang.String userLanguages)
Tests whether or not the specified language specification matches the user preferences. |
static short |
parseCoordinateSystem(org.w3c.dom.Element e,
java.lang.String attr,
java.lang.String coordinateSystem)
Parses the specified coordinate system defined by the specified element. |
static short |
parseMarkerCoordinateSystem(org.w3c.dom.Element e,
java.lang.String attr,
java.lang.String coordinateSystem)
Parses the specified coordinate system defined by the specified marker element. |
static java.awt.geom.AffineTransform |
toObjectBBox(java.awt.geom.AffineTransform Tx,
GraphicsNode node)
Returns an AffineTransform to move to the objectBoundingBox coordinate system. |
static java.awt.geom.Rectangle2D |
toObjectBBox(java.awt.geom.Rectangle2D r,
GraphicsNode node)
Returns the specified a Rectangle2D move to the objectBoundingBox coordinate system of the specified graphics node. |
Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
public static final short USER_SPACE_ON_USE
public static final short OBJECT_BOUNDING_BOX
public static final short STROKE_WIDTH
Constructor Detail |
protected SVGUtilities()
Method Detail |
public static org.w3c.dom.Node getImportedChild(org.w3c.dom.Node n)
public static org.w3c.dom.Element getParentElement(org.w3c.dom.Element elt)
public static float[] convertSVGNumberList(SVGNumberList l)
l
- the list to convertpublic static float convertSVGNumber(java.lang.String s)
s
- the float representation to convertpublic static int convertSVGInteger(java.lang.String s)
s
- the integer representation to convertpublic static float convertRatio(java.lang.String v)
v
- the ratio value to convertjava.lang.NumberFormatException
- if the ratio is not a valid
number or percentagepublic static java.lang.String getDescription(SVGElement elt)
public static boolean matchUserAgent(org.w3c.dom.Element elt, UserAgent ua)
elt
- the element to checkua
- the user agentprotected static boolean matchUserLanguage(java.lang.String s, java.lang.String userLanguages)
s
- the langage to checkuserLanguages
- the user langagespublic static java.lang.String getChainableAttributeNS(org.w3c.dom.Element element, java.lang.String namespaceURI, java.lang.String attrName, BridgeContext ctx)
element
- the element to start withnamespaceURI
- the namespace URI of the attribute to returnattrName
- the name of the attribute to searchctx
- the bridge contextpublic static java.awt.geom.Point2D convertPoint(java.lang.String xStr, java.lang.String xAttr, java.lang.String yStr, java.lang.String yAttr, short unitsType, UnitProcessor.Context uctx)
xStr
- the x coordinatexAttr
- the name of the attribute that represents the x coordinateyStr
- the y coordinateyAttr
- the name of the attribute that represents the y coordinateunitsType
- the coordinate system (OBJECT_BOUNDING_BOX |
USER_SPACE_ON_USE)uctx
- the unit processor contextpublic static float convertLength(java.lang.String length, java.lang.String attr, short unitsType, UnitProcessor.Context uctx)
length
- the lengthattr
- the name of the attribute that represents the lengthunitsType
- the coordinate system (OBJECT_BOUNDING_BOX |
USER_SPACE_ON_USE)uctx
- the unit processor contextpublic static java.awt.geom.Rectangle2D convertMaskRegion(org.w3c.dom.Element maskElement, org.w3c.dom.Element maskedElement, GraphicsNode maskedNode, BridgeContext ctx)
maskElement
- the mask element that defines the various attributesmaskedElement
- the element referencing the maskmaskedNode
- the graphics node to mask (objectBoundingBox)ctx
- the bridge contextpublic static java.awt.geom.Rectangle2D convertPatternRegion(org.w3c.dom.Element patternElement, org.w3c.dom.Element paintedElement, GraphicsNode paintedNode, BridgeContext ctx)
patternElement
- the pattern element that defines the attributespaintedElement
- the element referencing the patternpaintedNode
- the graphics node to paint (objectBoundingBox)ctx
- the bridge contextpublic static float[] convertFilterRes(org.w3c.dom.Element filterElement, BridgeContext ctx)
filterElement
- the filter elementctx
- the bridge contextpublic static java.lang.Float[] convertSVGNumberOptionalNumber(org.w3c.dom.Element elem, java.lang.String attrName, java.lang.String attrValue)
public static java.awt.geom.Rectangle2D convertFilterChainRegion(org.w3c.dom.Element filterElement, org.w3c.dom.Element filteredElement, GraphicsNode filteredNode, BridgeContext ctx)
filterElement
- the filter element that defines the attributesfilteredElement
- the element referencing the filterfilteredNode
- the graphics node to filter (objectBoundingBox)uctx
- the unit processor context (userSpaceOnUse)ctx
- the bridge contextprotected static java.awt.geom.Rectangle2D extendRegion(java.lang.String dxStr, java.lang.String dyStr, java.lang.String dwStr, java.lang.String dhStr, short unitsType, GraphicsNode filteredNode, java.awt.geom.Rectangle2D region, UnitProcessor.Context uctx)
dxStr
- the differential x coordinate of the regiondyStr
- the differential y coordinate of the regiondwStr
- the differential width of the regiondhStr
- the differential height of the regionunitsType
- specifies whether the values are in userSpaceOnUse
or objectBoundingBox spaceregion
- the region to extenductx
- the unit processor context (needed for userSpaceOnUse)public static java.awt.geom.Rectangle2D convertFilterPrimitiveRegion(org.w3c.dom.Element filterPrimitiveElement, org.w3c.dom.Element filteredElement, GraphicsNode filteredNode, java.awt.geom.Rectangle2D defaultRegion, java.awt.geom.Rectangle2D filterRegion, BridgeContext ctx)
filterPrimitiveElement
- the filter primitive elementfilteredElement
- the element referencing the filterfilteredNode
- the graphics node to use (objectBoundingBox)defaultRegion
- the default region to filterfilterRegion
- the filter chain regionctx
- the bridge contextpublic static short parseCoordinateSystem(org.w3c.dom.Element e, java.lang.String attr, java.lang.String coordinateSystem)
e
- the element that defines the coordinate systemattr
- the attribute which contains the coordinate systemcoordinateSystem
- the coordinate system to parsepublic static short parseMarkerCoordinateSystem(org.w3c.dom.Element e, java.lang.String attr, java.lang.String coordinateSystem)
e
- the element that defines the coordinate systemattr
- the attribute which contains the coordinate systemcoordinateSystem
- the coordinate system to parseprotected static java.awt.geom.Rectangle2D convertRegion(java.lang.String xStr, java.lang.String yStr, java.lang.String wStr, java.lang.String hStr, short unitsType, GraphicsNode targetNode, UnitProcessor.Context uctx)
xStr
- the x coordinate of the regionyStr
- the y coordinate of the regionwStr
- the width of the regionhStr
- the height of the regiontargetNode
- the graphics node (needed for objectBoundingBox)uctx
- the unit processor context (needed for userSpaceOnUse)rc
- the graphics node render contextpublic static java.awt.geom.AffineTransform convertTransform(org.w3c.dom.Element e, java.lang.String attr, java.lang.String transform)
e
- the element that defines the transformattr
- the name of the attribute that represents the transformtransform
- the transform to parsepublic static java.awt.geom.AffineTransform toObjectBBox(java.awt.geom.AffineTransform Tx, GraphicsNode node)
Tx
- the original transformationnode
- the graphics node that defines the coordinate
system to move intorc
- the graphics node render contextpublic static java.awt.geom.Rectangle2D toObjectBBox(java.awt.geom.Rectangle2D r, GraphicsNode node)
r
- the original Rectangle2Dnode
- the graphics node that defines the coordinate
system to move intorc
- the graphics node render contextpublic static void bridgeChildren(BridgeContext ctx, org.w3c.dom.Element elt)
ctx
- active BridgeContexte
- element to be scanned
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |