svnno****@sourc*****
svnno****@sourc*****
2010年 2月 27日 (土) 23:16:32 JST
Revision: 1683
http://sourceforge.jp/projects/sie/svn/view?view=rev&revision=1683
Author: dhrname
Date: 2010-02-27 23:16:32 +0900 (Sat, 27 Feb 2010)
Log Message:
-----------
getCTMとgetScreenCTMメソッドを修正
Modified Paths:
--------------
branches/ufltima/dom/svg.js
Modified: branches/ufltima/dom/svg.js
===================================================================
--- branches/ufltima/dom/svg.js 2010-02-27 14:15:45 UTC (rev 1682)
+++ branches/ufltima/dom/svg.js 2010-02-27 14:16:32 UTC (rev 1683)
@@ -165,21 +165,24 @@
/*getCTMメソッド
*CTMとは現在の利用座標系に対する変換行列
+ *注意点として、SVG1.1とSVG Tiny1.2では内容が異なる。たとえば、
+ *1.1のgetCTMメソッドが1.2において、getScreenCTMという名前に変更されている。また、1.2ではgetCTMが言及されていない
+ *もし、要素の中心座標を取得したい人がいれば、transformプロパティのconsolidateメソッドを使うこと
*/
/*SVGMatrix*/ SVGElement.prototype.getCTM = function() {
+ return (this.getScreenCTM());
+};
+
+/*SVGMatrix*/ SVGElement.prototype.getScreenCTM = function(){
var s;
if (this.parentNode) {
- s = this.parentNode.getCTM().multiply(this.transform.consolidate());
+ s = this.parentNode.getScreenCTM().multiply(this.transform.consolidate());
} else {
s = this.transform.consolidate();
}
return s;
};
-/*SVGMatrix*/ SVGElement.prototype.getScreenCTM = function(){
- return (this.ownerDocument.documentElement.getCTM());
-};
-
/*getTransformToElementメソッド
*これは、あるelementへの変換行列を計算して返す
*たとえば、親要素から子要素への変換行列を算出することが可能
@@ -622,8 +625,14 @@
if (!!CSS2Properties[name] || name.indexOf("-") > -1) {
tar._attributeStyle.setProperty(name, evt.newValue, "");
} else if (name === "transform") {
- } else if (name.indexOf("on") === 0) {
+ } else if (name === "style") {
+ } else if (name === "class") {
+ } else if (evt.relatedNode.localName === "id") { //xml:idあるいはid属性ならば
+ } else if (name.indexOf("on") === 0) { //event属性ならば
}
+ evt.initMutationEvent("DOMNodeInsertedIntoDocument", false, false, null, null, null, null, null);
+ tar.dispatchEvent(evt); //描画を開始するために、dispatchEventメソッドを使う
+ evt = name = null;
}, false);
return this;
};
@@ -706,7 +715,7 @@
function SVGDefsElement() {
SVGElement.apply(this, arguments);
- this.style.display = "none";
+ this.style.setProperty("display", "none");
return this;
};
SVGDefsElement.constructor = SVGElement;
@@ -885,6 +894,9 @@
return this;
};
SVGMatrix.prototype = {
+ /*multiplyメソッド
+ *行列の積を求めて返す
+ */
/*SVGMatrix*/ multiply : function(/*SVGMatrix*/ secondMatrix ) {
var s = new SVGMatrix(), m = secondMatrix;
s.a = this.a * m.a + this.c * m.b;
@@ -896,6 +908,9 @@
m = secondMatrix = null;
return s;
},
+ /*inverseメソッド
+ *逆行列を返す
+ */
/*SVGMatrix*/ inverse : function() {
var s = new SVGMatrix(), n = this._determinant();
if (n !== 0) {
@@ -1288,6 +1303,19 @@
/*readonly SVGPathSegList*/ this.animatedPathSegList = this.pathSegList = new SVGPathSegList();
/*readonly SVGPathSegList*/ this.animatedNormalizedPathSegList = this.normalizedPathSegList = new SVGPathSegList();
/*readonly SVGAnimatedNumber*/ this.pathLength = new SVGAnimatedNumber();
+ this.addEventListener("DOMAttrModified", function(evt){});
+ /*以下の処理は、このpath要素ノードがDOMツリーに追加されて初めて、
+ *描画が開始されることを示す。つまり、appendChildで挿入されない限り、描画をしない。
+ */
+ this.addEventListener("DOMNodeInserted", function(evt){
+ if (evt.eventPhase === Event.BUBBLING_PHASE) {
+ return; //強制終了させる
+ }
+ evt.target.addEventListener("DOMNodeInsertedIntoDocument", function(evt){
+ var tar = evt.target, matrix = tar.getScreenCTM();
+
+ });
+ });
return this;
};
SVGPathElement.constructor = SVGElement;