source: Dev/trunk/src/client/dojox/drawing/annotations/Arrow.js @ 529

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

Added Dojo 1.9.3 release.

  • Property svn:executable set to *
File size: 1.6 KB
Line 
1define(["../util/oo", "../stencil/Path"],
2function(oo, Path){
3
4//dojox.drawing.annotations.Arrow =
5return oo.declare(
6
7        Path,
8        function(/* dojox.__stencilArgs */options){
9                this.stencil.connectMult([
10                        [this.stencil, "select", this, "select"],
11                        [this.stencil, "deselect", this, "deselect"],
12                        [this.stencil, "render", this, "render"],
13                        [this.stencil, "onDelete", this, "destroy"]
14                ]);
15               
16                this.connect("onBeforeRender", this, function(){
17                        var o = this.stencil.points[this.idx1];
18                        var c = this.stencil.points[this.idx2];
19                        if(this.stencil.getRadius() >= this.minimumSize){
20                                this.points = this.arrowHead(c.x, c.y, o.x, o.y, this.style);
21                        }else{
22                                this.points = [];
23                        }
24                });
25               
26        },
27        {
28                // summary:
29                //              An annotation called internally to put an arrowhead
30                //              on ether end of a Line. Initiated in Arrow (and Vector)
31                //              with the optional params: arrowStart and arrowEnd. Both
32                //              default true for Axes.
33
34                idx1:0,
35                idx2:1,
36               
37                subShape:true,
38                minimumSize:30,
39                //annotation:true, NOT!
40               
41                arrowHead: function(x1, y1, x2, y2, style){
42                        // summary:
43                        //              Creates data used to draw arrow head.
44
45                        var obj = {
46                                start:{
47                                        x:x1,
48                                        y:y1
49                                },
50                                x:x2,
51                                y:y2
52                        }
53                        var angle = this.util.angle(obj);
54                       
55                        var lineLength = this.util.length(obj);
56                        var al = style.arrows.length;
57                        var aw = style.arrows.width/2;
58                        if(lineLength<al){
59                                al = lineLength/2;
60                        }
61                        var p1 = this.util.pointOnCircle(x2, y2, -al, angle-aw);
62                        var p2 = this.util.pointOnCircle(x2, y2, -al, angle+aw);
63                       
64                        return [
65                                {x:x2, y:y2},
66                                p1,
67                                p2
68                        ];
69                }
70               
71        }
72);
73});
Note: See TracBrowser for help on using the repository browser.