1
/* YUI 3.9.1 (build 5852) Copyright 2013 Yahoo! Inc. http://yuilibrary.com/license/ */
2
YUI.add('graphics', function (Y, NAME) {
6
* <p>The `Graphics` module provides a JavaScript API for creating shapes in a variety of formats across
7
* a <a href="http://developer.yahoo.com/yui/articles/gbs">browser test baseline</a>.
8
* Based on device and browser capabilities, `Graphics` leverages <a href="http://www.w3.org/TR/SVG/">SVG</a>,
9
* <a href="http://www.w3.org/TR/html5/the-canvas-element.html">Canvas</a> and <a href="http://www.w3.org/TR/NOTE-VML">VML</a>
10
* to render its graphical elements.</p>
12
* <p>The `Graphics` module features a <a href="../classes/Graphic.html">`Graphic`</a> class that allows you to easily create and manage shapes.
13
* Currently, a <a href="../classes/Graphic.html">`Graphic`</a> instance can be used to create predifined shapes and free-form polygons with fill
14
* and stroke properties.</p>
16
* <p>The `Graphics` module normalizes an API through the use of alias and implementation classes that share
17
* interfaces. Each alias class points to an appropriate implementation class dependent on the browser's
18
* capabilities. There should rarely, if ever, be a need to interact directly with an implementation class.</p>
20
* <p>Below is a list of available classes.
22
* <li><a href="../classes/Graphic.html">`Graphic`</a>
23
* <li><a href="../classes/Shape.html">`Shape`</a>
24
* <li><a href="../classes/Circle.html">`Circle`</a>
25
* <li><a href="../classes/Ellipse.html">`Ellipse`</a>
26
* <li><a href="../classes/Rect.html">`Rect`</a>
27
* <li><a href="../classes/Path.html">`Path`</a>
29
* You can also extend the `Shape` class to create your own custom shape classes.</p>
33
var SETTER = "setter",
34
PluginHost = Y.Plugin.Host,
37
READONLY = "readOnly",
40
WRITE_ONCE = "writeOnce",
45
* AttributeLite provides Attribute-like getters and setters for shape classes in the Graphics module.
46
* It provides a get/set API without the event infastructure. This class is temporary and a work in progress.
48
* @class AttributeLite
51
AttributeLite = function()
53
var host = this; // help compression
55
// Perf tweak - avoid creating event literals if not required.
56
host._ATTR_E_FACADE = {};
58
Y.EventTarget.call(this, {emitFacade:true});
60
host.prototype = Y.mix(AttributeLite.prototype, host.prototype);
63
AttributeLite.prototype = {
65
* Initializes the attributes for a shape. If an attribute config is passed into the constructor of the host,
66
* the initial values will be overwritten.
69
* @param {Object} cfg Optional object containing attributes key value pairs to be set.
71
addAttrs: function(cfg)
74
attrConfig = this.constructor.ATTRS,
81
if(attrConfig.hasOwnProperty(i))
84
if(attr.hasOwnProperty(VALUE))
86
state[i] = attr.value;
88
else if(attr.hasOwnProperty(VALUEFN))
91
if(Y_LANG.isString(fn))
93
state[i] = host[fn].apply(host);
97
state[i] = fn.apply(host);
105
if(attrConfig.hasOwnProperty(i))
107
attr = attrConfig[i];
108
if(attr.hasOwnProperty(READONLY) && attr.readOnly)
113
if(attr.hasOwnProperty(WRITE_ONCE) && attr.writeOnce)
115
attr.readOnly = true;
118
if(cfg && cfg.hasOwnProperty(i))
120
if(attr.hasOwnProperty(SETTER))
122
host._state[i] = attr.setter.apply(host, [cfg[i]]);
126
host._state[i] = cfg[i];
134
* For a given item, returns the value of the property requested, or undefined if not found.
137
* @param name {String} The name of the item
138
* @return {Any} The value of the supplied property.
144
attrConfig = host.constructor.ATTRS;
145
if(attrConfig && attrConfig[attr])
147
getter = attrConfig[attr].getter;
150
if(typeof getter === STR)
152
return host[getter].apply(host);
154
return attrConfig[attr].getter.apply(host);
157
return host._state[attr];
163
* Sets the value of an attribute.
166
* @param {String|Object} name The name of the attribute. Alternatively, an object of key value pairs can
167
* be passed in to set multiple attributes at once.
168
* @param {Any} value The value to set the attribute to. This value is ignored if an object is received as
173
var attr = arguments[0],
175
if(Y_LANG.isObject(attr))
179
if(attr.hasOwnProperty(i))
181
this._set(i, attr[i]);
187
this._set.apply(this, arguments);
192
* Provides setter logic. Used by `set`.
195
* @param {String|Object} name The name of the attribute. Alternatively, an object of key value pairs can
196
* be passed in to set multiple attributes at once.
197
* @param {Any} value The value to set the attribute to. This value is ignored if an object is received as
201
_set: function(attr, val)
206
attrConfig = host.constructor.ATTRS;
207
if(attrConfig && attrConfig.hasOwnProperty(attr))
209
setter = attrConfig[attr].setter;
213
if(typeof setter === STR)
215
val = host[setter].apply(host, args);
219
val = attrConfig[attr].setter.apply(host, args);
222
host._state[attr] = val;
226
Y.mix(AttributeLite, Y.EventTarget, false, null, 1);
227
Y.AttributeLite = AttributeLite;
230
* GraphicBase serves as the base class for the graphic layer. It serves the same purpose as
231
* Base but uses a lightweight getter/setter class instead of Attribute.
232
* This class is temporary and a work in progress.
236
* @param {Object} cfg Key value pairs for attributes
238
GraphicBase = function(cfg)
241
PluginHost = Y.Plugin && Y.Plugin.Host;
242
if (host._initPlugins && PluginHost) {
243
PluginHost.call(host);
246
host.name = host.constructor.NAME;
247
host._eventPrefix = host.constructor.EVENT_PREFIX || host.constructor.NAME;
248
AttributeLite.call(host);
250
host.init.apply(this, arguments);
251
if (host._initPlugins) {
252
// Need to initPlugins manually, to handle constructor parsing, static Plug parsing
253
host._initPlugins(cfg);
255
host.initialized = true;
258
GraphicBase.NAME = "baseGraphic";
260
GraphicBase.prototype = {
262
* Init method, invoked during construction.
263
* Fires an init event after calling `initializer` on implementers.
270
this.publish("init", {
273
this.initializer.apply(this, arguments);
274
this.fire("init", {cfg: arguments[0]});
278
* Camel case concatanates two strings.
280
* @method _camelCaseConcat
281
* @param {String} prefix The first string
282
* @param {String} name The second string
286
_camelCaseConcat: function(prefix, name)
288
return prefix + name.charAt(0).toUpperCase() + name.slice(1);
291
//Straightup augment, no wrapper functions
292
Y.mix(GraphicBase, Y.AttributeLite, false, null, 1);
293
Y.mix(GraphicBase, PluginHost, false, null, 1);
294
GraphicBase.prototype.constructor = GraphicBase;
295
GraphicBase.plug = PluginHost.plug;
296
GraphicBase.unplug = PluginHost.unplug;
297
Y.GraphicBase = GraphicBase;
301
* `Drawing` provides a set of drawing methods used by `Path` and custom shape classes.
302
* `Drawing` has the following implementations based on browser capability.
304
* <li><a href="SVGDrawing.html">`SVGDrawing`</a></li>
305
* <li><a href="VMLDrawing.html">`VMLDrawing`</a></li>
306
* <li><a href="CanvasDrawing.html">`CanvasDrawing`</a></li>
313
* Draws a line segment using the current line style from the current drawing position to the specified x and y coordinates.
316
* @param {Number} point1 x-coordinate for the end point.
317
* @param {Number} point2 y-coordinate for the end point.
320
* Moves the current drawing position to specified x and y coordinates.
323
* @param {Number} x x-coordinate for the end point.
324
* @param {Number} y y-coordinate for the end point.
327
* Draws a bezier curve.
330
* @param {Number} cp1x x-coordinate for the first control point.
331
* @param {Number} cp1y y-coordinate for the first control point.
332
* @param {Number} cp2x x-coordinate for the second control point.
333
* @param {Number} cp2y y-coordinate for the second control point.
334
* @param {Number} x x-coordinate for the end point.
335
* @param {Number} y y-coordinate for the end point.
338
* Draws a quadratic bezier curve.
340
* @method quadraticCurveTo
341
* @param {Number} cpx x-coordinate for the control point.
342
* @param {Number} cpy y-coordinate for the control point.
343
* @param {Number} x x-coordinate for the end point.
344
* @param {Number} y y-coordinate for the end point.
350
* @param {Number} x x-coordinate
351
* @param {Number} y y-coordinate
352
* @param {Number} w width
353
* @param {Number} h height
356
* Draws a rectangle with rounded corners.
358
* @method drawRoundRect
359
* @param {Number} x x-coordinate
360
* @param {Number} y y-coordinate
361
* @param {Number} w width
362
* @param {Number} h height
363
* @param {Number} ew width of the ellipse used to draw the rounded corners
364
* @param {Number} eh height of the ellipse used to draw the rounded corners
367
* Completes a drawing operation.
377
* <p>Base class for creating shapes.</p>
378
* <p>`Shape` is an abstract class and is not meant to be used directly. The following classes extend
382
* <li><a href="Circle.html">`Circle`</a></li>
383
* <li><a href="Ellipse.html">`Ellipse`</a></li>
384
* <li><a href="Rect.html">`Rect`</a></li>
385
* <li><a href="Path.html">`Path`</a></li>
388
* `Shape` can also be extended to create custom shape classes.</p>
390
* `Shape` has the following implementations based on browser capability.
392
* <li><a href="SVGShape.html">`SVGShape`</a></li>
393
* <li><a href="VMLShape.html">`VMLShape`</a></li>
394
* <li><a href="CanvasShape.html">`CanvasShape`</a></li>
397
* It is not necessary to interact with these classes directly. `Shape` will point to the appropriate implemention.</p>
401
* @param {Object} cfg (optional) Attribute configs
404
* Init method, invoked during construction.
405
* Calls `initializer` method.
411
* Initializes the shape
414
* @method initializer
417
* Add a class name to each node.
420
* @param {String} className the class name to add to the node's class attribute
423
* Removes a class name from each node.
425
* @method removeClass
426
* @param {String} className the class name to remove from the node's class attribute
429
* Gets the current position of the node in page coordinates.
432
* @return Array The XY position of the shape.
435
* Set the position of the shape in page coordinates, regardless of how the node is positioned.
438
* @param {Array} Contains x & y values for new position (coordinates are page-based)
441
* Determines whether the node is an ancestor of another HTML element in the DOM hierarchy.
444
* @param {Shape | HTMLElement} needle The possible node or descendent
445
* @return Boolean Whether or not this shape is the needle or its ancestor.
448
* Compares nodes to determine if they match.
449
* Node instances can be compared to each other and/or HTMLElements.
451
* @param {HTMLElement | Node} refNode The reference node to compare to the node.
452
* @return {Boolean} True if the nodes match, false if they do not.
455
* Test if the supplied node matches the supplied selector.
458
* @param {String} selector The CSS selector to test against.
459
* @return Boolean Wheter or not the shape matches the selector.
462
* Sets the value of an attribute.
465
* @param {String|Object} name The name of the attribute. Alternatively, an object of key value pairs can
466
* be passed in to set multiple attributes at once.
467
* @param {Any} value The value to set the attribute to. This value is ignored if an object is received as
471
* Specifies a 2d translation.
474
* @param {Number} x The value to transate on the x-axis.
475
* @param {Number} y The value to translate on the y-axis.
478
* Translates the shape along the x-axis. When translating x and y coordinates,
479
* use the `translate` method.
482
* @param {Number} x The value to translate.
485
* Translates the shape along the y-axis. When translating x and y coordinates,
486
* use the `translate` method.
489
* @param {Number} y The value to translate.
492
* Skews the shape around the x-axis and y-axis.
495
* @param {Number} x The value to skew on the x-axis.
496
* @param {Number} y The value to skew on the y-axis.
499
* Skews the shape around the x-axis.
502
* @param {Number} x x-coordinate
505
* Skews the shape around the y-axis.
508
* @param {Number} y y-coordinate
511
* Rotates the shape clockwise around it transformOrigin.
514
* @param {Number} deg The degree of the rotation.
517
* Specifies a 2d scaling operation.
520
* @param {Number} val
523
* Returns the bounds for a shape.
525
* Calculates the a new bounding box from the original corner coordinates (base on size and position) and the transform matrix.
526
* The calculated bounding box is used by the graphic instance to calculate its viewBox.
532
* Destroys the instance.
537
* 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
538
* fraction of the shape's corresponding bounding box dimension. The default value is [0.5, 0.5].
540
* @config transformOrigin
544
* <p>A string containing, in order, transform operations applied to the shape instance. The `transform` string can contain the following values:
547
* <dt>rotate</dt><dd>Rotates the shape clockwise around it transformOrigin.</dd>
548
* <dt>translate</dt><dd>Specifies a 2d translation.</dd>
549
* <dt>skew</dt><dd>Skews the shape around the x-axis and y-axis.</dd>
550
* <dt>scale</dt><dd>Specifies a 2d scaling operation.</dd>
551
* <dt>translateX</dt><dd>Translates the shape along the x-axis.</dd>
552
* <dt>translateY</dt><dd>Translates the shape along the y-axis.</dd>
553
* <dt>skewX</dt><dd>Skews the shape around the x-axis.</dd>
554
* <dt>skewY</dt><dd>Skews the shape around the y-axis.</dd>
555
* <dt>matrix</dt><dd>Specifies a 2D transformation matrix comprised of the specified six values.</dd>
558
* <p>Applying transforms through the transform attribute will reset the transform matrix and apply a new transform. The shape class also contains
559
* corresponding methods for each transform that will apply the transform to the current matrix. The below code illustrates how you might use the
560
* `transform` attribute to instantiate a recangle with a rotation of 45 degrees.</p>
561
var myRect = new Y.Rect({
565
transform: "rotate(45)"
567
* <p>The code below would apply `translate` and `rotate` to an existing shape.</p>
569
myRect.set("transform", "translate(40, 50) rotate(45)");
574
* Unique id for class instance.
580
* Indicates the x position of shape.
586
* Indicates the y position of shape.
592
* Indicates the width of the shape
598
* Indicates the height of the shape
604
* Indicates whether the shape is visible.
610
* Contains information about the fill of the shape.
612
* <dt>color</dt><dd>The color of the fill.</dd>
613
* <dt>opacity</dt><dd>Number between 0 and 1 that indicates the opacity of the fill. The default value is 1.</dd>
614
* <dt>type</dt><dd>Type of fill.
616
* <dt>solid</dt><dd>Solid single color fill. (default)</dd>
617
* <dt>linear</dt><dd>Linear gradient fill.</dd>
618
* <dt>radial</dt><dd>Radial gradient fill.</dd>
622
* <p>If a `linear` or `radial` is specified as the fill type. The following additional property is used:
624
* <dt>stops</dt><dd>An array of objects containing the following properties:
626
* <dt>color</dt><dd>The color of the stop.</dd>
627
* <dt>opacity</dt><dd>Number between 0 and 1 that indicates the opacity of the stop. The default value is 1.
628
* Note: No effect for IE 6 - 8</dd>
629
* <dt>offset</dt><dd>Number between 0 and 1 indicating where the color stop is positioned.</dd>
632
* <p>Linear gradients also have the following property:</p>
633
* <dt>rotation</dt><dd>Linear gradients flow left to right by default. The rotation property allows you to change the
634
* flow by rotation. (e.g. A rotation of 180 would make the gradient pain from right to left.)</dd>
635
* <p>Radial gradients have the following additional properties:</p>
636
* <dt>r</dt><dd>Radius of the gradient circle.</dd>
637
* <dt>fx</dt><dd>Focal point x-coordinate of the gradient.</dd>
638
* <dt>fy</dt><dd>Focal point y-coordinate of the gradient.</dd>
640
* <p>The x-coordinate of the center of the gradient circle. Determines where the color stop begins. The default value 0.5.</p>
641
* <p><strong>Note: </strong>Currently, this property is not implemented for corresponding `CanvasShape` and
642
* `VMLShape` classes which are used on Android or IE 6 - 8.</p>
645
* <p>The y-coordinate of the center of the gradient circle. Determines where the color stop begins. The default value 0.5.</p>
646
* <p><strong>Note: </strong>Currently, this property is not implemented for corresponding `CanvasShape` and `VMLShape`
647
* classes which are used on Android or IE 6 - 8.</p>
655
* Contains information about the stroke of the shape.
657
* <dt>color</dt><dd>The color of the stroke.</dd>
658
* <dt>weight</dt><dd>Number that indicates the width of the stroke.</dd>
659
* <dt>opacity</dt><dd>Number between 0 and 1 that indicates the opacity of the stroke. The default value is 1.</dd>
660
* <dt>dashstyle</dt>Indicates whether to draw a dashed stroke. When set to "none", a solid stroke is drawn. When set
661
* to an array, the first index indicates the length of the dash. The second index indicates the length of gap.
662
* <dt>linecap</dt><dd>Specifies the linecap for the stroke. The following values can be specified:
664
* <dt>butt (default)</dt><dd>Specifies a butt linecap.</dd>
665
* <dt>square</dt><dd>Specifies a sqare linecap.</dd>
666
* <dt>round</dt><dd>Specifies a round linecap.</dd>
669
* <dt>linejoin</dt><dd>Specifies a linejoin for the stroke. The following values can be specified:
671
* <dt>round (default)</dt><dd>Specifies that the linejoin will be round.</dd>
672
* <dt>bevel</dt><dd>Specifies a bevel for the linejoin.</dd>
673
* <dt>miter limit</dt><dd>An integer specifying the miter limit of a miter linejoin. If you want to specify a linejoin
674
* of miter, you simply specify the limit as opposed to having separate miter and miter limit values.</dd>
683
* Dom node for the shape.
690
* Represents an SVG Path string. This will be parsed and added to shape's API to represent the SVG data across all
691
* implementations. Note that when using VML or SVG implementations, part of this content will be added to the DOM using
692
* respective VML/SVG attributes. If your content comes from an untrusted source, you will need to ensure that no
693
* malicious code is included in that content.
699
* Reference to the parent graphic instance
707
* <p>Creates circle shape with editable attributes.</p>
708
* <p>`Circle` instances can be created using the <a href="Graphic.html#method_addShape">`addShape`</a> method of the
709
* <a href="Graphic.html">`Graphic`</a> class. The method's `cfg` argument contains a `type` attribute. Assigning "circle"
710
* or `Y.Circle` to this attribute will create a `Circle` instance. Required attributes for instantiating a `Circle` are
711
* `type` and `radius`. Optional attributes include:
713
* <li><a href="#attr_fill">fill</a></li>
714
* <li><a href="#attr_id">id</a></li>
715
* <li><a href="#attr_stroke">stroke</a></li>
716
* <li><a href="#attr_transform">transform</a></li>
717
* <li><a href="#attr_transformOrigin">transformOrigin</a></li>
718
* <li><a href="#attr_visible">visible</a></li>
719
* <li><a href="#attr_x">x</a></li>
720
* <li><a href="#attr_y">y</a></li>
723
* The below code creates a circle by defining the `type` attribute as "circle":</p>
725
var myCircle = myGraphic.addShape({
737
* Below, this same circle is created by defining the `type` attribute with a class reference:
739
var myCircle = myGraphic.addShape({
751
* <p>`Circle` has the following implementations based on browser capability.
753
* <li><a href="SVGCircle.html">`SVGCircle`</a></li>
754
* <li><a href="VMLCircle.html">`VMLCircle`</a></li>
755
* <li><a href="CanvasCircle.html">`CanvasCircle`</a></li>
758
* It is not necessary to interact with these classes directly. `Circle` will point to the appropriate implemention.</p>
765
* Radius of the circle
771
* <p>Creates an ellipse shape with editable attributes.</p>
772
* <p>`Ellipse` instances can be created using the <a href="Graphic.html#method_addShape">`addShape`</a> method of the
773
* <a href="Graphic.html">`Graphic`</a> class. The method's `cfg` argument contains a `type` attribute. Assigning "ellipse"
774
* or `Y.Ellipse` to this attribute will create a `Ellipse` instance. Required attributes for instantiating a `Ellipse` are
775
* `type`, `width` and `height`. Optional attributes include:
777
* <li><a href="#attr_fill">fill</a></li>
778
* <li><a href="#attr_id">id</a></li>
779
* <li><a href="#attr_stroke">stroke</a></li>
780
* <li><a href="#attr_transform">transform</a></li>
781
* <li><a href="#attr_transformOrigin">transformOrigin</a></li>
782
* <li><a href="#attr_visible">visible</a></li>
783
* <li><a href="#attr_x">x</a></li>
784
* <li><a href="#attr_y">y</a></li>
787
* The below code creates an ellipse by defining the `type` attribute as "ellipse":</p>
789
var myEllipse = myGraphic.addShape({
802
* Below, the same ellipse is created by defining the `type` attribute with a class reference:
804
var myEllipse = myGraphic.addShape({
817
* <p>`Ellipse` has the following implementations based on browser capability.
819
* <li><a href="SVGEllipse.html">`SVGEllipse`</a></li>
820
* <li><a href="VMLEllipse.html">`VMLEllipse`</a></li>
821
* <li><a href="CanvasEllipse.html">`CanvasEllipse`</a></li>
824
* It is not necessary to interact with these classes directly. `Ellipse` will point to the appropriate implemention.</p>
831
* <p>Creates an rectangle shape with editable attributes.</p>
832
* <p>`Rect` instances can be created using the <a href="Graphic.html#method_addShape">`addShape`</a> method of the
833
* <a href="Graphic.html">`Graphic`</a> class. The method's `cfg` argument contains a `type` attribute. Assigning "rect"
834
* or `Y.Rect` to this attribute will create a `Rect` instance. Required attributes for instantiating a `Rect` are `type`,
835
* `width` and `height`. Optional attributes include:
837
* <li><a href="#attr_fill">fill</a></li>
838
* <li><a href="#attr_id">id</a></li>
839
* <li><a href="#attr_stroke">stroke</a></li>
840
* <li><a href="#attr_transform">transform</a></li>
841
* <li><a href="#attr_transformOrigin">transformOrigin</a></li>
842
* <li><a href="#attr_visible">visible</a></li>
843
* <li><a href="#attr_x">x</a></li>
844
* <li><a href="#attr_y">y</a></li>
847
* The below code creates a rectangle by defining the `type` attribute as "rect":</p>
849
var myRect = myGraphic.addShape({
862
* Below, the same rectangle is created by defining the `type` attribute with a class reference:
864
var myRect = myGraphic.addShape({
877
* <p>`Rect` has the following implementations based on browser capability.
879
* <li><a href="SVGRect.html">`SVGRect`</a></li>
880
* <li><a href="VMLRect.html">`VMLRect`</a></li>
881
* <li><a href="CanvasRect.html">`CanvasRect`</a></li>
884
* It is not necessary to interact with these classes directly. `Rect` will point to the appropriate implemention.</p>
891
* <p>The `Path` class creates a shape through the use of drawing methods. The `Path` class has the following drawing methods available:</p>
893
* <li><a href="#method_clear">`clear`</a></li>
894
* <li><a href="#method_curveTo">`curveTo`</a></li>
895
* <li><a href="#method_drawRect">`drawRect`</a></li>
896
* <li><a href="#method_drawRoundRect">`drawRoundRect`</a></li>
897
* <li><a href="#method_end">`end`</a></li>
898
* <li><a href="#method_lineTo">`lineTo`</a></li>
899
* <li><a href="#method_moveTo">`moveTo`</a></li>
900
* <li><a href="#method_quadraticCurveTo">`quadraticCurveTo`</a></li>
903
* <p>Like other shapes, `Path` elements are created using the <a href="Graphic.html#method_addShape">`addShape`</a>
904
* method of the <a href="Graphic.html">`Graphic`</a> class. The method's `cfg` argument contains a `type` attribute.
905
* Assigning "path" or `Y.Path` to this attribute will create a `Path` instance. After instantiation, a series of drawing
906
* operations must be performed in order to render a shape. The below code instantiates a path element by defining the
907
* `type` attribute as "path":</p>
909
var myPath = myGraphic.addShape({
920
* Below a `Path` element with the same properties is instantiated by defining the `type` attribute with a class reference:
922
var myPath = myGraphic.addShape({
933
* After instantiation, a shape or segment needs to be drawn for an element to render. After all draw operations are performed,
934
* the <a href="#method_end">`end`</a> method will render the shape. The code below will draw a triangle:
936
myPath.moveTo(35, 5);
937
myPath.lineTo(65, 65);
938
myPath.lineTo(5, 65);
939
myPath.lineTo(35, 5);
942
* <p>`Path` has the following implementations based on browser capability.
944
* <li><a href="SVGPath.html">`SVGPath`</a></li>
945
* <li><a href="VMLPath.html">`VMLPath`</a></li>
946
* <li><a href="CanvasPath.html">`CanvasPath`</a></li>
948
* It is not necessary to interact with these classes directly. `Path` will point to the appropriate implemention.</p>
956
* Indicates the path used for the node.
963
* `Graphic` acts a factory and container for shapes. You need at least one `Graphic` instance to create shapes for your application.
964
* <p>The code block below creates a `Graphic` instance and appends it to an HTMLElement with the id 'mygraphiccontainer'.</p>
966
var myGraphic = new Y.Graphic({render:"#mygraphiccontainer"});
968
* <p>Alternatively, you can add a `Graphic` instance to the DOM using the <a href="#method_render">`render`</a> method.</p>
969
var myGraphic = new Y.Graphic();
970
myGraphic.render("#mygraphiccontainer");
972
* `Graphic` has the following implementations based on browser capability.
974
* <li><a href="SVGGraphic.html">`SVGGraphic`</a></li>
975
* <li><a href="VMLGraphic.html">`VMLGraphic`</a></li>
976
* <li><a href="CanvasGraphic.html">`CanvasGraphic`</a></li>
979
* It is not necessary to interact with these classes directly. `Graphic` will point to the appropriate implemention.</p>
985
* Whether or not to render the `Graphic` automatically after to a specified parent node after init. This can be a Node
986
* instance or a CSS selector string.
989
* @type Node | String
992
* Unique id for class instance.
998
* Key value pairs in which a shape instance is associated with its id.
1005
* Object containing size and coordinate data for the content of a Graphic in relation to the coordSpace node.
1007
* @config contentBounds
1012
* The html element that represents to coordinate system of the Graphic instance.
1019
* Indicates the width of the `Graphic`.
1025
* Indicates the height of the `Graphic`.
1031
* Determines the sizing of the Graphic.
1034
* <dt>sizeContentToGraphic</dt><dd>The Graphic's width and height attributes are, either explicitly set through the
1035
* <code>width</code> and <code>height</code> attributes or are determined by the dimensions of the parent element. The
1036
* content contained in the Graphic will be sized to fit with in the Graphic instance's dimensions. When using this
1037
* setting, the <code>preserveAspectRatio</code> attribute will determine how the contents are sized.</dd>
1038
* <dt>sizeGraphicToContent</dt><dd>(Also accepts a value of true) The Graphic's width and height are determined by the
1039
* size and positioning of the content.</dd>
1040
* <dt>false</dt><dd>The Graphic's width and height attributes are, either explicitly set through the <code>width</code>
1041
* and <code>height</code> attributes or are determined by the dimensions of the parent element. The contents of the
1042
* Graphic instance are not affected by this setting.</dd>
1047
* @type Boolean | String
1051
* Determines how content is sized when <code>autoSize</code> is set to <code>sizeContentToGraphic</code>.
1054
* <dt>none<dt><dd>Do not force uniform scaling. Scale the graphic content of the given element non-uniformly if necessary
1055
* such that the element's bounding box exactly matches the viewport rectangle.</dd>
1056
* <dt>xMinYMin</dt><dd>Force uniform scaling position along the top left of the Graphic's node.</dd>
1057
* <dt>xMidYMin</dt><dd>Force uniform scaling horizontally centered and positioned at the top of the Graphic's node.<dd>
1058
* <dt>xMaxYMin</dt><dd>Force uniform scaling positioned horizontally from the right and vertically from the top.</dd>
1059
* <dt>xMinYMid</dt>Force uniform scaling positioned horizontally from the left and vertically centered.</dd>
1060
* <dt>xMidYMid (the default)</dt><dd>Force uniform scaling with the content centered.</dd>
1061
* <dt>xMaxYMid</dt><dd>Force uniform scaling positioned horizontally from the right and vertically centered.</dd>
1062
* <dt>xMinYMax</dt><dd>Force uniform scaling positioned horizontally from the left and vertically from the bottom.</dd>
1063
* <dt>xMidYMax</dt><dd>Force uniform scaling horizontally centered and position vertically from the bottom.</dd>
1064
* <dt>xMaxYMax</dt><dd>Force uniform scaling positioned horizontally from the right and vertically from the bottom.</dd>
1067
* @config preserveAspectRatio
1072
* The contentBounds will resize to greater values but not to smaller values. (for performance)
1073
* When resizing the contentBounds down is desirable, set the resizeDown value to true.
1075
* @config resizeDown
1079
* Indicates the x-coordinate for the instance.
1085
* Indicates the y-coordinate for the instance.
1091
* Indicates whether or not the instance will automatically redraw after a change is made to a shape.
1092
* This property will get set to false when batching operations.
1100
* Indicates whether the `Graphic` and its children are visible.
1106
* Gets the current position of the graphic instance in page coordinates.
1109
* @return Array The XY position of the shape.
1112
* Adds the graphics node to the dom.
1115
* @param {Node|String} parentNode node in which to render the graphics node into.
1118
* Removes all nodes.
1123
* <p>Generates a shape instance by type. The method accepts an object that contain's the shape's
1124
* type and attributes to be customized. For example, the code below would create a rectangle:</p>
1126
var myRect = myGraphic.addShape({
1139
* <p>The `Graphics` module includes a few basic shapes. More information on their creation
1140
* can be found in each shape's documentation:
1143
* <li><a href="Circle.html">`Circle`</a></li>
1144
* <li><a href="Ellipse.html">`Ellipse`</a></li>
1145
* <li><a href="Rect.html">`Rect`</a></li>
1146
* <li><a href="Path.html">`Path`</a></li>
1149
* The `Graphics` module also allows for the creation of custom shapes. If a custom shape
1150
* has been created, it can be instantiated with the `addShape` method as well. The attributes,
1151
* required and optional, would need to be defined in the custom shape.
1153
var myCustomShape = myGraphic.addShape({
1154
type: Y.MyCustomShape,
1167
* @param {Object} cfg Object containing the shape's type and attributes.
1171
* Removes a shape instance from from the graphic instance.
1173
* @method removeShape
1174
* @param {Shape|String} shape The instance or id of the shape to be removed.
1177
* Removes all shape instances from the dom.
1179
* @method removeAllShapes
1182
* Returns a shape based on the id of its dom node.
1184
* @method getShapeById
1185
* @param {String} id Dom id of the shape's node attribute.
1189
* Allows for creating multiple shapes in order to batch appending and redraw operations.
1192
* @param {Function} method Method to execute.
1196
}, '3.9.1', {"requires": ["node", "event-custom", "pluginhost", "matrix", "classnamemanager"]});