|
From: <me...@us...> - 2011-04-26 14:11:44
|
Revision: 21075
http://qooxdoo-contrib.svn.sourceforge.net/qooxdoo-contrib/?rev=21075&view=rev
Author: mevers
Date: 2011-04-26 14:11:38 +0000 (Tue, 26 Apr 2011)
Log Message:
-----------
Renamed getUri to getFuncIri on svg.core.Element to be more consistent with the SVG specification. Fixed a bug in svg.struct.Use.
Modified Paths:
--------------
trunk/qooxdoo-contrib/SVG/trunk/source/class/svg/core/Element.js
trunk/qooxdoo-contrib/SVG/trunk/source/class/svg/core/MHref.js
trunk/qooxdoo-contrib/SVG/trunk/source/class/svg/paint/MFillProperties.js
trunk/qooxdoo-contrib/SVG/trunk/source/class/svg/paint/MStrokeProperties.js
trunk/qooxdoo-contrib/SVG/trunk/source/class/svg/struct/Use.js
Modified: trunk/qooxdoo-contrib/SVG/trunk/source/class/svg/core/Element.js
===================================================================
--- trunk/qooxdoo-contrib/SVG/trunk/source/class/svg/core/Element.js 2011-04-22 16:29:50 UTC (rev 21074)
+++ trunk/qooxdoo-contrib/SVG/trunk/source/class/svg/core/Element.js 2011-04-26 14:11:38 UTC (rev 21075)
@@ -25,7 +25,7 @@
qx.Class.define("svg.core.Element",
{
extend : qx.html.Element,
-
+
include : [ svg.core.MTitleDescription,
svg.core.dom.MElement,
svg.core.dom.MLocatable],
@@ -38,13 +38,13 @@
construct : function(tagName)
{
this.base(arguments, tagName);
- this.__svgElement = document.createElementNS(svg.core.Element.SVG_NAMESPACE, this.getNodeName());
+ this.__svgElement = document.createElementNS(svg.core.Element.SVG_NAMESPACE, tagName);
},
statics : {
SVG_NAMESPACE : "http://www.w3.org/2000/svg"
},
-
+
properties :
{
/**
@@ -95,70 +95,75 @@
getDomElement : function() {
return this.__svgElement;
},
-
+
/**
- * Gets an Uri reference to this element. An {@link #id} must have been set for this.
- *
- * Returns _null_ if no id is set.
- *
+ * Gets an FuncIRI reference to this element. An {@link #id} must have been set for this.
+ *
+ * Returns _null_ if no id is set.
+ *
+ * More info:
+ * <ul>
+ * <li>http://www.w3.org/TR/SVG/types.html#DataTypeFuncIRI</li>
+ * </ul>
+ *
* @return {String}
- * an uri reference, i.e.
+ * an FuncIRI reference, i.e. url(#abc)
*/
- getUri : function() {
+ getFuncIri : function() {
var id = this.getId();
-
+
if (null == id) {
if ((qx.core.Environment.get("qx.debug"))) {
this.warn("Can't create uri reference; id is null.");
}
return null;
}
- return "url(#" + id + ")";
+ return "url(#" + id + ")";
},
-
-
+
+
/**
* Checks if the DOM element is currently in the document tree. Note that this returns the *actual*
* state of the DOM element, which may change when the framework's element queue is flushed.
- *
+ *
* @return {Boolean}
* true if the DOM element is now in the document tree, false otherwise.
*/
inDocumentTree : function() {
var el = this.__svgElement;
-
+
//return "element is created AND ("element has parent" OR "element is the document root")
return (null !== el) && ((null !== el.parentNode) || (el.ownerDocument.documentElement === el));
},
-
+
/**
* Searches the current element's ancestor tree for the element that wraps the specified
* DOM element. The search includes the current element.
- *
+ *
* <pre>
* var eSvg = new svg.struct.Svg();
* var eGroup = new svg.struct.Group();
* var eRect = new svg.shape.Rect();
- *
+ *
* eSvg.add(eGroup);
* eGroup.add(eRect);
- *
+ *
* var x = eRect.parentByDomElement(eSvg.getDomElement()); //x === eSvg
- *
+ *
* </pre>
- *
+ *
* @param domElement {Element} DOM Element
- *
+ *
* @return {svg.core.Element|null}
* The found svg element, or <pre>null</pre> if nothing was found.
*/
parentByDomElement : function(domElement) {
var el = this;
-
+
while (el !== null && el.getDomElement() !== domElement) {
el = el.getParent();
}
-
+
return el;
}
Modified: trunk/qooxdoo-contrib/SVG/trunk/source/class/svg/core/MHref.js
===================================================================
--- trunk/qooxdoo-contrib/SVG/trunk/source/class/svg/core/MHref.js 2011-04-22 16:29:50 UTC (rev 21074)
+++ trunk/qooxdoo-contrib/SVG/trunk/source/class/svg/core/MHref.js 2011-04-26 14:11:38 UTC (rev 21075)
@@ -15,41 +15,41 @@
/**
* Refer to other elements or fragments.
- *
+ *
* *Important!*
* The _xlink:href_ attribute must be set using the {@link #setHref} method.
* Setting it through the {@link qx.html.Element#set} method will *NOT* work.
* This is because the attribute must be placed in the xlink xml
* namespace. This method takes care of that, the set method does not.
- *
+ *
* The namespace used is *http://www.w3.org/1999/xlink*.
*/
qx.Mixin.define("svg.core.MHref",
{
statics : { XLINK_NAMESPACE : "http://www.w3.org/1999/xlink" },
-
+
properties :
{
-
+
/**
* Reference to an element/fragment within an SVG document. Sets the _xlink:href_ attribute.
- *
+ *
* There are two ways to refer to an element:
- *
+ *
* <pre class="javascript>
* var circle = new svg.shape.Line();
* circle.setId("myCircle");
- *
+ *
* //option 1: refer to element object
* element.setHref(circle);
- *
+ *
* //option 2: refer to element using url():
* element.setHref("url(#myCircle)");
* </pre>
- *
+ *
* <span class="item-deprecated">Using the first option will keep the reference alive even
* if the target's id is changed!</span> (feature not yet implemented)
- *
+ *
*/
href : {
nullable: true,
@@ -62,76 +62,27 @@
members :
{
-
- __listenerId: null,
-
+
_applyHref : function(value, old) {
-
- if (value == null) {
+
+ if (null === value) {
this.removeAttribute("xlink:href");
return;
}
-
- if (value instanceof svg.core.Element) {
- value = value.getUri();
- }
- this.getDomElement().setAttributeNS(svg.core.MHref.XLINK_NAMESPACE, "xlink:href", value);
-
- }
-
-/*
- //applies xlink:href
- _applyHref : function(value, old) {
-
- //break binding with previous value if needed
- if (old != null && old instanceof svg.core.Element) {
- this.getHref().removeListenerById(this.__listenerId);
- this.__listenerId = null;
- }
-
- //if new value is null, remove attribute
- if (value == null) {
- this.removeAttribute("xlink:href");
- }
-
- //if it's an element, bind the id
- else if (value instanceof svg.core.Element) {
- if (value.getId() != null) {
- this.__updateAttribute(value.getUri());
- this.__listenerId = value.addListener("changeId", this.__listener, this);
- }
- else {
- //the target element does not have an id
- this.removeAttribute("xlink:href");
-
+ if (value instanceof svg.core.Element) {
+ var id = value.getId();
+ if (null === id) {
if ((qx.core.Environment.get("qx.debug"))) {
- this.warn("Refering to element requires an id!");
+ this.warn("Can't create uri reference; id is null.");
}
+ return;
}
+ value = '#' + id;
}
-
- //just set to the string value
- else {
- this.__updateAttribute(value);
- }
- },
-
- __updateAttribute: function(value) {
this.getDomElement().setAttributeNS(svg.core.MHref.XLINK_NAMESPACE, "xlink:href", value);
- },
-
- __listener: function(e) {
- var newId = e.getData();
-
- if (null != newId) {
- this.__updateAttribute(newId);
- } else {
- this.resetHref();
- }
+
}
-*/
-
-
+
}
});
\ No newline at end of file
Modified: trunk/qooxdoo-contrib/SVG/trunk/source/class/svg/paint/MFillProperties.js
===================================================================
--- trunk/qooxdoo-contrib/SVG/trunk/source/class/svg/paint/MFillProperties.js 2011-04-22 16:29:50 UTC (rev 21074)
+++ trunk/qooxdoo-contrib/SVG/trunk/source/class/svg/paint/MFillProperties.js 2011-04-26 14:11:38 UTC (rev 21075)
@@ -37,10 +37,10 @@
*/
qx.Mixin.define("svg.paint.MFillProperties",
{
-
+
properties :
{
-
+
/**
* The paint used for filling the interior.
* The interior is determined according to the rules associated with the
@@ -66,10 +66,10 @@
apply: "_applyFill",
event: "changeFill"
},
-
+
/**
- * The algorithm used to determine the interior.
- *
+ * The algorithm used to determine the interior.
+ *
* More info:
* <ul>
* <li>http://www.w3.org/TR/SVG/painting.html#FillRuleProperty</li>
@@ -82,10 +82,10 @@
check: ["nonzero", "evenodd", "inherit"],
event: "changeFillRule"
},
-
+
/**
* The opacity of the interior.
- *
+ *
* More info:
* <ul>
* <li>http://www.w3.org/TR/SVG/painting.html#FillOpacityProperty</li>
@@ -98,25 +98,25 @@
check: "!isNaN(value) && value >= 0 && value <= 1",
event: "changeFillOpacity"
}
-
+
},
-
+
members :
{
-
+
//applies fill
_applyFill : function(value, old) {
-
+
if (null == value) {
this.removeAttribute("fill");
return;
}
if (value instanceof svg.core.Element) {
- value = value.getUri();
+ value = value.getFuncIri();
}
this.setAttribute("fill", value);
},
-
+
//applies fill-rule
_applyFillRule : function(value, old) {
if (null == value) {
Modified: trunk/qooxdoo-contrib/SVG/trunk/source/class/svg/paint/MStrokeProperties.js
===================================================================
--- trunk/qooxdoo-contrib/SVG/trunk/source/class/svg/paint/MStrokeProperties.js 2011-04-22 16:29:50 UTC (rev 21074)
+++ trunk/qooxdoo-contrib/SVG/trunk/source/class/svg/paint/MStrokeProperties.js 2011-04-26 14:11:38 UTC (rev 21075)
@@ -37,12 +37,12 @@
*/
qx.Mixin.define("svg.paint.MStrokeProperties",
{
-
+
properties :
{
/**
* The paint used when stroking the shape outline.
- *
+ *
* More info:
* <ul>
* <li>http://www.w3.org/TR/SVG/painting.html#StrokeProperty</li>
@@ -54,7 +54,7 @@
apply: "_applyStroke",
event: "changeStroke"
},
-
+
/**
* The width of the stroke on the current object.
* The value can either be a _length_ or a _percentage_.
@@ -63,7 +63,7 @@
* viewport.
*
* A zero value causes no stroke to be painted.
- *
+ *
* More info:
* <ul>
* <li>http://www.w3.org/TR/SVG/painting.html#StrokeWidthProperty</li>
@@ -76,7 +76,7 @@
check: "!isNaN(value) && value >= 0",
event: "changeStrokeWidth"
},
-
+
/**
* The opacity of the stroke.
*
@@ -92,10 +92,10 @@
check: "!isNaN(value) && value >= 0 && value <= 1",
event: "changeStrokeOpacity"
},
-
+
/**
* The shape to be used at the end of open subpaths when they are stroked.
- *
+ *
* More info:
* <ul>
* <li>http://www.w3.org/TR/SVG/painting.html#StrokeLinecapProperty</li>
@@ -108,10 +108,10 @@
check: ["butt", "round", "square"],
event: "changeLineCap"
},
-
+
/**
* The shape to be used at the corners of paths or basic shapes when they are stroked.
- *
+ *
* More info:
* <ul>
* <li>http://www.w3.org/TR/SVG/painting.html#StrokeLinejoinProperty</li>
@@ -124,10 +124,10 @@
check: ["miter", "round", "bevel"],
event: "changeLineJoin"
},
-
+
/**
* The limit on the ratio of the miter length to the {@link #strokeWidth}.
- *
+ *
* When two line segments meet at a sharp angle and miter joins have been
* specified, it is possible for the miter to extend far beyond the thickness
* of the line stroking the path.
@@ -135,9 +135,9 @@
* A miterlimit imposes a limit on the ratio of the miter length to the
* strokeWidth. When the limit is exceeded, the join is converted from a
* miter to a bevel.
- *
+ *
* Value must be 1 or greater.
- *
+ *
* More info:
* <ul>
* <li>http://www.w3.org/TR/SVG/painting.html#StrokeMiterlimitProperty</li>
@@ -150,17 +150,17 @@
check: "!isNaN(value) && value >= 1",
event: "changeMiterLimit"
},
-
+
/**
* The pattern of dashes and gaps used to stroke paths.
- *
+ *
* It contains a list of comma and/or white space separated lengths
* and percentages that specify the lengths of alternating dashes and gaps.
*
* If an odd number of values is provided, then the list of values is repeated
* to yield an even number of values. Thus, stroke-dasharray: 5,3,2 is equivalent
* to stroke-dasharray: 5,3,2,5,3,2.
- *
+ *
* More info:
* <ul>
* <li>http://www.w3.org/TR/SVG/painting.html#StrokeDasharrayProperty</li>
@@ -173,13 +173,13 @@
check: "String",
event: "changeDashArray"
},
-
+
/**
* Distance into the dash pattern to start the dash.
- *
+ *
* If a percentage is used, the value represents a percentage of the current
* viewport. Values can be negative.
- *
+ *
* More info:
* <ul>
* <li>http://www.w3.org/TR/SVG/painting.html#StrokeDashoffsetProperty</li>
@@ -191,9 +191,9 @@
apply: "_applyDashOffset",
event: "changeDashOffset"
}
-
+
},
-
+
members :
{
//applies stroke
@@ -203,10 +203,10 @@
return;
}
if (value instanceof svg.core.Element) {
- value = value.getUri();
+ value = value.getFuncIri();
}
this.setAttribute("stroke", value);
-
+
},
//applies stroke-width
@@ -235,7 +235,7 @@
this.setAttribute("stroke-linecap", value);
}
},
-
+
//applies stroke-linejoin
_applyLinejoin : function(value, old) {
if (null == value) {
@@ -244,7 +244,7 @@
this.setAttribute("stroke-linejoin", value);
}
},
-
+
//applies stroke-miterlimit
_applyMiterLimit : function(value, old) {
if (null == value) {
Modified: trunk/qooxdoo-contrib/SVG/trunk/source/class/svg/struct/Use.js
===================================================================
--- trunk/qooxdoo-contrib/SVG/trunk/source/class/svg/struct/Use.js 2011-04-22 16:29:50 UTC (rev 21074)
+++ trunk/qooxdoo-contrib/SVG/trunk/source/class/svg/struct/Use.js 2011-04-26 14:11:38 UTC (rev 21075)
@@ -32,7 +32,7 @@
include : [ svg.core.MHref ],
construct : function() {
- this.base(arguments);
+ this.base(arguments, "use");
},
properties :
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|