VMLGraphic Class
yui3/src/graphics/js/VMLGraphic.js:1
<a href="http://www.w3.org/TR/NOTE-VML">VML</a> implementation of the <a href="Graphic.html">Graphic
</a> class.
VMLGraphic
is not intended to be used directly. Instead, use the <a href="Graphic.html">Graphic
</a> class.
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>
capabilities, the <a href="Graphic.html">Graphic
</a> class will point to the VMLGraphic
class.
Index
Methods
- _appendShape
- _calculateCoordOrigin
- _createGraphic
- _createGraphicNode
- _getDocFrag
- _getShapeClass
- _getUpdatedContentBounds
- _redraw
- _removeChildren
- _toBack
- _toFront
- _toggleVisible
- addShape
- addToRedrawQueue
- batch
- clear
- destroy
- getShapeById
- getXY
- initializer
- removeAllShapes
- removeShape
- render
- set
- setPosition
- setSize
Properties
Attributes
Methods
_appendShape
-
shape
Adds a shape instance to the graphic instance.
Parameters:
-
shape
ShapeThe shape instance to be added to the graphic.
_calculateCoordOrigin
-
position
-
size
-
coordsSize
Determines the value for either an x or y coordinate to be used for the <code>coordOrigin</code> of the Graphic.
Parameters:
Returns:
Number
_createGraphic
()
private
Creates a group element
_createGraphicNode
-
type
-
pe
Creates a graphic node
Parameters:
-
type
Stringnode type to create
-
pe
Stringspecified pointer-events value
Returns:
HTMLElement
_getDocFrag
()
private
Returns a document fragment to for attaching shapes.
Returns:
DocumentFragment
_getShapeClass
-
val
Returns a shape class. Used by addShape
.
Parameters:
-
val
Shape | StringIndicates which shape class.
Returns:
Function
_getUpdatedContentBounds
()
Object
private
Recalculates and returns the contentBounds
for the Graphic
instance.
Returns:
_redraw
()
private
Redraws all shapes.
_removeChildren
-
node
Removes all child nodes.
Parameters:
-
node
Object
_toBack
-
Shape
Inserts shape as the first child of the content node.
Parameters:
-
Shape
VMLShapeto add.
_toggleVisible
-
val
Toggles visibility
Parameters:
-
val
Booleanindicates visibilitye
addShape
-
cfg
Generates a shape instance by type.
Parameters:
-
cfg
Objectattributes for the shape
Returns:
Shape
addToRedrawQueue
-
shape
Adds a shape to the redraw queue and calculates the contentBounds.
Parameters:
-
shape
VMLShape
batch
-
method
Allows for creating multiple shapes in order to batch appending and redraw operations.
Parameters:
-
method
FunctionMethod to execute.
clear
()
Clears the graphics object.
destroy
()
Removes all nodes.
getShapeById
-
id
Returns a shape based on the id of its dom node.
Parameters:
-
id
StringDom id of the shape's node attribute.
Returns:
Shape
getXY
()
Gets the current position of the graphic instance in page coordinates.
Returns:
Array The XY position of the shape.
initializer
()
private
Initializes the class.
removeAllShapes
()
Removes all shape instances from the dom.
removeShape
-
shape
Removes a shape instance from from the graphic instance.
Parameters:
-
shape
Shape | StringThe instance or id of the shape to be removed.
render
-
parentNode
Adds the graphics node to the dom.
Parameters:
-
parentNode
HTMLElementnode in which to render the graphics node into.
set
-
name
-
value
Sets the value of an attribute.
Parameters:
-
name
String | ObjectThe name of the attribute. Alternatively, an object of key value pairs can be passed in to set multiple attributes at once.
-
value
AnyThe value to set the attribute to. This value is ignored if an object is received as the name param.
setPosition
-
x
-
y
Sets the positon of the graphics object.
Properties
_shapeClass
Object
private
Look up for shape classes. Used by addShape
to retrieve a class for instantiation.
Attributes
autoDraw
Boolean
private
Indicates whether or not the instance will automatically redraw after a change is made to a shape. This property will get set to false when batching operations.
Default: true
autoSize
Boolean | String
Determines the sizing of the Graphic.
<dl> <dt>sizeContentToGraphic</dt><dd>The Graphic's width and height attributes are, either explicitly set through the <code>width</code> and <code>height</code> attributes or are determined by the dimensions of the parent element. The content contained in the Graphic will be sized to fit with in the Graphic instance's dimensions. When using this setting, the <code>preserveAspectRatio</code> attribute will determine how the contents are sized.</dd> <dt>sizeGraphicToContent</dt><dd>(Also accepts a value of true) The Graphic's width and height are determined by the size and positioning of the content.</dd> <dt>false</dt><dd>The Graphic's width and height attributes are, either explicitly set through the <code>width</code> and <code>height</code> attributes or are determined by the dimensions of the parent element. The contents of the Graphic instance are not affected by this setting.</dd> </dl>
Default: false
contentBounds
Object
Object containing size and coordinate data for the content of a Graphic in relation to the coordSpace node.
preserveAspectRatio
String
Determines how content is sized when <code>autoSize</code> is set to <code>sizeContentToGraphic</code>.
<dl> <dt>none<dt><dd>Do not force uniform scaling. Scale the graphic content of the given element non-uniformly if necessary such that the element's bounding box exactly matches the viewport rectangle.</dd> <dt>xMinYMin</dt><dd>Force uniform scaling position along the top left of the Graphic's node.</dd> <dt>xMidYMin</dt><dd>Force uniform scaling horizontally centered and positioned at the top of the Graphic's node.<dd> <dt>xMaxYMin</dt><dd>Force uniform scaling positioned horizontally from the right and vertically from the top.</dd> <dt>xMinYMid</dt>Force uniform scaling positioned horizontally from the left and vertically centered.</dd> <dt>xMidYMid (the default)</dt><dd>Force uniform scaling with the content centered.</dd> <dt>xMaxYMid</dt><dd>Force uniform scaling positioned horizontally from the right and vertically centered.</dd> <dt>xMinYMax</dt><dd>Force uniform scaling positioned horizontally from the left and vertically from the bottom.</dd> <dt>xMidYMax</dt><dd>Force uniform scaling horizontally centered and position vertically from the bottom.</dd> <dt>xMaxYMax</dt><dd>Force uniform scaling positioned horizontally from the right and vertically from the bottom.</dd> </dl>
Default: xMidYMid
render
Node | String
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.