dojox/sketch/Annotation.js

  • Provides:

    • dojox.sketch.Annotation
  • Requires:

    • dojox.sketch.Anchor in common
    • dojox.sketch._Plugin in common
  • dojox.sketch.AnnotationTool

    • type
      Function
    • chains:
      • ta._Plugin: (prototype)
      • ta._Plugin: (call)
    • summary
  • dojox.sketch.AnnotationTool.onMouseDown

    • type
      Function
    • parameters:
      • e: (typeof )
    • source: [view]
         this._omd=true;
    • summary
  • dojox.sketch.AnnotationTool.onMouseMove

    • type
      Function
    • parameters:
      • e: (typeof )
      • rect: (typeof )
    • source: [view]
         if(!this._omd){
          return;
         }
         if(this._cshape){
          this._cshape.setShape(rect);
         } else {
          this._cshape=this.figure.surface.createRect(rect)
           .setStroke({color:"#999", width:1, style:"ShortDot"})
           .setFill([255,255,255,0.7]);
          this._cshape.getEventSource().setAttribute("shape-rendering","crispEdges");
         }
    • summary
  • dojox.sketch.AnnotationTool.onMouseUp

    • type
      Function
    • parameters:
      • e: (typeof )
    • source: [view]
         if(!this._omd){
          return;
         }
         this._omd=false;
         var f=this.figure;
         if(this._cshape){
          f.surface.remove(this._cshape);
          delete this._cshape;
         }
         if(!(f._startPoint.x==e.pageX&&f._startPoint.y==e.pageY)){
          // The minimum number of pixels one has to travel before a shape
          //  gets drawn.
          var limit=10;
          if(Math.max(
           limit,
           Math.abs(f._absEnd.x-f._start.x),
           Math.abs(f._absEnd.y-f._start.y)
          )>limit){
           this._create(f._start, f._end);
          }
         }
    • summary
  • dojox.sketch.AnnotationTool._create

    • type
      Function
    • parameters:
      • start: (typeof )
      • end: (typeof )
    • source: [view]
      dojo.provide("dojox.sketch.Annotation");
      dojo.require("dojox.sketch.Anchor");
      dojo.require("dojox.sketch._Plugin");


      (function(){
       var ta=dojox.sketch;
       dojo.declare("dojox.sketch.AnnotationTool", ta._Plugin, {
        onMouseDown: function(e){
         this._omd=true;
        },
        onMouseMove: function(e,rect){
         if(!this._omd){
          return;
         }
         if(this._cshape){
          this._cshape.setShape(rect);
         } else {
          this._cshape=this.figure.surface.createRect(rect)
           .setStroke({color:"#999", width:1, style:"ShortDot"})
           .setFill([255,255,255,0.7]);
          this._cshape.getEventSource().setAttribute("shape-rendering","crispEdges");
         }
        },
        onMouseUp: function(e){
         if(!this._omd){
          return;
         }
         this._omd=false;
         var f=this.figure;
         if(this._cshape){
          f.surface.remove(this._cshape);
          delete this._cshape;
         }
         if(!(f._startPoint.x==e.pageX&&f._startPoint.y==e.pageY)){
          // The minimum number of pixels one has to travel before a shape
          //  gets drawn.
          var limit=10;
          if(Math.max(
           limit,
           Math.abs(f._absEnd.x-f._start.x),
           Math.abs(f._absEnd.y-f._start.y)
          )>limit){
           this._create(f._start, f._end);
          }
         }
        },
        _create: function(start,end){
         // create a new shape, needs to be accessible from the
         //  dragging functions.
         var f=this.figure;
         var _=f.nextKey();
         var a=new (this.annotation)(f, _);
         a.transform={
          dx:f._calCol(start.x/f.zoomFactor),
          dy:f._calCol(start.y/f.zoomFactor)
         };
         a.end={
          x:f._calCol(end.x/f.zoomFactor),
          y:f._calCol(end.y/f.zoomFactor)
         };
         if(a.control){
          a.control={
           x:f._calCol((end.x/2)/f.zoomFactor),
           y:f._calCol((end.y/2)/f.zoomFactor)
          };
         }
         f.onBeforeCreateShape(a);
         a.initialize();
         f.select(a);
         f.onCreateShape(a);
         f.history.add(ta.CommandTypes.Create,a);
    • summary
  • dojox.sketch.AnnotationTool._omd

    • summary
  • dojox.sketch.AnnotationTool._cshape

    • summary
  • p.constructor

    • summary
  • p.type

    • summary
  • p.getType

    • summary
  • p.onRemove

    • summary
  • p.property

    • summary
  • p.onPropertyChange

    • summary
  • p.onCreate

    • summary
  • p.onDblClick

    • summary
  • p.initialize

    • summary
  • p.destroy

    • summary
  • p.draw

    • summary
  • p.apply

    • summary
  • p.serialize

    • summary
  • p.getBBox

    • summary
  • p.beginEdit

    • summary
  • p.endEdit

    • summary
  • p.calculate

    • summary
  • p.drawBBox

    • summary
  • p.setBinding

    • summary
  • p.getTextBox

    • summary
  • p.setMode

    • summary
  • p.zoom

    • summary
  • p.writeCommonAttrs

    • summary
  • p.readCommonAttrs

    • summary
  • dojox.sketch.Annotation.Modes

    • type
      Object
    • summary
  • dojox.sketch.Annotation

    • type
      Function
    • parameters:
      • figure: (typeof )
      • id: (typeof )
    • source: [view]
      dojo.provide("dojox.sketch.Annotation");
      dojo.require("dojox.sketch.Anchor");
      dojo.require("dojox.sketch._Plugin");


      (function(){
       var ta=dojox.sketch;
       dojo.declare("dojox.sketch.AnnotationTool", ta._Plugin, {
        onMouseDown: function(e){
         this._omd=true;
        },
        onMouseMove: function(e,rect){
         if(!this._omd){
          return;
         }
         if(this._cshape){
          this._cshape.setShape(rect);
         } else {
          this._cshape=this.figure.surface.createRect(rect)
           .setStroke({color:"#999", width:1, style:"ShortDot"})
           .setFill([255,255,255,0.7]);
          this._cshape.getEventSource().setAttribute("shape-rendering","crispEdges");
         }
        },
        onMouseUp: function(e){
         if(!this._omd){
          return;
         }
         this._omd=false;
         var f=this.figure;
         if(this._cshape){
          f.surface.remove(this._cshape);
          delete this._cshape;
         }
         if(!(f._startPoint.x==e.pageX&&f._startPoint.y==e.pageY)){
          // The minimum number of pixels one has to travel before a shape
          //  gets drawn.
          var limit=10;
          if(Math.max(
           limit,
           Math.abs(f._absEnd.x-f._start.x),
           Math.abs(f._absEnd.y-f._start.y)
          )>limit){
           this._create(f._start, f._end);
          }
         }
        },
        _create: function(start,end){
         // create a new shape, needs to be accessible from the
         //  dragging functions.
         var f=this.figure;
         var _=f.nextKey();
         var a=new (this.annotation)(f, _);
         a.transform={
          dx:f._calCol(start.x/f.zoomFactor),
          dy:f._calCol(start.y/f.zoomFactor)
         };
         a.end={
          x:f._calCol(end.x/f.zoomFactor),
          y:f._calCol(end.y/f.zoomFactor)
         };
         if(a.control){
          a.control={
           x:f._calCol((end.x/2)/f.zoomFactor),
           y:f._calCol((end.y/2)/f.zoomFactor)
          };
         }
         f.onBeforeCreateShape(a);
         a.initialize();
         f.select(a);
         f.onCreateShape(a);
         f.history.add(ta.CommandTypes.Create,a);
        }
       });


       ta.Annotation=function(figure, id){
        // for editing stuff.
        this.id=this._key=id;
        this.figure=figure;
        this.mode=ta.Annotation.Modes.View;
        this.shape=null; // dojox.gfx.Group
        this.boundingBox=null; // rect for boundaries
        this.hasAnchors=true;
        this.anchors={}; // ta.Anchor
        this._properties={
         'stroke':{ color:"blue", width:2 },
         'font': {family:"Arial", size:16, weight:"bold"},
         'fill': "blue",
         'label': ""
        };


        if(this.figure){
         this.figure.add(this);
        }
    • summary
  • dojox.sketch.Annotation.id

    • summary
  • dojox.sketch.Annotation.figure

    • summary
  • dojox.sketch.Annotation.mode

    • summary
  • dojox.sketch.Annotation.shape

    • summary
  • dojox.sketch.Annotation.boundingBox

    • summary
  • dojox.sketch.Annotation.hasAnchors

    • summary
  • dojox.sketch.Annotation.anchors

    • summary
  • dojox.sketch.Annotation._properties

    • summary
  • dojox.sketch.Annotation.register

    • type
      Function
    • parameters:
      • name: (typeof )
      • toolclass: (typeof )
    • source: [view]
        var cls=ta[name+'Annotation'];
        ta.registerTool(name, function(p){
         dojo.mixin(p, {
          shape: name,
          annotation:cls
         });
         return new (toolclass || ta.AnnotationTool)(p);
        });
    • summary
  • dojox.sketch.Annotation.Modes.View

    • summary
  • dojox.sketch.Annotation.Modes.Edit

    • summary
  • dojox.sketch

    • type
      Object
    • summary
  • dojox

    • type
      Object
    • summary