Project

General

Profile

Statistics
| Revision:

root / trunk / web / dojo / dojox / drawing / stencil / Path.js @ 13

History | View | Annotate | Download (2.37 KB)

1 9 andrej.cim
/*
2
        Copyright (c) 2004-2010, The Dojo Foundation All Rights Reserved.
3
        Available via Academic Free License >= 2.1 OR the modified BSD license.
4
        see: http://dojotoolkit.org/license for details
5
*/
6
7
8
if(!dojo._hasResource["dojox.drawing.stencil.Path"]){
9
dojo._hasResource["dojox.drawing.stencil.Path"]=true;
10
dojo.provide("dojox.drawing.stencil.Path");
11
dojox.drawing.stencil.Path=dojox.drawing.util.oo.declare(dojox.drawing.stencil._Base,function(_1){
12
dojo.disconnect(this._postRenderCon);
13
},{type:"dojox.drawing.stencil.Path",closePath:true,baseRender:true,closeRadius:10,closeColor:{r:255,g:255,b:0,a:0.5},_create:function(_2,_3){
14
this.remove(this[_2]);
15
if(!this.points.length){
16
return;
17
}
18
if(dojox.gfx.renderer=="svg"){
19
var _4=[];
20
dojo.forEach(this.points,function(o,i){
21
if(!o.skip){
22
if(i==0){
23
_4.push("M "+o.x+" "+o.y);
24
}else{
25
var _5=(o.t||"")+" ";
26
if(o.x===undefined){
27
_4.push(_5);
28
}else{
29
_4.push(_5+o.x+" "+o.y);
30
}
31
}
32
}
33
},this);
34
if(this.closePath){
35
_4.push("Z");
36
}
37
this.stringPath=_4.join(" ");
38
this[_2]=this.container.createPath(_4.join(" ")).setStroke(_3);
39
this.closePath&&this[_2].setFill(_3.fill);
40
}else{
41
this[_2]=this.container.createPath({}).setStroke(_3);
42
this.closePath&&this[_2].setFill(_3.fill);
43
dojo.forEach(this.points,function(o,i){
44
if(!o.skip){
45
if(i==0||o.t=="M"){
46
this[_2].moveTo(o.x,o.y);
47
}else{
48
if(o.t=="Z"){
49
this.closePath&&this[_2].closePath();
50
}else{
51
this[_2].lineTo(o.x,o.y);
52
}
53
}
54
}
55
},this);
56
this.closePath&&this[_2].closePath();
57
}
58
this._setNodeAtts(this[_2]);
59
},render:function(){
60
this.onBeforeRender(this);
61
this.renderHit&&this._create("hit",this.style.currentHit);
62
this._create("shape",this.style.current);
63
},getBounds:function(_6){
64
var _7=10000,_8=10000,_9=0,_a=0;
65
dojo.forEach(this.points,function(p){
66
if(p.x!==undefined&&!isNaN(p.x)){
67
_7=Math.min(_7,p.x);
68
_8=Math.min(_8,p.y);
69
_9=Math.max(_9,p.x);
70
_a=Math.max(_a,p.y);
71
}
72
});
73
return {x1:_7,y1:_8,x2:_9,y2:_a,x:_7,y:_8,w:_9-_7,h:_a-_8};
74
},checkClosePoint:function(_b,_c,_d){
75
var _e=this.util.distance(_b.x,_b.y,_c.x,_c.y);
76
if(this.points.length>1){
77
if(_e<this.closeRadius&&!this.closeGuide&&!_d){
78
var c={cx:_b.x,cy:_b.y,rx:this.closeRadius,ry:this.closeRadius};
79
this.closeGuide=this.container.createEllipse(c).setFill(this.closeColor);
80
}else{
81
if(_d||_e>this.closeRadius&&this.closeGuide){
82
this.remove(this.closeGuide);
83
this.closeGuide=null;
84
}
85
}
86
}
87
return _e<this.closeRadius;
88
}});
89
dojox.drawing.register({name:"dojox.drawing.stencil.Path"},"stencil");
90
}