root / trunk / web / dojo / dojox / sketch / Anchor.js @ 12
History | View | Annotate | Download (1.6 KB)
1 | 9 | andrej.cim | /*
|
---|---|---|---|
2 | Copyright (c) 2004-2010, The Dojo Foundation All Rights Reserved.
|
||
3 | Available via Academic Free License >= 2.1 OR the modified BSD license.
|
||
4 | see: http://dojotoolkit.org/license for details
|
||
5 | */
|
||
6 | |||
7 | |||
8 | if(!dojo._hasResource["dojox.sketch.Anchor"]){ |
||
9 | dojo._hasResource["dojox.sketch.Anchor"]=true; |
||
10 | dojo.provide("dojox.sketch.Anchor");
|
||
11 | dojo.require("dojox.gfx");
|
||
12 | (function(){
|
||
13 | var ta=dojox.sketch;
|
||
14 | ta.Anchor=function(an,id,_1){ |
||
15 | var _2=this; |
||
16 | var _3=4; |
||
17 | var _4=null; |
||
18 | this.type=function(){ |
||
19 | return "Anchor"; |
||
20 | }; |
||
21 | this.annotation=an;
|
||
22 | this.id=id;
|
||
23 | this._key="anchor-"+ta.Anchor.count++; |
||
24 | this.shape=null; |
||
25 | this.isControl=(_1!=null)?_1:true; |
||
26 | this.beginEdit=function(){ |
||
27 | this.annotation.beginEdit(ta.CommandTypes.Modify);
|
||
28 | }; |
||
29 | this.endEdit=function(){ |
||
30 | this.annotation.endEdit();
|
||
31 | }; |
||
32 | this.zoom=function(_5){ |
||
33 | if(this.shape){ |
||
34 | var rs=Math.floor(_3/_5);
|
||
35 | var _6=dojox.gfx.renderer=="vml"?1:1/_5; |
||
36 | this.shape.setShape({x:an[id].x-rs,y:an[id].y-rs,width:rs*2,height:rs*2}).setStroke({color:"black",width:_6}); |
||
37 | } |
||
38 | }; |
||
39 | this.setBinding=function(pt){ |
||
40 | an[id]={x:an[id].x+pt.dx,y:an[id].y+pt.dy}; |
||
41 | an.draw(); |
||
42 | an.drawBBox(); |
||
43 | }; |
||
44 | this.setUndo=function(){ |
||
45 | an.setUndo(); |
||
46 | }; |
||
47 | this.enable=function(){ |
||
48 | if(!an.shape){
|
||
49 | return;
|
||
50 | } |
||
51 | an.figure._add(this);
|
||
52 | _4={x:an[id].x-_3,y:an[id].y-_3,width:_3*2,height:_3*2}; |
||
53 | this.shape=an.shape.createRect(_4).setFill([255,255,255,0.35]); |
||
54 | this.shape.getEventSource().setAttribute("id",_2._key); |
||
55 | this.shape.getEventSource().setAttribute("shape-rendering","crispEdges"); |
||
56 | this.zoom(an.figure.zoomFactor);
|
||
57 | }; |
||
58 | this.disable=function(){ |
||
59 | an.figure._remove(this);
|
||
60 | if(an.shape){
|
||
61 | an.shape.remove(this.shape);
|
||
62 | } |
||
63 | this.shape=null; |
||
64 | _4=null;
|
||
65 | }; |
||
66 | }; |
||
67 | ta.Anchor.count=0;
|
||
68 | })(); |
||
69 | } |