[Sie-announce] SIEコード [1413] コーディングの整形をした

Back to archive index

svnno****@sourc***** svnno****@sourc*****
2009年 11月 15日 (日) 23:34:08 JST


Revision: 1413
          http://sourceforge.jp/projects/sie/svn/view?view=rev&revision=1413
Author:   dhrname
Date:     2009-11-15 23:34:08 +0900 (Sun, 15 Nov 2009)

Log Message:
-----------
コーディングの整形をした

Modified Paths:
--------------
    branches/05x/054/sie.js

Modified: branches/05x/054/sie.js
===================================================================
--- branches/05x/054/sie.js	2009-11-15 12:59:44 UTC (rev 1412)
+++ branches/05x/054/sie.js	2009-11-15 14:34:08 UTC (rev 1413)
@@ -149,7 +149,11 @@
 //SVGtoVML 本体。SVGDocumentの代わりを担う
 //object要素の幅と高さがwとh(単位はpxに統一)。svg要素の幅と高さがswi.valueとshi.value。svg要素にwidth属性が指定されていない場合、swi.value=wである。
 function SVGtoVML( /*element*/ obc, /*float*/ w, /*float*/ h, /*STLength*/ swi, /*STLength*/ shi) {
-  this.rootElement = obc; this.w = w; this.h = h; this.swi = swi; this.shi = shi;
+  this.rootElement = obc;
+  this.w = w;
+  this.h = h;
+  this.swi = swi;
+  this.shi = shi;
   return this;
 }
 SVGtoVML.prototype.read = function stvread(/*element*/ ob) {
@@ -157,7 +161,7 @@
   this.vi = new STViewSpec(this.rootElement);
   try{
   this.children = []; //子要素
-  var sw = this.swi.value,  sh = this.shi.value;
+  var sw = this.swi.value, sh = this.shi.value;
   this.getObject("USE", STUseElement, "use", sw, sh); //use要素を先に処理
   var mat = this.vi.set(sw, sh, ob); //返り値はMatrix型
   this.chset(this.rootElement, mat, sw, sh);
@@ -347,19 +351,19 @@
 //g要素の処理
 function STGroupElement( /*element*/ g, /*Matrix*/ matrix, /*float*/w, h) {
   try{
-  this.tar = g;
-  this.transformable = NAIBU.transformToCTM(g,matrix); //g要素のtransform属性を前もって処理
-  //以下、ツリーとして処理
-  this.children = [];
-  this.chset(g,this.transformable, w, h);
-  w = h = null;
+    this.tar = g;
+    this.transformable = NAIBU.transformToCTM(g,matrix); //g要素のtransform属性を前もって処理
+    //以下、ツリーとして処理
+    this.children = [];
+    this.chset(g,this.transformable, w, h);
+    w = h = null;
   } catch(e){stlog.add(e,3144);}
   return this;
 }
 STGroupElement.prototype.set = function (sw,sh) {
   try{
-  stvsetob(this.children,sw,sh);
-  this.children = this.transformable = null;
+    stvsetob(this.children,sw,sh);
+    this.children = this.transformable = null;
   } catch(e){stlog.addd(e,3145);}
 };
 STGroupElement.prototype.chset = SVGtoVML.prototype.chset;
@@ -1441,28 +1445,63 @@
       deg = lis.match(NAIBU.degR);
       degli = deg.length;
       if (degli === 6) {
-        a = parseFloat(deg[0]); b = parseFloat(deg[1]); c = parseFloat(deg[2]); d = parseFloat(deg[3]); e = parseFloat(deg[4]); f = parseFloat(deg[5]);
+        a = parseFloat(deg[0]);
+        b = parseFloat(deg[1]);
+        c = parseFloat(deg[2]);
+        d = parseFloat(deg[3]);
+        e = parseFloat(deg[4]);
+        f = parseFloat(deg[5]);
       } else {
         rad = parseFloat(deg[0]) / 180 * Math.PI;
         if (degli === 3) {
           var cx = parseFloat(deg[1]), cy = parseFloat(deg[2]);
-          a = Math.cos(rad); b = Math.sin(rad); c = -b; d = a; e = (1-a)*cx-c*cy; f = -b*cx+(1-d)*cy;
+          a = Math.cos(rad);
+          b = Math.sin(rad);
+          c = -b;
+          d = a;
+          e = (1-a)*cx-c*cy;
+          f = -b*cx+(1-d)*cy;
         } else if (degli <= 2) {
           switch (com) {
           case "translate":
-            a = 1; b = 0; c = 0; d = 1; e = parseFloat(deg[0]); f = parseFloat(deg[1] || 0);
+            a = 1;
+            b = 0;
+            c = 0;
+            d = 1;
+            e = parseFloat(deg[0]);
+            f = parseFloat(deg[1] || 0);
           break;
           case "scale":
-            a = parseFloat(deg[0]); b = 0; c = 0; d = parseFloat(deg[1] || deg[0]); e = 0; f = 0;
+            a = parseFloat(deg[0]);
+            b = 0;
+            c = 0;
+            d = parseFloat(deg[1] || deg[0]);
+            e = 0;
+            f = 0;
           break;
           case "rotate":
-            a = Math.cos(rad); b = Math.sin(rad); c = -b; d = a; e = 0; f = 0;
+            a = Math.cos(rad);
+            b = Math.sin(rad);
+            c = -b;
+            d = a;
+            e = 0;
+            f = 0;
           break;
           case "skewX":
-            a = 1; b = 0; c = Math.tan(rad); d = 1; e = 0; f = 0;
+            a = 1;
+            b = 0;
+            c = Math.tan(rad);
+            d = 1;
+            e = 0;
+            f = 0;
           break;
           case "skewY":
-            a = 1; b = Math.tan(rad); c = 0; d = 1; e = 0; f = 0;
+            a = 1;
+            b = Math.tan(rad);
+            c = 0;
+            d = 1;
+            e = 0;
+            f = 0;
           break;
           }
         }
@@ -1479,7 +1518,8 @@
 
 //SVGPointを参照
 function Point( /*number*/ x, /*number*/ y) {
-  this.x = x; this.y = y;
+  this.x = x;
+  this.y = y;
   return this;
 }
 Point.prototype.matrixTransform = function ( /*Matrix*/ m) {
@@ -1487,7 +1527,7 @@
   var y = parseInt(m.b * this.x + m.d * this.y + m.f);
   if (-1 < x && x < 1) {x=1;}
   if (-1 < y && y < 1) {y=1;}
-  var s = new Point(x,y);
+  var s = new Point(x, y);
   return s;
 };
 
@@ -1515,12 +1555,18 @@
 
 //SVGMatrixを参照。行列
 function Matrix(a,b,c,d,e,f) { //引数はすべてNumber型
-  this.a = a; this.b = b; this.c = c; this.d = d; this.e = e; this.f = f;
+  this.a = a;
+  this.b = b;
+  this.c = c;
+  this.d = d;
+  this.e = e;
+  this.f = f;
   return this;
 }
 //Matrix同士の積を算出
 Matrix.prototype.multiply = function ( /*Matrix*/ m) {
-  var s = new Matrix(this.a * m.a + this.c * m.b,this.b * m.a + this.d * m.b,this.a * m.c + this.c * m.d,this.b * m.c + this.d * m.d,this.a * m.e + this.c * m.f + this.e,this.b * m.e + this.d * m.f + this.f);
+  var s = new Matrix(this.a * m.a + this.c * m.b, this.b * m.a + this.d * m.b, this.a * m.c + this.c * m.d,
+                     this.b * m.c + this.d * m.d, this.a * m.e + this.c * m.f + this.e, this.b * m.e + this.d * m.f + this.f);
   return s;
 };
 //行列式
@@ -1632,9 +1678,11 @@
 };
 
 //SVGRectを参照
-function STRect(x,y,w,h) { //引数はすべてNumber型
-  this.x = x; this.y = y;
-  this.width = w; this.height = h;
+function STRect(x, y, w, h) { //引数はすべてNumber型
+  this.x = x;
+  this.y = y;
+  this.width = w;
+  this.height = h;
   return this;
 }
 
@@ -1655,15 +1703,18 @@
   return s;
 };
 //2つの点から角度を算出
-STArc.prototype.CVAngle = function starccvangle(ux,uy,vx,vy) {
+STArc.prototype.CVAngle = function starccvangle(ux, uy, vx, vy) {
   var rad = Math.atan2(vy, vx) - Math.atan2(uy, ux);
   return (rad >= 0) ? rad : 2 * Math.PI + rad;
 };
 //弧をベジェ曲線に変換
-STArc.prototype.set = function starcset(x1,y1,rx,ry,psai,fA,fS,x4,y4) {
+STArc.prototype.set = function starcset(x1, y1, rx, ry, psai, fA, fS, x4, y4) {
   var fS = parseFloat(fS), rx = parseFloat(rx), ry = parseFloat(ry), psai = parseFloat(psai),  x1 = parseFloat(x1),  x4 = parseFloat(x4),  y1 = parseFloat(y1),  y4 = parseFloat(y4);
-  if (rx === 0 || ry === 0) {throw "line";}
-  rx = Math.abs(rx); ry = Math.abs(ry);
+  if (rx === 0 || ry === 0) {
+    throw "line";
+  }
+  rx = Math.abs(rx);
+  ry = Math.abs(ry);
   var ccx = (x1 - x4) / 2,  ccy = (y1 - y4) / 2;
   var cpsi = Math.cos(psai*Math.PI/180), spsi = Math.sin(psai*Math.PI/180);
   var x1d = cpsi*ccx + spsi*ccy,  y1d = -1*spsi*ccx + cpsi*ccy;
@@ -1718,8 +1769,9 @@
 //setをできるだけ繰り返す
 STArc.prototype.sset = function starcsset( /*float*/ nox, /*float*/ noy, /*array*/ f, /*float*/ rx, /*float*/ ry) {
   for (var i=1,fli=f.length;i<fli+1;i+=7){
-    this.set(nox,noy,f[i],f[i+1],f[i+2],f[i+3],f[i+4],f[i+5]+rx,f[i+6]+ry);
-    nox = f[i+5]+rx; noy = f[i+6]+ry;
+    this.set(nox, noy, f[i], f[i+1], f[i+2], f[i+3], f[i+4], f[i+5]+rx, f[i+6]+ry);
+    nox = f[i+5]+rx;
+    noy = f[i+6]+ry;
   }
 };
 
@@ -1846,7 +1898,8 @@
   try {
     var tsrc = document.getElementsByTagName("FONTFACEURI");
     for (var i=0;i<tsrc.length;++i) {
-      var src = tsrc[i].getAttribute("xlink:href"), ids = src.substring(src.indexOf("#")+1, src.length);
+      var src = tsrc[i].getAttribute("xlink:href");
+      var ids = src.substring(src.indexOf("#")+1, src.length);
       getURL(src.replace(/#.+$/, ""), _ie_font, [ {id : ids, style:{}} ], 1);
     }
   } catch (e) {stlog.add(e,1847);}
@@ -1873,7 +1926,8 @@
   }
 };
 NAIBU._ie_createFont = function(/*Element*/ ti, /*Element*/ font) {
-  var node = ti.firstChild, data, glyphs = font.getElementsByTagName("glyph"), em = parseFloat(font.getElementsByTagName("font-face").item(0).getAttribute("units-per-em") || 0);
+  var node = ti.firstChild, data, glyphs = font.getElementsByTagName("glyph");
+  var em = parseFloat(font.getElementsByTagName("font-face").item(0).getAttribute("units-per-em") || 0);
   var advX = parseFloat(font.getAttribute("horiz-adv-x")); //字幅の設定
   var dx = parseFloat(ti.style.left), fontSize = parseFloat(ti.style.fontSize), dy = parseFloat(ti.style.top) - fontSize * 0.25, fe = fontSize / em; //0.25はディセンダの調整をあらかじめしているため
    while(node) {
@@ -1927,7 +1981,8 @@
 NAIBU._fontSearchURI = function(doc){
   var tsrc = doc.getElementsByTagNameNS(NAIBU.svgNameSpace, "font-face-uri");
   for (var i=0;i<tsrc.length;++i) {
-    var src = tsrc[i].getAttributeNS("http://www.w3.org/1999/xlink", "href"), ids = src.substring(src.indexOf("#")+1, src.length);
+    var src = tsrc[i].getAttributeNS("http://www.w3.org/1999/xlink", "href");
+    var ids = src.substring(src.indexOf("#")+1, src.length);
     getURL(src.replace(/#.+$/, ""), _noie_font, [ {id : ids, style : {}, docu : doc} ], 1);
   }
 };
@@ -1951,7 +2006,8 @@
 };
 NAIBU._noie_createFont = function(/*Element*/ ti, /*Element*/ font) {
   var style = ti.ownerDocument.defaultView.getComputedStyle(ti, '')
-  var node = ti.firstChild, data, glyphs = font.getElementsByTagNameNS(NAIBU.svgNameSpace, "glyph"), em = parseFloat(font.getElementsByTagNameNS(NAIBU.svgNameSpace, "font-face").item(0).getAttribute("units-per-em") || 0);
+  var node = ti.firstChild, data, glyphs = font.getElementsByTagNameNS(NAIBU.svgNameSpace, "glyph");
+  var em = parseFloat(font.getElementsByTagNameNS(NAIBU.svgNameSpace, "font-face").item(0).getAttribute("units-per-em") || 0);
   var advX = parseFloat(font.getAttributeNS(null, "horiz-adv-x")); //字幅の設定
   var dx = parseFloat(ti.getAttributeNS(null, "x") || 0), fontSize = parseFloat(style.fontSize), dy = parseFloat(ti.getAttributeNS(null, "y") || 0), fe = fontSize / em;
    while(node) {
@@ -2053,7 +2109,7 @@
 if (success  &&  data.success) {
   try {
     var obj = data.obj[data.num-1];
-    var obw = new STLength(obj.getAttribute("width"),obj.clientWidth),  obh = new STLength(obj.getAttribute("height"),obj.clientHeight);
+    var obw = new STLength(obj.getAttribute("width"),obj.clientWidth), obh = new STLength(obj.getAttribute("height"),obj.clientHeight);
     var obwidth = obw.value, obheight = obh.value;
   } catch(e) {stlog.add(e,1209);}
   //正規表現でソースをVML用に書き換え
@@ -2113,12 +2169,12 @@
   var regah = obc.getAttribute("svgheight") || obheight;
   var regw = new STLength(regaw,obwidth);
   var regh = new STLength(regah,obheight);
-  var regwv = regw.value,  reghv = regh.value;
+  var regwv = regw.value, reghv = regh.value;
   obst.width = regwv+ "px";
   obst.height = reghv+ "px";
   ob.coordsize = regwv  +" "+  reghv;
-  var STdocument = new SVGtoVML(obc,obwidth,obheight,regw,regh);
-  obj.parentNode.insertBefore(ob,obj);
+  var STdocument = new SVGtoVML(obc, obwidth, obheight, regw, regh);
+  obj.parentNode.insertBefore(ob, obj);
   STdocument.read(ob);
   STdocument.set(ob);
   STdocument = obw = obh = regw = regh = null;
@@ -2137,7 +2193,7 @@
     xmlhttp.setRequestHeader("X-Requested-With", "XMLHttpRequest");
     xmlhttp.onreadystatechange = function() {
       if (xmlhttp.readyState === 4  &&  xmlhttp.status === 200) {
-        fn({success:true,content:xmlhttp.responseText,obj:ob,num:n});
+        fn( {success:true, content:xmlhttp.responseText, obj:ob, num:n} );
         xmlhttp = null;
       }
     };




Sie-announce メーリングリストの案内
Back to archive index