source: [view]
dojo.provide("dojox.sketch.UnderlineAnnotation");
dojo.require("dojox.sketch.Annotation");
dojo.require("dojox.sketch.Anchor");
(function(){
var ta=dojox.sketch;
ta.UnderlineAnnotation=function(figure, id){
ta.Annotation.call(this, figure, id);
this.transform={dx:0, dy:0};
this.start={x:0, y:0};
this.property('label','#');
this.labelShape=null;
this.lineShape=null;
//this.anchors.start=new ta.Anchor(this, "start");
};
ta.UnderlineAnnotation.prototype=new ta.Annotation;
var p=ta.UnderlineAnnotation.prototype;
p.constructor=ta.UnderlineAnnotation;
p.type=function(){ return 'Underline'; };
p.getType=function(){ return ta.UnderlineAnnotation; };
p.apply=function(obj){
if(!obj){ return; }
if(obj.documentElement){ obj=obj.documentElement; }
this.readCommonAttrs(obj);
for(var i=0; i var c=obj.childNodes[i];
if(c.localName=="text"){
this.property('label',c.childNodes[0].nodeValue);
var style=c.getAttribute('style');
var m=style.match(/fill:([^;]+);/);
if(m){
var stroke=this.property('stroke');
stroke.collor=m[1];
this.property('stroke',stroke);
this.property('fill',stroke.collor);
}
}/*else if(c.localName=="line"){
var stroke=this.property('stroke');
var style=c.getAttribute('style');
var m=style.match(/stroke:([^;]+);/)[1];
if(m){
stroke.color=m;
this.property('fill',m);
}
m=style.match(/stroke-width:([^;]+);/)[1];
if(m){
stroke.width=m;
}
this.property('stroke',stroke);
}*/
}
};
p.initialize=function(obj){
//var font=(ta.Annotation.labelFont)?ta.Annotation.labelFont:{family:"Times", size:"16px"};
this.apply(obj);
// create either from scratch or based on the passed node
this.shape=this.figure.group.createGroup();
this.shape.getEventSource().setAttribute("id", this.id);
//if(this.transform.dx || this.transform.dy){ this.shape.setTransform(this.transform); }
this.labelShape=this.shape.createText({
x:0,
y:0,
text:this.property('label'),
decoration:"underline",
align:"start"
})
//.setFont(font)
//.setFill(this.property('fill'));
this.labelShape.getEventSource().setAttribute('id',this.id+"-labelShape");
this.lineShape=this.shape.createLine({
x1:1,
x2:this.labelShape.getTextWidth(),
y1:2,
y2:2
})
//.setStroke({ color:this.property('fill'), width:1 });
this.lineShape.getEventSource().setAttribute("shape-rendering","crispEdges");
this.draw();