VMLGraphic.js revision e1d9c39d1eb1062e5c99cf8994b981636d8841cc
09688ec5ffb8b9cf9883a770e2f9ebd60b28888dTripp/**
09688ec5ffb8b9cf9883a770e2f9ebd60b28888dTripp * <a href="http://www.w3.org/TR/NOTE-VML">VML</a> implementation of the <a href="Graphic.html">`Graphic`</a> class.
09688ec5ffb8b9cf9883a770e2f9ebd60b28888dTripp * `VMLGraphic` is not intended to be used directly. Instead, use the <a href="Graphic.html">`Graphic`</a> class.
09688ec5ffb8b9cf9883a770e2f9ebd60b28888dTripp * If the browser lacks <a href="http://www.w3.org/TR/SVG/">SVG</a> and <a href="http://www.w3.org/TR/html5/the-canvas-element.html">Canvas</a>
09688ec5ffb8b9cf9883a770e2f9ebd60b28888dTripp * capabilities, the <a href="Graphic.html">`Graphic`</a> class will point to the `VMLGraphic` class.
09688ec5ffb8b9cf9883a770e2f9ebd60b28888dTripp *
4ef2f7e4cb7c7d255be077c47d542199f7bf8607Tripp * @module graphics
a89ad754cce3cfc8aee71760e10217b54020360dTripp * @class VMLGraphic
a89ad754cce3cfc8aee71760e10217b54020360dTripp * @constructor
a89ad754cce3cfc8aee71760e10217b54020360dTripp */
a89ad754cce3cfc8aee71760e10217b54020360dTrippVMLGraphic = function() {
a89ad754cce3cfc8aee71760e10217b54020360dTripp VMLGraphic.superclass.constructor.apply(this, arguments);
a89ad754cce3cfc8aee71760e10217b54020360dTripp};
a89ad754cce3cfc8aee71760e10217b54020360dTripp
c7ba96d16d58075a9ab8d5c1e46c6c83ce11cb4eTrippVMLGraphic.NAME = "vmlGraphic";
c7ba96d16d58075a9ab8d5c1e46c6c83ce11cb4eTripp
c7ba96d16d58075a9ab8d5c1e46c6c83ce11cb4eTrippVMLGraphic.ATTRS = {
c7ba96d16d58075a9ab8d5c1e46c6c83ce11cb4eTripp /**
c7ba96d16d58075a9ab8d5c1e46c6c83ce11cb4eTripp * Whether or not to render the `Graphic` automatically after to a specified parent node after init. This can be a Node instance or a CSS selector string.
c7ba96d16d58075a9ab8d5c1e46c6c83ce11cb4eTripp *
c7ba96d16d58075a9ab8d5c1e46c6c83ce11cb4eTripp * @config render
c7ba96d16d58075a9ab8d5c1e46c6c83ce11cb4eTripp * @type Node | String
c7ba96d16d58075a9ab8d5c1e46c6c83ce11cb4eTripp */
c7ba96d16d58075a9ab8d5c1e46c6c83ce11cb4eTripp render: {},
c7ba96d16d58075a9ab8d5c1e46c6c83ce11cb4eTripp
c7ba96d16d58075a9ab8d5c1e46c6c83ce11cb4eTripp /**
c7ba96d16d58075a9ab8d5c1e46c6c83ce11cb4eTripp * Unique id for class instance.
c7ba96d16d58075a9ab8d5c1e46c6c83ce11cb4eTripp *
c7ba96d16d58075a9ab8d5c1e46c6c83ce11cb4eTripp * @config id
c7ba96d16d58075a9ab8d5c1e46c6c83ce11cb4eTripp * @type String
c7ba96d16d58075a9ab8d5c1e46c6c83ce11cb4eTripp */
c7ba96d16d58075a9ab8d5c1e46c6c83ce11cb4eTripp id: {
c7ba96d16d58075a9ab8d5c1e46c6c83ce11cb4eTripp valueFn: function()
c7ba96d16d58075a9ab8d5c1e46c6c83ce11cb4eTripp {
c7ba96d16d58075a9ab8d5c1e46c6c83ce11cb4eTripp return Y.guid();
c7ba96d16d58075a9ab8d5c1e46c6c83ce11cb4eTripp },
c7ba96d16d58075a9ab8d5c1e46c6c83ce11cb4eTripp
a89ad754cce3cfc8aee71760e10217b54020360dTripp setter: function(val)
a89ad754cce3cfc8aee71760e10217b54020360dTripp {
a89ad754cce3cfc8aee71760e10217b54020360dTripp var node = this._node;
a89ad754cce3cfc8aee71760e10217b54020360dTripp if(node)
a89ad754cce3cfc8aee71760e10217b54020360dTripp {
a89ad754cce3cfc8aee71760e10217b54020360dTripp node.setAttribute("id", val);
a89ad754cce3cfc8aee71760e10217b54020360dTripp }
a89ad754cce3cfc8aee71760e10217b54020360dTripp return val;
a89ad754cce3cfc8aee71760e10217b54020360dTripp }
a89ad754cce3cfc8aee71760e10217b54020360dTripp },
a89ad754cce3cfc8aee71760e10217b54020360dTripp
a89ad754cce3cfc8aee71760e10217b54020360dTripp /**
a89ad754cce3cfc8aee71760e10217b54020360dTripp * Key value pairs in which a shape instance is associated with its id.
a89ad754cce3cfc8aee71760e10217b54020360dTripp *
a89ad754cce3cfc8aee71760e10217b54020360dTripp * @config shapes
a89ad754cce3cfc8aee71760e10217b54020360dTripp * @type Object
a89ad754cce3cfc8aee71760e10217b54020360dTripp * @readOnly
a89ad754cce3cfc8aee71760e10217b54020360dTripp */
a89ad754cce3cfc8aee71760e10217b54020360dTripp shapes: {
a89ad754cce3cfc8aee71760e10217b54020360dTripp readOnly: true,
7947db4b7d8682ea81598e3a4283e659a8103be6Tripp
a89ad754cce3cfc8aee71760e10217b54020360dTripp getter: function()
a89ad754cce3cfc8aee71760e10217b54020360dTripp {
a89ad754cce3cfc8aee71760e10217b54020360dTripp return this._shapes;
7947db4b7d8682ea81598e3a4283e659a8103be6Tripp }
a89ad754cce3cfc8aee71760e10217b54020360dTripp },
a89ad754cce3cfc8aee71760e10217b54020360dTripp
a89ad754cce3cfc8aee71760e10217b54020360dTripp /**
a89ad754cce3cfc8aee71760e10217b54020360dTripp * Object containing size and coordinate data for the content of a Graphic in relation to the coordSpace node.
7947db4b7d8682ea81598e3a4283e659a8103be6Tripp *
a89ad754cce3cfc8aee71760e10217b54020360dTripp * @config contentBounds
a89ad754cce3cfc8aee71760e10217b54020360dTripp * @type Object
a89ad754cce3cfc8aee71760e10217b54020360dTripp */
a89ad754cce3cfc8aee71760e10217b54020360dTripp contentBounds: {
a89ad754cce3cfc8aee71760e10217b54020360dTripp readOnly: true,
a89ad754cce3cfc8aee71760e10217b54020360dTripp
c7ba96d16d58075a9ab8d5c1e46c6c83ce11cb4eTripp getter: function()
a89ad754cce3cfc8aee71760e10217b54020360dTripp {
a89ad754cce3cfc8aee71760e10217b54020360dTripp return this._contentBounds;
a89ad754cce3cfc8aee71760e10217b54020360dTripp }
c7ba96d16d58075a9ab8d5c1e46c6c83ce11cb4eTripp },
a89ad754cce3cfc8aee71760e10217b54020360dTripp
a89ad754cce3cfc8aee71760e10217b54020360dTripp /**
a89ad754cce3cfc8aee71760e10217b54020360dTripp * The html element that represents to coordinate system of the Graphic instance.
a89ad754cce3cfc8aee71760e10217b54020360dTripp *
c7ba96d16d58075a9ab8d5c1e46c6c83ce11cb4eTripp * @config node
a89ad754cce3cfc8aee71760e10217b54020360dTripp * @type HTMLElement
a89ad754cce3cfc8aee71760e10217b54020360dTripp */
09688ec5ffb8b9cf9883a770e2f9ebd60b28888dTripp node: {
7947db4b7d8682ea81598e3a4283e659a8103be6Tripp readOnly: true,
7947db4b7d8682ea81598e3a4283e659a8103be6Tripp
7947db4b7d8682ea81598e3a4283e659a8103be6Tripp getter: function()
c7ba96d16d58075a9ab8d5c1e46c6c83ce11cb4eTripp {
7947db4b7d8682ea81598e3a4283e659a8103be6Tripp return this._node;
7947db4b7d8682ea81598e3a4283e659a8103be6Tripp }
7947db4b7d8682ea81598e3a4283e659a8103be6Tripp },
7947db4b7d8682ea81598e3a4283e659a8103be6Tripp
7947db4b7d8682ea81598e3a4283e659a8103be6Tripp /**
7947db4b7d8682ea81598e3a4283e659a8103be6Tripp * Indicates the width of the `Graphic`.
7947db4b7d8682ea81598e3a4283e659a8103be6Tripp *
c7ba96d16d58075a9ab8d5c1e46c6c83ce11cb4eTripp * @config width
c7ba96d16d58075a9ab8d5c1e46c6c83ce11cb4eTripp * @type Number
c7ba96d16d58075a9ab8d5c1e46c6c83ce11cb4eTripp */
c7ba96d16d58075a9ab8d5c1e46c6c83ce11cb4eTripp width: {
c7ba96d16d58075a9ab8d5c1e46c6c83ce11cb4eTripp setter: function(val)
c7ba96d16d58075a9ab8d5c1e46c6c83ce11cb4eTripp {
c7ba96d16d58075a9ab8d5c1e46c6c83ce11cb4eTripp if(this._node)
c7ba96d16d58075a9ab8d5c1e46c6c83ce11cb4eTripp {
c7ba96d16d58075a9ab8d5c1e46c6c83ce11cb4eTripp this._node.style.width = val + "px";
c7ba96d16d58075a9ab8d5c1e46c6c83ce11cb4eTripp }
c7ba96d16d58075a9ab8d5c1e46c6c83ce11cb4eTripp return val;
c7ba96d16d58075a9ab8d5c1e46c6c83ce11cb4eTripp }
c7ba96d16d58075a9ab8d5c1e46c6c83ce11cb4eTripp },
c7ba96d16d58075a9ab8d5c1e46c6c83ce11cb4eTripp
c7ba96d16d58075a9ab8d5c1e46c6c83ce11cb4eTripp /**
c7ba96d16d58075a9ab8d5c1e46c6c83ce11cb4eTripp * Indicates the height of the `Graphic`.
c7ba96d16d58075a9ab8d5c1e46c6c83ce11cb4eTripp *
c7ba96d16d58075a9ab8d5c1e46c6c83ce11cb4eTripp * @config height
c7ba96d16d58075a9ab8d5c1e46c6c83ce11cb4eTripp * @type Number
c7ba96d16d58075a9ab8d5c1e46c6c83ce11cb4eTripp */
c7ba96d16d58075a9ab8d5c1e46c6c83ce11cb4eTripp height: {
c7ba96d16d58075a9ab8d5c1e46c6c83ce11cb4eTripp setter: function(val)
c7ba96d16d58075a9ab8d5c1e46c6c83ce11cb4eTripp {
c7ba96d16d58075a9ab8d5c1e46c6c83ce11cb4eTripp if(this._node)
c7ba96d16d58075a9ab8d5c1e46c6c83ce11cb4eTripp {
c7ba96d16d58075a9ab8d5c1e46c6c83ce11cb4eTripp this._node.style.height = val + "px";
c7ba96d16d58075a9ab8d5c1e46c6c83ce11cb4eTripp }
c7ba96d16d58075a9ab8d5c1e46c6c83ce11cb4eTripp return val;
c7ba96d16d58075a9ab8d5c1e46c6c83ce11cb4eTripp }
c7ba96d16d58075a9ab8d5c1e46c6c83ce11cb4eTripp },
c7ba96d16d58075a9ab8d5c1e46c6c83ce11cb4eTripp
c7ba96d16d58075a9ab8d5c1e46c6c83ce11cb4eTripp /**
c7ba96d16d58075a9ab8d5c1e46c6c83ce11cb4eTripp * Determines how the size of instance is calculated. If true, the width and height are determined by the size of the contents.
c7ba96d16d58075a9ab8d5c1e46c6c83ce11cb4eTripp * If false, the width and height values are either explicitly set or determined by the size of the parent node's dimensions.
c7ba96d16d58075a9ab8d5c1e46c6c83ce11cb4eTripp *
c7ba96d16d58075a9ab8d5c1e46c6c83ce11cb4eTripp * @config autoSize
c7ba96d16d58075a9ab8d5c1e46c6c83ce11cb4eTripp * @type Boolean
c7ba96d16d58075a9ab8d5c1e46c6c83ce11cb4eTripp * @default false
c7ba96d16d58075a9ab8d5c1e46c6c83ce11cb4eTripp */
c7ba96d16d58075a9ab8d5c1e46c6c83ce11cb4eTripp autoSize: {
c7ba96d16d58075a9ab8d5c1e46c6c83ce11cb4eTripp value: false
c7ba96d16d58075a9ab8d5c1e46c6c83ce11cb4eTripp },
c7ba96d16d58075a9ab8d5c1e46c6c83ce11cb4eTripp
c7ba96d16d58075a9ab8d5c1e46c6c83ce11cb4eTripp /**
c7ba96d16d58075a9ab8d5c1e46c6c83ce11cb4eTripp * The contentBounds will resize to greater values but not values. (for performance)
c7ba96d16d58075a9ab8d5c1e46c6c83ce11cb4eTripp * When resizing the contentBounds down is desirable, set the resizeDown value to true.
c7ba96d16d58075a9ab8d5c1e46c6c83ce11cb4eTripp *
c7ba96d16d58075a9ab8d5c1e46c6c83ce11cb4eTripp * @config resizeDown
c7ba96d16d58075a9ab8d5c1e46c6c83ce11cb4eTripp * @type Boolean
c7ba96d16d58075a9ab8d5c1e46c6c83ce11cb4eTripp */
c7ba96d16d58075a9ab8d5c1e46c6c83ce11cb4eTripp resizeDown: {
c7ba96d16d58075a9ab8d5c1e46c6c83ce11cb4eTripp getter: function()
c7ba96d16d58075a9ab8d5c1e46c6c83ce11cb4eTripp {
c7ba96d16d58075a9ab8d5c1e46c6c83ce11cb4eTripp return this._resizeDown;
c7ba96d16d58075a9ab8d5c1e46c6c83ce11cb4eTripp },
c7ba96d16d58075a9ab8d5c1e46c6c83ce11cb4eTripp
c7ba96d16d58075a9ab8d5c1e46c6c83ce11cb4eTripp setter: function(val)
c7ba96d16d58075a9ab8d5c1e46c6c83ce11cb4eTripp {
c7ba96d16d58075a9ab8d5c1e46c6c83ce11cb4eTripp this._resizeDown = val;
c7ba96d16d58075a9ab8d5c1e46c6c83ce11cb4eTripp if(this._node)
c7ba96d16d58075a9ab8d5c1e46c6c83ce11cb4eTripp {
c7ba96d16d58075a9ab8d5c1e46c6c83ce11cb4eTripp this._redraw();
c7ba96d16d58075a9ab8d5c1e46c6c83ce11cb4eTripp }
c7ba96d16d58075a9ab8d5c1e46c6c83ce11cb4eTripp return val;
c7ba96d16d58075a9ab8d5c1e46c6c83ce11cb4eTripp }
c7ba96d16d58075a9ab8d5c1e46c6c83ce11cb4eTripp },
c7ba96d16d58075a9ab8d5c1e46c6c83ce11cb4eTripp
c7ba96d16d58075a9ab8d5c1e46c6c83ce11cb4eTripp /**
c7ba96d16d58075a9ab8d5c1e46c6c83ce11cb4eTripp * Indicates the x-coordinate for the instance.
c7ba96d16d58075a9ab8d5c1e46c6c83ce11cb4eTripp *
c7ba96d16d58075a9ab8d5c1e46c6c83ce11cb4eTripp * @config x
c7ba96d16d58075a9ab8d5c1e46c6c83ce11cb4eTripp * @type Number
c7ba96d16d58075a9ab8d5c1e46c6c83ce11cb4eTripp */
c7ba96d16d58075a9ab8d5c1e46c6c83ce11cb4eTripp x: {
c7ba96d16d58075a9ab8d5c1e46c6c83ce11cb4eTripp getter: function()
c7ba96d16d58075a9ab8d5c1e46c6c83ce11cb4eTripp {
c7ba96d16d58075a9ab8d5c1e46c6c83ce11cb4eTripp return this._x;
c7ba96d16d58075a9ab8d5c1e46c6c83ce11cb4eTripp },
c7ba96d16d58075a9ab8d5c1e46c6c83ce11cb4eTripp
c7ba96d16d58075a9ab8d5c1e46c6c83ce11cb4eTripp setter: function(val)
7947db4b7d8682ea81598e3a4283e659a8103be6Tripp {
7947db4b7d8682ea81598e3a4283e659a8103be6Tripp this._x = val;
7947db4b7d8682ea81598e3a4283e659a8103be6Tripp if(this._node)
7947db4b7d8682ea81598e3a4283e659a8103be6Tripp {
c7ba96d16d58075a9ab8d5c1e46c6c83ce11cb4eTripp this._node.style.left = val + "px";
c7ba96d16d58075a9ab8d5c1e46c6c83ce11cb4eTripp }
c7ba96d16d58075a9ab8d5c1e46c6c83ce11cb4eTripp return val;
c7ba96d16d58075a9ab8d5c1e46c6c83ce11cb4eTripp }
c7ba96d16d58075a9ab8d5c1e46c6c83ce11cb4eTripp },
c7ba96d16d58075a9ab8d5c1e46c6c83ce11cb4eTripp
c7ba96d16d58075a9ab8d5c1e46c6c83ce11cb4eTripp /**
c7ba96d16d58075a9ab8d5c1e46c6c83ce11cb4eTripp * Indicates the y-coordinate for the instance.
c7ba96d16d58075a9ab8d5c1e46c6c83ce11cb4eTripp *
c7ba96d16d58075a9ab8d5c1e46c6c83ce11cb4eTripp * @config y
c7ba96d16d58075a9ab8d5c1e46c6c83ce11cb4eTripp * @type Number
c7ba96d16d58075a9ab8d5c1e46c6c83ce11cb4eTripp */
c7ba96d16d58075a9ab8d5c1e46c6c83ce11cb4eTripp y: {
7947db4b7d8682ea81598e3a4283e659a8103be6Tripp getter: function()
7947db4b7d8682ea81598e3a4283e659a8103be6Tripp {
7947db4b7d8682ea81598e3a4283e659a8103be6Tripp return this._y;
7947db4b7d8682ea81598e3a4283e659a8103be6Tripp },
7947db4b7d8682ea81598e3a4283e659a8103be6Tripp
7947db4b7d8682ea81598e3a4283e659a8103be6Tripp setter: function(val)
7947db4b7d8682ea81598e3a4283e659a8103be6Tripp {
7947db4b7d8682ea81598e3a4283e659a8103be6Tripp this._y = val;
7947db4b7d8682ea81598e3a4283e659a8103be6Tripp if(this._node)
7947db4b7d8682ea81598e3a4283e659a8103be6Tripp {
a89ad754cce3cfc8aee71760e10217b54020360dTripp this._node.style.top = val + "px";
a89ad754cce3cfc8aee71760e10217b54020360dTripp }
a89ad754cce3cfc8aee71760e10217b54020360dTripp return val;
a89ad754cce3cfc8aee71760e10217b54020360dTripp }
a89ad754cce3cfc8aee71760e10217b54020360dTripp },
a89ad754cce3cfc8aee71760e10217b54020360dTripp
a89ad754cce3cfc8aee71760e10217b54020360dTripp /**
a89ad754cce3cfc8aee71760e10217b54020360dTripp * Indicates whether or not the instance will automatically redraw after a change is made to a shape.
a89ad754cce3cfc8aee71760e10217b54020360dTripp * This property will get set to false when batching operations.
a89ad754cce3cfc8aee71760e10217b54020360dTripp *
09688ec5ffb8b9cf9883a770e2f9ebd60b28888dTripp * @config autoDraw
a89ad754cce3cfc8aee71760e10217b54020360dTripp * @type Boolean
09688ec5ffb8b9cf9883a770e2f9ebd60b28888dTripp * @default true
c7ba96d16d58075a9ab8d5c1e46c6c83ce11cb4eTripp * @private
c7ba96d16d58075a9ab8d5c1e46c6c83ce11cb4eTripp */
c7ba96d16d58075a9ab8d5c1e46c6c83ce11cb4eTripp autoDraw: {
c7ba96d16d58075a9ab8d5c1e46c6c83ce11cb4eTripp value: true
c7ba96d16d58075a9ab8d5c1e46c6c83ce11cb4eTripp },
c7ba96d16d58075a9ab8d5c1e46c6c83ce11cb4eTripp
c7ba96d16d58075a9ab8d5c1e46c6c83ce11cb4eTripp visible: {
c7ba96d16d58075a9ab8d5c1e46c6c83ce11cb4eTripp value: true,
c7ba96d16d58075a9ab8d5c1e46c6c83ce11cb4eTripp
c7ba96d16d58075a9ab8d5c1e46c6c83ce11cb4eTripp setter: function(val)
c7ba96d16d58075a9ab8d5c1e46c6c83ce11cb4eTripp {
09688ec5ffb8b9cf9883a770e2f9ebd60b28888dTripp this._toggleVisible(val);
09688ec5ffb8b9cf9883a770e2f9ebd60b28888dTripp return val;
09688ec5ffb8b9cf9883a770e2f9ebd60b28888dTripp }
09688ec5ffb8b9cf9883a770e2f9ebd60b28888dTripp }
09688ec5ffb8b9cf9883a770e2f9ebd60b28888dTripp};
09688ec5ffb8b9cf9883a770e2f9ebd60b28888dTripp
c7ba96d16d58075a9ab8d5c1e46c6c83ce11cb4eTrippY.extend(VMLGraphic, Y.BaseGraphic, {
c7ba96d16d58075a9ab8d5c1e46c6c83ce11cb4eTripp /**
c7ba96d16d58075a9ab8d5c1e46c6c83ce11cb4eTripp * Storage for `x` attribute.
09688ec5ffb8b9cf9883a770e2f9ebd60b28888dTripp *
c7ba96d16d58075a9ab8d5c1e46c6c83ce11cb4eTripp * @property _x
09688ec5ffb8b9cf9883a770e2f9ebd60b28888dTripp * @type Number
c7ba96d16d58075a9ab8d5c1e46c6c83ce11cb4eTripp * @private
09688ec5ffb8b9cf9883a770e2f9ebd60b28888dTripp */
09688ec5ffb8b9cf9883a770e2f9ebd60b28888dTripp _x: 0,
09688ec5ffb8b9cf9883a770e2f9ebd60b28888dTripp
a89ad754cce3cfc8aee71760e10217b54020360dTripp /**
c7ba96d16d58075a9ab8d5c1e46c6c83ce11cb4eTripp * Storage for `y` attribute.
c7ba96d16d58075a9ab8d5c1e46c6c83ce11cb4eTripp *
09688ec5ffb8b9cf9883a770e2f9ebd60b28888dTripp * @property _y
c7ba96d16d58075a9ab8d5c1e46c6c83ce11cb4eTripp * @type Number
09688ec5ffb8b9cf9883a770e2f9ebd60b28888dTripp * @private
09688ec5ffb8b9cf9883a770e2f9ebd60b28888dTripp */
09688ec5ffb8b9cf9883a770e2f9ebd60b28888dTripp _y: 0,
09688ec5ffb8b9cf9883a770e2f9ebd60b28888dTripp
09688ec5ffb8b9cf9883a770e2f9ebd60b28888dTripp /**
09688ec5ffb8b9cf9883a770e2f9ebd60b28888dTripp * Gets the current position of the graphic instance in page coordinates.
09688ec5ffb8b9cf9883a770e2f9ebd60b28888dTripp *
a89ad754cce3cfc8aee71760e10217b54020360dTripp * @method getXY
a89ad754cce3cfc8aee71760e10217b54020360dTripp * @return Array The XY position of the shape.
09688ec5ffb8b9cf9883a770e2f9ebd60b28888dTripp */
7947db4b7d8682ea81598e3a4283e659a8103be6Tripp getXY: function()
a89ad754cce3cfc8aee71760e10217b54020360dTripp {
a89ad754cce3cfc8aee71760e10217b54020360dTripp var node = Y.one(this._node),
a89ad754cce3cfc8aee71760e10217b54020360dTripp xy;
a89ad754cce3cfc8aee71760e10217b54020360dTripp if(node)
a89ad754cce3cfc8aee71760e10217b54020360dTripp {
09688ec5ffb8b9cf9883a770e2f9ebd60b28888dTripp xy = node.getXY();
c7ba96d16d58075a9ab8d5c1e46c6c83ce11cb4eTripp }
c7ba96d16d58075a9ab8d5c1e46c6c83ce11cb4eTripp return xy;
c7ba96d16d58075a9ab8d5c1e46c6c83ce11cb4eTripp },
c7ba96d16d58075a9ab8d5c1e46c6c83ce11cb4eTripp
a89ad754cce3cfc8aee71760e10217b54020360dTripp /**
a89ad754cce3cfc8aee71760e10217b54020360dTripp * @private
c7ba96d16d58075a9ab8d5c1e46c6c83ce11cb4eTripp * @property _resizeDown
a89ad754cce3cfc8aee71760e10217b54020360dTripp * @type Boolean
09688ec5ffb8b9cf9883a770e2f9ebd60b28888dTripp */
a89ad754cce3cfc8aee71760e10217b54020360dTripp _resizeDown: false,
09688ec5ffb8b9cf9883a770e2f9ebd60b28888dTripp
09688ec5ffb8b9cf9883a770e2f9ebd60b28888dTripp /**
09688ec5ffb8b9cf9883a770e2f9ebd60b28888dTripp * Initializes the class.
09688ec5ffb8b9cf9883a770e2f9ebd60b28888dTripp *
09688ec5ffb8b9cf9883a770e2f9ebd60b28888dTripp * @method initializer
09688ec5ffb8b9cf9883a770e2f9ebd60b28888dTripp * @private
09688ec5ffb8b9cf9883a770e2f9ebd60b28888dTripp */
09688ec5ffb8b9cf9883a770e2f9ebd60b28888dTripp initializer: function(config) {
09688ec5ffb8b9cf9883a770e2f9ebd60b28888dTripp var render = this.get("render");
09688ec5ffb8b9cf9883a770e2f9ebd60b28888dTripp this._shapes = {};
09688ec5ffb8b9cf9883a770e2f9ebd60b28888dTripp this._contentBounds = {
a89ad754cce3cfc8aee71760e10217b54020360dTripp left: 0,
a89ad754cce3cfc8aee71760e10217b54020360dTripp top: 0,
a89ad754cce3cfc8aee71760e10217b54020360dTripp right: 0,
c7ba96d16d58075a9ab8d5c1e46c6c83ce11cb4eTripp bottom: 0
a89ad754cce3cfc8aee71760e10217b54020360dTripp };
a89ad754cce3cfc8aee71760e10217b54020360dTripp this._node = this._createGraphic();
a89ad754cce3cfc8aee71760e10217b54020360dTripp this._node.setAttribute("id", this.get("id"));
09688ec5ffb8b9cf9883a770e2f9ebd60b28888dTripp if(render)
09688ec5ffb8b9cf9883a770e2f9ebd60b28888dTripp {
09688ec5ffb8b9cf9883a770e2f9ebd60b28888dTripp this.render(render);
09688ec5ffb8b9cf9883a770e2f9ebd60b28888dTripp }
09688ec5ffb8b9cf9883a770e2f9ebd60b28888dTripp },
c7ba96d16d58075a9ab8d5c1e46c6c83ce11cb4eTripp
09688ec5ffb8b9cf9883a770e2f9ebd60b28888dTripp /**
c7ba96d16d58075a9ab8d5c1e46c6c83ce11cb4eTripp * Adds the graphics node to the dom.
09688ec5ffb8b9cf9883a770e2f9ebd60b28888dTripp *
c7ba96d16d58075a9ab8d5c1e46c6c83ce11cb4eTripp * @method render
c7ba96d16d58075a9ab8d5c1e46c6c83ce11cb4eTripp * @param {HTMLElement} parentNode node in which to render the graphics node into.
c7ba96d16d58075a9ab8d5c1e46c6c83ce11cb4eTripp */
c7ba96d16d58075a9ab8d5c1e46c6c83ce11cb4eTripp render: function(render) {
c7ba96d16d58075a9ab8d5c1e46c6c83ce11cb4eTripp var parentNode = Y.one(render),
c7ba96d16d58075a9ab8d5c1e46c6c83ce11cb4eTripp w = this.get("width") || parseInt(parentNode.getComputedStyle("width"), 10),
c7ba96d16d58075a9ab8d5c1e46c6c83ce11cb4eTripp h = this.get("height") || parseInt(parentNode.getComputedStyle("height"), 10);
c7ba96d16d58075a9ab8d5c1e46c6c83ce11cb4eTripp parentNode = parentNode || DOCUMENT.body;
09688ec5ffb8b9cf9883a770e2f9ebd60b28888dTripp parentNode.appendChild(this._node);
09688ec5ffb8b9cf9883a770e2f9ebd60b28888dTripp this.setSize(w, h);
09688ec5ffb8b9cf9883a770e2f9ebd60b28888dTripp this.parentNode = parentNode;
c7ba96d16d58075a9ab8d5c1e46c6c83ce11cb4eTripp this.set("width", w);
09688ec5ffb8b9cf9883a770e2f9ebd60b28888dTripp this.set("height", h);
c7ba96d16d58075a9ab8d5c1e46c6c83ce11cb4eTripp return this;
c7ba96d16d58075a9ab8d5c1e46c6c83ce11cb4eTripp },
c7ba96d16d58075a9ab8d5c1e46c6c83ce11cb4eTripp
c7ba96d16d58075a9ab8d5c1e46c6c83ce11cb4eTripp /**
09688ec5ffb8b9cf9883a770e2f9ebd60b28888dTripp * Removes all nodes.
c7ba96d16d58075a9ab8d5c1e46c6c83ce11cb4eTripp *
09688ec5ffb8b9cf9883a770e2f9ebd60b28888dTripp * @method destroy
c7ba96d16d58075a9ab8d5c1e46c6c83ce11cb4eTripp */
c7ba96d16d58075a9ab8d5c1e46c6c83ce11cb4eTripp destroy: function()
c7ba96d16d58075a9ab8d5c1e46c6c83ce11cb4eTripp {
c7ba96d16d58075a9ab8d5c1e46c6c83ce11cb4eTripp this.clear();
09688ec5ffb8b9cf9883a770e2f9ebd60b28888dTripp Y.one(this._node).remove(true);
09688ec5ffb8b9cf9883a770e2f9ebd60b28888dTripp },
09688ec5ffb8b9cf9883a770e2f9ebd60b28888dTripp
09688ec5ffb8b9cf9883a770e2f9ebd60b28888dTripp /**
09688ec5ffb8b9cf9883a770e2f9ebd60b28888dTripp * Generates a shape instance by type.
09688ec5ffb8b9cf9883a770e2f9ebd60b28888dTripp *
09688ec5ffb8b9cf9883a770e2f9ebd60b28888dTripp * @method addShape
09688ec5ffb8b9cf9883a770e2f9ebd60b28888dTripp * @param {Object} cfg attributes for the shape
09688ec5ffb8b9cf9883a770e2f9ebd60b28888dTripp * @return Shape
09688ec5ffb8b9cf9883a770e2f9ebd60b28888dTripp */
09688ec5ffb8b9cf9883a770e2f9ebd60b28888dTripp addShape: function(cfg)
a89ad754cce3cfc8aee71760e10217b54020360dTripp {
c7ba96d16d58075a9ab8d5c1e46c6c83ce11cb4eTripp cfg.graphic = this;
c7ba96d16d58075a9ab8d5c1e46c6c83ce11cb4eTripp var shapeClass = this._getShapeClass(cfg.type),
c7ba96d16d58075a9ab8d5c1e46c6c83ce11cb4eTripp shape = new shapeClass(cfg);
c7ba96d16d58075a9ab8d5c1e46c6c83ce11cb4eTripp this._appendShape(shape);
c7ba96d16d58075a9ab8d5c1e46c6c83ce11cb4eTripp return shape;
09688ec5ffb8b9cf9883a770e2f9ebd60b28888dTripp },
c7ba96d16d58075a9ab8d5c1e46c6c83ce11cb4eTripp
a89ad754cce3cfc8aee71760e10217b54020360dTripp /**
a89ad754cce3cfc8aee71760e10217b54020360dTripp * Adds a shape instance to the graphic instance.
a89ad754cce3cfc8aee71760e10217b54020360dTripp *
a89ad754cce3cfc8aee71760e10217b54020360dTripp * @method _appendShape
a89ad754cce3cfc8aee71760e10217b54020360dTripp * @param {Shape} shape The shape instance to be added to the graphic.
a89ad754cce3cfc8aee71760e10217b54020360dTripp * @private
a89ad754cce3cfc8aee71760e10217b54020360dTripp */
a89ad754cce3cfc8aee71760e10217b54020360dTripp _appendShape: function(shape)
a89ad754cce3cfc8aee71760e10217b54020360dTripp {
a89ad754cce3cfc8aee71760e10217b54020360dTripp var node = shape.node,
a89ad754cce3cfc8aee71760e10217b54020360dTripp parentNode = this._frag || this._node;
a89ad754cce3cfc8aee71760e10217b54020360dTripp if(this.get("autoDraw"))
a89ad754cce3cfc8aee71760e10217b54020360dTripp {
a89ad754cce3cfc8aee71760e10217b54020360dTripp parentNode.appendChild(node);
a89ad754cce3cfc8aee71760e10217b54020360dTripp }
a89ad754cce3cfc8aee71760e10217b54020360dTripp else
a89ad754cce3cfc8aee71760e10217b54020360dTripp {
a89ad754cce3cfc8aee71760e10217b54020360dTripp this._getDocFrag().appendChild(node);
a89ad754cce3cfc8aee71760e10217b54020360dTripp }
a89ad754cce3cfc8aee71760e10217b54020360dTripp },
a89ad754cce3cfc8aee71760e10217b54020360dTripp
a89ad754cce3cfc8aee71760e10217b54020360dTripp /**
09688ec5ffb8b9cf9883a770e2f9ebd60b28888dTripp * Removes a shape instance from from the graphic instance.
c7ba96d16d58075a9ab8d5c1e46c6c83ce11cb4eTripp *
09688ec5ffb8b9cf9883a770e2f9ebd60b28888dTripp * @method removeShape
c7ba96d16d58075a9ab8d5c1e46c6c83ce11cb4eTripp * @param {Shape|String} shape The instance or id of the shape to be removed.
09688ec5ffb8b9cf9883a770e2f9ebd60b28888dTripp */
a89ad754cce3cfc8aee71760e10217b54020360dTripp removeShape: function(shape)
09688ec5ffb8b9cf9883a770e2f9ebd60b28888dTripp {
09688ec5ffb8b9cf9883a770e2f9ebd60b28888dTripp if(!shape instanceof VMLShape)
09688ec5ffb8b9cf9883a770e2f9ebd60b28888dTripp {
c7ba96d16d58075a9ab8d5c1e46c6c83ce11cb4eTripp if(Y_LANG.isString(shape))
09688ec5ffb8b9cf9883a770e2f9ebd60b28888dTripp {
c7ba96d16d58075a9ab8d5c1e46c6c83ce11cb4eTripp shape = this._shapes[shape];
09688ec5ffb8b9cf9883a770e2f9ebd60b28888dTripp }
c7ba96d16d58075a9ab8d5c1e46c6c83ce11cb4eTripp }
09688ec5ffb8b9cf9883a770e2f9ebd60b28888dTripp if(shape && shape instanceof VMLShape)
c7ba96d16d58075a9ab8d5c1e46c6c83ce11cb4eTripp {
c7ba96d16d58075a9ab8d5c1e46c6c83ce11cb4eTripp shape._destroy();
c7ba96d16d58075a9ab8d5c1e46c6c83ce11cb4eTripp this._shapes[shape.get("id")] = null;
c7ba96d16d58075a9ab8d5c1e46c6c83ce11cb4eTripp delete this._shapes[shape.get("id")];
c7ba96d16d58075a9ab8d5c1e46c6c83ce11cb4eTripp }
c7ba96d16d58075a9ab8d5c1e46c6c83ce11cb4eTripp if(this.get("autoDraw"))
c7ba96d16d58075a9ab8d5c1e46c6c83ce11cb4eTripp {
c7ba96d16d58075a9ab8d5c1e46c6c83ce11cb4eTripp this._redraw();
c7ba96d16d58075a9ab8d5c1e46c6c83ce11cb4eTripp }
c7ba96d16d58075a9ab8d5c1e46c6c83ce11cb4eTripp },
c7ba96d16d58075a9ab8d5c1e46c6c83ce11cb4eTripp
c7ba96d16d58075a9ab8d5c1e46c6c83ce11cb4eTripp /**
c7ba96d16d58075a9ab8d5c1e46c6c83ce11cb4eTripp * Removes all shape instances from the dom.
c7ba96d16d58075a9ab8d5c1e46c6c83ce11cb4eTripp *
c7ba96d16d58075a9ab8d5c1e46c6c83ce11cb4eTripp * @method removeAllShapes
c7ba96d16d58075a9ab8d5c1e46c6c83ce11cb4eTripp */
c7ba96d16d58075a9ab8d5c1e46c6c83ce11cb4eTripp removeAllShapes: function()
c7ba96d16d58075a9ab8d5c1e46c6c83ce11cb4eTripp {
c7ba96d16d58075a9ab8d5c1e46c6c83ce11cb4eTripp var shapes = this._shapes,
c7ba96d16d58075a9ab8d5c1e46c6c83ce11cb4eTripp i;
c7ba96d16d58075a9ab8d5c1e46c6c83ce11cb4eTripp for(i in shapes)
c7ba96d16d58075a9ab8d5c1e46c6c83ce11cb4eTripp {
c7ba96d16d58075a9ab8d5c1e46c6c83ce11cb4eTripp if(shapes.hasOwnProperty(i))
c7ba96d16d58075a9ab8d5c1e46c6c83ce11cb4eTripp {
c7ba96d16d58075a9ab8d5c1e46c6c83ce11cb4eTripp shapes[i].destroy();
c7ba96d16d58075a9ab8d5c1e46c6c83ce11cb4eTripp }
c7ba96d16d58075a9ab8d5c1e46c6c83ce11cb4eTripp }
c7ba96d16d58075a9ab8d5c1e46c6c83ce11cb4eTripp this._shapes = {};
c7ba96d16d58075a9ab8d5c1e46c6c83ce11cb4eTripp },
c7ba96d16d58075a9ab8d5c1e46c6c83ce11cb4eTripp
c7ba96d16d58075a9ab8d5c1e46c6c83ce11cb4eTripp /**
09688ec5ffb8b9cf9883a770e2f9ebd60b28888dTripp * Removes all child nodes.
09688ec5ffb8b9cf9883a770e2f9ebd60b28888dTripp *
09688ec5ffb8b9cf9883a770e2f9ebd60b28888dTripp * @method _removeChildren
c7ba96d16d58075a9ab8d5c1e46c6c83ce11cb4eTripp * @param node
09688ec5ffb8b9cf9883a770e2f9ebd60b28888dTripp * @private
c7ba96d16d58075a9ab8d5c1e46c6c83ce11cb4eTripp */
09688ec5ffb8b9cf9883a770e2f9ebd60b28888dTripp _removeChildren: function(node)
c7ba96d16d58075a9ab8d5c1e46c6c83ce11cb4eTripp {
c7ba96d16d58075a9ab8d5c1e46c6c83ce11cb4eTripp if(node.hasChildNodes())
c7ba96d16d58075a9ab8d5c1e46c6c83ce11cb4eTripp {
c7ba96d16d58075a9ab8d5c1e46c6c83ce11cb4eTripp var child;
c7ba96d16d58075a9ab8d5c1e46c6c83ce11cb4eTripp while(node.firstChild)
c7ba96d16d58075a9ab8d5c1e46c6c83ce11cb4eTripp {
c7ba96d16d58075a9ab8d5c1e46c6c83ce11cb4eTripp child = node.firstChild;
c7ba96d16d58075a9ab8d5c1e46c6c83ce11cb4eTripp this._removeChildren(child);
c7ba96d16d58075a9ab8d5c1e46c6c83ce11cb4eTripp node.removeChild(child);
c7ba96d16d58075a9ab8d5c1e46c6c83ce11cb4eTripp }
c7ba96d16d58075a9ab8d5c1e46c6c83ce11cb4eTripp }
c7ba96d16d58075a9ab8d5c1e46c6c83ce11cb4eTripp },
c7ba96d16d58075a9ab8d5c1e46c6c83ce11cb4eTripp
c7ba96d16d58075a9ab8d5c1e46c6c83ce11cb4eTripp /**
c7ba96d16d58075a9ab8d5c1e46c6c83ce11cb4eTripp * Clears the graphics object.
c7ba96d16d58075a9ab8d5c1e46c6c83ce11cb4eTripp *
c7ba96d16d58075a9ab8d5c1e46c6c83ce11cb4eTripp * @method clear
c7ba96d16d58075a9ab8d5c1e46c6c83ce11cb4eTripp */
c7ba96d16d58075a9ab8d5c1e46c6c83ce11cb4eTripp clear: function() {
c7ba96d16d58075a9ab8d5c1e46c6c83ce11cb4eTripp this.removeAllShapes();
c7ba96d16d58075a9ab8d5c1e46c6c83ce11cb4eTripp this._removeChildren(this._node);
c7ba96d16d58075a9ab8d5c1e46c6c83ce11cb4eTripp },
c7ba96d16d58075a9ab8d5c1e46c6c83ce11cb4eTripp
c7ba96d16d58075a9ab8d5c1e46c6c83ce11cb4eTripp /**
c7ba96d16d58075a9ab8d5c1e46c6c83ce11cb4eTripp * Toggles visibility
c7ba96d16d58075a9ab8d5c1e46c6c83ce11cb4eTripp *
c7ba96d16d58075a9ab8d5c1e46c6c83ce11cb4eTripp * @method _toggleVisible
c7ba96d16d58075a9ab8d5c1e46c6c83ce11cb4eTripp * @param {Boolean} val indicates visibilitye
c7ba96d16d58075a9ab8d5c1e46c6c83ce11cb4eTripp * @private
c7ba96d16d58075a9ab8d5c1e46c6c83ce11cb4eTripp */
09688ec5ffb8b9cf9883a770e2f9ebd60b28888dTripp _toggleVisible: function(val)
09688ec5ffb8b9cf9883a770e2f9ebd60b28888dTripp {
09688ec5ffb8b9cf9883a770e2f9ebd60b28888dTripp var i,
09688ec5ffb8b9cf9883a770e2f9ebd60b28888dTripp shapes = this._shapes,
09688ec5ffb8b9cf9883a770e2f9ebd60b28888dTripp visibility = val ? "visible" : "hidden";
09688ec5ffb8b9cf9883a770e2f9ebd60b28888dTripp if(shapes)
09688ec5ffb8b9cf9883a770e2f9ebd60b28888dTripp {
09688ec5ffb8b9cf9883a770e2f9ebd60b28888dTripp for(i in shapes)
09688ec5ffb8b9cf9883a770e2f9ebd60b28888dTripp {
09688ec5ffb8b9cf9883a770e2f9ebd60b28888dTripp if(shapes.hasOwnProperty(i))
09688ec5ffb8b9cf9883a770e2f9ebd60b28888dTripp {
09688ec5ffb8b9cf9883a770e2f9ebd60b28888dTripp shapes[i].set("visible", val);
09688ec5ffb8b9cf9883a770e2f9ebd60b28888dTripp }
09688ec5ffb8b9cf9883a770e2f9ebd60b28888dTripp }
09688ec5ffb8b9cf9883a770e2f9ebd60b28888dTripp }
09688ec5ffb8b9cf9883a770e2f9ebd60b28888dTripp this._node.style.visibility = visibility;
09688ec5ffb8b9cf9883a770e2f9ebd60b28888dTripp },
09688ec5ffb8b9cf9883a770e2f9ebd60b28888dTripp
09688ec5ffb8b9cf9883a770e2f9ebd60b28888dTripp /**
09688ec5ffb8b9cf9883a770e2f9ebd60b28888dTripp * Sets the size of the graphics object.
09688ec5ffb8b9cf9883a770e2f9ebd60b28888dTripp *
09688ec5ffb8b9cf9883a770e2f9ebd60b28888dTripp * @method setSize
09688ec5ffb8b9cf9883a770e2f9ebd60b28888dTripp * @param w {Number} width to set for the instance.
09688ec5ffb8b9cf9883a770e2f9ebd60b28888dTripp * @param h {Number} height to set for the instance.
09688ec5ffb8b9cf9883a770e2f9ebd60b28888dTripp */
9eaaa502227248d304ac9170902697d02158c1d9Tripp setSize: function(w, h) {
9eaaa502227248d304ac9170902697d02158c1d9Tripp w = Math.round(w);
9eaaa502227248d304ac9170902697d02158c1d9Tripp h = Math.round(h);
9eaaa502227248d304ac9170902697d02158c1d9Tripp this._node.style.width = w + 'px';
9eaaa502227248d304ac9170902697d02158c1d9Tripp this._node.style.height = h + 'px';
09688ec5ffb8b9cf9883a770e2f9ebd60b28888dTripp this._node.coordSize = w + ' ' + h;
09688ec5ffb8b9cf9883a770e2f9ebd60b28888dTripp },
4ef2f7e4cb7c7d255be077c47d542199f7bf8607Tripp
c7ba96d16d58075a9ab8d5c1e46c6c83ce11cb4eTripp /**
09688ec5ffb8b9cf9883a770e2f9ebd60b28888dTripp * Sets the positon of the graphics object.
c7ba96d16d58075a9ab8d5c1e46c6c83ce11cb4eTripp *
c7ba96d16d58075a9ab8d5c1e46c6c83ce11cb4eTripp * @method setPosition
c7ba96d16d58075a9ab8d5c1e46c6c83ce11cb4eTripp * @param {Number} x x-coordinate for the object.
c7ba96d16d58075a9ab8d5c1e46c6c83ce11cb4eTripp * @param {Number} y y-coordinate for the object.
c7ba96d16d58075a9ab8d5c1e46c6c83ce11cb4eTripp */
c7ba96d16d58075a9ab8d5c1e46c6c83ce11cb4eTripp setPosition: function(x, y)
c7ba96d16d58075a9ab8d5c1e46c6c83ce11cb4eTripp {
c7ba96d16d58075a9ab8d5c1e46c6c83ce11cb4eTripp x = Math.round(x);
c7ba96d16d58075a9ab8d5c1e46c6c83ce11cb4eTripp y = Math.round(y);
c7ba96d16d58075a9ab8d5c1e46c6c83ce11cb4eTripp this._node.style.left = x + "px";
c7ba96d16d58075a9ab8d5c1e46c6c83ce11cb4eTripp this._node.style.top = y + "px";
c7ba96d16d58075a9ab8d5c1e46c6c83ce11cb4eTripp },
c7ba96d16d58075a9ab8d5c1e46c6c83ce11cb4eTripp
c7ba96d16d58075a9ab8d5c1e46c6c83ce11cb4eTripp /**
c7ba96d16d58075a9ab8d5c1e46c6c83ce11cb4eTripp * Creates a group element
c7ba96d16d58075a9ab8d5c1e46c6c83ce11cb4eTripp *
c7ba96d16d58075a9ab8d5c1e46c6c83ce11cb4eTripp * @method _createGraphic
c7ba96d16d58075a9ab8d5c1e46c6c83ce11cb4eTripp * @private
c7ba96d16d58075a9ab8d5c1e46c6c83ce11cb4eTripp */
c7ba96d16d58075a9ab8d5c1e46c6c83ce11cb4eTripp _createGraphic: function() {
c7ba96d16d58075a9ab8d5c1e46c6c83ce11cb4eTripp var group = DOCUMENT.createElement('<group xmlns="urn:schemas-microsft.com:vml" style="behavior:url(#default#VML);display:block;zoom:1;" />');
c7ba96d16d58075a9ab8d5c1e46c6c83ce11cb4eTripp group.style.display = "block";
c7ba96d16d58075a9ab8d5c1e46c6c83ce11cb4eTripp group.style.position = 'absolute';
c7ba96d16d58075a9ab8d5c1e46c6c83ce11cb4eTripp return group;
c7ba96d16d58075a9ab8d5c1e46c6c83ce11cb4eTripp },
c7ba96d16d58075a9ab8d5c1e46c6c83ce11cb4eTripp
c7ba96d16d58075a9ab8d5c1e46c6c83ce11cb4eTripp /**
c7ba96d16d58075a9ab8d5c1e46c6c83ce11cb4eTripp * Creates a graphic node
c7ba96d16d58075a9ab8d5c1e46c6c83ce11cb4eTripp *
c7ba96d16d58075a9ab8d5c1e46c6c83ce11cb4eTripp * @method _createGraphicNode
c7ba96d16d58075a9ab8d5c1e46c6c83ce11cb4eTripp * @param {String} type node type to create
c7ba96d16d58075a9ab8d5c1e46c6c83ce11cb4eTripp * @param {String} pe specified pointer-events value
c7ba96d16d58075a9ab8d5c1e46c6c83ce11cb4eTripp * @return HTMLElement
09688ec5ffb8b9cf9883a770e2f9ebd60b28888dTripp * @private
09688ec5ffb8b9cf9883a770e2f9ebd60b28888dTripp */
09688ec5ffb8b9cf9883a770e2f9ebd60b28888dTripp _createGraphicNode: function(type)
c7ba96d16d58075a9ab8d5c1e46c6c83ce11cb4eTripp {
09688ec5ffb8b9cf9883a770e2f9ebd60b28888dTripp return DOCUMENT.createElement('<' + type + ' xmlns="urn:schemas-microsft.com:vml" style="behavior:url(#default#VML);display:inline-block;zoom:1;" />');
c7ba96d16d58075a9ab8d5c1e46c6c83ce11cb4eTripp
c7ba96d16d58075a9ab8d5c1e46c6c83ce11cb4eTripp },
09688ec5ffb8b9cf9883a770e2f9ebd60b28888dTripp
c7ba96d16d58075a9ab8d5c1e46c6c83ce11cb4eTripp /**
c7ba96d16d58075a9ab8d5c1e46c6c83ce11cb4eTripp * Returns a shape based on the id of its dom node.
c7ba96d16d58075a9ab8d5c1e46c6c83ce11cb4eTripp *
c7ba96d16d58075a9ab8d5c1e46c6c83ce11cb4eTripp * @method getShapeById
c7ba96d16d58075a9ab8d5c1e46c6c83ce11cb4eTripp * @param {String} id Dom id of the shape's node attribute.
c7ba96d16d58075a9ab8d5c1e46c6c83ce11cb4eTripp * @return Shape
c7ba96d16d58075a9ab8d5c1e46c6c83ce11cb4eTripp */
c7ba96d16d58075a9ab8d5c1e46c6c83ce11cb4eTripp getShapeById: function(id)
c7ba96d16d58075a9ab8d5c1e46c6c83ce11cb4eTripp {
c7ba96d16d58075a9ab8d5c1e46c6c83ce11cb4eTripp return this._shapes[id];
c7ba96d16d58075a9ab8d5c1e46c6c83ce11cb4eTripp },
c7ba96d16d58075a9ab8d5c1e46c6c83ce11cb4eTripp
c7ba96d16d58075a9ab8d5c1e46c6c83ce11cb4eTripp /**
c7ba96d16d58075a9ab8d5c1e46c6c83ce11cb4eTripp * Returns a shape class. Used by `addShape`.
c7ba96d16d58075a9ab8d5c1e46c6c83ce11cb4eTripp *
c7ba96d16d58075a9ab8d5c1e46c6c83ce11cb4eTripp * @method _getShapeClass
c7ba96d16d58075a9ab8d5c1e46c6c83ce11cb4eTripp * @param {Shape | String} val Indicates which shape class.
c7ba96d16d58075a9ab8d5c1e46c6c83ce11cb4eTripp * @return Function
c7ba96d16d58075a9ab8d5c1e46c6c83ce11cb4eTripp * @private
c7ba96d16d58075a9ab8d5c1e46c6c83ce11cb4eTripp */
c7ba96d16d58075a9ab8d5c1e46c6c83ce11cb4eTripp _getShapeClass: function(val)
c7ba96d16d58075a9ab8d5c1e46c6c83ce11cb4eTripp {
c7ba96d16d58075a9ab8d5c1e46c6c83ce11cb4eTripp var shape = this._shapeClass[val];
c7ba96d16d58075a9ab8d5c1e46c6c83ce11cb4eTripp if(shape)
09688ec5ffb8b9cf9883a770e2f9ebd60b28888dTripp {
09688ec5ffb8b9cf9883a770e2f9ebd60b28888dTripp return shape;
09688ec5ffb8b9cf9883a770e2f9ebd60b28888dTripp }
09688ec5ffb8b9cf9883a770e2f9ebd60b28888dTripp return val;
c7ba96d16d58075a9ab8d5c1e46c6c83ce11cb4eTripp },
c7ba96d16d58075a9ab8d5c1e46c6c83ce11cb4eTripp
c7ba96d16d58075a9ab8d5c1e46c6c83ce11cb4eTripp /**
c7ba96d16d58075a9ab8d5c1e46c6c83ce11cb4eTripp * Look up for shape classes. Used by `addShape` to retrieve a class for instantiation.
c7ba96d16d58075a9ab8d5c1e46c6c83ce11cb4eTripp *
c7ba96d16d58075a9ab8d5c1e46c6c83ce11cb4eTripp * @property _shapeClass
c7ba96d16d58075a9ab8d5c1e46c6c83ce11cb4eTripp * @type Object
09688ec5ffb8b9cf9883a770e2f9ebd60b28888dTripp * @private
09688ec5ffb8b9cf9883a770e2f9ebd60b28888dTripp */
09688ec5ffb8b9cf9883a770e2f9ebd60b28888dTripp _shapeClass: {
09688ec5ffb8b9cf9883a770e2f9ebd60b28888dTripp circle: Y.VMLCircle,
09688ec5ffb8b9cf9883a770e2f9ebd60b28888dTripp rect: Y.VMLRect,
09688ec5ffb8b9cf9883a770e2f9ebd60b28888dTripp path: Y.VMLPath,
c7ba96d16d58075a9ab8d5c1e46c6c83ce11cb4eTripp ellipse: Y.VMLEllipse,
c7ba96d16d58075a9ab8d5c1e46c6c83ce11cb4eTripp pieslice: Y.VMLPieSlice
c7ba96d16d58075a9ab8d5c1e46c6c83ce11cb4eTripp },
c7ba96d16d58075a9ab8d5c1e46c6c83ce11cb4eTripp
09688ec5ffb8b9cf9883a770e2f9ebd60b28888dTripp /**
09688ec5ffb8b9cf9883a770e2f9ebd60b28888dTripp * Allows for creating multiple shapes in order to batch appending and redraw operations.
a89ad754cce3cfc8aee71760e10217b54020360dTripp *
a89ad754cce3cfc8aee71760e10217b54020360dTripp * @method batch
7947db4b7d8682ea81598e3a4283e659a8103be6Tripp * @param {Function} method Method to execute.
c7ba96d16d58075a9ab8d5c1e46c6c83ce11cb4eTripp */
09688ec5ffb8b9cf9883a770e2f9ebd60b28888dTripp batch: function(method)
09688ec5ffb8b9cf9883a770e2f9ebd60b28888dTripp {
09688ec5ffb8b9cf9883a770e2f9ebd60b28888dTripp var autoDraw = this.get("autoDraw");
c7ba96d16d58075a9ab8d5c1e46c6c83ce11cb4eTripp this.set("autoDraw", false);
09688ec5ffb8b9cf9883a770e2f9ebd60b28888dTripp method.apply();
c7ba96d16d58075a9ab8d5c1e46c6c83ce11cb4eTripp this._redraw();
c7ba96d16d58075a9ab8d5c1e46c6c83ce11cb4eTripp this.set("autoDraw", autoDraw);
09688ec5ffb8b9cf9883a770e2f9ebd60b28888dTripp },
c7ba96d16d58075a9ab8d5c1e46c6c83ce11cb4eTripp
c7ba96d16d58075a9ab8d5c1e46c6c83ce11cb4eTripp /**
c7ba96d16d58075a9ab8d5c1e46c6c83ce11cb4eTripp * Returns a document fragment to for attaching shapes.
c7ba96d16d58075a9ab8d5c1e46c6c83ce11cb4eTripp *
c7ba96d16d58075a9ab8d5c1e46c6c83ce11cb4eTripp * @method _getDocFrag
c7ba96d16d58075a9ab8d5c1e46c6c83ce11cb4eTripp * @return DocumentFragment
c7ba96d16d58075a9ab8d5c1e46c6c83ce11cb4eTripp * @private
c7ba96d16d58075a9ab8d5c1e46c6c83ce11cb4eTripp */
c7ba96d16d58075a9ab8d5c1e46c6c83ce11cb4eTripp _getDocFrag: function()
c7ba96d16d58075a9ab8d5c1e46c6c83ce11cb4eTripp {
c7ba96d16d58075a9ab8d5c1e46c6c83ce11cb4eTripp if(!this._frag)
c7ba96d16d58075a9ab8d5c1e46c6c83ce11cb4eTripp {
c7ba96d16d58075a9ab8d5c1e46c6c83ce11cb4eTripp this._frag = DOCUMENT.createDocumentFragment();
c7ba96d16d58075a9ab8d5c1e46c6c83ce11cb4eTripp }
c7ba96d16d58075a9ab8d5c1e46c6c83ce11cb4eTripp return this._frag;
c7ba96d16d58075a9ab8d5c1e46c6c83ce11cb4eTripp },
c7ba96d16d58075a9ab8d5c1e46c6c83ce11cb4eTripp
c7ba96d16d58075a9ab8d5c1e46c6c83ce11cb4eTripp /**
c7ba96d16d58075a9ab8d5c1e46c6c83ce11cb4eTripp * Adds a shape to the redraw queue and calculates the contentBounds.
c7ba96d16d58075a9ab8d5c1e46c6c83ce11cb4eTripp *
c7ba96d16d58075a9ab8d5c1e46c6c83ce11cb4eTripp * @method addToRedrawQueue
c7ba96d16d58075a9ab8d5c1e46c6c83ce11cb4eTripp * @param shape {VMLShape}
09688ec5ffb8b9cf9883a770e2f9ebd60b28888dTripp * @protected
c7ba96d16d58075a9ab8d5c1e46c6c83ce11cb4eTripp */
c7ba96d16d58075a9ab8d5c1e46c6c83ce11cb4eTripp addToRedrawQueue: function(shape)
c7ba96d16d58075a9ab8d5c1e46c6c83ce11cb4eTripp {
09688ec5ffb8b9cf9883a770e2f9ebd60b28888dTripp var shapeBox,
c7ba96d16d58075a9ab8d5c1e46c6c83ce11cb4eTripp box;
09688ec5ffb8b9cf9883a770e2f9ebd60b28888dTripp this._shapes[shape.get("id")] = shape;
c7ba96d16d58075a9ab8d5c1e46c6c83ce11cb4eTripp if(!this._resizeDown)
09688ec5ffb8b9cf9883a770e2f9ebd60b28888dTripp {
09688ec5ffb8b9cf9883a770e2f9ebd60b28888dTripp shapeBox = shape.getBounds();
09688ec5ffb8b9cf9883a770e2f9ebd60b28888dTripp box = this._contentBounds;
09688ec5ffb8b9cf9883a770e2f9ebd60b28888dTripp box.left = box.left < shapeBox.left ? box.left : shapeBox.left;
09688ec5ffb8b9cf9883a770e2f9ebd60b28888dTripp box.top = box.top < shapeBox.top ? box.top : shapeBox.top;
09688ec5ffb8b9cf9883a770e2f9ebd60b28888dTripp box.right = box.right > shapeBox.right ? box.right : shapeBox.right;
09688ec5ffb8b9cf9883a770e2f9ebd60b28888dTripp box.bottom = box.bottom > shapeBox.bottom ? box.bottom : shapeBox.bottom;
09688ec5ffb8b9cf9883a770e2f9ebd60b28888dTripp box.width = box.right - box.left;
09688ec5ffb8b9cf9883a770e2f9ebd60b28888dTripp box.height = box.bottom - box.top;
09688ec5ffb8b9cf9883a770e2f9ebd60b28888dTripp this._contentBounds = box;
09688ec5ffb8b9cf9883a770e2f9ebd60b28888dTripp }
09688ec5ffb8b9cf9883a770e2f9ebd60b28888dTripp if(this.get("autoDraw"))
09688ec5ffb8b9cf9883a770e2f9ebd60b28888dTripp {
09688ec5ffb8b9cf9883a770e2f9ebd60b28888dTripp this._redraw();
09688ec5ffb8b9cf9883a770e2f9ebd60b28888dTripp }
09688ec5ffb8b9cf9883a770e2f9ebd60b28888dTripp },
09688ec5ffb8b9cf9883a770e2f9ebd60b28888dTripp
09688ec5ffb8b9cf9883a770e2f9ebd60b28888dTripp /**
09688ec5ffb8b9cf9883a770e2f9ebd60b28888dTripp * Redraws all shapes.
09688ec5ffb8b9cf9883a770e2f9ebd60b28888dTripp *
09688ec5ffb8b9cf9883a770e2f9ebd60b28888dTripp * @method _redraw
09688ec5ffb8b9cf9883a770e2f9ebd60b28888dTripp * @private
09688ec5ffb8b9cf9883a770e2f9ebd60b28888dTripp */
09688ec5ffb8b9cf9883a770e2f9ebd60b28888dTripp _redraw: function()
09688ec5ffb8b9cf9883a770e2f9ebd60b28888dTripp {
a89ad754cce3cfc8aee71760e10217b54020360dTripp var box = this._resizeDown ? this._getUpdatedContentBounds() : this._contentBounds;
09688ec5ffb8b9cf9883a770e2f9ebd60b28888dTripp if(this.get("autoSize"))
09688ec5ffb8b9cf9883a770e2f9ebd60b28888dTripp {
09688ec5ffb8b9cf9883a770e2f9ebd60b28888dTripp this.setSize(box.right, box.bottom);
09688ec5ffb8b9cf9883a770e2f9ebd60b28888dTripp }
09688ec5ffb8b9cf9883a770e2f9ebd60b28888dTripp if(this._frag)
09688ec5ffb8b9cf9883a770e2f9ebd60b28888dTripp {
09688ec5ffb8b9cf9883a770e2f9ebd60b28888dTripp this._node.appendChild(this._frag);
09688ec5ffb8b9cf9883a770e2f9ebd60b28888dTripp this._frag = null;
09688ec5ffb8b9cf9883a770e2f9ebd60b28888dTripp }
09688ec5ffb8b9cf9883a770e2f9ebd60b28888dTripp },
09688ec5ffb8b9cf9883a770e2f9ebd60b28888dTripp
09688ec5ffb8b9cf9883a770e2f9ebd60b28888dTripp /**
09688ec5ffb8b9cf9883a770e2f9ebd60b28888dTripp * Recalculates and returns the `contentBounds` for the `Graphic` instance.
a89ad754cce3cfc8aee71760e10217b54020360dTripp *
a89ad754cce3cfc8aee71760e10217b54020360dTripp * @method _getUpdatedContentBounds
09688ec5ffb8b9cf9883a770e2f9ebd60b28888dTripp * @return {Object}
09688ec5ffb8b9cf9883a770e2f9ebd60b28888dTripp * @private
*/
_getUpdatedContentBounds: function()
{
var bounds,
i,
shape,
queue = this._shapes,
box = {
left: 0,
top: 0,
right: 0,
bottom: 0
};
for(i in queue)
{
if(queue.hasOwnProperty(i))
{
shape = queue[i];
bounds = shape.getBounds();
box.left = Math.min(box.left, bounds.left);
box.top = Math.min(box.top, bounds.top);
box.right = Math.max(box.right, bounds.right);
box.bottom = Math.max(box.bottom, bounds.bottom);
}
}
box.width = box.right - box.left;
box.height = box.bottom - box.top;
this._contentBounds = box;
return box;
}
});
Y.VMLGraphic = VMLGraphic;