source: Dev/branches/rest-dojo-ui/client/dojox/drawing/stencil/Ellipse.js @ 256

Last change on this file since 256 was 256, checked in by hendrikvanantwerpen, 13 years ago

Reworked project structure based on REST interaction and Dojo library. As
soon as this is stable, the old jQueryUI branch can be removed (it's
kept for reference).

  • Property svn:executable set to *
File size: 2.1 KB
Line 
1dojo.provide("dojox.drawing.stencil.Ellipse");
2
3/*=====
4__StencilData = {
5        // summary:
6        //              the data used to create the dojox.gfx Shape
7        //
8
9        //      cx: Number
10        //              Center point x
11        cx:0,
12        //      cy: Number
13        //              Center point y
14        cy:0,
15        //      rx: Number
16        //              Horizontal radius
17        rx:0,
18        //      ry: Number
19        //              Vertical radius
20        ry:0
21}
22=====*/
23
24dojox.drawing.stencil.Ellipse = dojox.drawing.util.oo.declare(
25        // summary:
26        //              Creates a dojox.gfx Ellipse based on data or points provided.
27        //
28        dojox.drawing.stencil._Base,
29        function(options){
30                // summary:
31                //              constructor
32        },
33        {
34               
35                type:"dojox.drawing.stencil.Ellipse",
36                anchorType: "group",
37                baseRender:true,
38                dataToPoints: function(/*Object*/o){
39                        //summary:
40                        //              Converts data to points.
41                        o = o || this.data;
42                        var x = o.cx - o.rx,
43                                y = o.cy - o.ry,
44                                w = o.rx*2,
45                                h = o.ry*2
46                        this.points = [
47                                {x:x, y:y},     // TL
48                                {x:x+w, y:y},   // TR
49                                {x:x+w, y:y+h}, // BR
50                                {x:x, y:y+h}    // BL
51                        ];
52                        return this.points; //Array
53                },
54               
55                pointsToData: function(/*Array*/p){
56                        // summary:
57                        //              Converts points to data
58                        p = p || this.points;
59                        var s = p[0];
60                        var e = p[2];
61                        this.data = {
62                                cx: s.x + (e.x - s.x)/2,
63                                cy: s.y + (e.y - s.y)/2,
64                                rx: (e.x - s.x)*.5,
65                                ry: (e.y - s.y)*.5
66                        };
67                        return this.data; //Object
68               
69                },
70               
71                _create: function(/*String*/shp, /*__StencilData*/d, /*Object*/sty){
72                        // summary:
73                        //              Creates a dojox.gfx.shape based on passed arguments.
74                        //              Can be called many times by implementation to create
75                        //              multiple shapes in one stencil.
76                        //
77                        this.remove(this[shp]);
78                        this[shp] = this.container.createEllipse(d)
79                                .setStroke(sty)
80                                .setFill(sty.fill);
81                        this._setNodeAtts(this[shp]);
82                },
83               
84                render: function(){
85                        // summary:
86                        //              Renders the 'hit' object (the shape used for an expanded
87                        //              hit area and for highlighting) and the'shape' (the actual
88                        //              display object).
89                        //
90                        this.onBeforeRender(this);
91                        this.renderHit && this._create("hit", this.data, this.style.currentHit);
92                        this._create("shape", this.data, this.style.current);
93                }
94               
95        }
96);
97
98dojox.drawing.register({
99        name:"dojox.drawing.stencil.Ellipse"
100}, "stencil");
Note: See TracBrowser for help on using the repository browser.