|
From: <me...@us...> - 2011-04-28 13:12:25
|
Revision: 21081
http://qooxdoo-contrib.svn.sourceforge.net/qooxdoo-contrib/?rev=21081&view=rev
Author: mevers
Date: 2011-04-28 13:12:18 +0000 (Thu, 28 Apr 2011)
Log Message:
-----------
Added new MPathElement mixin to the path.Path object so it implements
"getTotalLength", "getPointAtLength", etc...
Modified Paths:
--------------
trunk/qooxdoo-contrib/SVG/trunk/source/class/svg/path/Path.js
Added Paths:
-----------
trunk/qooxdoo-contrib/SVG/trunk/source/class/svg/path/dom/
trunk/qooxdoo-contrib/SVG/trunk/source/class/svg/path/dom/MPathElement.js
Modified: trunk/qooxdoo-contrib/SVG/trunk/source/class/svg/path/Path.js
===================================================================
--- trunk/qooxdoo-contrib/SVG/trunk/source/class/svg/path/Path.js 2011-04-28 12:56:43 UTC (rev 21080)
+++ trunk/qooxdoo-contrib/SVG/trunk/source/class/svg/path/Path.js 2011-04-28 13:12:18 UTC (rev 21081)
@@ -22,23 +22,24 @@
qx.Class.define("svg.path.Path",
{
extend : svg.core.Element,
-
+
include : [ svg.paint.MFillProperties,
svg.paint.MStrokeProperties,
- svg.paint.MMarkerProperties ],
+ svg.paint.MMarkerProperties,
+ svg.path.dom.MPathElement],
construct : function() {
this.base(arguments, "path");
},
-
+
properties :
{
/**
* The definition of the outline of a shape.
- *
+ *
* You can provide an instance of {@link PathData} (recommended!),
- * or a string with hand-written path data.
- *
+ * or a string with hand-written path data.
+ *
* More info:
* <ul>
* <li>http://www.w3.org/TR/SVG/paths.html#PathData</li>
@@ -51,12 +52,12 @@
check: "value instanceof svg.path.PathData || typeof(value) == 'string'",
event: "changePathData"
},
-
+
/**
* The author's computation of the total length of the path, in user units.
* This value is used to calibrate the user agent's own distance-along-a-path
* calculations with that of the author.
- *
+ *
* More info:
* <ul>
* <li>http://www.w3.org/TR/SVG/paths.html#PathLengthAttribute</li>
@@ -73,7 +74,7 @@
members :
{
-
+
//applies path data
_applyPathData: function(value, old) {
if (null === value) {
@@ -86,24 +87,24 @@
else {
this.setAttribute("d", value);
}
-
+
if (old instanceof svg.path.PathData) {
old.removeListener("change", this.__changeListener, this);
}
},
-
+
//applies path length
_applyPathLength: function(value, old) {
- if (null == value) {
+ if (null === value) {
this.removeAttribute("pathLength");
} else {
this.setAttribute("pathLength", value);
}
},
-
+
/**
* Updates the "d" attribute when PathData has changed.
- *
+ *
* @param ev {qx.event.Data}
* data event fired by PathData
*/
Added: trunk/qooxdoo-contrib/SVG/trunk/source/class/svg/path/dom/MPathElement.js
===================================================================
--- trunk/qooxdoo-contrib/SVG/trunk/source/class/svg/path/dom/MPathElement.js (rev 0)
+++ trunk/qooxdoo-contrib/SVG/trunk/source/class/svg/path/dom/MPathElement.js 2011-04-28 13:12:18 UTC (rev 21081)
@@ -0,0 +1,91 @@
+/* ************************************************************************
+
+ Copyright:
+ 2010-2011 Martijn Evers
+
+ License:
+ LGPL: http://www.gnu.org/licenses/lgpl.html
+ EPL: http://www.eclipse.org/org/documents/epl-v10.php
+ See the LICENSE file in the project's top-level directory for details.
+
+ Authors:
+ * Martijn Evers (mevers)
+
+************************************************************************ */
+
+/**
+ * Implements the SVGPathElement interface.
+ *
+ * More info:
+ * <ul>
+ * <li>http://www.w3.org/TR/SVG/paths.html#InterfaceSVGPathElement</li>
+ * </ul>
+ */
+qx.Mixin.define("svg.path.dom.MPathElement", {
+
+ members :
+ {
+ /**
+ * Returns the user agent's computed value for the total length of the path
+ * using the user agent's distance-along-a-path algorithm, as a distance
+ * in the current user coordinate system.
+ *
+ * This is the implementation of:
+ * <ul>
+ * <li>http://www.w3.org/TR/SVG/paths.html#__svg__SVGPathElement__getTotalLength</li>
+ * </ul>
+ *
+ * @return {Float} The total length of the path.
+ */
+ getTotalLength : function() {
+ if ((qx.core.Environment.get("qx.debug"))) {
+ svg.core.Assert.assertElementInDocTree(this);
+ }
+ return this.getDomElement().getTotalLength();
+ },
+
+ /**
+ * Returns the (x,y) coordinate in user space which is distance units along the
+ * path, utilizing the user agent's distance-along-a-path algorithm.
+ *
+ * This is the implementation of:
+ * <ul>
+ * <li>http://www.w3.org/TR/SVG/paths.html#__svg__SVGPathElement__getPointAtLength</li>
+ * </ul>
+ *
+ * @param distance {Float}
+ * The distance along the path, relative to the start of
+ * the path, as a distance in the current user coordinate system.
+ *
+ * @return {SVGPoint} The returned point in user space.
+ */
+ getPointAtLength : function(distance) {
+ if ((qx.core.Environment.get("qx.debug"))) {
+ svg.core.Assert.assertElementInDocTree(this);
+ }
+ return this.getDomElement().getPointAtLength(distance);
+ },
+
+ /**
+ * Returns the index into pathSegList which is distance units along the
+ * path, utilizing the user agent's distance-along-a-path algorithm.
+ *
+ * This is the implementation of:
+ * <ul>
+ * <li>http://www.w3.org/TR/SVG/paths.html#__svg__SVGPathElement__getPathSegAtLength</li>
+ * </ul>
+ *
+ * @param distance {Float}
+ * The distance along the path, relative to the start of
+ * the path, as a distance in the current user coordinate system.
+ *
+ * @return {Double} The index of the path segment, where the first path segment is number 0.
+ */
+ getPathSegAtLength : function(distance) {
+ if ((qx.core.Environment.get("qx.debug"))) {
+ svg.core.Assert.assertElementInDocTree(this);
+ }
+ return this.getDomElement().getPathSegAtLength(distance);
+ }
+ }
+});
\ No newline at end of file
Property changes on: trunk/qooxdoo-contrib/SVG/trunk/source/class/svg/path/dom/MPathElement.js
___________________________________________________________________
Added: svn:mime-type
+ text/plain
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|