dojox/sketch/LeadAnnotation.js

  • Provides:

    • dojox.sketch.LeadAnnotation
  • Requires:

    • dojox.sketch.Annotation in common
    • dojox.sketch.Anchor in common
  • dojox.sketch.LeadAnnotation.prototype

    • summary
  • dojox.sketch.LeadAnnotation.prototype.constructor

    • summary
  • dojox.sketch.LeadAnnotation

    • type
      Function
    • parameters:
      • figure: (typeof )
      • id: (typeof )
    • source: [view]
        ta.Annotation.call(this, figure, id);
        this.transform={dx:0, dy:0 };
        this.start={ x:0, y:0 };
        this.control={x:100, y:-50};
        this.end={ x:200, y:0 };
        this.textPosition={ x:0, y:0 };
        this.textOffset=4;
        //this.textAlign="middle";
        this.textYOffset=10;


      //  this.property('label',this.id);
        this.pathShape=null;
        this.labelShape=null;


        this.anchors.start=new ta.Anchor(this, "start");
        this.anchors.control=new ta.Anchor(this, "control");
        this.anchors.end=new ta.Anchor(this, "end");
    • summary
  • dojox.sketch.LeadAnnotation.transform

    • summary
  • dojox.sketch.LeadAnnotation.start

    • summary
  • dojox.sketch.LeadAnnotation.control

    • summary
  • dojox.sketch.LeadAnnotation.end

    • summary
  • dojox.sketch.LeadAnnotation.textPosition

    • summary
  • dojox.sketch.LeadAnnotation.textOffset

    • summary
  • dojox.sketch.LeadAnnotation.textYOffset

    • summary
  • dojox.sketch.LeadAnnotation.pathShape

    • summary
  • dojox.sketch.LeadAnnotation.labelShape

    • summary
  • dojox.sketch.LeadAnnotation.anchors.start

    • summary
  • dojox.sketch.LeadAnnotation.anchors.control

    • summary
  • dojox.sketch.LeadAnnotation.anchors.end

    • summary
  • ta.LeadAnnotation.type

    • type
      Function
    • source: [view]
       p.type=function(){ return 'Lead';
    • summary
  • ta.LeadAnnotation.getType

    • type
      Function
    • source: [view]
       p.getType=function(){ return ta.LeadAnnotation;
    • summary
  • ta.LeadAnnotation._pos

    • type
      Function
    • source: [view]
        var offset=this.textOffset, x=0, y=0;
        var slope=this.calculate.slope(this.control, this.end);
        this.textAlign="middle";
        if(Math.abs(slope)>=1){
         x=this.end.x+this.calculate.dx(this.control, this.end, offset);
         if(this.control.y>this.end.y){
          y=this.end.y-offset;
         } else {
          y=this.end.y+offset+this.textYOffset;
         }
        } else if(slope==0){
         x=this.end.x+offset;
         y=this.end.y+this.textYOffset;
        } else {
         if(this.start.x>this.end.x){
          x=this.end.x-offset;
          this.textAlign="end";
         } else {
          x=this.end.x+offset;
          this.textAlign="start";
         }
         if(this.start.y    y=this.end.y+this.calculate.dy(this.control, this.end, offset)+this.textYOffset;
         } else {
          y=this.end.y+this.calculate.dy(this.control, this.end, -offset);
         }
        }
        this.textPosition={ x:x, y:y };
    • summary
  • ta.LeadAnnotation.textAlign

    • summary
  • ta.LeadAnnotation.textPosition

    • summary
  • ta.LeadAnnotation.apply

    • type
      Function
    • parameters:
      • obj: (typeof )
    • source: [view]
        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.length?c.childNodes[0].nodeValue:'');
         }
         else if(c.localName=="path"){
          // the line
          var d=c.getAttribute('d').split(" ");
          var s=d[0].split(",");
          this.start.x=parseFloat(s[0].substr(1),10);
          this.start.y=parseFloat(s[1],10);
          s=d[1].split(",");
          this.control.x=parseFloat(s[0].substr(1),10);
          this.control.y=parseFloat(s[1],10);
          s=d[2].split(",");
          this.end.x=parseFloat(s[0],10);
          this.end.y=parseFloat(s[1],10);
          var stroke=this.property('stroke');
          var style=c.getAttribute('style');
          var m=style.match(/stroke:([^;]+);/);
          if(m){
           stroke.color=m[1];
           this.property('fill',m[1]);
          }
          m=style.match(/stroke-width:([^;]+);/);
          if(m){
           stroke.width=m[1];
          }
          this.property('stroke',stroke);
         }
        }
    • summary
  • ta.LeadAnnotation.start.x

    • summary
  • ta.LeadAnnotation.start.y

    • summary
  • ta.LeadAnnotation.control.x

    • summary
  • ta.LeadAnnotation.control.y

    • summary
  • ta.LeadAnnotation.end.x

    • summary
  • ta.LeadAnnotation.end.y

    • summary
  • ta.LeadAnnotation.initialize

    • type
      Function
    • parameters:
      • obj: (typeof )
    • source: [view]
        this.apply(obj);
        this._pos();


        // create either from scratch or based on the passed node
        this.shape=this.figure.group.createGroup();
        this.shape.getEventSource().setAttribute("id", this.id);
        this.pathShape=this.shape.createPath("M"+this.start.x+","+this.start.y+" Q"+this.control.x+","+this.control.y+" "+this.end.x+","+this.end.y+" l0,0");
        this.labelShape=this.shape.createText({
          x:this.textPosition.x,
          y:this.textPosition.y,
          text:this.property('label'),
          align:this.textAlign
         });
        this.labelShape.getEventSource().setAttribute('id',this.id+"-labelShape");
        this.draw();
    • chains:
      • this: (call)
    • summary
  • ta.LeadAnnotation.shape

    • summary
  • ta.LeadAnnotation.pathShape

    • summary
  • ta.LeadAnnotation.labelShape

    • summary
  • ta.LeadAnnotation.destroy

    • type
      Function
    • source: [view]
        if(!this.shape){ return; }
        this.shape.remove(this.pathShape);
        this.shape.remove(this.labelShape);
        this.figure.group.remove(this.shape);
        this.shape=this.pathShape=this.labelShape=null;
    • summary
  • ta.LeadAnnotation.getBBox

    • type
      Function
    • source: [view]
        var x=Math.min(this.start.x, this.control.x, this.end.x);
        var y=Math.min(this.start.y, this.control.y, this.end.y);
        var w=Math.max(this.start.x, this.control.x, this.end.x)-x;
        var h=Math.max(this.start.y, this.control.y, this.end.y)-y;
        return { x:x, y:y, width:w, height:h };
    • summary
  • ta.LeadAnnotation.draw

    • type
      Function
    • parameters:
      • obj: (typeof )
    • source: [view]
        this.apply(obj);
        this._pos();
        this.shape.setTransform(this.transform);
        this.pathShape.setShape("M"+this.start.x+","+this.start.y+" Q"+this.control.x+","+this.control.y+" "+this.end.x+","+this.end.y+" l0,0");
        this.labelShape.setShape({
          x:this.textPosition.x,
          y:this.textPosition.y,
          text:this.property('label')
         })
         .setFill(this.property('fill'));
        this.zoom();
    • chains:
      • this: (call)
    • summary
  • ta.LeadAnnotation.serialize

    • type
      Function
    • source: [view]
        var stroke=this.property('stroke');
        return ''
         + '   + "Q"+this.control.x+","+this.control.y+" "
         + this.end.x+","+this.end.y
         + '" />'
         + '   + 'x="' + this.textPosition.x + '" '
         + 'y="' + this.textPosition.y + '">'
         + this.property('label')
         + '
      '
         + '
      ';
    • summary
  • dojox.sketch

    • type
      Object
    • summary
  • dojox

    • type
      Object
    • summary