dojox/sketch/Anchor.js

  • Provides:

    • dojox.sketch.Anchor
  • Requires:

    • dojox.gfx in common
  • dojox.sketch.Anchor.count

    • summary
  • dojox.sketch.Anchor

    • type
      Function
    • parameters:
      • an: (typeof )
      • id: (typeof )
      • isControl: (typeof )
    • source: [view]
        var self=this;
        var size=4; // .5 * size of anchor.
        var rect=null;


        this.type=function(){ return "Anchor"; };
        this.annotation=an;


        this.id=id;
        this._key="anchor-" + ta.Anchor.count++;
        this.shape=null;
        this.isControl=(isControl!=null)?isControl:true;


        this.beginEdit=function(){
         this.annotation.beginEdit(ta.CommandTypes.Modify);
        };
        this.endEdit=function(){
         this.annotation.endEdit();
        };
        this.zoom=function(pct){
         if(this.shape){
          var rs=Math.floor(size/pct);
          var width=dojox.gfx.renderer=='vml'?1:1/pct
          this.shape.setShape({ x:an[id].x-rs, y:an[id].y-rs, width:rs*2, height:rs*2 }).setStroke({ color:"black", width:width }); //For IE, maybe we need Math.ceil(1/pct)||1
         }
        }
        /*this.doChange=function(pt){
         if(this.isControl){
          this.shape.applyTransform(pt);
         } else{
          an.transform.dx+=pt.dx;
          an.transform.dy+=pt.dy;
         }
        };*/
        this.setBinding=function(pt){
         an[id]={ x: an[id].x+pt.dx, y:an[id].y+pt.dy };
         an.draw();
         an.drawBBox();
        };
        this.setUndo=function(){ an.setUndo(); };


        this.enable=function(){
         if(!an.shape){ return; }
         an.figure._add(this);
         rect={ x:an[id].x-size, y:an[id].y-size, width:size*2, height:size*2 };
         this.shape=an.shape.createRect(rect)
          //.setStroke({ color:"black", width:1 })
          .setFill([255,255,255,0.35]);
         this.shape.getEventSource().setAttribute("id", self._key);
         this.shape.getEventSource().setAttribute("shape-rendering", "crispEdges");
         this.zoom(an.figure.zoomFactor);
        };
        this.disable=function(){
         an.figure._remove(this);
         if(an.shape){ an.shape.remove(this.shape); }
         this.shape=null;
         rect=null;
        };
    • summary
  • dojox.sketch.Anchor.annotation

    • summary
  • dojox.sketch.Anchor.id

    • summary
  • dojox.sketch.Anchor._key

    • summary
  • dojox.sketch.Anchor.shape

    • summary
  • dojox.sketch.Anchor.isControl

    • summary
  • dojox.sketch.Anchor.type

    • type
      Function
    • source: [view]
        this.type=function(){ return "Anchor";
    • summary
  • dojox.sketch.Anchor.beginEdit

    • type
      Function
    • source: [view]
         this.annotation.beginEdit(ta.CommandTypes.Modify);
    • summary
  • dojox.sketch.Anchor.endEdit

    • type
      Function
    • source: [view]
         this.annotation.endEdit();
    • summary
  • dojox.sketch.Anchor.zoom

    • type
      Function
    • parameters:
      • pct: (typeof )
    • source: [view]
         if(this.shape){
          var rs=Math.floor(size/pct);
          var width=dojox.gfx.renderer=='vml'?1:1/pct
          this.shape.setShape({ x:an[id].x-rs, y:an[id].y-rs, width:rs*2, height:rs*2 }).setStroke({ color:"black", width:width }); //For IE, maybe we need Math.ceil(1/pct)||1
         }
    • summary
  • dojox.sketch.Anchor.setBinding

    • type
      Function
    • parameters:
      • pt: (typeof )
    • source: [view]
         an[id]={ x: an[id].x+pt.dx, y:an[id].y+pt.dy };
         an.draw();
         an.drawBBox();
    • summary
  • dojox.sketch.Anchor.setUndo

    • type
      Function
    • source: [view]
        this.setUndo=function(){ an.setUndo();
    • summary
  • dojox.sketch.Anchor.enable

    • type
      Function
    • source: [view]
         if(!an.shape){ return; }
         an.figure._add(this);
         rect={ x:an[id].x-size, y:an[id].y-size, width:size*2, height:size*2 };
         this.shape=an.shape.createRect(rect)
          //.setStroke({ color:"black", width:1 })
          .setFill([255,255,255,0.35]);
         this.shape.getEventSource().setAttribute("id", self._key);
         this.shape.getEventSource().setAttribute("shape-rendering", "crispEdges");
         this.zoom(an.figure.zoomFactor);
    • summary
  • dojox.sketch.Anchor.disable

    • type
      Function
    • source: [view]
         an.figure._remove(this);
         if(an.shape){ an.shape.remove(this.shape); }
         this.shape=null;
         rect=null;
    • summary
  • dojox.sketch

    • type
      Object
    • summary
  • dojox

    • type
      Object
    • summary