enable.savage.svg.document module¶
SVGDocument
-
class
enable.savage.svg.document.
ResourceGetter
(dirname=None)[source]¶ Bases:
object
Simple context for getting relative-pathed resources.
-
classmethod
fromfilename
(filename)[source]¶ Use the directory containing this file as the base directory.
-
classmethod
-
class
enable.savage.svg.document.
SVGDocument
(element, resources=None, renderer=<class 'enable.savage.svg.backends.null.null_renderer.NullRenderer'>)[source]¶ Bases:
object
-
addGroupToDocument
(node)[source]¶ For parent elements: push on a state, then process all child elements
-
addStrokeToPath
(path, stroke)[source]¶ Given a stroke from a path command (in the form (command, arguments)) create the path commands that represent it.
TODO: break out into (yet another) class/module, especially so we can get O(1) dispatch on type?
-
createTransformOpsFromNode
(node, attribute='transform')[source]¶ Returns an oplist for transformations. This applies to a node, not the current state because the transform stack is saved in the graphics context.
This oplist does not include the push/pop state commands
-
createTransformOpsFromXY
(node)[source]¶ On some nodes, x and y attributes cause a translation of the coordinate system.
-
dereference
(href, resources=None)[source]¶ Find the element specified by the give href.
- Parameters
href (str) – The reference pointing to the desired element. Forms like ‘url(uri#theid)’ and ‘uri#xpointer(id(theid))’ will be normalized to pull out just the uri and the id.
resources (ResourceGetter, optional) – The ResourceGetter to use. If not provided, the one attached to the SVGDocument is used. This is useful when silly test suites like to test annoying XLink features. FIXME: <sigh> xml:base is inheritable.
- Returns
element
- Return type
- Raises
KeyError : – If the element is not found.
-
findIDs
(element, uri='')[source]¶ Iterate through the tree under an element and record all elements which specify an id attribute.
The root element is given the ID ‘’ in addition to whatever id= attribute it may be given.
-
generatePathOps
(path)[source]¶ Look at the current state and generate the draw operations (fill, stroke, neither) for the path.
-
processElement
(element)[source]¶ Process one element of the XML tree. Returns the path representing the node, and an operation list for drawing the node.
Parent nodes should return a path (for hittesting), but no draw operations
-
property
state
¶ Retrieve the current state, without popping
-
-
class
enable.savage.svg.document.
XMLNS
(url)[source]¶ Bases:
object
Utility object for dealing the namespaced names quoted the way ElementTree requires.
-
enable.savage.svg.document.
fractionalValue
(value)[source]¶ Parse a string consisting of a float in the range [0..1] or a percentage as a float number in the range [0..1].
-
enable.savage.svg.document.
normalize_href
(href)[source]¶ Normalize an href to remove url(…) and xpointer(id(…)) extraneous bits.
- Parameters
href (str) –
- Returns
uri (str) – A URI (or maybe a file system path) to the resource.
fragment (str) – The normalized #fragment, if any