dojox/sketch/DoubleArrowAnnotation.js

  • Provides:

    • dojox.sketch.DoubleArrowAnnotation
  • Requires:

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

    • summary
  • dojox.sketch.DoubleArrowAnnotation.prototype.constructor

    • summary
  • dojox.sketch.DoubleArrowAnnotation

    • 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=6;
        this.textYOffset=10;
        this.textAlign="middle";
        this.startRotation=0;
        this.endRotation=0;


      //  this.property('label',this.id);
        this.labelShape=null;
        this.pathShape=null;
        this.startArrow=null;
        this.startArrowGroup=null;
        this.endArrow=null;
        this.endArrowGroup=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.DoubleArrowAnnotation.transform

    • summary
  • dojox.sketch.DoubleArrowAnnotation.start

    • summary
  • dojox.sketch.DoubleArrowAnnotation.control

    • summary
  • dojox.sketch.DoubleArrowAnnotation.end

    • summary
  • dojox.sketch.DoubleArrowAnnotation.textPosition

    • summary
  • dojox.sketch.DoubleArrowAnnotation.textOffset

    • summary
  • dojox.sketch.DoubleArrowAnnotation.textYOffset

    • summary
  • dojox.sketch.DoubleArrowAnnotation.textAlign

    • summary
  • dojox.sketch.DoubleArrowAnnotation.startRotation

    • summary
  • dojox.sketch.DoubleArrowAnnotation.endRotation

    • summary
  • dojox.sketch.DoubleArrowAnnotation.labelShape

    • summary
  • dojox.sketch.DoubleArrowAnnotation.pathShape

    • summary
  • dojox.sketch.DoubleArrowAnnotation.startArrow

    • summary
  • dojox.sketch.DoubleArrowAnnotation.startArrowGroup

    • summary
  • dojox.sketch.DoubleArrowAnnotation.endArrow

    • summary
  • dojox.sketch.DoubleArrowAnnotation.endArrowGroup

    • summary
  • dojox.sketch.DoubleArrowAnnotation.anchors.start

    • summary
  • dojox.sketch.DoubleArrowAnnotation.anchors.control

    • summary
  • dojox.sketch.DoubleArrowAnnotation.anchors.end

    • summary
  • ta.DoubleArrowAnnotation.type

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

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

    • type
      Function
    • source: [view]
      dojo.provide("dojox.sketch.DoubleArrowAnnotation");


      dojo.require("dojox.sketch.Annotation");
      dojo.require("dojox.sketch.Anchor");


      (function(){
       var ta=dojox.sketch;
       ta.DoubleArrowAnnotation=function(figure, id){
        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=6;
        this.textYOffset=10;
        this.textAlign="middle";
        this.startRotation=0;
        this.endRotation=0;


      //  this.property('label',this.id);
        this.labelShape=null;
        this.pathShape=null;
        this.startArrow=null;
        this.startArrowGroup=null;
        this.endArrow=null;
        this.endArrowGroup=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");
       };
       ta.DoubleArrowAnnotation.prototype=new ta.Annotation;
       var p=ta.DoubleArrowAnnotation.prototype;
       p.constructor=ta.DoubleArrowAnnotation;


       p.type=function(){ return 'DoubleArrow'; };
       p.getType=function(){ return ta.DoubleArrowAnnotation; };


       p._rot=function(){
        // arrowhead rotation
        var opp=this.control.y-this.start.y;
        var adj=this.control.x-this.start.x;
        this.startRotation=Math.atan2(opp,adj);


        opp=this.end.y-this.control.y;
        adj=this.end.x-this.control.x;
        this.endRotation=Math.atan2(opp,adj);
    • summary
  • ta.DoubleArrowAnnotation.startRotation

    • summary
  • ta.DoubleArrowAnnotation.endRotation

    • summary
  • ta.DoubleArrowAnnotation._pos

    • type
      Function
    • source: [view]
      dojo.provide("dojox.sketch.DoubleArrowAnnotation");


      dojo.require("dojox.sketch.Annotation");
      dojo.require("dojox.sketch.Anchor");


      (function(){
       var ta=dojox.sketch;
       ta.DoubleArrowAnnotation=function(figure, id){
        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=6;
        this.textYOffset=10;
        this.textAlign="middle";
        this.startRotation=0;
        this.endRotation=0;


      //  this.property('label',this.id);
        this.labelShape=null;
        this.pathShape=null;
        this.startArrow=null;
        this.startArrowGroup=null;
        this.endArrow=null;
        this.endArrowGroup=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");
       };
       ta.DoubleArrowAnnotation.prototype=new ta.Annotation;
       var p=ta.DoubleArrowAnnotation.prototype;
       p.constructor=ta.DoubleArrowAnnotation;


       p.type=function(){ return 'DoubleArrow'; };
       p.getType=function(){ return ta.DoubleArrowAnnotation; };


       p._rot=function(){
        // arrowhead rotation
        var opp=this.control.y-this.start.y;
        var adj=this.control.x-this.start.x;
        this.startRotation=Math.atan2(opp,adj);


        opp=this.end.y-this.control.y;
        adj=this.end.x-this.control.x;
        this.endRotation=Math.atan2(opp,adj);
       };
       p._pos=function(){
        // text position
        var offset=this.textOffset;


        // figure out the pull of the curve and place accordingly
        if(this.control.y  else { offset+=this.textYOffset; }
        var ab={
         x:((this.control.x-this.start.x)*.5)+this.start.x,
         y:((this.control.y-this.start.y)*.5)+this.start.y
        };
        var bc={
         x:((this.end.x-this.control.x)*.5)+this.control.x,
         y:((this.end.y-this.control.y)*.5)+this.control.y
        };
        this.textPosition={
         x:((bc.x-ab.x)*.5)+ab.x,
         y:(((bc.y-ab.y)*.5)+ab.y)+offset
        };
    • summary
  • ta.DoubleArrowAnnotation.textPosition

    • summary
  • ta.DoubleArrowAnnotation.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.DoubleArrowAnnotation.start.x

    • summary
  • ta.DoubleArrowAnnotation.start.y

    • summary
  • ta.DoubleArrowAnnotation.control.x

    • summary
  • ta.DoubleArrowAnnotation.control.y

    • summary
  • ta.DoubleArrowAnnotation.end.x

    • summary
  • ta.DoubleArrowAnnotation.end.y

    • summary
  • ta.DoubleArrowAnnotation.initialize

    • type
      Function
    • parameters:
      • obj: (typeof )
    • source: [view]
      dojo.provide("dojox.sketch.DoubleArrowAnnotation");


      dojo.require("dojox.sketch.Annotation");
      dojo.require("dojox.sketch.Anchor");


      (function(){
       var ta=dojox.sketch;
       ta.DoubleArrowAnnotation=function(figure, id){
        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=6;
        this.textYOffset=10;
        this.textAlign="middle";
        this.startRotation=0;
        this.endRotation=0;


      //  this.property('label',this.id);
        this.labelShape=null;
        this.pathShape=null;
        this.startArrow=null;
        this.startArrowGroup=null;
        this.endArrow=null;
        this.endArrowGroup=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");
       };
       ta.DoubleArrowAnnotation.prototype=new ta.Annotation;
       var p=ta.DoubleArrowAnnotation.prototype;
       p.constructor=ta.DoubleArrowAnnotation;


       p.type=function(){ return 'DoubleArrow'; };
       p.getType=function(){ return ta.DoubleArrowAnnotation; };


       p._rot=function(){
        // arrowhead rotation
        var opp=this.control.y-this.start.y;
        var adj=this.control.x-this.start.x;
        this.startRotation=Math.atan2(opp,adj);


        opp=this.end.y-this.control.y;
        adj=this.end.x-this.control.x;
        this.endRotation=Math.atan2(opp,adj);
       };
       p._pos=function(){
        // text position
        var offset=this.textOffset;


        // figure out the pull of the curve and place accordingly
        if(this.control.y  else { offset+=this.textYOffset; }
        var ab={
         x:((this.control.x-this.start.x)*.5)+this.start.x,
         y:((this.control.y-this.start.y)*.5)+this.start.y
        };
        var bc={
         x:((this.end.x-this.control.x)*.5)+this.control.x,
         y:((this.end.y-this.control.y)*.5)+this.control.y
        };
        this.textPosition={
         x:((bc.x-ab.x)*.5)+ab.x,
         y:(((bc.y-ab.y)*.5)+ab.y)+offset
        };
       };

       
       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.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);
         }
        }
       };
       p.initialize=function(obj){
        // create, based on passed DOM node if available.
        var font=(ta.Annotation.labelFont)?ta.Annotation.labelFont:{family:"Times", size:"16px"};
        this.apply(obj);


        // calculate the other positions
        this._rot();
        this._pos();


        // rotation matrix
        var rot=this.startRotation;
        var startRot=dojox.gfx.matrix.rotate(rot);


        rot=this.endRotation;
        var endRot=dojox.gfx.matrix.rotateAt(rot, this.end.x, this.end.y);


        // draw the shapes
        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.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")
         //.setStroke(this.property('stroke'));

        
        this.startArrowGroup=this.shape.createGroup().setTransform({ dx:this.start.x, dy:this.start.y });
        this.startArrowGroup.applyTransform(startRot);
        this.startArrow=this.startArrowGroup.createPath();//"M0,0 l20,-5 -3,5 3,5 Z").setFill(this.property('fill'));

        
        this.endArrowGroup=this.shape.createGroup().setTransform(endRot);
        this.endArrow=this.endArrowGroup.createPath();//("M" + this.end.x + "," + this.end.y + " l-20,-5 3,5 -3,5 Z").setFill(this.property('fill'));


        this.labelShape=this.shape.createText({
          x:this.textPosition.x,
          y:this.textPosition.y,
          text:this.property('label'),
          align:this.textAlign
         })
         //.setFont(font)
         .setFill(this.property('fill'));
        this.labelShape.getEventSource().setAttribute('id',this.id+"-labelShape");
        this.draw();
    • chains:
      • this: (call)
    • summary
  • ta.DoubleArrowAnnotation.shape

    • summary
  • ta.DoubleArrowAnnotation.pathShape

    • summary
  • ta.DoubleArrowAnnotation.startArrowGroup

    • summary
  • ta.DoubleArrowAnnotation.startArrow

    • summary
  • ta.DoubleArrowAnnotation.endArrowGroup

    • summary
  • ta.DoubleArrowAnnotation.endArrow

    • summary
  • ta.DoubleArrowAnnotation.labelShape

    • summary
  • ta.DoubleArrowAnnotation.destroy

    • type
      Function
    • source: [view]
        if(!this.shape){ return; }
        this.startArrowGroup.remove(this.startArrow);
        this.endArrowGroup.remove(this.endArrow);
        this.shape.remove(this.startArrowGroup);
        this.shape.remove(this.endArrowGroup);
        this.shape.remove(this.pathShape);
        this.shape.remove(this.labelShape);
        this.figure.group.remove(this.shape);
        this.shape=this.pathShape=this.labelShape=this.startArrowGroup=this.startArrow=this.endArrowGroup=this.endArrow=null;
    • summary
  • ta.DoubleArrowAnnotation.draw

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


        // rotation matrix
        var rot=this.startRotation;
        var startRot=dojox.gfx.matrix.rotate(rot);
        rot=this.endRotation;
        var endRot=dojox.gfx.matrix.rotateAt(rot, this.end.x, this.end.y);


        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")
         //.setStroke(this.property('stroke'));
        this.startArrowGroup.setTransform({ dx:this.start.x, dy:this.start.y }).applyTransform(startRot);
        this.startArrow.setFill(this.property('fill'));

        
        this.endArrowGroup.setTransform(endRot);
        this.endArrow.setFill(this.property('fill'));
        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.DoubleArrowAnnotation.zoom

    • type
      Function
    • parameters:
      • pct: (typeof )
    • source: [view]
        if(this.startArrow){
         pct = pct || this.figure.zoomFactor;
         ta.Annotation.prototype.zoom.call(this,pct);


         var l=pct>1?20:Math.floor(20/pct), w=pct>1?5:Math.floor(5/pct),h=pct>1?3:Math.floor(3/pct);
         this.startArrow.setShape("M0,0 l"+l+",-"+w+" -"+h+","+w+" "+h+","+w+" Z");//.setFill(this.property('fill'));


         this.endArrow.setShape("M" + this.end.x + "," + this.end.y + " l-"+l+",-"+w+" "+h+","+w+" -"+h+","+w+" Z");
        }
    • summary
  • ta.DoubleArrowAnnotation.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.DoubleArrowAnnotation.serialize

    • type
      Function
    • source: [view]
        var s=this.property('stroke');
        return ''
         + '   + "Q"+this.control.x+","+this.control.y+" "
         + this.end.x+","+this.end.y
         + '" />'
         + '   + 'rotate(' + (Math.round((this.startRotation*(180/Math.PI))*Math.pow(10,4))/Math.pow(10,4)) + ')">'
         + ''
         + '
      '
         + '   + ')">'
         + ''
         + '
      '
         + '   + 'x="' + this.textPosition.x + '" '
         + 'y="' + this.textPosition.y + '">'
         + this.property('label')
         + '
      '
         + '
      ';
    • summary
  • dojox.sketch

    • type
      Object
    • summary
  • dojox

    • type
      Object
    • summary