CanvasShape.js revision 09688ec5ffb8b9cf9883a770e2f9ebd60b28888d
09688ec5ffb8b9cf9883a770e2f9ebd60b28888dTripp/**
09688ec5ffb8b9cf9883a770e2f9ebd60b28888dTripp * Base class for creating shapes.
09688ec5ffb8b9cf9883a770e2f9ebd60b28888dTripp *
09688ec5ffb8b9cf9883a770e2f9ebd60b28888dTripp * @class CanvasShape
09688ec5ffb8b9cf9883a770e2f9ebd60b28888dTripp */
09688ec5ffb8b9cf9883a770e2f9ebd60b28888dTrippvar SHAPE = "canvasShape",
09688ec5ffb8b9cf9883a770e2f9ebd60b28888dTripp Y_LANG = Y.Lang,
09688ec5ffb8b9cf9883a770e2f9ebd60b28888dTripp AttributeLite = Y.AttributeLite,
09688ec5ffb8b9cf9883a770e2f9ebd60b28888dTripp PluginHost = Y.Plugin.Host,
09688ec5ffb8b9cf9883a770e2f9ebd60b28888dTripp CanvasShape = function(cfg)
09688ec5ffb8b9cf9883a770e2f9ebd60b28888dTripp {
09688ec5ffb8b9cf9883a770e2f9ebd60b28888dTripp var host = this,
09688ec5ffb8b9cf9883a770e2f9ebd60b28888dTripp PluginHost = Y.Plugin && Y.Plugin.Host;
09688ec5ffb8b9cf9883a770e2f9ebd60b28888dTripp if (host._initPlugins && PluginHost) {
09688ec5ffb8b9cf9883a770e2f9ebd60b28888dTripp PluginHost.call(host);
09688ec5ffb8b9cf9883a770e2f9ebd60b28888dTripp }
09688ec5ffb8b9cf9883a770e2f9ebd60b28888dTripp
09688ec5ffb8b9cf9883a770e2f9ebd60b28888dTripp host.name = host.constructor.NAME;
09688ec5ffb8b9cf9883a770e2f9ebd60b28888dTripp host._eventPrefix = host.constructor.EVENT_PREFIX || host.constructor.NAME;
09688ec5ffb8b9cf9883a770e2f9ebd60b28888dTripp AttributeLite.call(host);
09688ec5ffb8b9cf9883a770e2f9ebd60b28888dTripp host.addAttrs(cfg);
09688ec5ffb8b9cf9883a770e2f9ebd60b28888dTripp host.init.apply(this, arguments);
09688ec5ffb8b9cf9883a770e2f9ebd60b28888dTripp if (host._initPlugins) {
09688ec5ffb8b9cf9883a770e2f9ebd60b28888dTripp // Need to initPlugins manually, to handle constructor parsing, static Plug parsing
09688ec5ffb8b9cf9883a770e2f9ebd60b28888dTripp host._initPlugins(cfg);
09688ec5ffb8b9cf9883a770e2f9ebd60b28888dTripp }
09688ec5ffb8b9cf9883a770e2f9ebd60b28888dTripp host.initialized = true;
09688ec5ffb8b9cf9883a770e2f9ebd60b28888dTripp };
09688ec5ffb8b9cf9883a770e2f9ebd60b28888dTripp CanvasShape.NAME = "canvasShape";
09688ec5ffb8b9cf9883a770e2f9ebd60b28888dTripp CanvasShape.prototype = Y.merge(Y.CanvasDrawing.prototype, {
09688ec5ffb8b9cf9883a770e2f9ebd60b28888dTripp init: function()
09688ec5ffb8b9cf9883a770e2f9ebd60b28888dTripp {
09688ec5ffb8b9cf9883a770e2f9ebd60b28888dTripp this.initializer.apply(this, arguments);
09688ec5ffb8b9cf9883a770e2f9ebd60b28888dTripp },
09688ec5ffb8b9cf9883a770e2f9ebd60b28888dTripp
09688ec5ffb8b9cf9883a770e2f9ebd60b28888dTripp /**
09688ec5ffb8b9cf9883a770e2f9ebd60b28888dTripp * Initializes the shape
09688ec5ffb8b9cf9883a770e2f9ebd60b28888dTripp *
09688ec5ffb8b9cf9883a770e2f9ebd60b28888dTripp * @private
09688ec5ffb8b9cf9883a770e2f9ebd60b28888dTripp * @method _initialize
09688ec5ffb8b9cf9883a770e2f9ebd60b28888dTripp */
09688ec5ffb8b9cf9883a770e2f9ebd60b28888dTripp initializer: function(cfg)
09688ec5ffb8b9cf9883a770e2f9ebd60b28888dTripp {
09688ec5ffb8b9cf9883a770e2f9ebd60b28888dTripp var host = this;
09688ec5ffb8b9cf9883a770e2f9ebd60b28888dTripp host.createNode();
09688ec5ffb8b9cf9883a770e2f9ebd60b28888dTripp host._graphic = cfg.graphic;
09688ec5ffb8b9cf9883a770e2f9ebd60b28888dTripp host._xcoords = [0];
09688ec5ffb8b9cf9883a770e2f9ebd60b28888dTripp host._ycoords = [0];
09688ec5ffb8b9cf9883a770e2f9ebd60b28888dTripp /*
09688ec5ffb8b9cf9883a770e2f9ebd60b28888dTripp host.get("stroke");
09688ec5ffb8b9cf9883a770e2f9ebd60b28888dTripp host.get("fill");
09688ec5ffb8b9cf9883a770e2f9ebd60b28888dTripp node.setAttribute("width", host.get("width"));
09688ec5ffb8b9cf9883a770e2f9ebd60b28888dTripp node.setAttribute("height", host.get("height"));
09688ec5ffb8b9cf9883a770e2f9ebd60b28888dTripp */
09688ec5ffb8b9cf9883a770e2f9ebd60b28888dTripp host._updateHandler();
09688ec5ffb8b9cf9883a770e2f9ebd60b28888dTripp },
09688ec5ffb8b9cf9883a770e2f9ebd60b28888dTripp
09688ec5ffb8b9cf9883a770e2f9ebd60b28888dTripp /**
09688ec5ffb8b9cf9883a770e2f9ebd60b28888dTripp * Add a class name to each node.
09688ec5ffb8b9cf9883a770e2f9ebd60b28888dTripp *
09688ec5ffb8b9cf9883a770e2f9ebd60b28888dTripp * @method addClass
09688ec5ffb8b9cf9883a770e2f9ebd60b28888dTripp * @param {String} className the class name to add to the node's class attribute
09688ec5ffb8b9cf9883a770e2f9ebd60b28888dTripp */
09688ec5ffb8b9cf9883a770e2f9ebd60b28888dTripp addClass: function(className)
09688ec5ffb8b9cf9883a770e2f9ebd60b28888dTripp {
09688ec5ffb8b9cf9883a770e2f9ebd60b28888dTripp var node = Y.one(this.get("node"));
09688ec5ffb8b9cf9883a770e2f9ebd60b28888dTripp node.addClass(className);
09688ec5ffb8b9cf9883a770e2f9ebd60b28888dTripp },
09688ec5ffb8b9cf9883a770e2f9ebd60b28888dTripp
09688ec5ffb8b9cf9883a770e2f9ebd60b28888dTripp /**
09688ec5ffb8b9cf9883a770e2f9ebd60b28888dTripp * Removes a class name from each node.
09688ec5ffb8b9cf9883a770e2f9ebd60b28888dTripp *
09688ec5ffb8b9cf9883a770e2f9ebd60b28888dTripp * @method removeClass
09688ec5ffb8b9cf9883a770e2f9ebd60b28888dTripp * @param {String} className the class name to remove from the node's class attribute
09688ec5ffb8b9cf9883a770e2f9ebd60b28888dTripp */
09688ec5ffb8b9cf9883a770e2f9ebd60b28888dTripp removeClass: function(className)
09688ec5ffb8b9cf9883a770e2f9ebd60b28888dTripp {
09688ec5ffb8b9cf9883a770e2f9ebd60b28888dTripp var node = Y.one(this.get("node"));
09688ec5ffb8b9cf9883a770e2f9ebd60b28888dTripp node.removeClass(className);
09688ec5ffb8b9cf9883a770e2f9ebd60b28888dTripp },
09688ec5ffb8b9cf9883a770e2f9ebd60b28888dTripp
09688ec5ffb8b9cf9883a770e2f9ebd60b28888dTripp /**
09688ec5ffb8b9cf9883a770e2f9ebd60b28888dTripp * Gets the current position of the node in page coordinates.
09688ec5ffb8b9cf9883a770e2f9ebd60b28888dTripp *
09688ec5ffb8b9cf9883a770e2f9ebd60b28888dTripp * @method getXY
09688ec5ffb8b9cf9883a770e2f9ebd60b28888dTripp * @return Array The XY position of the shape.
09688ec5ffb8b9cf9883a770e2f9ebd60b28888dTripp */
09688ec5ffb8b9cf9883a770e2f9ebd60b28888dTripp getXY: function()
09688ec5ffb8b9cf9883a770e2f9ebd60b28888dTripp {
09688ec5ffb8b9cf9883a770e2f9ebd60b28888dTripp var graphic = this.get("graphic"),
09688ec5ffb8b9cf9883a770e2f9ebd60b28888dTripp parentXY = graphic.getXY(),
09688ec5ffb8b9cf9883a770e2f9ebd60b28888dTripp x = this.get("x"),
09688ec5ffb8b9cf9883a770e2f9ebd60b28888dTripp y = this.get("y");
09688ec5ffb8b9cf9883a770e2f9ebd60b28888dTripp return [parentXY[0] + x, parentXY[1] + y];
09688ec5ffb8b9cf9883a770e2f9ebd60b28888dTripp },
09688ec5ffb8b9cf9883a770e2f9ebd60b28888dTripp
09688ec5ffb8b9cf9883a770e2f9ebd60b28888dTripp /**
09688ec5ffb8b9cf9883a770e2f9ebd60b28888dTripp * Set the position of the shape in page coordinates, regardless of how the node is positioned.
09688ec5ffb8b9cf9883a770e2f9ebd60b28888dTripp *
09688ec5ffb8b9cf9883a770e2f9ebd60b28888dTripp * @method setXY
09688ec5ffb8b9cf9883a770e2f9ebd60b28888dTripp * @param {Array} Contains X & Y values for new position (coordinates are page-based)
09688ec5ffb8b9cf9883a770e2f9ebd60b28888dTripp */
09688ec5ffb8b9cf9883a770e2f9ebd60b28888dTripp setXY: function(xy)
09688ec5ffb8b9cf9883a770e2f9ebd60b28888dTripp {
09688ec5ffb8b9cf9883a770e2f9ebd60b28888dTripp var graphic = this.get("graphic"),
09688ec5ffb8b9cf9883a770e2f9ebd60b28888dTripp parentXY = graphic.getXY(),
09688ec5ffb8b9cf9883a770e2f9ebd60b28888dTripp x = xy[0] - parentXY[0],
09688ec5ffb8b9cf9883a770e2f9ebd60b28888dTripp y = xy[1] - parentXY[1];
09688ec5ffb8b9cf9883a770e2f9ebd60b28888dTripp this._set("x", x);
09688ec5ffb8b9cf9883a770e2f9ebd60b28888dTripp this._set("y", y);
09688ec5ffb8b9cf9883a770e2f9ebd60b28888dTripp this._updateNodePosition(x, y);
09688ec5ffb8b9cf9883a770e2f9ebd60b28888dTripp },
09688ec5ffb8b9cf9883a770e2f9ebd60b28888dTripp
09688ec5ffb8b9cf9883a770e2f9ebd60b28888dTripp /**
09688ec5ffb8b9cf9883a770e2f9ebd60b28888dTripp * Determines whether the node is an ancestor of another HTML element in the DOM hierarchy.
09688ec5ffb8b9cf9883a770e2f9ebd60b28888dTripp *
09688ec5ffb8b9cf9883a770e2f9ebd60b28888dTripp * @method contains
09688ec5ffb8b9cf9883a770e2f9ebd60b28888dTripp * @param {CanvasShape | HTMLElement} needle The possible node or descendent
09688ec5ffb8b9cf9883a770e2f9ebd60b28888dTripp * @return Boolean Whether or not this shape is the needle or its ancestor.
09688ec5ffb8b9cf9883a770e2f9ebd60b28888dTripp */
09688ec5ffb8b9cf9883a770e2f9ebd60b28888dTripp contains: function(needle)
09688ec5ffb8b9cf9883a770e2f9ebd60b28888dTripp {
09688ec5ffb8b9cf9883a770e2f9ebd60b28888dTripp return needle === Y.one(this.node);
09688ec5ffb8b9cf9883a770e2f9ebd60b28888dTripp },
09688ec5ffb8b9cf9883a770e2f9ebd60b28888dTripp
09688ec5ffb8b9cf9883a770e2f9ebd60b28888dTripp /**
09688ec5ffb8b9cf9883a770e2f9ebd60b28888dTripp * Test if the supplied node matches the supplied selector.
09688ec5ffb8b9cf9883a770e2f9ebd60b28888dTripp *
09688ec5ffb8b9cf9883a770e2f9ebd60b28888dTripp * @method test
09688ec5ffb8b9cf9883a770e2f9ebd60b28888dTripp * @param {String} selector The CSS selector to test against.
09688ec5ffb8b9cf9883a770e2f9ebd60b28888dTripp * @return Boolean Wheter or not the shape matches the selector.
09688ec5ffb8b9cf9883a770e2f9ebd60b28888dTripp */
09688ec5ffb8b9cf9883a770e2f9ebd60b28888dTripp test: function(selector)
09688ec5ffb8b9cf9883a770e2f9ebd60b28888dTripp {
09688ec5ffb8b9cf9883a770e2f9ebd60b28888dTripp return Y.one(this.get("node")).test(selector);
09688ec5ffb8b9cf9883a770e2f9ebd60b28888dTripp //return Y.Selector.test(this.node, selector);
09688ec5ffb8b9cf9883a770e2f9ebd60b28888dTripp },
09688ec5ffb8b9cf9883a770e2f9ebd60b28888dTripp
09688ec5ffb8b9cf9883a770e2f9ebd60b28888dTripp /**
09688ec5ffb8b9cf9883a770e2f9ebd60b28888dTripp * Compares nodes to determine if they match.
09688ec5ffb8b9cf9883a770e2f9ebd60b28888dTripp * Node instances can be compared to each other and/or HTMLElements.
09688ec5ffb8b9cf9883a770e2f9ebd60b28888dTripp * @method compareTo
09688ec5ffb8b9cf9883a770e2f9ebd60b28888dTripp * @param {HTMLElement | Node} refNode The reference node to compare to the node.
09688ec5ffb8b9cf9883a770e2f9ebd60b28888dTripp * @return {Boolean} True if the nodes match, false if they do not.
09688ec5ffb8b9cf9883a770e2f9ebd60b28888dTripp */
09688ec5ffb8b9cf9883a770e2f9ebd60b28888dTripp compareTo: function(refNode) {
09688ec5ffb8b9cf9883a770e2f9ebd60b28888dTripp var node = this.node;
09688ec5ffb8b9cf9883a770e2f9ebd60b28888dTripp return node === refNode;
09688ec5ffb8b9cf9883a770e2f9ebd60b28888dTripp },
09688ec5ffb8b9cf9883a770e2f9ebd60b28888dTripp
09688ec5ffb8b9cf9883a770e2f9ebd60b28888dTripp /**
09688ec5ffb8b9cf9883a770e2f9ebd60b28888dTripp * Value function for fill attribute
09688ec5ffb8b9cf9883a770e2f9ebd60b28888dTripp *
09688ec5ffb8b9cf9883a770e2f9ebd60b28888dTripp * @private
09688ec5ffb8b9cf9883a770e2f9ebd60b28888dTripp * @method _getDefaultFill
09688ec5ffb8b9cf9883a770e2f9ebd60b28888dTripp * @return Object
09688ec5ffb8b9cf9883a770e2f9ebd60b28888dTripp */
09688ec5ffb8b9cf9883a770e2f9ebd60b28888dTripp _getDefaultFill: function() {
09688ec5ffb8b9cf9883a770e2f9ebd60b28888dTripp return {
09688ec5ffb8b9cf9883a770e2f9ebd60b28888dTripp type: "solid",
09688ec5ffb8b9cf9883a770e2f9ebd60b28888dTripp cx: 0.5,
09688ec5ffb8b9cf9883a770e2f9ebd60b28888dTripp cy: 0.5,
09688ec5ffb8b9cf9883a770e2f9ebd60b28888dTripp fx: 0.5,
09688ec5ffb8b9cf9883a770e2f9ebd60b28888dTripp fy: 0.5,
09688ec5ffb8b9cf9883a770e2f9ebd60b28888dTripp r: 0.5
09688ec5ffb8b9cf9883a770e2f9ebd60b28888dTripp };
09688ec5ffb8b9cf9883a770e2f9ebd60b28888dTripp },
09688ec5ffb8b9cf9883a770e2f9ebd60b28888dTripp
09688ec5ffb8b9cf9883a770e2f9ebd60b28888dTripp /**
09688ec5ffb8b9cf9883a770e2f9ebd60b28888dTripp * Value function for stroke attribute
09688ec5ffb8b9cf9883a770e2f9ebd60b28888dTripp *
09688ec5ffb8b9cf9883a770e2f9ebd60b28888dTripp * @private
09688ec5ffb8b9cf9883a770e2f9ebd60b28888dTripp * @method _getDefaultStroke
09688ec5ffb8b9cf9883a770e2f9ebd60b28888dTripp * @return Object
09688ec5ffb8b9cf9883a770e2f9ebd60b28888dTripp */
09688ec5ffb8b9cf9883a770e2f9ebd60b28888dTripp _getDefaultStroke: function()
09688ec5ffb8b9cf9883a770e2f9ebd60b28888dTripp {
09688ec5ffb8b9cf9883a770e2f9ebd60b28888dTripp return {
09688ec5ffb8b9cf9883a770e2f9ebd60b28888dTripp weight: 1,
09688ec5ffb8b9cf9883a770e2f9ebd60b28888dTripp dashstyle: "none",
09688ec5ffb8b9cf9883a770e2f9ebd60b28888dTripp color: "#000",
09688ec5ffb8b9cf9883a770e2f9ebd60b28888dTripp opacity: 1.0
09688ec5ffb8b9cf9883a770e2f9ebd60b28888dTripp };
09688ec5ffb8b9cf9883a770e2f9ebd60b28888dTripp },
09688ec5ffb8b9cf9883a770e2f9ebd60b28888dTripp
09688ec5ffb8b9cf9883a770e2f9ebd60b28888dTripp /**
09688ec5ffb8b9cf9883a770e2f9ebd60b28888dTripp * Left edge of the path
09688ec5ffb8b9cf9883a770e2f9ebd60b28888dTripp *
09688ec5ffb8b9cf9883a770e2f9ebd60b28888dTripp * @private
09688ec5ffb8b9cf9883a770e2f9ebd60b28888dTripp */
09688ec5ffb8b9cf9883a770e2f9ebd60b28888dTripp _left: 0,
09688ec5ffb8b9cf9883a770e2f9ebd60b28888dTripp
09688ec5ffb8b9cf9883a770e2f9ebd60b28888dTripp /**
09688ec5ffb8b9cf9883a770e2f9ebd60b28888dTripp * Right edge of the path
09688ec5ffb8b9cf9883a770e2f9ebd60b28888dTripp *
09688ec5ffb8b9cf9883a770e2f9ebd60b28888dTripp * @private
09688ec5ffb8b9cf9883a770e2f9ebd60b28888dTripp */
09688ec5ffb8b9cf9883a770e2f9ebd60b28888dTripp _right: 0,
09688ec5ffb8b9cf9883a770e2f9ebd60b28888dTripp
09688ec5ffb8b9cf9883a770e2f9ebd60b28888dTripp /**
09688ec5ffb8b9cf9883a770e2f9ebd60b28888dTripp * Top edge of the path
09688ec5ffb8b9cf9883a770e2f9ebd60b28888dTripp *
09688ec5ffb8b9cf9883a770e2f9ebd60b28888dTripp * @private
09688ec5ffb8b9cf9883a770e2f9ebd60b28888dTripp */
09688ec5ffb8b9cf9883a770e2f9ebd60b28888dTripp _top: 0,
09688ec5ffb8b9cf9883a770e2f9ebd60b28888dTripp
09688ec5ffb8b9cf9883a770e2f9ebd60b28888dTripp /**
09688ec5ffb8b9cf9883a770e2f9ebd60b28888dTripp * Bottom edge of the path
09688ec5ffb8b9cf9883a770e2f9ebd60b28888dTripp *
09688ec5ffb8b9cf9883a770e2f9ebd60b28888dTripp * @private
09688ec5ffb8b9cf9883a770e2f9ebd60b28888dTripp */
09688ec5ffb8b9cf9883a770e2f9ebd60b28888dTripp _bottom: 0,
09688ec5ffb8b9cf9883a770e2f9ebd60b28888dTripp
09688ec5ffb8b9cf9883a770e2f9ebd60b28888dTripp /**
09688ec5ffb8b9cf9883a770e2f9ebd60b28888dTripp * Creates the dom node for the shape.
09688ec5ffb8b9cf9883a770e2f9ebd60b28888dTripp *
09688ec5ffb8b9cf9883a770e2f9ebd60b28888dTripp * @private
09688ec5ffb8b9cf9883a770e2f9ebd60b28888dTripp * @return HTMLElement
09688ec5ffb8b9cf9883a770e2f9ebd60b28888dTripp */
09688ec5ffb8b9cf9883a770e2f9ebd60b28888dTripp createNode: function()
09688ec5ffb8b9cf9883a770e2f9ebd60b28888dTripp {
09688ec5ffb8b9cf9883a770e2f9ebd60b28888dTripp var node = Y.config.doc.createElement('canvas'),
09688ec5ffb8b9cf9883a770e2f9ebd60b28888dTripp id = this.get("id");
09688ec5ffb8b9cf9883a770e2f9ebd60b28888dTripp this._context = node.getContext('2d');
09688ec5ffb8b9cf9883a770e2f9ebd60b28888dTripp node.setAttribute("class", "yui3-" + SHAPE);
09688ec5ffb8b9cf9883a770e2f9ebd60b28888dTripp node.setAttribute("class", "yui3-" + this.name);
09688ec5ffb8b9cf9883a770e2f9ebd60b28888dTripp node.setAttribute("id", id);
09688ec5ffb8b9cf9883a770e2f9ebd60b28888dTripp id = "#" + id;
09688ec5ffb8b9cf9883a770e2f9ebd60b28888dTripp this.node = node;
09688ec5ffb8b9cf9883a770e2f9ebd60b28888dTripp },
09688ec5ffb8b9cf9883a770e2f9ebd60b28888dTripp
09688ec5ffb8b9cf9883a770e2f9ebd60b28888dTripp /**
09688ec5ffb8b9cf9883a770e2f9ebd60b28888dTripp * @private
09688ec5ffb8b9cf9883a770e2f9ebd60b28888dTripp */
09688ec5ffb8b9cf9883a770e2f9ebd60b28888dTripp isMouseEvent: function(type)
09688ec5ffb8b9cf9883a770e2f9ebd60b28888dTripp {
09688ec5ffb8b9cf9883a770e2f9ebd60b28888dTripp if(type.indexOf('mouse') > -1 || type.indexOf('click') > -1)
09688ec5ffb8b9cf9883a770e2f9ebd60b28888dTripp {
09688ec5ffb8b9cf9883a770e2f9ebd60b28888dTripp return true;
09688ec5ffb8b9cf9883a770e2f9ebd60b28888dTripp }
09688ec5ffb8b9cf9883a770e2f9ebd60b28888dTripp return false;
09688ec5ffb8b9cf9883a770e2f9ebd60b28888dTripp },
09688ec5ffb8b9cf9883a770e2f9ebd60b28888dTripp
09688ec5ffb8b9cf9883a770e2f9ebd60b28888dTripp /**
09688ec5ffb8b9cf9883a770e2f9ebd60b28888dTripp * @private
09688ec5ffb8b9cf9883a770e2f9ebd60b28888dTripp */
09688ec5ffb8b9cf9883a770e2f9ebd60b28888dTripp before: function(type, fn)
09688ec5ffb8b9cf9883a770e2f9ebd60b28888dTripp {
09688ec5ffb8b9cf9883a770e2f9ebd60b28888dTripp if(this.isMouseEvent(type))
09688ec5ffb8b9cf9883a770e2f9ebd60b28888dTripp {
09688ec5ffb8b9cf9883a770e2f9ebd60b28888dTripp return Y.before(type, fn, "#" + this.get("id"));
09688ec5ffb8b9cf9883a770e2f9ebd60b28888dTripp }
09688ec5ffb8b9cf9883a770e2f9ebd60b28888dTripp return Y.on.apply(this, arguments);
09688ec5ffb8b9cf9883a770e2f9ebd60b28888dTripp },
09688ec5ffb8b9cf9883a770e2f9ebd60b28888dTripp
09688ec5ffb8b9cf9883a770e2f9ebd60b28888dTripp /**
09688ec5ffb8b9cf9883a770e2f9ebd60b28888dTripp * @private
09688ec5ffb8b9cf9883a770e2f9ebd60b28888dTripp */
09688ec5ffb8b9cf9883a770e2f9ebd60b28888dTripp on: function(type, fn)
09688ec5ffb8b9cf9883a770e2f9ebd60b28888dTripp {
09688ec5ffb8b9cf9883a770e2f9ebd60b28888dTripp if(this.isMouseEvent(type))
09688ec5ffb8b9cf9883a770e2f9ebd60b28888dTripp {
09688ec5ffb8b9cf9883a770e2f9ebd60b28888dTripp return Y.on(type, fn, "#" + this.get("id"));
09688ec5ffb8b9cf9883a770e2f9ebd60b28888dTripp }
09688ec5ffb8b9cf9883a770e2f9ebd60b28888dTripp return Y.on.apply(this, arguments);
09688ec5ffb8b9cf9883a770e2f9ebd60b28888dTripp },
09688ec5ffb8b9cf9883a770e2f9ebd60b28888dTripp
09688ec5ffb8b9cf9883a770e2f9ebd60b28888dTripp /**
09688ec5ffb8b9cf9883a770e2f9ebd60b28888dTripp * @private
09688ec5ffb8b9cf9883a770e2f9ebd60b28888dTripp */
09688ec5ffb8b9cf9883a770e2f9ebd60b28888dTripp after: function(type, fn)
09688ec5ffb8b9cf9883a770e2f9ebd60b28888dTripp {
09688ec5ffb8b9cf9883a770e2f9ebd60b28888dTripp if(this.isMouseEvent(type))
09688ec5ffb8b9cf9883a770e2f9ebd60b28888dTripp {
09688ec5ffb8b9cf9883a770e2f9ebd60b28888dTripp return Y.after(type, fn, "#" + this.get("id"));
09688ec5ffb8b9cf9883a770e2f9ebd60b28888dTripp }
09688ec5ffb8b9cf9883a770e2f9ebd60b28888dTripp return Y.on.apply(this, arguments);
09688ec5ffb8b9cf9883a770e2f9ebd60b28888dTripp },
09688ec5ffb8b9cf9883a770e2f9ebd60b28888dTripp
09688ec5ffb8b9cf9883a770e2f9ebd60b28888dTripp /**
09688ec5ffb8b9cf9883a770e2f9ebd60b28888dTripp * Adds a stroke to the shape node.
09688ec5ffb8b9cf9883a770e2f9ebd60b28888dTripp *
09688ec5ffb8b9cf9883a770e2f9ebd60b28888dTripp * @method _strokeChangeHandler
09688ec5ffb8b9cf9883a770e2f9ebd60b28888dTripp * @private
09688ec5ffb8b9cf9883a770e2f9ebd60b28888dTripp */
09688ec5ffb8b9cf9883a770e2f9ebd60b28888dTripp _setStrokeProps: function(stroke)
09688ec5ffb8b9cf9883a770e2f9ebd60b28888dTripp {
09688ec5ffb8b9cf9883a770e2f9ebd60b28888dTripp var color = stroke.color,
09688ec5ffb8b9cf9883a770e2f9ebd60b28888dTripp weight = stroke.weight,
09688ec5ffb8b9cf9883a770e2f9ebd60b28888dTripp opacity = stroke.opacity,
09688ec5ffb8b9cf9883a770e2f9ebd60b28888dTripp linejoin = stroke.linejoin || "round",
09688ec5ffb8b9cf9883a770e2f9ebd60b28888dTripp linecap = stroke.linecap || "butt",
09688ec5ffb8b9cf9883a770e2f9ebd60b28888dTripp dashstyle = stroke.dashstyle;
09688ec5ffb8b9cf9883a770e2f9ebd60b28888dTripp this._miterlimit = null;
09688ec5ffb8b9cf9883a770e2f9ebd60b28888dTripp this._dashstyle = (dashstyle && Y.Lang.isArray(dashstyle) && dashstyle.length > 1) ? dashstyle : null;
09688ec5ffb8b9cf9883a770e2f9ebd60b28888dTripp this._strokeWeight = weight;
09688ec5ffb8b9cf9883a770e2f9ebd60b28888dTripp
09688ec5ffb8b9cf9883a770e2f9ebd60b28888dTripp if (weight)
09688ec5ffb8b9cf9883a770e2f9ebd60b28888dTripp {
09688ec5ffb8b9cf9883a770e2f9ebd60b28888dTripp this._stroke = 1;
09688ec5ffb8b9cf9883a770e2f9ebd60b28888dTripp }
09688ec5ffb8b9cf9883a770e2f9ebd60b28888dTripp else
09688ec5ffb8b9cf9883a770e2f9ebd60b28888dTripp {
09688ec5ffb8b9cf9883a770e2f9ebd60b28888dTripp this._stroke = 0;
09688ec5ffb8b9cf9883a770e2f9ebd60b28888dTripp }
09688ec5ffb8b9cf9883a770e2f9ebd60b28888dTripp if (opacity) {
09688ec5ffb8b9cf9883a770e2f9ebd60b28888dTripp this._strokeStyle = this._2RGBA(color, opacity);
09688ec5ffb8b9cf9883a770e2f9ebd60b28888dTripp }
09688ec5ffb8b9cf9883a770e2f9ebd60b28888dTripp else
09688ec5ffb8b9cf9883a770e2f9ebd60b28888dTripp {
09688ec5ffb8b9cf9883a770e2f9ebd60b28888dTripp this._strokeStyle = color;
09688ec5ffb8b9cf9883a770e2f9ebd60b28888dTripp }
09688ec5ffb8b9cf9883a770e2f9ebd60b28888dTripp this._linecap = linecap;
09688ec5ffb8b9cf9883a770e2f9ebd60b28888dTripp if(linejoin == "round" || linejoin == "square")
09688ec5ffb8b9cf9883a770e2f9ebd60b28888dTripp {
09688ec5ffb8b9cf9883a770e2f9ebd60b28888dTripp this._linejoin = linejoin;
09688ec5ffb8b9cf9883a770e2f9ebd60b28888dTripp }
09688ec5ffb8b9cf9883a770e2f9ebd60b28888dTripp else
09688ec5ffb8b9cf9883a770e2f9ebd60b28888dTripp {
09688ec5ffb8b9cf9883a770e2f9ebd60b28888dTripp linejoin = parseInt(linejoin, 10);
09688ec5ffb8b9cf9883a770e2f9ebd60b28888dTripp if(Y.Lang.isNumber(linejoin))
09688ec5ffb8b9cf9883a770e2f9ebd60b28888dTripp {
09688ec5ffb8b9cf9883a770e2f9ebd60b28888dTripp this._miterlimit = Math.max(linejoin, 1);
09688ec5ffb8b9cf9883a770e2f9ebd60b28888dTripp this._linejoin = "miter";
09688ec5ffb8b9cf9883a770e2f9ebd60b28888dTripp }
09688ec5ffb8b9cf9883a770e2f9ebd60b28888dTripp }
09688ec5ffb8b9cf9883a770e2f9ebd60b28888dTripp },
09688ec5ffb8b9cf9883a770e2f9ebd60b28888dTripp
09688ec5ffb8b9cf9883a770e2f9ebd60b28888dTripp set: function()
09688ec5ffb8b9cf9883a770e2f9ebd60b28888dTripp {
09688ec5ffb8b9cf9883a770e2f9ebd60b28888dTripp var host = this,
09688ec5ffb8b9cf9883a770e2f9ebd60b28888dTripp val = arguments[0];
09688ec5ffb8b9cf9883a770e2f9ebd60b28888dTripp AttributeLite.prototype.set.apply(host, arguments);
09688ec5ffb8b9cf9883a770e2f9ebd60b28888dTripp if(host.initialized && val != "x" && val != "y")
09688ec5ffb8b9cf9883a770e2f9ebd60b28888dTripp {
09688ec5ffb8b9cf9883a770e2f9ebd60b28888dTripp host._updateHandler();
09688ec5ffb8b9cf9883a770e2f9ebd60b28888dTripp }
09688ec5ffb8b9cf9883a770e2f9ebd60b28888dTripp },
09688ec5ffb8b9cf9883a770e2f9ebd60b28888dTripp
09688ec5ffb8b9cf9883a770e2f9ebd60b28888dTripp /**
09688ec5ffb8b9cf9883a770e2f9ebd60b28888dTripp * Adds a fill to the shape node.
09688ec5ffb8b9cf9883a770e2f9ebd60b28888dTripp *
09688ec5ffb8b9cf9883a770e2f9ebd60b28888dTripp * @method _fillChangeHandler
09688ec5ffb8b9cf9883a770e2f9ebd60b28888dTripp * @private
09688ec5ffb8b9cf9883a770e2f9ebd60b28888dTripp */
09688ec5ffb8b9cf9883a770e2f9ebd60b28888dTripp _setFillProps: function(fill)
09688ec5ffb8b9cf9883a770e2f9ebd60b28888dTripp {
09688ec5ffb8b9cf9883a770e2f9ebd60b28888dTripp var isNumber = Y.Lang.isNumber,
09688ec5ffb8b9cf9883a770e2f9ebd60b28888dTripp color = fill.color,
09688ec5ffb8b9cf9883a770e2f9ebd60b28888dTripp opacity,
09688ec5ffb8b9cf9883a770e2f9ebd60b28888dTripp type = fill.type;
09688ec5ffb8b9cf9883a770e2f9ebd60b28888dTripp if(type == "linear" || type == "radial")
09688ec5ffb8b9cf9883a770e2f9ebd60b28888dTripp {
09688ec5ffb8b9cf9883a770e2f9ebd60b28888dTripp this._fillType = type;
09688ec5ffb8b9cf9883a770e2f9ebd60b28888dTripp }
09688ec5ffb8b9cf9883a770e2f9ebd60b28888dTripp else if(color)
09688ec5ffb8b9cf9883a770e2f9ebd60b28888dTripp {
09688ec5ffb8b9cf9883a770e2f9ebd60b28888dTripp opacity = fill.opacity;
09688ec5ffb8b9cf9883a770e2f9ebd60b28888dTripp if (isNumber(opacity))
09688ec5ffb8b9cf9883a770e2f9ebd60b28888dTripp {
09688ec5ffb8b9cf9883a770e2f9ebd60b28888dTripp opacity = Math.max(0, Math.min(1, opacity));
09688ec5ffb8b9cf9883a770e2f9ebd60b28888dTripp color = this._2RGBA(color, opacity);
09688ec5ffb8b9cf9883a770e2f9ebd60b28888dTripp }
09688ec5ffb8b9cf9883a770e2f9ebd60b28888dTripp else
09688ec5ffb8b9cf9883a770e2f9ebd60b28888dTripp {
09688ec5ffb8b9cf9883a770e2f9ebd60b28888dTripp color = this._2RGB(color);
09688ec5ffb8b9cf9883a770e2f9ebd60b28888dTripp }
09688ec5ffb8b9cf9883a770e2f9ebd60b28888dTripp
09688ec5ffb8b9cf9883a770e2f9ebd60b28888dTripp this._fillColor = color;
09688ec5ffb8b9cf9883a770e2f9ebd60b28888dTripp this._fillType = 'solid';
09688ec5ffb8b9cf9883a770e2f9ebd60b28888dTripp }
09688ec5ffb8b9cf9883a770e2f9ebd60b28888dTripp else
09688ec5ffb8b9cf9883a770e2f9ebd60b28888dTripp {
09688ec5ffb8b9cf9883a770e2f9ebd60b28888dTripp this._fillColor = null;
09688ec5ffb8b9cf9883a770e2f9ebd60b28888dTripp }
09688ec5ffb8b9cf9883a770e2f9ebd60b28888dTripp },
09688ec5ffb8b9cf9883a770e2f9ebd60b28888dTripp
09688ec5ffb8b9cf9883a770e2f9ebd60b28888dTripp /**
09688ec5ffb8b9cf9883a770e2f9ebd60b28888dTripp * Applies translate transformation.
09688ec5ffb8b9cf9883a770e2f9ebd60b28888dTripp *
09688ec5ffb8b9cf9883a770e2f9ebd60b28888dTripp * @method translate
09688ec5ffb8b9cf9883a770e2f9ebd60b28888dTripp * @param {Number} x The x-coordinate
09688ec5ffb8b9cf9883a770e2f9ebd60b28888dTripp * @param {Number} y The y-coordinate
09688ec5ffb8b9cf9883a770e2f9ebd60b28888dTripp * @protected
09688ec5ffb8b9cf9883a770e2f9ebd60b28888dTripp */
09688ec5ffb8b9cf9883a770e2f9ebd60b28888dTripp translate: function(x, y)
09688ec5ffb8b9cf9883a770e2f9ebd60b28888dTripp {
09688ec5ffb8b9cf9883a770e2f9ebd60b28888dTripp var translate = "translate(" + x + "px, " + y + "px)";
09688ec5ffb8b9cf9883a770e2f9ebd60b28888dTripp this._updateTransform("translate", /translate\(.*\)/, translate);
09688ec5ffb8b9cf9883a770e2f9ebd60b28888dTripp },
09688ec5ffb8b9cf9883a770e2f9ebd60b28888dTripp
09688ec5ffb8b9cf9883a770e2f9ebd60b28888dTripp /**
09688ec5ffb8b9cf9883a770e2f9ebd60b28888dTripp * Applies a skew to the x-coordinate
09688ec5ffb8b9cf9883a770e2f9ebd60b28888dTripp *
09688ec5ffb8b9cf9883a770e2f9ebd60b28888dTripp * @method skewX:q
09688ec5ffb8b9cf9883a770e2f9ebd60b28888dTripp * @param {Number} x x-coordinate
09688ec5ffb8b9cf9883a770e2f9ebd60b28888dTripp */
09688ec5ffb8b9cf9883a770e2f9ebd60b28888dTripp skewX: function(x)
09688ec5ffb8b9cf9883a770e2f9ebd60b28888dTripp {
09688ec5ffb8b9cf9883a770e2f9ebd60b28888dTripp },
09688ec5ffb8b9cf9883a770e2f9ebd60b28888dTripp
09688ec5ffb8b9cf9883a770e2f9ebd60b28888dTripp /**
09688ec5ffb8b9cf9883a770e2f9ebd60b28888dTripp * Applies a skew to the x-coordinate
09688ec5ffb8b9cf9883a770e2f9ebd60b28888dTripp *
09688ec5ffb8b9cf9883a770e2f9ebd60b28888dTripp * @method skewX:q
09688ec5ffb8b9cf9883a770e2f9ebd60b28888dTripp * @param {Number} x x-coordinate
09688ec5ffb8b9cf9883a770e2f9ebd60b28888dTripp */
09688ec5ffb8b9cf9883a770e2f9ebd60b28888dTripp skewY: function(y)
09688ec5ffb8b9cf9883a770e2f9ebd60b28888dTripp {
09688ec5ffb8b9cf9883a770e2f9ebd60b28888dTripp },
09688ec5ffb8b9cf9883a770e2f9ebd60b28888dTripp
09688ec5ffb8b9cf9883a770e2f9ebd60b28888dTripp /**
09688ec5ffb8b9cf9883a770e2f9ebd60b28888dTripp * @private
09688ec5ffb8b9cf9883a770e2f9ebd60b28888dTripp */
09688ec5ffb8b9cf9883a770e2f9ebd60b28888dTripp _rotation: 0,
09688ec5ffb8b9cf9883a770e2f9ebd60b28888dTripp
09688ec5ffb8b9cf9883a770e2f9ebd60b28888dTripp /**
09688ec5ffb8b9cf9883a770e2f9ebd60b28888dTripp * Applies a rotation.
09688ec5ffb8b9cf9883a770e2f9ebd60b28888dTripp *
09688ec5ffb8b9cf9883a770e2f9ebd60b28888dTripp * @method rotate
09688ec5ffb8b9cf9883a770e2f9ebd60b28888dTripp * @param
09688ec5ffb8b9cf9883a770e2f9ebd60b28888dTripp */
09688ec5ffb8b9cf9883a770e2f9ebd60b28888dTripp rotate: function(deg)
09688ec5ffb8b9cf9883a770e2f9ebd60b28888dTripp {
09688ec5ffb8b9cf9883a770e2f9ebd60b28888dTripp var rotate = "rotate(" + deg + "deg)";
09688ec5ffb8b9cf9883a770e2f9ebd60b28888dTripp this._rotation = deg;
09688ec5ffb8b9cf9883a770e2f9ebd60b28888dTripp this._updateTransform("rotate", /rotate\(.*\)/, rotate);
09688ec5ffb8b9cf9883a770e2f9ebd60b28888dTripp },
09688ec5ffb8b9cf9883a770e2f9ebd60b28888dTripp
09688ec5ffb8b9cf9883a770e2f9ebd60b28888dTripp /**
09688ec5ffb8b9cf9883a770e2f9ebd60b28888dTripp * An array of x, y values which indicates the transformOrigin in which to rotate the shape. Valid values range between 0 and 1 representing a
09688ec5ffb8b9cf9883a770e2f9ebd60b28888dTripp * fraction of the shape's corresponding bounding box dimension. The default value is [0.5, 0.5].
09688ec5ffb8b9cf9883a770e2f9ebd60b28888dTripp *
09688ec5ffb8b9cf9883a770e2f9ebd60b28888dTripp * @attribute transformOrigin
09688ec5ffb8b9cf9883a770e2f9ebd60b28888dTripp * @type Array
09688ec5ffb8b9cf9883a770e2f9ebd60b28888dTripp */
09688ec5ffb8b9cf9883a770e2f9ebd60b28888dTripp _transformOrigin: function(x, y)
09688ec5ffb8b9cf9883a770e2f9ebd60b28888dTripp {
09688ec5ffb8b9cf9883a770e2f9ebd60b28888dTripp var node = this.get("node");
09688ec5ffb8b9cf9883a770e2f9ebd60b28888dTripp node.style.MozTransformOrigin = (100 * x) + "% " + (100 * y) + "%";
09688ec5ffb8b9cf9883a770e2f9ebd60b28888dTripp },
09688ec5ffb8b9cf9883a770e2f9ebd60b28888dTripp
09688ec5ffb8b9cf9883a770e2f9ebd60b28888dTripp /**
09688ec5ffb8b9cf9883a770e2f9ebd60b28888dTripp * Applies a scale transform
09688ec5ffb8b9cf9883a770e2f9ebd60b28888dTripp *
09688ec5ffb8b9cf9883a770e2f9ebd60b28888dTripp * @method scale
09688ec5ffb8b9cf9883a770e2f9ebd60b28888dTripp * @param {Number} val
09688ec5ffb8b9cf9883a770e2f9ebd60b28888dTripp */
09688ec5ffb8b9cf9883a770e2f9ebd60b28888dTripp scale: function(val)
09688ec5ffb8b9cf9883a770e2f9ebd60b28888dTripp {
09688ec5ffb8b9cf9883a770e2f9ebd60b28888dTripp },
09688ec5ffb8b9cf9883a770e2f9ebd60b28888dTripp
09688ec5ffb8b9cf9883a770e2f9ebd60b28888dTripp /**
09688ec5ffb8b9cf9883a770e2f9ebd60b28888dTripp * Applies a matrix transformation
09688ec5ffb8b9cf9883a770e2f9ebd60b28888dTripp *
09688ec5ffb8b9cf9883a770e2f9ebd60b28888dTripp * @method matrix
09688ec5ffb8b9cf9883a770e2f9ebd60b28888dTripp */
09688ec5ffb8b9cf9883a770e2f9ebd60b28888dTripp matrix: function(a, b, c, d, e, f)
09688ec5ffb8b9cf9883a770e2f9ebd60b28888dTripp {
09688ec5ffb8b9cf9883a770e2f9ebd60b28888dTripp },
09688ec5ffb8b9cf9883a770e2f9ebd60b28888dTripp
09688ec5ffb8b9cf9883a770e2f9ebd60b28888dTripp /**
09688ec5ffb8b9cf9883a770e2f9ebd60b28888dTripp * @private
09688ec5ffb8b9cf9883a770e2f9ebd60b28888dTripp */
09688ec5ffb8b9cf9883a770e2f9ebd60b28888dTripp _updateTransform: function(type, test, val)
09688ec5ffb8b9cf9883a770e2f9ebd60b28888dTripp {
09688ec5ffb8b9cf9883a770e2f9ebd60b28888dTripp var node = this.get("node"),
09688ec5ffb8b9cf9883a770e2f9ebd60b28888dTripp transform = node.style.MozTransform || node.style.webkitTransform || node.style.msTransform || node.style.OTransform,
09688ec5ffb8b9cf9883a770e2f9ebd60b28888dTripp transformOrigin = this.get("transformOrigin");
09688ec5ffb8b9cf9883a770e2f9ebd60b28888dTripp
09688ec5ffb8b9cf9883a770e2f9ebd60b28888dTripp if(transform && transform.length > 0)
09688ec5ffb8b9cf9883a770e2f9ebd60b28888dTripp {
09688ec5ffb8b9cf9883a770e2f9ebd60b28888dTripp if(transform.indexOf(type) > -1)
09688ec5ffb8b9cf9883a770e2f9ebd60b28888dTripp {
09688ec5ffb8b9cf9883a770e2f9ebd60b28888dTripp transform = transform.replace(test, val);
09688ec5ffb8b9cf9883a770e2f9ebd60b28888dTripp }
09688ec5ffb8b9cf9883a770e2f9ebd60b28888dTripp else
09688ec5ffb8b9cf9883a770e2f9ebd60b28888dTripp {
09688ec5ffb8b9cf9883a770e2f9ebd60b28888dTripp transform += " " + val;
09688ec5ffb8b9cf9883a770e2f9ebd60b28888dTripp }
09688ec5ffb8b9cf9883a770e2f9ebd60b28888dTripp }
09688ec5ffb8b9cf9883a770e2f9ebd60b28888dTripp else
09688ec5ffb8b9cf9883a770e2f9ebd60b28888dTripp {
09688ec5ffb8b9cf9883a770e2f9ebd60b28888dTripp transform = val;
09688ec5ffb8b9cf9883a770e2f9ebd60b28888dTripp }
09688ec5ffb8b9cf9883a770e2f9ebd60b28888dTripp transformOrigin = (100 * transformOrigin[0]) + "% " + (100 * transformOrigin[1]) + "%";
09688ec5ffb8b9cf9883a770e2f9ebd60b28888dTripp node.style.MozTransformOrigin = transformOrigin;
09688ec5ffb8b9cf9883a770e2f9ebd60b28888dTripp node.style.webkitTransformOrigin = transformOrigin;
09688ec5ffb8b9cf9883a770e2f9ebd60b28888dTripp node.style.msTransformOrigin = transformOrigin;
09688ec5ffb8b9cf9883a770e2f9ebd60b28888dTripp node.style.OTransformOrigin = transformOrigin;
09688ec5ffb8b9cf9883a770e2f9ebd60b28888dTripp node.style.MozTransform = transform;
09688ec5ffb8b9cf9883a770e2f9ebd60b28888dTripp node.style.webkitTransform = transform;
09688ec5ffb8b9cf9883a770e2f9ebd60b28888dTripp node.style.msTransform = transform;
09688ec5ffb8b9cf9883a770e2f9ebd60b28888dTripp node.style.OTransform = transform;
09688ec5ffb8b9cf9883a770e2f9ebd60b28888dTripp },
09688ec5ffb8b9cf9883a770e2f9ebd60b28888dTripp
09688ec5ffb8b9cf9883a770e2f9ebd60b28888dTripp /**
09688ec5ffb8b9cf9883a770e2f9ebd60b28888dTripp * @private
09688ec5ffb8b9cf9883a770e2f9ebd60b28888dTripp */
09688ec5ffb8b9cf9883a770e2f9ebd60b28888dTripp _updateHandler: function()
09688ec5ffb8b9cf9883a770e2f9ebd60b28888dTripp {
09688ec5ffb8b9cf9883a770e2f9ebd60b28888dTripp this._draw();
09688ec5ffb8b9cf9883a770e2f9ebd60b28888dTripp },
09688ec5ffb8b9cf9883a770e2f9ebd60b28888dTripp
09688ec5ffb8b9cf9883a770e2f9ebd60b28888dTripp /**
09688ec5ffb8b9cf9883a770e2f9ebd60b28888dTripp * @private
09688ec5ffb8b9cf9883a770e2f9ebd60b28888dTripp */
09688ec5ffb8b9cf9883a770e2f9ebd60b28888dTripp _draw: function()
09688ec5ffb8b9cf9883a770e2f9ebd60b28888dTripp {
09688ec5ffb8b9cf9883a770e2f9ebd60b28888dTripp this._paint();
09688ec5ffb8b9cf9883a770e2f9ebd60b28888dTripp },
09688ec5ffb8b9cf9883a770e2f9ebd60b28888dTripp
09688ec5ffb8b9cf9883a770e2f9ebd60b28888dTripp /**
09688ec5ffb8b9cf9883a770e2f9ebd60b28888dTripp * Completes a shape or drawing
09688ec5ffb8b9cf9883a770e2f9ebd60b28888dTripp *
09688ec5ffb8b9cf9883a770e2f9ebd60b28888dTripp * @method _paint
09688ec5ffb8b9cf9883a770e2f9ebd60b28888dTripp * @private
09688ec5ffb8b9cf9883a770e2f9ebd60b28888dTripp */
09688ec5ffb8b9cf9883a770e2f9ebd60b28888dTripp _paint: function()
09688ec5ffb8b9cf9883a770e2f9ebd60b28888dTripp {
09688ec5ffb8b9cf9883a770e2f9ebd60b28888dTripp if(!this._methods)
09688ec5ffb8b9cf9883a770e2f9ebd60b28888dTripp {
09688ec5ffb8b9cf9883a770e2f9ebd60b28888dTripp return;
09688ec5ffb8b9cf9883a770e2f9ebd60b28888dTripp }
09688ec5ffb8b9cf9883a770e2f9ebd60b28888dTripp var node = this.get("node"),
09688ec5ffb8b9cf9883a770e2f9ebd60b28888dTripp w = this.get("width") || this._width,
09688ec5ffb8b9cf9883a770e2f9ebd60b28888dTripp h = this.get("height") || this._height,
09688ec5ffb8b9cf9883a770e2f9ebd60b28888dTripp context = this._context,
09688ec5ffb8b9cf9883a770e2f9ebd60b28888dTripp methods = [],
09688ec5ffb8b9cf9883a770e2f9ebd60b28888dTripp cachedMethods = this._methods.concat(),
09688ec5ffb8b9cf9883a770e2f9ebd60b28888dTripp i = 0,
09688ec5ffb8b9cf9883a770e2f9ebd60b28888dTripp j,
09688ec5ffb8b9cf9883a770e2f9ebd60b28888dTripp method,
09688ec5ffb8b9cf9883a770e2f9ebd60b28888dTripp args,
09688ec5ffb8b9cf9883a770e2f9ebd60b28888dTripp len = 0;
09688ec5ffb8b9cf9883a770e2f9ebd60b28888dTripp this._context.clearRect(0, 0, w, h);
09688ec5ffb8b9cf9883a770e2f9ebd60b28888dTripp if(this._methods)
09688ec5ffb8b9cf9883a770e2f9ebd60b28888dTripp {
09688ec5ffb8b9cf9883a770e2f9ebd60b28888dTripp len = cachedMethods.length;
09688ec5ffb8b9cf9883a770e2f9ebd60b28888dTripp if(!len || len < 1)
09688ec5ffb8b9cf9883a770e2f9ebd60b28888dTripp {
09688ec5ffb8b9cf9883a770e2f9ebd60b28888dTripp return;
09688ec5ffb8b9cf9883a770e2f9ebd60b28888dTripp }
09688ec5ffb8b9cf9883a770e2f9ebd60b28888dTripp for(; i < len; ++i)
09688ec5ffb8b9cf9883a770e2f9ebd60b28888dTripp {
09688ec5ffb8b9cf9883a770e2f9ebd60b28888dTripp methods[i] = cachedMethods[i].concat();
09688ec5ffb8b9cf9883a770e2f9ebd60b28888dTripp args = methods[i];
09688ec5ffb8b9cf9883a770e2f9ebd60b28888dTripp for(j = 1; j < args.length; ++j)
09688ec5ffb8b9cf9883a770e2f9ebd60b28888dTripp {
09688ec5ffb8b9cf9883a770e2f9ebd60b28888dTripp if(j % 2 === 0)
09688ec5ffb8b9cf9883a770e2f9ebd60b28888dTripp {
09688ec5ffb8b9cf9883a770e2f9ebd60b28888dTripp args[j] = args[j] - this._top;
09688ec5ffb8b9cf9883a770e2f9ebd60b28888dTripp }
09688ec5ffb8b9cf9883a770e2f9ebd60b28888dTripp else
09688ec5ffb8b9cf9883a770e2f9ebd60b28888dTripp {
09688ec5ffb8b9cf9883a770e2f9ebd60b28888dTripp args[j] = args[j] - this._left;
09688ec5ffb8b9cf9883a770e2f9ebd60b28888dTripp }
09688ec5ffb8b9cf9883a770e2f9ebd60b28888dTripp }
09688ec5ffb8b9cf9883a770e2f9ebd60b28888dTripp }
09688ec5ffb8b9cf9883a770e2f9ebd60b28888dTripp node.setAttribute("width", w);
09688ec5ffb8b9cf9883a770e2f9ebd60b28888dTripp node.setAttribute("height", h);
09688ec5ffb8b9cf9883a770e2f9ebd60b28888dTripp context.beginPath();
09688ec5ffb8b9cf9883a770e2f9ebd60b28888dTripp for(i = 0; i < len; ++i)
09688ec5ffb8b9cf9883a770e2f9ebd60b28888dTripp {
09688ec5ffb8b9cf9883a770e2f9ebd60b28888dTripp args = methods[i].concat();
09688ec5ffb8b9cf9883a770e2f9ebd60b28888dTripp if(args && args.length > 0)
09688ec5ffb8b9cf9883a770e2f9ebd60b28888dTripp {
09688ec5ffb8b9cf9883a770e2f9ebd60b28888dTripp method = args.shift();
09688ec5ffb8b9cf9883a770e2f9ebd60b28888dTripp if(method)
09688ec5ffb8b9cf9883a770e2f9ebd60b28888dTripp {
09688ec5ffb8b9cf9883a770e2f9ebd60b28888dTripp if(method && method == "lineTo" && this._dashstyle)
09688ec5ffb8b9cf9883a770e2f9ebd60b28888dTripp {
09688ec5ffb8b9cf9883a770e2f9ebd60b28888dTripp args.unshift(this._xcoords[i] - this._left, this._ycoords[i] - this._top);
09688ec5ffb8b9cf9883a770e2f9ebd60b28888dTripp this._drawDashedLine.apply(this, args);
09688ec5ffb8b9cf9883a770e2f9ebd60b28888dTripp }
09688ec5ffb8b9cf9883a770e2f9ebd60b28888dTripp else
09688ec5ffb8b9cf9883a770e2f9ebd60b28888dTripp {
09688ec5ffb8b9cf9883a770e2f9ebd60b28888dTripp context[method].apply(context, args);
09688ec5ffb8b9cf9883a770e2f9ebd60b28888dTripp }
09688ec5ffb8b9cf9883a770e2f9ebd60b28888dTripp }
09688ec5ffb8b9cf9883a770e2f9ebd60b28888dTripp }
09688ec5ffb8b9cf9883a770e2f9ebd60b28888dTripp }
09688ec5ffb8b9cf9883a770e2f9ebd60b28888dTripp
09688ec5ffb8b9cf9883a770e2f9ebd60b28888dTripp
09688ec5ffb8b9cf9883a770e2f9ebd60b28888dTripp if (this._fillType)
09688ec5ffb8b9cf9883a770e2f9ebd60b28888dTripp {
09688ec5ffb8b9cf9883a770e2f9ebd60b28888dTripp if(this._fillType == "linear")
09688ec5ffb8b9cf9883a770e2f9ebd60b28888dTripp {
09688ec5ffb8b9cf9883a770e2f9ebd60b28888dTripp context.fillStyle = this._getLinearGradient();
09688ec5ffb8b9cf9883a770e2f9ebd60b28888dTripp }
09688ec5ffb8b9cf9883a770e2f9ebd60b28888dTripp else if(this._fillType == "radial")
09688ec5ffb8b9cf9883a770e2f9ebd60b28888dTripp {
09688ec5ffb8b9cf9883a770e2f9ebd60b28888dTripp context.fillStyle = this._getRadialGradient();
09688ec5ffb8b9cf9883a770e2f9ebd60b28888dTripp }
09688ec5ffb8b9cf9883a770e2f9ebd60b28888dTripp else
09688ec5ffb8b9cf9883a770e2f9ebd60b28888dTripp {
09688ec5ffb8b9cf9883a770e2f9ebd60b28888dTripp context.fillStyle = this._fillColor;
09688ec5ffb8b9cf9883a770e2f9ebd60b28888dTripp }
09688ec5ffb8b9cf9883a770e2f9ebd60b28888dTripp context.closePath();
09688ec5ffb8b9cf9883a770e2f9ebd60b28888dTripp context.fill();
09688ec5ffb8b9cf9883a770e2f9ebd60b28888dTripp }
09688ec5ffb8b9cf9883a770e2f9ebd60b28888dTripp
09688ec5ffb8b9cf9883a770e2f9ebd60b28888dTripp if (this._stroke) {
09688ec5ffb8b9cf9883a770e2f9ebd60b28888dTripp if(this._strokeWeight)
09688ec5ffb8b9cf9883a770e2f9ebd60b28888dTripp {
09688ec5ffb8b9cf9883a770e2f9ebd60b28888dTripp context.lineWidth = this._strokeWeight;
09688ec5ffb8b9cf9883a770e2f9ebd60b28888dTripp }
09688ec5ffb8b9cf9883a770e2f9ebd60b28888dTripp context.lineCap = this._linecap;
09688ec5ffb8b9cf9883a770e2f9ebd60b28888dTripp context.lineJoin = this._linejoin;
09688ec5ffb8b9cf9883a770e2f9ebd60b28888dTripp if(this._miterlimit)
09688ec5ffb8b9cf9883a770e2f9ebd60b28888dTripp {
09688ec5ffb8b9cf9883a770e2f9ebd60b28888dTripp context.miterLimit = this._miterlimit;
09688ec5ffb8b9cf9883a770e2f9ebd60b28888dTripp }
09688ec5ffb8b9cf9883a770e2f9ebd60b28888dTripp context.strokeStyle = this._strokeStyle;
09688ec5ffb8b9cf9883a770e2f9ebd60b28888dTripp context.stroke();
09688ec5ffb8b9cf9883a770e2f9ebd60b28888dTripp }
09688ec5ffb8b9cf9883a770e2f9ebd60b28888dTripp this._drawingComplete = true;
09688ec5ffb8b9cf9883a770e2f9ebd60b28888dTripp this._clearAndUpdateCoords();
09688ec5ffb8b9cf9883a770e2f9ebd60b28888dTripp this._updateNodePosition();
09688ec5ffb8b9cf9883a770e2f9ebd60b28888dTripp this._methods = cachedMethods;
09688ec5ffb8b9cf9883a770e2f9ebd60b28888dTripp }
09688ec5ffb8b9cf9883a770e2f9ebd60b28888dTripp },
09688ec5ffb8b9cf9883a770e2f9ebd60b28888dTripp
09688ec5ffb8b9cf9883a770e2f9ebd60b28888dTripp /**
09688ec5ffb8b9cf9883a770e2f9ebd60b28888dTripp * Draws a dashed line between two points.
09688ec5ffb8b9cf9883a770e2f9ebd60b28888dTripp *
09688ec5ffb8b9cf9883a770e2f9ebd60b28888dTripp * @method _drawDashedLine
09688ec5ffb8b9cf9883a770e2f9ebd60b28888dTripp * @param {Number} xStart The x position of the start of the line
09688ec5ffb8b9cf9883a770e2f9ebd60b28888dTripp * @param {Number} yStart The y position of the start of the line
09688ec5ffb8b9cf9883a770e2f9ebd60b28888dTripp * @param {Number} xEnd The x position of the end of the line
09688ec5ffb8b9cf9883a770e2f9ebd60b28888dTripp * @param {Number} yEnd The y position of the end of the line
09688ec5ffb8b9cf9883a770e2f9ebd60b28888dTripp * @private
09688ec5ffb8b9cf9883a770e2f9ebd60b28888dTripp */
09688ec5ffb8b9cf9883a770e2f9ebd60b28888dTripp _drawDashedLine: function(xStart, yStart, xEnd, yEnd)
09688ec5ffb8b9cf9883a770e2f9ebd60b28888dTripp {
09688ec5ffb8b9cf9883a770e2f9ebd60b28888dTripp var context = this._context,
09688ec5ffb8b9cf9883a770e2f9ebd60b28888dTripp dashsize = this._dashstyle[0],
09688ec5ffb8b9cf9883a770e2f9ebd60b28888dTripp gapsize = this._dashstyle[1],
09688ec5ffb8b9cf9883a770e2f9ebd60b28888dTripp segmentLength = dashsize + gapsize,
09688ec5ffb8b9cf9883a770e2f9ebd60b28888dTripp xDelta = xEnd - xStart,
09688ec5ffb8b9cf9883a770e2f9ebd60b28888dTripp yDelta = yEnd - yStart,
09688ec5ffb8b9cf9883a770e2f9ebd60b28888dTripp delta = Math.sqrt(Math.pow(xDelta, 2) + Math.pow(yDelta, 2)),
09688ec5ffb8b9cf9883a770e2f9ebd60b28888dTripp segmentCount = Math.floor(Math.abs(delta / segmentLength)),
09688ec5ffb8b9cf9883a770e2f9ebd60b28888dTripp radians = Math.atan2(yDelta, xDelta),
09688ec5ffb8b9cf9883a770e2f9ebd60b28888dTripp xCurrent = xStart,
09688ec5ffb8b9cf9883a770e2f9ebd60b28888dTripp yCurrent = yStart,
09688ec5ffb8b9cf9883a770e2f9ebd60b28888dTripp i;
09688ec5ffb8b9cf9883a770e2f9ebd60b28888dTripp xDelta = Math.cos(radians) * segmentLength;
09688ec5ffb8b9cf9883a770e2f9ebd60b28888dTripp yDelta = Math.sin(radians) * segmentLength;
09688ec5ffb8b9cf9883a770e2f9ebd60b28888dTripp
09688ec5ffb8b9cf9883a770e2f9ebd60b28888dTripp for(i = 0; i < segmentCount; ++i)
09688ec5ffb8b9cf9883a770e2f9ebd60b28888dTripp {
09688ec5ffb8b9cf9883a770e2f9ebd60b28888dTripp context.moveTo(xCurrent, yCurrent);
09688ec5ffb8b9cf9883a770e2f9ebd60b28888dTripp context.lineTo(xCurrent + Math.cos(radians) * dashsize, yCurrent + Math.sin(radians) * dashsize);
09688ec5ffb8b9cf9883a770e2f9ebd60b28888dTripp xCurrent += xDelta;
09688ec5ffb8b9cf9883a770e2f9ebd60b28888dTripp yCurrent += yDelta;
09688ec5ffb8b9cf9883a770e2f9ebd60b28888dTripp }
09688ec5ffb8b9cf9883a770e2f9ebd60b28888dTripp
09688ec5ffb8b9cf9883a770e2f9ebd60b28888dTripp context.moveTo(xCurrent, yCurrent);
09688ec5ffb8b9cf9883a770e2f9ebd60b28888dTripp delta = Math.sqrt((xEnd - xCurrent) * (xEnd - xCurrent) + (yEnd - yCurrent) * (yEnd - yCurrent));
09688ec5ffb8b9cf9883a770e2f9ebd60b28888dTripp
09688ec5ffb8b9cf9883a770e2f9ebd60b28888dTripp if(delta > dashsize)
09688ec5ffb8b9cf9883a770e2f9ebd60b28888dTripp {
09688ec5ffb8b9cf9883a770e2f9ebd60b28888dTripp context.lineTo(xCurrent + Math.cos(radians) * dashsize, yCurrent + Math.sin(radians) * dashsize);
09688ec5ffb8b9cf9883a770e2f9ebd60b28888dTripp }
09688ec5ffb8b9cf9883a770e2f9ebd60b28888dTripp else if(delta > 0)
09688ec5ffb8b9cf9883a770e2f9ebd60b28888dTripp {
09688ec5ffb8b9cf9883a770e2f9ebd60b28888dTripp context.lineTo(xCurrent + Math.cos(radians) * delta, yCurrent + Math.sin(radians) * delta);
09688ec5ffb8b9cf9883a770e2f9ebd60b28888dTripp }
09688ec5ffb8b9cf9883a770e2f9ebd60b28888dTripp
09688ec5ffb8b9cf9883a770e2f9ebd60b28888dTripp context.moveTo(xEnd, yEnd);
09688ec5ffb8b9cf9883a770e2f9ebd60b28888dTripp },
09688ec5ffb8b9cf9883a770e2f9ebd60b28888dTripp
09688ec5ffb8b9cf9883a770e2f9ebd60b28888dTripp /**
09688ec5ffb8b9cf9883a770e2f9ebd60b28888dTripp * Clears the graphics object.
09688ec5ffb8b9cf9883a770e2f9ebd60b28888dTripp *
09688ec5ffb8b9cf9883a770e2f9ebd60b28888dTripp * @method clear
09688ec5ffb8b9cf9883a770e2f9ebd60b28888dTripp */
09688ec5ffb8b9cf9883a770e2f9ebd60b28888dTripp clear: function() {
09688ec5ffb8b9cf9883a770e2f9ebd60b28888dTripp var w = this.get("width"),
09688ec5ffb8b9cf9883a770e2f9ebd60b28888dTripp h = this.get("height");
09688ec5ffb8b9cf9883a770e2f9ebd60b28888dTripp this._initProps();
09688ec5ffb8b9cf9883a770e2f9ebd60b28888dTripp this._context.clearRect(0, 0, w, h);
09688ec5ffb8b9cf9883a770e2f9ebd60b28888dTripp return this;
09688ec5ffb8b9cf9883a770e2f9ebd60b28888dTripp }
09688ec5ffb8b9cf9883a770e2f9ebd60b28888dTripp });
09688ec5ffb8b9cf9883a770e2f9ebd60b28888dTripp
09688ec5ffb8b9cf9883a770e2f9ebd60b28888dTripp CanvasShape.ATTRS = {
09688ec5ffb8b9cf9883a770e2f9ebd60b28888dTripp /**
09688ec5ffb8b9cf9883a770e2f9ebd60b28888dTripp * An array of x, y values which indicates the transformOrigin in which to rotate the shape. Valid values range between 0 and 1 representing a
09688ec5ffb8b9cf9883a770e2f9ebd60b28888dTripp * fraction of the shape's corresponding bounding box dimension. The default value is [0.5, 0.5].
09688ec5ffb8b9cf9883a770e2f9ebd60b28888dTripp *
09688ec5ffb8b9cf9883a770e2f9ebd60b28888dTripp * @attribute transformOrigin
09688ec5ffb8b9cf9883a770e2f9ebd60b28888dTripp * @type Array
09688ec5ffb8b9cf9883a770e2f9ebd60b28888dTripp */
09688ec5ffb8b9cf9883a770e2f9ebd60b28888dTripp transformOrigin: {
09688ec5ffb8b9cf9883a770e2f9ebd60b28888dTripp valueFn: function()
09688ec5ffb8b9cf9883a770e2f9ebd60b28888dTripp {
09688ec5ffb8b9cf9883a770e2f9ebd60b28888dTripp return [0.5, 0.5];
09688ec5ffb8b9cf9883a770e2f9ebd60b28888dTripp }
09688ec5ffb8b9cf9883a770e2f9ebd60b28888dTripp },
09688ec5ffb8b9cf9883a770e2f9ebd60b28888dTripp
09688ec5ffb8b9cf9883a770e2f9ebd60b28888dTripp /**
09688ec5ffb8b9cf9883a770e2f9ebd60b28888dTripp * The rotation (in degrees) of the shape.
09688ec5ffb8b9cf9883a770e2f9ebd60b28888dTripp *
09688ec5ffb8b9cf9883a770e2f9ebd60b28888dTripp * @attribute rotation
09688ec5ffb8b9cf9883a770e2f9ebd60b28888dTripp * @type Number
09688ec5ffb8b9cf9883a770e2f9ebd60b28888dTripp */
09688ec5ffb8b9cf9883a770e2f9ebd60b28888dTripp rotation: {
09688ec5ffb8b9cf9883a770e2f9ebd60b28888dTripp setter: function(val)
09688ec5ffb8b9cf9883a770e2f9ebd60b28888dTripp {
09688ec5ffb8b9cf9883a770e2f9ebd60b28888dTripp this.rotate(val);
09688ec5ffb8b9cf9883a770e2f9ebd60b28888dTripp },
09688ec5ffb8b9cf9883a770e2f9ebd60b28888dTripp
09688ec5ffb8b9cf9883a770e2f9ebd60b28888dTripp getter: function()
09688ec5ffb8b9cf9883a770e2f9ebd60b28888dTripp {
09688ec5ffb8b9cf9883a770e2f9ebd60b28888dTripp return this._rotation;
09688ec5ffb8b9cf9883a770e2f9ebd60b28888dTripp }
09688ec5ffb8b9cf9883a770e2f9ebd60b28888dTripp },
09688ec5ffb8b9cf9883a770e2f9ebd60b28888dTripp
09688ec5ffb8b9cf9883a770e2f9ebd60b28888dTripp /**
09688ec5ffb8b9cf9883a770e2f9ebd60b28888dTripp * Dom node of the shape
09688ec5ffb8b9cf9883a770e2f9ebd60b28888dTripp *
09688ec5ffb8b9cf9883a770e2f9ebd60b28888dTripp * @attribute node
09688ec5ffb8b9cf9883a770e2f9ebd60b28888dTripp * @type HTMLElement
09688ec5ffb8b9cf9883a770e2f9ebd60b28888dTripp * @readOnly
09688ec5ffb8b9cf9883a770e2f9ebd60b28888dTripp */
09688ec5ffb8b9cf9883a770e2f9ebd60b28888dTripp node: {
09688ec5ffb8b9cf9883a770e2f9ebd60b28888dTripp readOnly: true,
09688ec5ffb8b9cf9883a770e2f9ebd60b28888dTripp
09688ec5ffb8b9cf9883a770e2f9ebd60b28888dTripp getter: function()
09688ec5ffb8b9cf9883a770e2f9ebd60b28888dTripp {
09688ec5ffb8b9cf9883a770e2f9ebd60b28888dTripp return this.node;
09688ec5ffb8b9cf9883a770e2f9ebd60b28888dTripp }
09688ec5ffb8b9cf9883a770e2f9ebd60b28888dTripp },
09688ec5ffb8b9cf9883a770e2f9ebd60b28888dTripp
09688ec5ffb8b9cf9883a770e2f9ebd60b28888dTripp /**
09688ec5ffb8b9cf9883a770e2f9ebd60b28888dTripp * Unique id for class instance.
09688ec5ffb8b9cf9883a770e2f9ebd60b28888dTripp *
09688ec5ffb8b9cf9883a770e2f9ebd60b28888dTripp * @attribute id
09688ec5ffb8b9cf9883a770e2f9ebd60b28888dTripp * @type String
09688ec5ffb8b9cf9883a770e2f9ebd60b28888dTripp */
09688ec5ffb8b9cf9883a770e2f9ebd60b28888dTripp id: {
09688ec5ffb8b9cf9883a770e2f9ebd60b28888dTripp valueFn: function()
09688ec5ffb8b9cf9883a770e2f9ebd60b28888dTripp {
09688ec5ffb8b9cf9883a770e2f9ebd60b28888dTripp return Y.guid();
09688ec5ffb8b9cf9883a770e2f9ebd60b28888dTripp }
09688ec5ffb8b9cf9883a770e2f9ebd60b28888dTripp },
09688ec5ffb8b9cf9883a770e2f9ebd60b28888dTripp
09688ec5ffb8b9cf9883a770e2f9ebd60b28888dTripp /**
09688ec5ffb8b9cf9883a770e2f9ebd60b28888dTripp *
09688ec5ffb8b9cf9883a770e2f9ebd60b28888dTripp * @attribute width
09688ec5ffb8b9cf9883a770e2f9ebd60b28888dTripp */
09688ec5ffb8b9cf9883a770e2f9ebd60b28888dTripp width: {},
09688ec5ffb8b9cf9883a770e2f9ebd60b28888dTripp
09688ec5ffb8b9cf9883a770e2f9ebd60b28888dTripp /**
09688ec5ffb8b9cf9883a770e2f9ebd60b28888dTripp *
09688ec5ffb8b9cf9883a770e2f9ebd60b28888dTripp * @attribute height
09688ec5ffb8b9cf9883a770e2f9ebd60b28888dTripp */
09688ec5ffb8b9cf9883a770e2f9ebd60b28888dTripp height: {},
09688ec5ffb8b9cf9883a770e2f9ebd60b28888dTripp
09688ec5ffb8b9cf9883a770e2f9ebd60b28888dTripp /**
09688ec5ffb8b9cf9883a770e2f9ebd60b28888dTripp * The x-coordinate for the shape.
09688ec5ffb8b9cf9883a770e2f9ebd60b28888dTripp */
09688ec5ffb8b9cf9883a770e2f9ebd60b28888dTripp x: {
09688ec5ffb8b9cf9883a770e2f9ebd60b28888dTripp value: 0
09688ec5ffb8b9cf9883a770e2f9ebd60b28888dTripp },
09688ec5ffb8b9cf9883a770e2f9ebd60b28888dTripp
09688ec5ffb8b9cf9883a770e2f9ebd60b28888dTripp /**
09688ec5ffb8b9cf9883a770e2f9ebd60b28888dTripp * The x-coordinate for the shape.
09688ec5ffb8b9cf9883a770e2f9ebd60b28888dTripp */
09688ec5ffb8b9cf9883a770e2f9ebd60b28888dTripp y: {
09688ec5ffb8b9cf9883a770e2f9ebd60b28888dTripp value: 0
09688ec5ffb8b9cf9883a770e2f9ebd60b28888dTripp },
09688ec5ffb8b9cf9883a770e2f9ebd60b28888dTripp
09688ec5ffb8b9cf9883a770e2f9ebd60b28888dTripp /**
09688ec5ffb8b9cf9883a770e2f9ebd60b28888dTripp * Indicates whether the shape is visible.
09688ec5ffb8b9cf9883a770e2f9ebd60b28888dTripp *
09688ec5ffb8b9cf9883a770e2f9ebd60b28888dTripp * @attribute visible
09688ec5ffb8b9cf9883a770e2f9ebd60b28888dTripp * @type Boolean
09688ec5ffb8b9cf9883a770e2f9ebd60b28888dTripp */
09688ec5ffb8b9cf9883a770e2f9ebd60b28888dTripp visible: {
09688ec5ffb8b9cf9883a770e2f9ebd60b28888dTripp value: true,
09688ec5ffb8b9cf9883a770e2f9ebd60b28888dTripp
09688ec5ffb8b9cf9883a770e2f9ebd60b28888dTripp setter: function(val){
09688ec5ffb8b9cf9883a770e2f9ebd60b28888dTripp var visibility = val ? "visible" : "hidden";
09688ec5ffb8b9cf9883a770e2f9ebd60b28888dTripp this.get("node").style.visibility = visibility;
09688ec5ffb8b9cf9883a770e2f9ebd60b28888dTripp return val;
09688ec5ffb8b9cf9883a770e2f9ebd60b28888dTripp }
09688ec5ffb8b9cf9883a770e2f9ebd60b28888dTripp },
09688ec5ffb8b9cf9883a770e2f9ebd60b28888dTripp
09688ec5ffb8b9cf9883a770e2f9ebd60b28888dTripp /**
09688ec5ffb8b9cf9883a770e2f9ebd60b28888dTripp * Contains information about the fill of the shape.
09688ec5ffb8b9cf9883a770e2f9ebd60b28888dTripp * <dl>
09688ec5ffb8b9cf9883a770e2f9ebd60b28888dTripp * <dt>color</dt><dd>The color of the fill.</dd>
09688ec5ffb8b9cf9883a770e2f9ebd60b28888dTripp * <dt>opacity</dt><dd>Number between 0 and 1 that indicates the opacity of the fill. The default value is 1.</dd>
09688ec5ffb8b9cf9883a770e2f9ebd60b28888dTripp * </dl>
09688ec5ffb8b9cf9883a770e2f9ebd60b28888dTripp *
09688ec5ffb8b9cf9883a770e2f9ebd60b28888dTripp * @attribute fill
09688ec5ffb8b9cf9883a770e2f9ebd60b28888dTripp * @type Object
09688ec5ffb8b9cf9883a770e2f9ebd60b28888dTripp */
09688ec5ffb8b9cf9883a770e2f9ebd60b28888dTripp fill: {
09688ec5ffb8b9cf9883a770e2f9ebd60b28888dTripp valueFn: "_getDefaultFill",
09688ec5ffb8b9cf9883a770e2f9ebd60b28888dTripp
09688ec5ffb8b9cf9883a770e2f9ebd60b28888dTripp setter: function(val)
09688ec5ffb8b9cf9883a770e2f9ebd60b28888dTripp {
09688ec5ffb8b9cf9883a770e2f9ebd60b28888dTripp var fill,
09688ec5ffb8b9cf9883a770e2f9ebd60b28888dTripp tmpl = this.get("fill") || this._getDefaultFill();
09688ec5ffb8b9cf9883a770e2f9ebd60b28888dTripp fill = (val) ? Y.merge(tmpl, val) : null;
09688ec5ffb8b9cf9883a770e2f9ebd60b28888dTripp if(fill && fill.color)
09688ec5ffb8b9cf9883a770e2f9ebd60b28888dTripp {
09688ec5ffb8b9cf9883a770e2f9ebd60b28888dTripp if(fill.color === undefined || fill.color == "none")
09688ec5ffb8b9cf9883a770e2f9ebd60b28888dTripp {
09688ec5ffb8b9cf9883a770e2f9ebd60b28888dTripp fill.color = null;
09688ec5ffb8b9cf9883a770e2f9ebd60b28888dTripp }
09688ec5ffb8b9cf9883a770e2f9ebd60b28888dTripp }
09688ec5ffb8b9cf9883a770e2f9ebd60b28888dTripp this._setFillProps(fill);
09688ec5ffb8b9cf9883a770e2f9ebd60b28888dTripp return fill;
09688ec5ffb8b9cf9883a770e2f9ebd60b28888dTripp }
09688ec5ffb8b9cf9883a770e2f9ebd60b28888dTripp },
09688ec5ffb8b9cf9883a770e2f9ebd60b28888dTripp
09688ec5ffb8b9cf9883a770e2f9ebd60b28888dTripp /**
09688ec5ffb8b9cf9883a770e2f9ebd60b28888dTripp * Contains information about the stroke of the shape.
09688ec5ffb8b9cf9883a770e2f9ebd60b28888dTripp * <dl>
09688ec5ffb8b9cf9883a770e2f9ebd60b28888dTripp * <dt>color</dt><dd>The color of the stroke.</dd>
09688ec5ffb8b9cf9883a770e2f9ebd60b28888dTripp * <dt>weight</dt><dd>Number that indicates the width of the stroke.</dd>
09688ec5ffb8b9cf9883a770e2f9ebd60b28888dTripp * <dt>opacity</dt><dd>Number between 0 and 1 that indicates the opacity of the stroke. The default value is 1.</dd>
09688ec5ffb8b9cf9883a770e2f9ebd60b28888dTripp * <dt>dashstyle</dt>Indicates whether to draw a dashed stroke. When set to "none", a solid stroke is drawn. When set to an array, the first index indicates the
09688ec5ffb8b9cf9883a770e2f9ebd60b28888dTripp * length of the dash. The second index indicates the length of gap.
09688ec5ffb8b9cf9883a770e2f9ebd60b28888dTripp * </dl>
09688ec5ffb8b9cf9883a770e2f9ebd60b28888dTripp *
09688ec5ffb8b9cf9883a770e2f9ebd60b28888dTripp * @attribute stroke
09688ec5ffb8b9cf9883a770e2f9ebd60b28888dTripp * @type Object
09688ec5ffb8b9cf9883a770e2f9ebd60b28888dTripp */
09688ec5ffb8b9cf9883a770e2f9ebd60b28888dTripp stroke: {
09688ec5ffb8b9cf9883a770e2f9ebd60b28888dTripp valueFn: "_getDefaultStroke",
09688ec5ffb8b9cf9883a770e2f9ebd60b28888dTripp
09688ec5ffb8b9cf9883a770e2f9ebd60b28888dTripp setter: function(val)
09688ec5ffb8b9cf9883a770e2f9ebd60b28888dTripp {
09688ec5ffb8b9cf9883a770e2f9ebd60b28888dTripp var tmpl = this.get("stroke") || this._getDefaultStroke();
09688ec5ffb8b9cf9883a770e2f9ebd60b28888dTripp val = (val) ? Y.merge(tmpl, val) : null;
09688ec5ffb8b9cf9883a770e2f9ebd60b28888dTripp this._setStrokeProps(val);
09688ec5ffb8b9cf9883a770e2f9ebd60b28888dTripp return val;
09688ec5ffb8b9cf9883a770e2f9ebd60b28888dTripp }
09688ec5ffb8b9cf9883a770e2f9ebd60b28888dTripp },
09688ec5ffb8b9cf9883a770e2f9ebd60b28888dTripp
09688ec5ffb8b9cf9883a770e2f9ebd60b28888dTripp /**
09688ec5ffb8b9cf9883a770e2f9ebd60b28888dTripp * Indicates whether or not the instance will size itself based on its contents.
09688ec5ffb8b9cf9883a770e2f9ebd60b28888dTripp *
09688ec5ffb8b9cf9883a770e2f9ebd60b28888dTripp * @attribute autoSize
09688ec5ffb8b9cf9883a770e2f9ebd60b28888dTripp * @type Boolean
09688ec5ffb8b9cf9883a770e2f9ebd60b28888dTripp */
09688ec5ffb8b9cf9883a770e2f9ebd60b28888dTripp autoSize: {
09688ec5ffb8b9cf9883a770e2f9ebd60b28888dTripp value: false
09688ec5ffb8b9cf9883a770e2f9ebd60b28888dTripp },
09688ec5ffb8b9cf9883a770e2f9ebd60b28888dTripp
09688ec5ffb8b9cf9883a770e2f9ebd60b28888dTripp /**
09688ec5ffb8b9cf9883a770e2f9ebd60b28888dTripp * Determines whether the instance will receive mouse events.
09688ec5ffb8b9cf9883a770e2f9ebd60b28888dTripp *
09688ec5ffb8b9cf9883a770e2f9ebd60b28888dTripp * @attribute pointerEvents
09688ec5ffb8b9cf9883a770e2f9ebd60b28888dTripp * @type string
09688ec5ffb8b9cf9883a770e2f9ebd60b28888dTripp */
09688ec5ffb8b9cf9883a770e2f9ebd60b28888dTripp pointerEvents: {
09688ec5ffb8b9cf9883a770e2f9ebd60b28888dTripp value: "visiblePainted"
09688ec5ffb8b9cf9883a770e2f9ebd60b28888dTripp },
09688ec5ffb8b9cf9883a770e2f9ebd60b28888dTripp
09688ec5ffb8b9cf9883a770e2f9ebd60b28888dTripp /**
09688ec5ffb8b9cf9883a770e2f9ebd60b28888dTripp * Reference to the container Graphic.
09688ec5ffb8b9cf9883a770e2f9ebd60b28888dTripp *
09688ec5ffb8b9cf9883a770e2f9ebd60b28888dTripp * @attribute graphic
09688ec5ffb8b9cf9883a770e2f9ebd60b28888dTripp * @type Graphic
09688ec5ffb8b9cf9883a770e2f9ebd60b28888dTripp */
09688ec5ffb8b9cf9883a770e2f9ebd60b28888dTripp graphic: {
09688ec5ffb8b9cf9883a770e2f9ebd60b28888dTripp readOnly: true,
09688ec5ffb8b9cf9883a770e2f9ebd60b28888dTripp
09688ec5ffb8b9cf9883a770e2f9ebd60b28888dTripp getter: function()
09688ec5ffb8b9cf9883a770e2f9ebd60b28888dTripp {
09688ec5ffb8b9cf9883a770e2f9ebd60b28888dTripp return this._graphic;
09688ec5ffb8b9cf9883a770e2f9ebd60b28888dTripp }
09688ec5ffb8b9cf9883a770e2f9ebd60b28888dTripp }
09688ec5ffb8b9cf9883a770e2f9ebd60b28888dTripp };
09688ec5ffb8b9cf9883a770e2f9ebd60b28888dTripp //Straightup augment, no wrapper functions
09688ec5ffb8b9cf9883a770e2f9ebd60b28888dTripp Y.mix(CanvasShape, Y.AttributeLite, false, null, 1);
09688ec5ffb8b9cf9883a770e2f9ebd60b28888dTripp Y.mix(CanvasShape, Y.EventTarget, false, null, 1);
09688ec5ffb8b9cf9883a770e2f9ebd60b28888dTripp Y.mix(CanvasShape, PluginHost, false, null, 1);
09688ec5ffb8b9cf9883a770e2f9ebd60b28888dTripp CanvasShape.plug = PluginHost.plug;
09688ec5ffb8b9cf9883a770e2f9ebd60b28888dTripp CanvasShape.unplug = PluginHost.unplug;
09688ec5ffb8b9cf9883a770e2f9ebd60b28888dTripp Y.CanvasShape = CanvasShape;