source: Dev/trunk/src/client/dojox/drawing/stencil/Rect.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.0 KB
Line 
1define(["dojo/_base/lang", "../util/oo", "./_Base", "../manager/_registry"],
2function(lang, oo, Base, registry){
3
4var Rect = oo.declare(
5        Base,
6        function(options){
7                // summary:
8                //              constructor
9                if(this.points.length){
10                        //this.render();
11                }
12        },
13        {
14                // summary:
15                //              Creates a dojox.gfx rectangle based on data or points provided.
16
17                type:"dojox.drawing.stencil.Rect",
18                anchorType: "group",
19                baseRender:true,
20               
21                dataToPoints: function(/*Object*/d){
22                        // summary:
23                        //              Converts data to points.
24                        d = d || this.data;
25                        this.points = [
26                                {x:d.x, y:d.y},                                                 // TL
27                                {x:d.x + d.width, y:d.y},                               // TR
28                                {x:d.x + d.width, y:d.y + d.height},    // BR
29                                {x:d.x, y:d.y + d.height}                               // BL
30                        ];
31                        return this.points;
32                },
33               
34                pointsToData: function(/*Array*/p){
35                        // summary:
36                        //              Converts points to data
37                        p = p || this.points;
38                        var s = p[0];
39                        var e = p[2];
40                        this.data = {
41                                x: s.x,
42                                y: s.y,
43                                width: e.x-s.x,
44                                height: e.y-s.y,
45                                r:this.data.r || 0
46                        };
47                        return this.data;
48                       
49                },
50               
51                _create: function(/*String*/shp, /*StencilData*/d, /*Object*/sty){
52                        // summary:
53                        //              Creates a dojox.gfx.shape based on passed arguments.
54                        //              Can be called many times by implementation to create
55                        //              multiple shapes in one stencil.
56
57                        //console.log("render rect", d)
58                        //console.log("rect sty:", sty)
59                        this.remove(this[shp]);
60                        this[shp] = this.container.createRect(d)
61                                .setStroke(sty)
62                                .setFill(sty.fill);
63                       
64                        this._setNodeAtts(this[shp]);
65                },
66               
67                render: function(){
68                        // summary:
69                        //              Renders the 'hit' object (the shape used for an expanded
70                        //              hit area and for highlighting) and the'shape' (the actual
71                        //              display object).
72
73                        this.onBeforeRender(this);
74                        this.renderHit && this._create("hit", this.data, this.style.currentHit);
75                        this._create("shape", this.data, this.style.current);
76                }
77        }
78);
79
80lang.setObject("dojox.drawing.stencil.Rect", Rect);
81registry.register({
82        name:"dojox.drawing.stencil.Rect"
83}, "stencil");
84
85return Rect;
86});
Note: See TracBrowser for help on using the repository browser.