Implements a canvas to be used with mxImageExport. This canvas writes all calls as SVG output to the given SVG root node.
var svgDoc = mxUtils.createXmlDocument(); var root = (svgDoc.createElementNS != null) ? svgDoc.createElementNS(mxConstants.NS_SVG, 'svg') : svgDoc.createElement('svg'); if (svgDoc.createElementNS == null) { root.setAttribute('xmlns', mxConstants.NS_SVG); } var bounds = graph.getGraphBounds(); root.setAttribute('width', (bounds.x + bounds.width + 4) + 'px'); root.setAttribute('height', (bounds.y + bounds.height + 4) + 'px'); root.setAttribute('version', '1.1'); svgDoc.appendChild(root); var svgCanvas = new mxSvgCanvas2D(root);
mxSvgCanvas2D | Implements a canvas to be used with mxImageExport. |
Functions | |
mxSvgCanvas2D | Constructs an SVG canvas. |
Variables | |
converter | Holds the mxUrlConverter to convert image URLs. |
autoAntiAlias | Specifies if anti aliasing should be disabled for rectangles and orthogonal paths. |
textEnabled | Specifies if text output should be enabled. |
foEnabled | Specifies if use of foreignObject for HTML markup is allowed. |
Functions | |
getConverter | Returns converter. |
isAutoAntiAlias | Returns autoAntiAlias. |
setAutoAntiAlias | Sets autoAntiAlias. |
isTextEnabled | Returns textEnabled. |
setTextEnabled | Sets textEnabled. |
isFoEnabled | Returns foEnabled. |
setFoEnabled | Sets foEnabled. |
save | Saves the state of the graphics object. |
restore | Restores the state of the graphics object. |
scale | Scales the current graphics object. |
translate | Translates the current graphics object. |
rotate | Rotates and/or flips the current graphics object. |
setStrokeWidth | Sets the stroke width. |
setStrokeColor | Sets the stroke color. |
setDashed | Sets the dashed state to true or false. |
setDashPattern | Sets the dashed pattern to the given space separated list of numbers. |
setLineCap | Sets the linecap. |
setLineJoin | Sets the linejoin. |
setMiterLimit | Sets the miterlimit. |
setFontSize | Sets the fontsize. |
setFontColor | Sets the fontcolor. |
setFontFamily | Sets the fontfamily. |
setFontStyle | Sets the fontstyle. |
setAlpha | Sets the current alpha. |
setFillColor | Sets the fillcolor. |
setGradient | Sets the gradient color. |
setGlassGradient | Sets the glass gradient. |
rect | Sets the current path to a rectangle. |
roundrect | Sets the current path to a rounded rectangle. |
ellipse | Sets the current path to an ellipse. |
image | Paints an image. |
text | Paints the given text. |
begin | Starts a new path. |
moveTo | Moves the current path the given coordinates. |
lineTo | Adds a line to the current path. |
quadTo | Adds a quadratic curve to the current path. |
curveTo | Adds a bezier curve to the current path. |
close | Closes the current path. |
stroke | Paints the outline of the current path. |
fill | Fills the current path. |
fillstroke | Fills and paints the outline of the current path. |
shadow | Paints the current path as a shadow of the given color. |
clip | Uses the current path for clipping. |
var mxSvgCanvas2D = function( root, styleEnabled )
Constructs an SVG canvas.
root | SVG container for the output. |
styleEnabled | Optional boolean that specifies if a style section should be added. The style section sets the default font-size, font-family and stroke-miterlimit globally. Default is false. |
var converter
Holds the mxUrlConverter to convert image URLs.
getConverter: function()
Returns converter.
isAutoAntiAlias: function()
Returns autoAntiAlias.
setAutoAntiAlias: function( value )
Sets autoAntiAlias.
isTextEnabled: function()
Returns textEnabled.
setTextEnabled: function( value )
Sets textEnabled.
isFoEnabled: function()
Returns foEnabled.
setFoEnabled: function( value )
Sets foEnabled.
Constructs an SVG canvas.
var mxSvgCanvas2D = function( root, styleEnabled )
Holds the mxUrlConverter to convert image URLs.
var converter
Specifies if anti aliasing should be disabled for rectangles and orthogonal paths.
var autoAntiAlias
Specifies if text output should be enabled.
var textEnabled
Specifies if use of foreignObject for HTML markup is allowed.
var foEnabled
Returns converter.
getConverter: function()
Returns autoAntiAlias.
isAutoAntiAlias: function()
Sets autoAntiAlias.
setAutoAntiAlias: function( value )
Returns textEnabled.
isTextEnabled: function()
Sets textEnabled.
setTextEnabled: function( value )
Returns foEnabled.
isFoEnabled: function()
Sets foEnabled.
setFoEnabled: function( value )
Saves the state of the graphics object.
save: function()
Restores the state of the graphics object.
restore: function()
Scales the current graphics object.
scale: function( value )
Translates the current graphics object.
translate: function( dx, dy )
Rotates and/or flips the current graphics object.
rotate: function( theta, flipH, flipV, cx, cy )
Sets the stroke width.
setStrokeWidth: function( value )
Sets the stroke color.
setStrokeColor: function( value )
Sets the dashed state to true or false.
setDashed: function( value )
Sets the dashed pattern to the given space separated list of numbers.
setDashPattern: function( value )
Sets the linecap.
setLineCap: function( value )
Sets the linejoin.
setLineJoin: function( value )
Sets the miterlimit.
setMiterLimit: function( value )
Sets the fontsize.
setFontSize: function( value )
Sets the fontcolor.
setFontColor: function( value )
Sets the fontfamily.
setFontFamily: function( value )
Sets the fontstyle.
setFontStyle: function( value )
Sets the current alpha.
setAlpha: function( alpha )
Sets the fillcolor.
setFillColor: function( value )
Sets the gradient color.
setGradient: function( color1, color2, x, y, w, h, direction )
Sets the glass gradient.
setGlassGradient: function( x, y, w, h )
Sets the current path to a rectangle.
rect: function( x, y, w, h )
Sets the current path to a rounded rectangle.
roundrect: function( x, y, w, h, dx, dy )
Sets the current path to an ellipse.
ellipse: function( x, y, w, h )
Paints an image.
image: function( x, y, w, h, src, aspect, flipH, flipV )
Paints the given text.
text: function( x, y, w, h, str, align, valign, vertical, wrap, format )
Starts a new path.
begin: function()
Moves the current path the given coordinates.
moveTo: function( x, y )
Adds a line to the current path.
lineTo: function( x, y )
Adds a quadratic curve to the current path.
quadTo: function( x1, y1, x2, y2 )
Adds a bezier curve to the current path.
curveTo: function( x1, y1, x2, y2, x3, y3 )
Closes the current path.
close: function()
Paints the outline of the current path.
stroke: function()
Fills the current path.
fill: function()
Paints the current path as a shadow of the given color.
shadow: function( value, filled )
Uses the current path for clipping.
clip: function()