Debian Codegraph @

dojox/drawing/tools/Pencil.js

raw symbols SCIP
1 define(["dojo/_base/lang", "../util/oo", "../manager/_registry", "../stencil/Path"],
2 function(lang, oo, registry, StencilPath){
3
4 //dojox.drawing.tools.Pencil
5 var Pencil = oo.declare(
6 StencilPath,
7 function(){
8 // summary:
9 // constructor
10 this._started = false;
11 },
12 {
13 // summary:
14 // Class for a drawable, continuous Path
15
16 draws:true,
17
18 // minDist: Number
19 // The distance the mouse must travel before rendering
20 // a path segment. Lower number is a higher definition
21 // path but more points.
22 minDist: 15, // how to make this more dynamic? Settable?
23
24 onDown: function(obj){
25 this._started = true;
26 var p = {
27 x:obj.x,
28 y:obj.y
29 };
30 this.points = [p];
31 this.lastPoint = p;
32 this.revertRenderHit = this.renderHit;
33 this.renderHit = false;
34 this.closePath = false;
35 },
36
37 onDrag: function(obj){
38 if(
39 !this._started
40 || this.minDist > this.util.distance(obj.x, obj.y, this.lastPoint.x, this.lastPoint.y)
41 ){ return; }
42
43 var p = {
44 x:obj.x,
45 y:obj.y
46 };
47 this.points.push(p);
48 this.render();
49 this.checkClosePoint(this.points[0], obj);
50 this.lastPoint = p;
51 },
52
53 onUp: function(obj){
54 if(!this._started){ return; }
55 if(!this.points || this.points.length<2){
56 this._started = false;
57 this.points = [];
58 return;
59 }
60 var box = this.getBounds();
61 if(box.w<this.minimumSize && box.h<this.minimumSize){
62 this.remove(this.hit, this.shape, this.closeGuide);
63 this._started = false;
64 this.setPoints([]);
65 return;
66 }
67 if(this.checkClosePoint(this.points[0], obj, true)){
68 this.closePath = true;
69 }
70 this.renderHit = this.revertRenderHit;
71 this.renderedOnce = true;
72 this.render();
73 this.onRender(this);
74
75 }
76 }
77 );
78
79 lang.setObject("dojox.drawing.tools.Pencil", Pencil);
80 Pencil.setup = {
81 name:"dojox.drawing.tools.Pencil",
82 tooltip:"Pencil Tool",
83 iconClass:"iconLine"
84 };
85
86 registry.register(Pencil.setup, "tool");
87
88 return Pencil;
89 });