Project

General

Profile

Statistics
| Revision:

root / trunk / web / dojo / dojox / drawing / tools / Pencil.js @ 12

History | View | Annotate | Download (1.55 KB)

1
/*
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.tools.Pencil"]){
9
dojo._hasResource["dojox.drawing.tools.Pencil"]=true;
10
dojo.provide("dojox.drawing.tools.Pencil");
11
dojox.drawing.tools.Pencil=dojox.drawing.util.oo.declare(dojox.drawing.stencil.Path,function(){
12
this._started=false;
13
},{draws:true,minDist:15,onDown:function(_1){
14
this._started=true;
15
var p={x:_1.x,y:_1.y};
16
this.points=[p];
17
this.lastPoint=p;
18
this.revertRenderHit=this.renderHit;
19
this.renderHit=false;
20
this.closePath=false;
21
},onDrag:function(_2){
22
if(!this._started||this.minDist>this.util.distance(_2.x,_2.y,this.lastPoint.x,this.lastPoint.y)){
23
return;
24
}
25
var p={x:_2.x,y:_2.y};
26
this.points.push(p);
27
this.render();
28
this.checkClosePoint(this.points[0],_2);
29
this.lastPoint=p;
30
},onUp:function(_3){
31
if(!this._started){
32
return;
33
}
34
if(!this.points||this.points.length<2){
35
this._started=false;
36
this.points=[];
37
return;
38
}
39
var _4=this.getBounds();
40
if(_4.w<this.minimumSize&&_4.h<this.minimumSize){
41
this.remove(this.hit,this.shape,this.closeGuide);
42
this._started=false;
43
this.setPoints([]);
44
return;
45
}
46
if(this.checkClosePoint(this.points[0],_3,true)){
47
this.closePath=true;
48
}
49
this.renderHit=this.revertRenderHit;
50
this.renderedOnce=true;
51
this.render();
52
this.onRender(this);
53
}});
54
dojox.drawing.tools.Pencil.setup={name:"dojox.drawing.tools.Pencil",tooltip:"Pencil Tool",iconClass:"iconLine"};
55
dojox.drawing.register(dojox.drawing.tools.Pencil.setup,"tool");
56
}