source: Dev/trunk/src/client/dojox/drawing/stencil/Line.js @ 532

Last change on this file since 532 was 483, checked in by hendrikvanantwerpen, 11 years ago

Added Dojo 1.9.3 release.

  • Property svn:executable set to *
File size: 2.5 KB
Line 
1define(["dojo/_base/lang", "../util/oo", "./_Base", "../manager/_registry"],
2function(lang, oo, Base, registry){
3var Line = oo.declare(
4        Base,
5        function(options){
6                // summary:
7                //              constructor
8        },
9        {
10                // summary:
11                //              Creates a dojox.gfx Line based on data or points provided.
12
13                type:"dojox.drawing.stencil.Line",
14                anchorType: "single",
15                baseRender:true,
16               
17/*=====
18StencilData: {
19        // summary:
20        //              The data used to create the dojox.gfx Shape, specify
21        //              x1,y1,x2,y2, or x,y,angle,radius
22
23        // x1: Number
24        //              First point x
25        // y1: Number
26        //              First point y
27        // x2: Number
28        //              Second point x
29        // y2: Number
30        //              Second point y
31       
32        // ALTERNATIVE:
33       
34        // x: Number
35        //              First point x
36        // y: Number
37        //              First point y
38        // angle: Number
39        //              angle of line
40        // radius: Number
41        //              length of line
42},
43
44StencilPoints: [
45        // summary:
46        //              An Array of dojox.__StencilPoint objects that describe the Stencil
47        //              [First point, Second point]
48],
49=====*/
50               
51                dataToPoints: function(o){
52                        // summary:
53                        //              Converts data to points.
54                        o = o || this.data;
55                        if(o.radius || o.angle){
56                                // instead of using x1,x2,y1,y1,
57                                // it's been set as x,y,angle,radius
58                               
59                                var pt = this.util.pointOnCircle(o.x,o.y,o.radius,o.angle);
60                                //console.log(" ---- pts:", pt.x, pt.y);
61                                this.data = o = {
62                                        x1:o.x,
63                                        y1:o.y,
64                                        x2:pt.x,
65                                        y2:pt.y
66                                }
67                               
68                        }
69                        this.points = [
70                                {x:o.x1, y:o.y1},
71                                {x:o.x2, y:o.y2}
72                        ];
73                        return this.points;
74                },
75                pointsToData: function(p){
76                        // summary:
77                        //              Converts points to data
78                        p = p || this.points;
79                        this.data = {
80                                x1: p[0].x,
81                                y1: p[0].y,
82                                x2: p[1].x,
83                                y2: p[1].y
84                        };
85                        return this.data;
86                },
87               
88                _create: function(/*String*/shp, /*StencilData*/d, /*Object*/sty){
89                        // summary:
90                        //              Creates a dojox.gfx.shape based on passed arguments.
91                        //              Can be called many times by implementation to create
92                        //              multiple shapes in one stencil.
93
94                        this.remove(this[shp]);
95                        this[shp] = this.container.createLine(d)
96                                .setStroke(sty);
97                        this._setNodeAtts(this[shp]);
98                },
99               
100                render: function(){
101                        // summary:
102                        //              Renders the 'hit' object (the shape used for an expanded
103                        //              hit area and for highlighting) and the'shape' (the actual
104                        //              display object).
105
106                        this.onBeforeRender(this);
107                        this.renderHit && this._create("hit", this.data, this.style.currentHit);
108                        this._create("shape", this.data, this.style.current);
109                       
110                }
111               
112        }
113);
114
115lang.setObject("dojox.drawing.stencil.Line", Line);
116registry.register({
117        name:"dojox.drawing.stencil.Line"
118}, "stencil");
119
120return Line;
121});
Note: See TracBrowser for help on using the repository browser.