Project

General

Profile

Statistics
| Revision:

root / trunk / web / dojo / dojox / drawing / annotations / Label.js

History | View | Annotate | Download (1.81 KB)

1
/*
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.drawing.annotations.Label"]){
9
dojo._hasResource["dojox.drawing.annotations.Label"]=true;
10
dojo.provide("dojox.drawing.annotations.Label");
11
dojo.require("dojox.drawing.stencil.Text");
12
dojox.drawing.annotations.Label=dojox.drawing.util.oo.declare(dojox.drawing.stencil.Text,function(_1){
13
this.master=_1.stencil;
14
this.labelPosition=_1.labelPosition||"BR";
15
if(dojo.isFunction(this.labelPosition)){
16
this.setLabel=this.setLabelCustom;
17
}
18
this.setLabel(_1.text||"");
19
this.connect(this.master,"onTransform",this,"setLabel");
20
this.connect(this.master,"destroy",this,"destroy");
21
if(this.style.labelSameColor){
22
this.connect(this.master,"attr",this,"beforeAttr");
23
}
24
},{_align:"start",setLabelCustom:function(_2){
25
var d=dojo.hitch(this.master,this.labelPosition)();
26
this.setData({x:d.x,y:d.y,width:d.w||this.style.text.minWidth,height:d.h||this._lineHeight});
27
if(_2&&!_2.split){
28
_2=null;
29
}
30
this.render(this.typesetter(_2));
31
},setLabel:function(_3){
32
var x,y,_4=this.master.getBounds();
33
if(/B/.test(this.labelPosition)){
34
y=_4.y2-this._lineHeight;
35
}else{
36
y=_4.y1;
37
}
38
if(/R/.test(this.labelPosition)){
39
x=_4.x2;
40
}else{
41
y=_4.y1;
42
this._align="end";
43
}
44
if(!this.labelWidth||(_3&&_3.split&&_3!=this.getText())){
45
this.setData({x:x,y:y,height:this._lineHeight,width:this.style.text.minWidth});
46
this.labelWidth=this.style.text.minWidth;
47
this.render(this.typesetter(_3));
48
}else{
49
this.setData({x:x,y:y,height:this.data.height,width:this.data.width});
50
this.render();
51
}
52
},beforeAttr:function(_5,_6){
53
if(_6!==undefined){
54
var k=_5;
55
_5={};
56
_5[k]=_6;
57
}
58
delete _5.x;
59
delete _5.y;
60
delete _5.width;
61
delete _5.height;
62
this.attr(_5);
63
!this.created&&this.render();
64
}});
65
}