SVGGraphic.js revision 66ca16dd76367c074fe4df1dcf7b555489a9bf85
4778ff543a041ac356d6e661cc9b66c3fafa2092Adam Moore * Graphic is a simple drawing api that allows for basic drawing operations.
4778ff543a041ac356d6e661cc9b66c3fafa2092Adam Moore * @module graphics
2c5ce90c334a2d0f18474e85c93b424b6ec9daaaAdam Moore * @class SVGGraphic
4778ff543a041ac356d6e661cc9b66c3fafa2092Adam Moore * @constructor
1b298c6f0ef597aa4ab0b8bcb25430b6c9a87749Adam Moore SVGGraphic.superclass.constructor.apply(this, arguments);
1b298c6f0ef597aa4ab0b8bcb25430b6c9a87749Adam Moore * Unique id for class instance.
87d6b0a14cce52c4faa4b78fc9878eb553dab0d5Adam Moore * @attribute id
1b298c6f0ef597aa4ab0b8bcb25430b6c9a87749Adam Moore * @type String
91ff24e65531ce8bf171340d9384182f8c168af3Adam Moore * Key value pairs in which a shape instance is associated with its id.
87d6b0a14cce52c4faa4b78fc9878eb553dab0d5Adam Moore * @attribute shapes
91ff24e65531ce8bf171340d9384182f8c168af3Adam Moore * @type Object
91ff24e65531ce8bf171340d9384182f8c168af3Adam Moore * Object containing size and coordinate data for the content of a Graphic in relation to the coordSpace node.
91ff24e65531ce8bf171340d9384182f8c168af3Adam Moore * @attribute contentBounds
91ff24e65531ce8bf171340d9384182f8c168af3Adam Moore * @type Object
d4dbc3afb5bb9cfd13490b358dc37bf951104ca7Adam Moore * The html element that represents to coordinate system of the Graphic instance.
d4dbc3afb5bb9cfd13490b358dc37bf951104ca7Adam Moore * @attribute node
d4dbc3afb5bb9cfd13490b358dc37bf951104ca7Adam Moore * @type HTMLElement
d4dbc3afb5bb9cfd13490b358dc37bf951104ca7Adam Moore return this._node;
d4dbc3afb5bb9cfd13490b358dc37bf951104ca7Adam Moore * Determines how the size of instance is calculated. If true, the width and height are determined by the size of the contents.
d4dbc3afb5bb9cfd13490b358dc37bf951104ca7Adam Moore * If false, the width and height values are either explicitly set or determined by the size of the parent node's dimensions.
d4dbc3afb5bb9cfd13490b358dc37bf951104ca7Adam Moore * @attribute autoSize
d4dbc3afb5bb9cfd13490b358dc37bf951104ca7Adam Moore * @type Boolean
d4dbc3afb5bb9cfd13490b358dc37bf951104ca7Adam Moore * @default false
1b298c6f0ef597aa4ab0b8bcb25430b6c9a87749Adam Moore * When overflow is set to true, by default, the contentBounds will resize to greater values but not to smaller values. (for performance)
87d6b0a14cce52c4faa4b78fc9878eb553dab0d5Adam Moore * When resizing the contentBounds down is desirable, set the resizeDown value to true.
1b298c6f0ef597aa4ab0b8bcb25430b6c9a87749Adam Moore * @attribute resizeDown
1b298c6f0ef597aa4ab0b8bcb25430b6c9a87749Adam Moore * @type Boolean
1b298c6f0ef597aa4ab0b8bcb25430b6c9a87749Adam Moore * Indicates the x-coordinate for the instance.
ba2701ee03e94104edf19911ee0989f8cee11088Adam Moore * @attribute x
1b298c6f0ef597aa4ab0b8bcb25430b6c9a87749Adam Moore * @type Number
1b298c6f0ef597aa4ab0b8bcb25430b6c9a87749Adam Moore return this._x;
23209f57fce338501bc1dc828a991d103732b92fAdam Moore * Indicates the y-coordinate for the instance.
23209f57fce338501bc1dc828a991d103732b92fAdam Moore * @attribute y
e0a1d83ad86620d8fd4e2bfa3c4ec5c0944a002aAdam Moore * @type Number
e0a1d83ad86620d8fd4e2bfa3c4ec5c0944a002aAdam Moore return this._y;
3395e5fc071521d4e6b258ef4c7c0ef38601b94eAdam Moore * Indicates whether or not the instance will automatically redraw after a change is made to a shape.
0dca577a07715960da42d47787eecc25b285182fAdam Moore * This property will get set to false when batching operations.
0dca577a07715960da42d47787eecc25b285182fAdam Moore * @attribute autoDraw
3395e5fc071521d4e6b258ef4c7c0ef38601b94eAdam Moore * @type Boolean
3395e5fc071521d4e6b258ef4c7c0ef38601b94eAdam Moore * @default true
3395e5fc071521d4e6b258ef4c7c0ef38601b94eAdam Moore * Indicates the pointer-events setting for the svg:svg element.
3395e5fc071521d4e6b258ef4c7c0ef38601b94eAdam Moore * @attribute pointerEvents
3395e5fc071521d4e6b258ef4c7c0ef38601b94eAdam Moore * @type String
9fb523cf517ad4d6a53ae9f461d672cba63835d2Adam Moore * Gets the current position of the graphic instance in page coordinates.
3395e5fc071521d4e6b258ef4c7c0ef38601b94eAdam Moore * @method getXY
9fb523cf517ad4d6a53ae9f461d672cba63835d2Adam Moore * @return Array The XY position of the shape.
return xy;
_resizeDown: false,
initializer: function() {
this._shapes = {};
this._contentBounds = {
this._gradients = {};
if(render)
destroy: function()
this.removeAllShapes();
return shape;
this._redraw();
return shape;
removeAllShapes: function()
for(i in shapes)
this._shapes = {};
var child;
clear: function() {
this.removeAllShapes();
if(shapes)
for(i in shapes)
if(shape)
return shape;
return val;
_shapeClass: {
return shape;
method();
this._redraw();
_getDocFrag: function()
if(!this._frag)
return this._frag;
_redraw: function()
this._contentNode.setAttribute("viewBox", "" + box.left + " " + box.top + " " + box.width + " " + box.height + "");
if(this._frag)
this._frag = null;
var shapeBox,
box;
this._redraw();
_getUpdatedContentBounds: function()
var bounds,
box = {
for(i in queue)
return box;
_createGraphics: function() {
return contentNode;
return node;
if(!this._defs)
return gradient;