1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
|
/*
Copyright (c) 2004-2011, The Dojo Foundation All Rights Reserved.
Available via Academic Free License >= 2.1 OR the modified BSD license.
see: http://dojotoolkit.org/license for details
*/
dojo._xdResourceLoaded(function(dojo, dijit, dojox){
return {depends: [["provide", "dojox.drawing.stencil.Line"]],
defineResource: function(dojo, dijit, dojox){if(!dojo._hasResource["dojox.drawing.stencil.Line"]){ //_hasResource checks added by build. Do not use _hasResource directly in your code.
dojo._hasResource["dojox.drawing.stencil.Line"] = true;
dojo.provide("dojox.drawing.stencil.Line");
dojox.drawing.stencil.Line = dojox.drawing.util.oo.declare(
// summary:
// Creates a dojox.gfx Line based on data or points provided.
//
dojox.drawing.stencil._Base,
function(options){
// summary:
// constructor
},
{
type:"dojox.drawing.stencil.Line",
anchorType: "single",
baseRender:true,
/*=====
StencilData: {
// summary:
// The data used to create the dojox.gfx Shape
// x1: Number
// First point x
// y1: Number
// First point y
// x2: Number
// Second point x
// y2: Number
// Second point y
// ALTERNATIVE:
// x: Number
// First point x
// y: Number
// First point y
// angle: Number
// angle of line
// radius: Number
// length of line
},
StencilPoints: [
// summary:
// An Array of dojox.__StencilPoint objects that describe the Stencil
// 0: Object
// First point
// 1: Object
// Second point
],
=====*/
dataToPoints: function(o){
//summary:
// Converts data to points.
o = o || this.data;
if(o.radius || o.angle){
// instead of using x1,x2,y1,y1,
// it's been set as x,y,angle,radius
var pt = this.util.pointOnCircle(o.x,o.y,o.radius,o.angle);
//console.log(" ---- pts:", pt.x, pt.y);
this.data = o = {
x1:o.x,
y1:o.y,
x2:pt.x,
y2:pt.y
}
}
this.points = [
{x:o.x1, y:o.y1},
{x:o.x2, y:o.y2}
];
return this.points;
},
pointsToData: function(p){
// summary:
// Converts points to data
p = p || this.points;
this.data = {
x1: p[0].x,
y1: p[0].y,
x2: p[1].x,
y2: p[1].y
};
return this.data;
},
_create: function(/*String*/shp, /*StencilData*/d, /*Object*/sty){
// summary:
// Creates a dojox.gfx.shape based on passed arguments.
// Can be called many times by implementation to create
// multiple shapes in one stencil.
//
this.remove(this[shp]);
this[shp] = this.container.createLine(d)
.setStroke(sty);
this._setNodeAtts(this[shp]);
},
render: function(){
// summary:
// Renders the 'hit' object (the shape used for an expanded
// hit area and for highlighting) and the'shape' (the actual
// display object).
//
this.onBeforeRender(this);
this.renderHit && this._create("hit", this.data, this.style.currentHit);
this._create("shape", this.data, this.style.current);
}
}
);
dojox.drawing.register({
name:"dojox.drawing.stencil.Line"
}, "stencil");
}
}};});
|