dojox/sketch/PreexistingAnnotation.js

  • Provides:

    • dojox.sketch.PreexistingAnnotation
  • Requires:

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

    • summary
  • dojox.sketch.PreexistingAnnotation.prototype.constructor

    • summary
  • dojox.sketch.PreexistingAnnotation

    • 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.end={ x:200, y:200 };
        this.radius=8;
        this.textPosition={ x:196, y:196 };
        this.textOffset=4;
        this.textAlign="end";


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


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

    • summary
  • dojox.sketch.PreexistingAnnotation.start

    • summary
  • dojox.sketch.PreexistingAnnotation.end

    • summary
  • dojox.sketch.PreexistingAnnotation.radius

    • summary
  • dojox.sketch.PreexistingAnnotation.textPosition

    • summary
  • dojox.sketch.PreexistingAnnotation.textOffset

    • summary
  • dojox.sketch.PreexistingAnnotation.textAlign

    • summary
  • dojox.sketch.PreexistingAnnotation.rectShape

    • summary
  • dojox.sketch.PreexistingAnnotation.labelShape

    • summary
  • dojox.sketch.PreexistingAnnotation.anchors.start

    • summary
  • dojox.sketch.PreexistingAnnotation.anchors.end

    • summary
  • ta.PreexistingAnnotation.type

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

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

    • type
      Function
    • source: [view]
        var x=Math.min(this.start.x, this.end.x);
        var y=Math.min(this.start.y, this.end.y);
        var w=Math.max(this.start.x, this.end.x);
        var h=Math.max(this.start.y, this.end.y);
        this.start={ x:x, y:y };
        this.end={ x:w, y:h };
        this.textPosition={ x:this.end.x-this.textOffset, y:this.end.y-this.textOffset };
    • summary
  • ta.PreexistingAnnotation.start

    • summary
  • ta.PreexistingAnnotation.end

    • summary
  • ta.PreexistingAnnotation.textPosition

    • summary
  • ta.PreexistingAnnotation.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=="rect"){
          if(c.getAttribute('x')!==null){ this.start.x=parseFloat(c.getAttribute('x'), 10); }
          if(c.getAttribute('width')!==null){ this.end.x=parseFloat(c.getAttribute('width'), 10)+parseFloat(c.getAttribute('x'), 10); }
          if(c.getAttribute('y')!==null){ this.start.y=parseFloat(c.getAttribute('y'), 10); }
          if(c.getAttribute('height')!==null){ this.end.y=parseFloat(c.getAttribute('height'), 10)+parseFloat(c.getAttribute('y'), 10); }
          if(c.getAttribute('r')!==null){ this.radius=parseFloat(c.getAttribute('r'),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.PreexistingAnnotation.start.x

    • summary
  • ta.PreexistingAnnotation.end.x

    • summary
  • ta.PreexistingAnnotation.start.y

    • summary
  • ta.PreexistingAnnotation.end.y

    • summary
  • ta.PreexistingAnnotation.radius

    • summary
  • ta.PreexistingAnnotation.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);
        //if(this.transform.dx || this.transform.dy){ this.shape.setTransform(this.transform); }
        this.rectShape=this.shape.createRect({
          x:this.start.x,
          y: this.start.y,
          width: this.end.x-this.start.x,
          height:this.end.y-this.start.y,
          r:this.radius
         })
         //.setStroke({color:this.property('fill'), width:1})
         .setFill([255,255,255,0.1]);
        this.rectShape.getEventSource().setAttribute("shape-rendering","crispEdges");
        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.PreexistingAnnotation.shape

    • summary
  • ta.PreexistingAnnotation.rectShape

    • summary
  • ta.PreexistingAnnotation.labelShape

    • summary
  • ta.PreexistingAnnotation.destroy

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

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

    • type
      Function
    • parameters:
      • obj: (typeof )
    • source: [view]
        this.apply(obj);
        this._pos();
        this.shape.setTransform(this.transform);
        this.rectShape.setShape({
          x:this.start.x,
          y: this.start.y,
          width: this.end.x-this.start.x,
          height:this.end.y-this.start.y,
          r:this.radius
         })
         //.setStroke({ color:this.property('fill'), width:1 })
         .setFill([255,255,255,0.1]);


        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.PreexistingAnnotation.zoom

    • type
      Function
    • parameters:
      • pct: (typeof )
    • source: [view]
        if(this.rectShape){
         pct = pct || this.figure.zoomFactor;
         ta.Annotation.prototype.zoom.call(this,pct);
         pct = dojox.gfx.renderer=='vml'?1:pct;
         this.rectShape.setStroke({color:this.property('fill'), width:1/pct});
        }
    • summary
  • ta.PreexistingAnnotation.serialize

    • type
      Function
    • source: [view]
        var s=this.property('stroke');
        return ''
         + '   + 'x="' + this.start.x + '" '
         + 'width="' + (this.end.x-this.start.x) + '" '
         + 'y="' + this.start.y + '" '
         + 'height="' + (this.end.y-this.start.y) + '" '
         + 'rx="' + this.radius + '" '
         + 'ry="' + this.radius + '" '
         + ' />'
         + '   + 'x="' + this.textPosition.x + '" '
         + 'y="' + this.textPosition.y + '">'
         + this.property('label')
         + '
      '
         + '
      ';
    • summary
  • dojox.sketch

    • type
      Object
    • summary
  • dojox

    • type
      Object
    • summary