diff --git a/web-UI/andes/drawing_test.html b/web-UI/andes/drawing_test.html deleted file mode 100644 index 9b4587d68..000000000 --- a/web-UI/andes/drawing_test.html +++ /dev/null @@ -1,114 +0,0 @@ - - - Drawing Test - - - - - - - - - -
-
- - -
- -
-
-
-
-
-
- -
-
- - - - diff --git a/web-UI/dojox/drawing/annotations/Angle.js b/web-UI/dojox/drawing/annotations/Angle.js deleted file mode 100755 index 2b7f9247e..000000000 --- a/web-UI/dojox/drawing/annotations/Angle.js +++ /dev/null @@ -1,104 +0,0 @@ -dojo.provide("dojox.drawing.annotations.Angle"); - -dojox.drawing.annotations.Angle = dojox.drawing.util.oo.declare( - // summary: - // When initiated, an HTML box will hover near the Stencil, - // displaying it's angle while drawn or modified. Currently - // only works with Vector, Line, Arrow, and Axes. - // description: - // Annotation is positioned with dojox.drawing.util.positioning.angle - // That method should be overwritten for custom placement. - // Called internally. To initiaize: - // TODO: currently always on - // - function(/*Object*/options){ - // arguments: - // options: Object - // One key value: the stencil that called this. - // - this.stencil = options.stencil; - this.util = options.stencil.util; - this.mouse = options.stencil.mouse; - - this.stencil.connectMult([ - ["onDrag", this, "showAngle"], - ["onUp", this, "hideAngle"], - ["onTransformBegin", this, "showAngle"], - ["onTransform", this, "showAngle"], - ["onTransformEnd", this, "hideAngle"] - ]); - }, - { - type:"dojox.drawing.tools.custom", - angle:0, - - showAngle: function(){ - // summary: - // Called to display angle - // - if(!this.stencil.selected && this.stencil.created){ return; } - if(this.stencil.getRadius() < this.stencil.minimumSize){ - this.hideAngle(); - return; - } - var node = this.getAngleNode(); - var d = this.stencil.pointsToData(); - var pt = dojox.drawing.util.positioning.angle({x:d.x1,y:d.y1},{x:d.x2,y:d.y2}); - var sc = this.mouse.scrollOffset(); - var mx = this.stencil.getTransform(); - var dx = mx.dx / this.mouse.zoom; - var dy = mx.dy / this.mouse.zoom; - pt.x /= this.mouse.zoom; - pt.y /= this.mouse.zoom; - - // adding _offX & _offY since this is HTML - // and we are from the page corner, not - // the canvas corner - var x = this.stencil._offX + pt.x - sc.left + dx; - var y = this.stencil._offY + pt.y - sc.top + dy; - dojo.style(node, { - left: x + "px", - top: y + "px", - align:pt.align - }); - - var angle=this.stencil.getAngle(); - if(this.stencil.style.zAxis && this.stencil.shortType=="vector") { - node.innerHTML = this.stencil.cosphi > 0 ? "out of" : "into"; - } else if(this.stencil.shortType=="line") { - node.innerHTML = this.stencil.style.zAxis?"out of":Math.ceil(angle%180); - } else { - node.innerHTML = Math.ceil(angle); - } - }, - - getAngleNode: function(){ - // summary: - // Gets or creates HTMLNode used for display - if(!this._angleNode){ - this._angleNode = dojo.create("span", null, dojo.body()); - dojo.addClass(this._angleNode, "textAnnotation"); - dojo.style(this._angleNode, "opacity", 1); - } - return this._angleNode; //HTMLNode - }, - - hideAngle: function(){ - // summary: - // Turns display off. - // - if(this._angleNode && dojo.style(this._angleNode, "opacity")>0.9){ - - dojo.fadeOut({node:this._angleNode, - duration:500, - onEnd: function(node){ - dojo.destroy(node); - } - }).play(); - this._angleNode = null; - } - - } - } - -) \ No newline at end of file diff --git a/web-UI/dojox/drawing/annotations/BoxShadow.js b/web-UI/dojox/drawing/annotations/BoxShadow.js deleted file mode 100644 index ac18c8acf..000000000 --- a/web-UI/dojox/drawing/annotations/BoxShadow.js +++ /dev/null @@ -1,319 +0,0 @@ -dojo.provide("dojox.drawing.annotations.BoxShadow"); - -dojox.drawing.annotations.BoxShadow = dojox.drawing.util.oo.declare( - // summary: - // Creates a box shadow under solid objects. Can change the - // shadow direction, color, size, and intensity. Can center - // the shadow and make it a Glow. - // description: - // This is a psuedo shadow, created by duplicating the - // original stencil and increasing the line weight while - // reducing the opacity. Therefore it will not work with - // text. Also won't look very good if the Stencil has no - // fill or is transparent. Can't do knockouts or inner - // shadows. Currently can't do paths - while doable, it - // will most likely choke IE into certain death. - // - function(/*Object*/options){ - this.stencil = options.stencil; - this.util = options.stencil.util; - this.mouse = options.stencil.mouse; - this.style = options.stencil.style; - - var shadowDefaults = { - // summary: - // When passing a shadow object into a stencil, that shadow - // object will be mixed in with these defaults. - // - // size: Number, mult: Number - // These two props work together. Both affect the size and quality - // of the shadow. size affects the actual size and mult affects the - // lineWidths that overlap to make the shadow. Generally you want a - // bigger 'size' than 'mult'. The defaults are good for a shadow, but - // you will want to increase them when making a glow. - // TODO: Make this more clear or use other properties. - size:6, - mult:4, - // alpha: Float - // Affects the alpha of the shadow. Because this is multiple shapes - // overlapped, you want much less than you may think. .1 is pretty - // dark and . is black. Higher numbers also give a sharper edge. - alpha:.05, - // place: String - // Tells the position of the shadow: - // B: bottom - // T: top - // L: left - // R: right - // C: center, or a glow - // Can be used in combinations such as BR, BL, L, T, etc. 'C' should - // be used by itself. - place:"BR", - // color: String - // The color of the shadow or glow. - color:"#646464" - } - - delete options.stencil; - this.options = dojo.mixin(shadowDefaults, options); - this.options.color = new dojo.Color(this.options.color) - this.options.color.a = this.options.alpha; - switch(this.stencil.shortType){ - case "image": - case "vector": - this.method = "createForZArrow"; break; - case "rect": - this.method = "createForRect"; break; - case "ellipse": - this.method = "createForEllipse"; break; - case "line": - this.method = "createForLine"; break; - case "path": - this.method = "createForPath"; break; - // path is a bit of a hassle. Plus I think in IE it would be - //slower than than the political process. Maybe TODO. - default: - console.warn("A shadow cannot be made for Stencil type ", this.stencil.type); - } - - if(this.method == "createForZArrow"){ - this.stencil.connectMult([ - [this.stencil, "onTransform", this, "onTransform"], - [this.stencil, "onDelete", this, "destroy"], - [this.stencil, "render", this, "render"] - ]); - } else if(this.method){ - this.render(); - this.stencil.connectMult([ - [this.stencil, "onTransform", this, "onTransform"], - [this.stencil, "render", this, "onRender"], - [this.stencil, "onDelete", this, "destroy"] - ]); - } - }, - { - showing:true, - render: function(){ - if(this.container){ - this.container.removeShape(); - } - this.container = this.stencil.container.createGroup(); - this.container.moveToBack(); - - var o = this.options, - size = o.size, - mult = o.mult, - d = this.method == "createForPath" - ? this.stencil.points - : this.stencil.data, - r = d.r || 1, - p = o.place, - c = o.color; - - this[this.method](o, size, mult, d, r, p, c); - }, - - hide: function(){ - if(this.showing){ - this.showing = false; - this.container.removeShape(); - } - }, - - show: function(){ - if(!this.showing){ - this.showing = true; - this.stencil.container.add(this.container); - } - }, - - createForPath: function(o, size, mult, pts, r, p, c){ - var sh = size * mult / 4, - shy = /B/.test(p) ? sh : /T/.test(p) ? sh*-1 : 0, - shx = /R/.test(p) ? sh : /L/.test(p) ? sh*-1 : 0; - - var closePath = true; - - for(var i=1;i<=size;i++){ - var lineWidth = i * mult; - //var rect = this.container.createLine({x1:d.x1+shx, y1:d.y1+shy, x2:d.x2+shx, y2:d.y2+shy}) - // .setStroke({width:lineWidth, color:c, cap:"round"}) - - if(dojox.gfx.renderer=="svg"){ - var strAr = []; - dojo.forEach(pts, function(o, i){ - if(i==0){ - strAr.push("M " + (o.x+shx) +" "+ (o.y+shy)); - }else{ - var cmd = o.t || "L "; - strAr.push(cmd + (o.x+shx) +" "+ (o.y+shy)); // Z + undefined works here - } - }, this); - if(closePath){ - strAr.push("Z"); - } - this.container.createPath(strAr.join(", ")).setStroke({width:lineWidth, color:c, cap:"round"}) - - }else{ - // Leaving this code for VML. It seems slightly faster but times vary. - var pth = this.container.createPath({}).setStroke({width:lineWidth, color:c, cap:"round"}) - - dojo.forEach(this.points, function(o, i){ - if(i==0 || o.t=="M"){ - pth.moveTo(o.x+shx, o.y+shy); - }else if(o.t=="Z"){ - closePath && pth.closePath(); - }else{ - pth.lineTo(o.x+shx, o.y+shy); - } - }, this); - - closePath && pth.closePath(); - } - - - } - }, - - createForLine: function(o, size, mult, d, r, p, c){ - - var sh = size * mult / 4, - shy = /B/.test(p) ? sh : /T/.test(p) ? sh*-1 : 0, - shx = /R/.test(p) ? sh : /L/.test(p) ? sh*-1 : 0; - for(var i=1;i<=size;i++){ - var lineWidth = i * mult; - this.container.createLine({x1:d.x1+shx, y1:d.y1+shy, x2:d.x2+shx, y2:d.y2+shy}) - .setStroke({width:lineWidth, color:c, cap:"round"}) - } - }, - createForEllipse: function(o, size, mult, d, r, p, c){ - - var sh = size * mult / 8, - shy = /B/.test(p) ? sh : /T/.test(p) ? sh*-1 : 0, - shx = /R/.test(p) ? sh*.8 : /L/.test(p) ? sh*-.8 : 0; - - for(var i=1;i<=size;i++){ - var lineWidth = i * mult; - this.container.createEllipse({cx:d.cx+shx, cy:d.cy+shy, rx:d.rx-sh, ry:d.ry-sh, r:r}) - .setStroke({width:lineWidth, color:c}) - } - }, - - createForRect: function(o, size, mult, d, r, p, c){ - - var sh = size * mult / 2, - shy = /B/.test(p) ? sh : /T/.test(p) ? 0 : sh /2, - shx = /R/.test(p) ? sh : /L/.test(p) ? 0 : sh /2; - - for(var i=1;i<=size;i++){ - var lineWidth = i * mult; - this.container.createRect({x:d.x+shx, y:d.y+shy, width:d.width-sh, height:d.height-sh, r:r}) - .setStroke({width:lineWidth, color:c}) - } - }, - - arrowPoints: function(){ - // summary: - // Creates data used to draw arrow head. - // - var d = this.stencil.data; - d.radius = this.stencil.getRadius(); - d.angle = this.style.zAngle + 30; - - var pt = this.util.pointOnCircle(d.x1, d.y1, d.radius*.75, d.angle); - var p = [ - {x:d.x1, y:d.y1}, - {x:pt.x, y:pt.y} - ]; - - var obj = { - start:{ - x:p[0].x, - y:p[0].y - }, - x:p[1].x, - y:p[1].y - } - var angle = this.util.angle(obj); - var lineLength = this.util.length(obj); - var al = this.style.arrows.length; - var aw = this.style.arrows.width/3; - if(lineLength - // See: - // Drawing.changeDefaults - // - // Determines whether in draw or edit mode (whether stencils - // are clickable. If clickMode is false, the original - // functionality of silently switching between select modes - // is enabled. If clickMode is true, it allows powerpoint- - // like functionality. Clickable is used by powerpoint to - // distinguish when things can be selected and when they can't - clickMode:true, - clickable:true, - - // current: Object - // current will point to either null or selected - current:null, - // currentHit: Object - // currentHit will point to either hitNorm or hitSelected - currentHit:null, - - // angleSnap: Number - // Line, arrows, vector and axes will all snap to this angle on mouse up - // shown angle also reflects the snap - // currently cannot accept less than 1 degree - angleSnap:1, - - // zAxis: Boolean - // If true, draw current object in z-direction. - // zAxisEnabled: Boolean - // If true, render axes with Z-axis included, allow objects drawn in z-direction. - zAxis: false, - zAxisEnabled: true, - zAngle: 225, - - // renderHitLines: Boolean - // If true, renders a second, larger layer for lines to make - // them more easily clickable. - renderHitLines: true, - // - // renderHitLayer: - // If true, renders a second layer for each Stencil, one - // acting as a 'hit' object for a wider mouse-click area. - // It also doubles as a hilight. If true, overrides - // renderHitLines setting. - renderHitLayer:true, - - // labelSameColor: - // If true, the label text color will be the same as the - // Stencil's line color. - labelSameColor:false, - - // - useSelectedStyle: true, - - norm:{ - // summary: - // Normal style of all shapes - // will get overridden by - // above andes styles - width:1, - color:"#000000", - style:"Solid", - cap:"round", // square, butt, round - fill:"#CCCCCC" - }, - - selected:{ - // summary: - // Selected style of all shapes - // styles not shown will used from - // norm - width:6, - color:"#00FF00" - }, - - highlighted:{ - // summary: - // Highlighted style of all shapes - // NOT CURRENTLY BEING USED - width:6, - color:"#FF00FF", - style:"Solid", - cap:"round", - fill:"#E11EBB" - }, - - disabled:{ - // summary: - // Disabled or "locked" or "fade" style of all shapes - width:1, - color:"#666666", - style:"solid", - cap:"round", - fill:"#cccccc" - }, - - // "hit" refers to the hidden object below the shape - // that is usually larger than the object to give a - // larger 'target' to click upon. These hit objects - // double as highlights. - // - hitNorm:{ - // summary: - // Normal style of a hit area - width:6, - color:{r:0, g:255, b:255, a:0}, - style:"Solid", - cap:"round", - fill:{r:255, g:255, b:255, a:0} - }, - hitSelected:{ - // summary: - // Selected style of a hit area - width:6, - color:"#FF9900", - style:"Solid", - cap:"round", - fill:{r:255, g:255, b:255, a:0} - }, - hitHighlighted:{ - // summary: - // Highlighted style of a hit area - width:6, - color:"#FFFF00", - style:"Solid", - cap:"round", - fill:{r:255, g:255, b:255, a:0} - }, - - - anchors:{ - // summary: - // Style for the anchor resize-points - size:10, - width:2, - color:"#999", - style:"solid", - fill:"#fff", - cap:"square", - minSize:10, - marginZero:5 // not really an anchor prop - }, - arrows:{ - // summary: - // Size of arrows on vectors. - // length is in pixels - // width is actually an angle - // but is close to pixels in size - length:30, - width:16 - }, - text:{ - // summary: - // Style of text - minWidth:100, - deleteEmptyCreate:true, - deleteEmptyModify:true, - pad:3, - size:"18px", - family:"sans-serif", - weight:"normal", - color:"#000000" - }, - textDisabled:{ - // summary: - // Style of disabled text - size:"18px", - family:"sans-serif", - weight:"normal", - color:"#cccccc" - }, - - textMode:{ - // summary: - // These styles apply to the containing - // text box (edit mode), and not the text itself - create:{ - width:2, - style:"dotted", - color:"#666666", - fill:null - }, - edit:{ - width:1, - style:"dashed", - color:"#666", - fill:null - } - - }, - - button:{ - norm:{ - "color": "#cccccc", - "fill": { - type:"linear", - x1:0, x2:0, y1:0, y2:100, - colors:[ - {offset:.5, color:"#ffffff"}, - {offset:1, color:"#e5e5e5"} - ] - } - }, - over:{ - "fill": { - type:"linear", - x1:0, x2:0, y1:0, y2:100, - colors:[{offset:.5, color:"#ffffff"}, {offset:1, color:"#e1eaf5"}] - }, - "color": "#92a0b3" - }, - down:{ - "fill": { - type:"linear", - x1:0, x2:0, y1:0, y2:100, - colors:[{offset:0, color:"#e1eaf5"}, {offset:1, color:"#ffffff"}] - }, - "color": "#92a0b3" - }, - selected:{ - "fill": { - type:"linear", - x1:0, x2:0, y1:0, y2:100, - colors:[{offset:0, color:"#97b4bf"}, {offset:1, color:"#c8dae1"}] - }, - "color": "#92a0b3" - }, - icon:{ - norm:{ - fill:null, - color:"#92a0b3" - }, - selected:{ - fill:"#ffffff", - color:"#92a0b3" - } - } - }, - - copy: function(){ - // summary - // Each shape gets its own copy - // of these styles so that instances - // do not change each other's styles - // - var cpy = function(obj){ - if(typeof(obj)!="object" || obj===null || obj===undefined){ - return obj; - } - var o; - if(obj.push){ - o = []; - for(var i=0; i this.y_anchor.org.y){ - // bottom anchor - - conT = this.y_anchor.point.y + s - this.org.y; - conB = Infinity; - - if(y < conT){ - // overlapping other anchor - y = conT; - } - - - }else{ - // top anchor - - conT = -orgy + marginZero; - conB = this.y_anchor.point.y - s - this.org.y; - - if(y < conT){ - // less than zero - y = conT; - }else if(y > conB){ - // overlapping other anchor - y = conB; - } - } - }else{ - // Lines - check for zero - conT = -orgy + marginZero; - if(y < conT){ - // less than zero - y = conT; - } - } - - - - - if(this.x_anchor){ - // prevent x overlap of opposite anchor - - if(this.org.x>this.x_anchor.org.x){ - // right anchor - - conL = this.x_anchor.point.x + s - this.org.x; - conR = Infinity; - - if(x < conL){ - // overlapping other anchor - x = conL; - } - - }else{ - // left anchor - - conL = -orgx + marginZero; - conR = this.x_anchor.point.x - s - this.org.x; - - if(x < conL){ - x = conL; - }else if(x > conR){ - // overlapping other anchor - x = conR; - } - } - }else{ - // Lines check for zero - conL = -orgx + marginZero; - if(x < conL){ - x = conL; - } - } - - this.shape.setTransform({ - dx:x, - dy:y - }); - if(this.linkedAnchor){ - // first and last points of a closed-curve-path - this.linkedAnchor.shape.setTransform({ - dx:x, - dy:y - }); - } - this.onTransformPoint(this); - } - }, - - anchorConstrain: function(/* Number */x,/* Number */ y){ - // summary: - // To be over written by tool! - // Add an anchorConstrain method to the tool - // and it will automatically overwrite this stub. - // Should return a constrained x & y value. - return null; - }, - - anchorPositionCheck: function(/* Number */x,/* Number */ y, /* Anchor */anchor){ - // summary: - // To be over written by tool! - // Add a anchorPositionCheck method to the tool - // and it will automatically overwrite this stub. - // Should return x and y coords. Success is both - // being greater than zero, fail is if one or both - // are less than zero. - return {x:1, y:1}; - }, - - setPoint: function(mx){ - // summary: - // Internal. Sets the Stencil's point - this.shape.applyTransform(mx); - }, - - connectMouse: function(){ - // summary: - // Internal. Connects anchor to manager.mouse - this._mouseHandle = this.mouse.register(this); - }, - - disconnectMouse: function(){ - // summary: - // Internal. Disconnects anchor to manager.mouse - this.mouse.unregister(this._mouseHandle); - }, - - reset: function(stencil){ - // summary: - // Called (usually) from a Stencil when that Stencil - // needed to make modifications to the position of the - // point. Basically used when teh anchor causes a - // less than zero condition. - }, - - destroy: function(){ - // summary: - // Destroys anchor. - dojo.disconnect(this._zCon); - this.disconnectMouse(); - this.shape.removeShape(); - } - } -); diff --git a/web-UI/dojox/drawing/manager/_registry.js b/web-UI/dojox/drawing/manager/_registry.js deleted file mode 100644 index bce0dbf4a..000000000 --- a/web-UI/dojox/drawing/manager/_registry.js +++ /dev/null @@ -1,31 +0,0 @@ -dojo.provide("dojox.drawing.manager._registry"); - -(function(){ - - var _registered = { - tool:{}, - stencil:{}, - drawing:{}, - plugin:{}, - button:{} - }; - - dojox.drawing.register = function(item, type){ - if(type=="drawing"){ - _registered.drawing[item.id] = item; - }else if(type=="tool"){ - _registered.tool[item.name] = item; - }else if(type=="stencil"){ - _registered.stencil[item.name] = item; - }else if(type=="plugin"){ - _registered.plugin[item.name] = item; - }else if(type=="button"){ - _registered.button[item.toolType] = item; - } - }; - - dojox.drawing.getRegistered = function(type, id){ - return id ? _registered[type][id] : _registered[type]; - } - -})(); \ No newline at end of file diff --git a/web-UI/dojox/drawing/plugins/tools/Pan.js b/web-UI/dojox/drawing/plugins/tools/Pan.js deleted file mode 100755 index 2ccd8e6a2..000000000 --- a/web-UI/dojox/drawing/plugins/tools/Pan.js +++ /dev/null @@ -1,242 +0,0 @@ -dojo.provide("dojox.drawing.plugins.tools.Pan"); -dojo.require("dojox.drawing.plugins._Plugin"); - -dojox.drawing.plugins.tools.Pan = dojox.drawing.util.oo.declare( - // summary: - // A plugin that allows for a scrolling canvas. An action - // tool is added to the toolbar that allows for panning. Holding - // the space bar is a shortcut to that action. The canvas will - // only pan and scroll if there are objects out of the viewable - // area. - // example: - // |
- // |
Line
- // |
Pan
- // |
- // - dojox.drawing.plugins._Plugin, - function(options){ - //this.domNode = options.node; - var _scrollTimeout; - this.toolbar = options.scope; - this.connect(this.toolbar, "onToolClick", this, function(){ - this.onSetPan(false) - }); - this.connect(this.keys, "onKeyUp", this, "onKeyUp"); - this.connect(this.keys, "onKeyDown", this, "onKeyDown"); - this.connect(this.keys, "onArrow", this, "onArrow"); - this.connect(this.anchors, "onAnchorUp", this, "checkBounds"); - this.connect(this.stencils, "register", this, "checkBounds"); - this.connect(this.canvas, "resize", this, "checkBounds"); - this.connect(this.canvas, "setZoom", this, "checkBounds"); - this.connect(this.canvas, "onScroll", this, function(){ - if(this._blockScroll){ - this._blockScroll = false; - return; - } - _scrollTimeout && clearTimeout(_scrollTimeout); - _scrollTimeout = setTimeout(dojo.hitch(this, "checkBounds"), 200); - }); - this._mouseHandle = this.mouse.register(this); - // This HAS to be called after setting initial objects or things get screwy. - //this.checkBounds(); - - },{ - selected:false, - keyScroll:false, - type:"dojox.drawing.plugins.tools.Pan", - - onPanUp: function(obj){ - if(obj.id == this.button.id){ - this.onSetPan(false); - } - }, - - onKeyUp: function(evt){ - switch(evt.keyCode){ - case 32: - this.onSetPan(false); - break; - case 39: case 37: case 38: case 40: - clearInterval(this._timer); - break; - } - }, - - onKeyDown: function(evt){ - if (evt.keyCode == 32) { - this.onSetPan(true); - } - }, - - interval: 20, - - onArrow: function(evt){ - if(this._timer) { clearInterval(this._timer); } - this._timer = setInterval(dojo.hitch(this,function(evt){ - this.canvas.domNode.parentNode.scrollLeft += evt.x*10; - this.canvas.domNode.parentNode.scrollTop += evt.y*10; - },evt), this.interval); - }, - - onSetPan: function(/*Boolean | Event*/ bool){ - if(bool === true || bool === false){ - this.selected = !bool; - } - console.log('ON SET PAN:', this.selected) - if(this.selected){ - this.selected = false; - this.button.deselect(); - }else{ - this.selected = true; - this.button.select(); - } - this.mouse.setEventMode(this.selected ? "pan" : ""); - }, - - onPanDrag: function(obj){ - var x = obj.x - obj.last.x; - var y = obj.y - obj.last.y; - this.canvas.domNode.parentNode.scrollTop -= obj.move.y; - this.canvas.domNode.parentNode.scrollLeft -= obj.move.x; - this.canvas.onScroll(); - }, - - onUp: function(obj){ - if (obj.withinCanvas) { - this.keyScroll = true; - } else { - this.keyScroll = false; - } - }, - - onStencilUp: function(obj){ - // this gets called even on click-off because of the - // issues with TextBlock deselection - this.checkBounds(); - }, - onStencilDrag: function(obj){ - // this gets called even on click-off because of the - // issues with TextBlock deselection - //this.checkBounds(); - }, - - checkBounds: function(){ - - //watch("CHECK BOUNDS DISABLED", true); return; - - - // summary: - // Scans all items on the canvas and checks if they are out of - // bounds. If so, a scroll bar (in Canvas) is shown. If the position - // is left or top, the canvas is scrolled all items are relocated - // the distance of the scroll. Ideally, it should look as if the - // items do not move. - - // logging stuff here so it can be turned on and off. This method is - // very high maintenance. - var log = function(){ - //console.log.apply(console, arguments); - } - var warn = function(){ - //console.warn.apply(console, arguments); - } - //console.clear(); - //console.time("check bounds"); - - // initialize a shot-tin of vars - var t=Infinity, r=-Infinity, b=-10000, l=10000, - sx=0, sy=0, dy=0, dx=0, - mx = this.stencils.group ? this.stencils.group.getTransform() : {dx:0, dy:0}, - sc = this.mouse.scrollOffset(), - // scY, scX: the scrollbar creates the need for extra dimension - scY = sc.left ? 10 : 0, - scX = sc.top ? 10 : 0, - // ch, cw: the current size of the canvas - ch = this.canvas.height, - cw = this.canvas.width, - z = this.canvas.zoom, - // pch, pcw: the normal size of the canvas (not scrolled) - // these could change if the container resizes. - pch = this.canvas.parentHeight, - pcw = this.canvas.parentWidth; - - - this.stencils.withSelected(function(m){ - var o = m.getBounds(); - warn("SEL BOUNDS:", o); - t = Math.min(o.y1 + mx.dy, t); - r = Math.max(o.x2 + mx.dx, r); - b = Math.max(o.y2 + mx.dy, b); - l = Math.min(o.x1 + mx.dx, l); - }); - - this.stencils.withUnselected(function(m){ - var o = m.getBounds(); - warn("UN BOUNDS:", o); - t = Math.min(o.y1, t); - r = Math.max(o.x2, r); - b = Math.max(o.y2, b); - l = Math.min(o.x1, l); - log("----------- B:", b, o.y2) - }); - - b *= z; - var xscroll = 0, yscroll = 0; - log("Bottom test", "b:", b, "z:", z, "ch:", ch, "pch:", pch, "top:", sc.top, "sy:", sy, "mx.dy:", mx.dy); - if(b > pch || sc.top ){ - log("*bottom scroll*"); - // item off bottom - ch = Math.max(b, pch + sc.top); - sy = sc.top; - xscroll += this.canvas.getScrollWidth(); - }else if(!sy && ch>pch){ - log("*bottom remove*"); - // item moved from bottom - ch = pch; - } - - r *= z; - if(r > pcw || sc.left){ - //log("*right scroll*"); - // item off right - cw = Math.max(r, pcw + sc.left); - sx = sc.left; - yscroll += this.canvas.getScrollWidth(); - }else if(!sx && cw>pcw){ - //log("*right remove*"); - // item moved from right - cw = pcw; - } - - // add extra space for scrollbars - // double it to give some breathing room - cw += xscroll*2; - ch += yscroll*2; - - this._blockScroll = true; - - // selected items are not transformed. The selection itself is - // and the items are on de-select - this.stencils.group && this.stencils.group.applyTransform({dx:dx, dy:dy}); - - // non-selected items are transformed - this.stencils.withUnselected(function(m){ - m.transformPoints({dx:dx, dy:dy}); - }); - - this.canvas.setDimensions(cw, ch, sx, sy); - - //console.timeEnd("check bounds"); - } - } -); - -dojox.drawing.plugins.tools.Pan.setup = { - name:"dojox.drawing.plugins.tools.Pan", - tooltip:"Pan Tool", - iconClass:"iconPan", - button:false -}; - -dojox.drawing.register(dojox.drawing.plugins.tools.Pan.setup, "plugin"); \ No newline at end of file diff --git a/web-UI/dojox/drawing/stencil/_Base.js b/web-UI/dojox/drawing/stencil/_Base.js deleted file mode 100755 index cfa100a69..000000000 --- a/web-UI/dojox/drawing/stencil/_Base.js +++ /dev/null @@ -1,1208 +0,0 @@ -dojo.provide("dojox.drawing.stencil._Base"); -dojo.require("dojo.fx.easing"); - -/*===== -StencilArgs = { -// container: [readonly] dojo.gfx.group -// The parent shape that contains all -// shapes used in a Stencil -container:null, -// -// anchorType: String -// Optionally blank or 'group'. 'group' tells -// an anchor point that it must constrain -// itself to other anchor points. -anchorType:"", -// -// isText: Boolean -// Whether this is a text object or not -// (either stencil.text or tools.TextBlock) -isText:false, -// -// shortType: String -// The type of stencil that corresponds with the types and -// constructors used in Drawing.registerTool -shortType:"", -// -// annotation: Boolean -// A Stencil used within a Stencil. An annotation -// is not selectable or clickable. A Label would -// be one example. -annotation:false, -// -// subShape: Boolean -// A Stencil used within a Stencil. A subShape -// is clickable. An arrow head would be an example. -subShape:false, -// -// style: Object -// An instance of the styles and defaults used within -// the Stencil. -style:null, -// -// util: Object -// Pointer to util.common -util:null, -// -// mouse: Object -// Pointer to the mouse instance -mouse:null, -// -// keys: Object -// Pointer to the keys class -keys:null, -// -// points: StencilPoints -// Points is an array of objects that make up the -// description of a Stencil. The points to a Rect -// that is 100x100 and at x:10 and y:10 would look like: -// [{x:10,y:10}, {x:110, y:10}, {x:110, y:110}, {x:10, y:110}] -// Points go clockwise from the top left. In the case of Paths, -// they would go in the order that the Stencil would be drawn. -// Always when the points Array is set, a data Object is created -// as well. So never set points directly, always use setPoints(). -// See: -// setPoints() -points:[], -// -// data: StencilData -// A data object typically (but not always) resembles the data -// that is used to create the dojox.gfx Shape. The same Rect -// example shown in points above would look like: -// {x:10, y:10, width:100, height:100} -// And an Ellipse with the same coordinates: -// {cx:55, cy:55, rx:50, ry:50} -// The only Stencil that does not support data (at this time) -// is the Path. While x1,x2,x3... culd be used in a data object -// it doesn't provide much benefit. -// Always when a data object is set, a set of points is created -// as well. So never set data directly, always use setData(). -// See: -// setData() -data:null, -// -// marginZero [readonly] Number -// How closely shape can get to y:0 or x:0. Less than zero has -// bugs in VML. This is set with defaults, and should be equal -// to half the size of an anchor point (5 px) -marginZero:0, -// -// created [readonly] Boolean -// Whether the Stencil has been rendered for the first time or -// not. -created: false, -// -// highlighted [readonly] Boolean -// Whether the Stencil is highlighted or not. -highlighted:false, -// -// selected [readonly] Boolean -// Whether the Stencil is selected or not. -selected:false, -// -// draws [readonly] Boolean -// Whether the Stencil can draw with a mouse drag or can just -// be created programmtically. If the Stencil comes from the -// stencil package, it should be draw:false. If it comes from -// the tools package it should be draw:true. -draws:false -} - -StencilPoint = { -// summary: -// One point Object in the points Array -// x: Number -// x position of point -// y: Number -// y position of point -} - -ToolsSetup = { -// summary: -// An object attached to a Tool's constructor -// used to inform the toolbar of its information -// and properties. -// description: -// This object is inserted into the *function* of -// a tool (not a stencil). Like: function.ToolsSetup -// It must be attached after constructr creation, so -// this object is found at the botton of the file. -// -// name:String -// Fully qualified name of constructor -// tooltip: Stirng -// Text to display on toolbar button hover -// iconClass: String -// CSS class with icon information to attach -// to toolbar button. -} -=====*/ - -dojox.drawing.stencil._Base = dojox.drawing.util.oo.declare( - // summary: - // The base class used for all Stencils. - // description: - // All stencils extend this base class. - // Most methods and events can be found here. - // - function(options){ - //console.log("______Base", this.type, options) - // clone style so changes are reflected in future shapes - dojo.mixin(this, options); - this.style = options.style || dojox.drawing.defaults.copy(); - if(options.stencil){ - this.stencil = options.stencil; - this.util = options.stencil.util; - this.mouse = options.stencil.mouse; - this.container = options.stencil.container; - this.style = options.stencil.style; - } - - // don't use the 'g' on these, it affects - // the global RegExp - var lineTypes = /Line|Vector|Axes|Arrow/; - var textTypes = /Text/; - - this.shortType = this.util.abbr(this.type); - this.isText = textTypes.test(this.type); - this.isLine = lineTypes.test(this.type); - - this.renderHit = this.style.renderHitLayer; - if(!this.renderHit && this.style.renderHitLines && this.isLine){ - this.renderHit = true; - } - if(!this.renderHit && this.style.useSelectedStyle){ - this.useSelectedStyle = true; - this.selCopy = dojo.clone(this.style.selected); - for(var nm in this.style.norm){ - if(this.style.selected[nm]===undefined){ - this.style.selected[nm] = this.style.norm[nm]; - } - } - this.textSelected = dojo.clone(this.style.text); - this.textSelected.color = this.style.selected.fill; - - } - - - this.angleSnap = this.style.angleSnap || 1; - - this.marginZero = options.marginZero || this.style.anchors.marginZero; - this.id = options.id || this.util.uid(this.type); - this._cons = []; - - if(!this.annotation && !this.subShape){ - this.util.attr(this.container, "id", this.id); - } - - this.connect(this, "onBeforeRender", "preventNegativePos"); - - this._offX = this.mouse.origin.x; - this._offY = this.mouse.origin.y; - - if(this.isText){ - this.align = options.align || this.align; - this.valign = options.valign || this.valign; - if(options.data && options.data.makeFit){ - var textObj = this.makeFit(options.data.text, options.data.width); - this.textSize = this.style.text.size = textObj.size; - this._lineHeight = textObj.box.h; - }else{ - this.textSize = parseInt(this.style.text.size, 10); - this._lineHeight = this.textSize * 1.4; - } - - - // TODO: thinner text selection - //this.style.hitSelected.width *= 0.5; - // - // ouch. how verbose. My mixin is weak.... - this.deleteEmptyCreate = options.deleteEmptyCreate!==undefined ? options.deleteEmptyCreate : this.style.text.deleteEmptyCreate; - this.deleteEmptyModify = options.deleteEmptyModify!==undefined ? options.deleteEmptyModify : this.style.text.deleteEmptyModify; - } - - //this.drawingType - - this.attr(options.data); - - // make truthy - // add to renders below - // this.baseRender && render() - //if(this.type == "dojox.drawing.tools.TextBlock"){ - if(this.noBaseRender){ - // TextBlock will handle rendering itself - return; - } - - //console.log("BASE OPTS:", options) - if(options.points){ - //console.log("__________Base.constr >>>> ", this.type, "points", options.points) - if(options.data && options.data.closePath===false){ - this.closePath = false; - } - this.setPoints(options.points); - this.connect(this, "render", this, "onRender", true); - this.baseRender && this.enabled && this.render(); - options.label && this.setLabel(options.label); - options.shadow && this.addShadow(options.shadow); - - }else if(options.data){ - //console.log("___________Base.constr", this.type, "options data", options.data) - options.data.width = options.data.width ? options.data.width : this.style.text.minWidth; - options.data.height = options.data.height ? options.data.height : this._lineHeight; - this.setData(options.data); - this.connect(this, "render", this, "onRender", true); - this.baseRender && this.enabled && this.render(options.data.text); - options.label && this.setLabel(options.label); - options.shadow && this.addShadow(options.shadow); - - }else if(this.draws){ - //console.log("_____________Base.constr", this.type, "draws") - this.points = []; - this.data = {}; - this.connectMouse(); - this._postRenderCon = dojo.connect(this, "render", this, "_onPostRender"); - } - if(this.showAngle){ - this.angleLabel = new dojox.drawing.annotations.Angle({stencil:this}); - } - - if(!this.enabled){ - this.disable(); - this.moveToBack(); - // some things render some don't... - this.render(options.data.text); - } - - if(this.shortType == "vector" && !options.data) { - options.data = { cosphi:0 }; - } - - }, - { - - // type: String - // The type of Stencil this is. Should be overridden - // by extending classes. - // FIXME: should this be declaredClass? - type:"dojox.drawing.stencil", - // - // minimumSize: Number - // The minimum size allowed for a render. If the size - // is less, the shape is destroyed. - minimumSize:10, - // - // enabled [readonly] Boolean - // Whether the Stencil is enabled or not. - enabled:true, - - - drawingType:"stencil", - - //points:[], - - setData: function(/*StencilData*/data){ - // summary: - // Setter for Stencil data; also converts - // data to points. See individual Stencils - // for specific data properties. - this.data = data; - this.points = this.dataToPoints(); - }, - - setPoints: function(/*StencilPoints*/points){ - // summary: - // Setter for Stencil points; also converts - // points to data. See individual Stencils - // for specific points properties. - this.points = points; - // Path doesn't do data - if(this.pointsToData){ - this.data = this.pointsToData(); - } - }, - - onDelete: function(/* Stencil */ stencil){ - // summary: - // Stub - fires before this is destroyed - console.info("onDelete", this.id); - }, - - onBeforeRender: function(/*Object*/ stencil){ - // summary: - // Stub - Fires before render occurs. - }, - - onModify: function(/*Object*/stencil){ - // summary: - // Stub - fires on change of any property, - // including style properties - - }, - - onChangeData: function(/*Object*/ stencil){ - // summary: - // Stub - fires on change of dimensional - // properties or a text change - }, - - onChangeText: function(value){ // value or 'this' ? - // summary: - // Stub - fires on change of text in a - // TextBlock tool only - }, - - onRender: function(/*Object*/ stencil){ - // summary: - // Stub - Fires on creation. - // Drawing connects to this (once!) to be - // notified of drag completion. But only if it - // was registered as a Tool. Creating Stencil in and of - // itself does not register it. - // - // This should fire - // at the *end* of creation (not during drag) - // - // FIXME: - // This should probably be onCreate. It should - // only fire once. But the mechanism for determining - // this is more complicated than it sounds. - // - //if(!this._postRenderCon){ - this._postRenderCon = dojo.connect(this, "render", this, "_onPostRender"); - //} - this.created = true; - this.disconnectMouse(); - - // for Silverlight - if(this.shape) { - this.shape.superClass = this; - }else{ - this.container.superClass = this; - } - this._setNodeAtts(this); - //console.warn("ONRENDER", this.id, this) - }, - - onChangeStyle: function(/*Object*/stencil){ - // summary: - // Fires when styles of shape has changed - // - this._isBeingModified = true; // need this to prevent onRender - if(!this.enabled){ - this.style.current = this.style.disabled; - this.style.currentText = this.style.textDisabled; - this.style.currentHit = this.style.hitNorm; - - }else{ - this.style.current = this.style.norm; - this.style.currentHit = this.style.hitNorm; - this.style.currentText = this.style.text; - } - - if(this.selected){ - if(this.useSelectedStyle){ - this.style.current = this.style.selected; - this.style.currentText = this.textSelected; - } - this.style.currentHit = this.style.hitSelected; - - }else if(this.highlighted){ - //this.style.current = this.style.highlighted; - this.style.currentHit = this.style.hitHighlighted; - //this.style.currentText = this.style.textHighlighted; - } - - // NOTE: Can't just change props like setStroke - // because Silverlight throws error - this.render(); - }, - - animate: function(options, create){ - console.warn("ANIMATE..........................") - var d = options.d || options.duration || 1000; - var ms = options.ms || 20; - var ease = options.ease || dojo.fx.easing.linear; - var steps = options.steps; - var ts = new Date().getTime(); - var w = 100; - var cnt = 0; - var isArray = true; - var sp, ep; - - if(dojo.isArray(options.start)){ - sp = options.start; - ep = options.end; - - }else if (dojo.isObject(options.start)){ - sp = options.start; - ep = options.end; - isArray = false; - }else{ - - console.warn("No data provided to animate") - } - - var v = setInterval(dojo.hitch(this, function(){ - var t = new Date().getTime() - ts; - var p = ease(1-t/d); - if(t > d || cnt++ > 100){ - clearInterval(v); - return; - } - - if(isArray){ - var pnts = []; - dojo.forEach(sp, function(pt, i){ - - var o = { - x: (ep[i].x-sp[i].x)*p + sp[i].x, - y: (ep[i].y-sp[i].y)*p + sp[i].y - }; - pnts.push(o); - }); - this.setPoints(pnts); - this.render(); - - }else{ - - var o = {}; - for(var nm in sp){ - o[nm] = (ep[nm] - sp[nm]) * p + sp[nm]; - } - - this.attr(o); - - } - //console.dir(pnts) - - - //this.attr("height", w); - ////console.log("W:", w) - //w += 5; - - }), ms); - }, - - attr: function(/*String | Object*/key, /* ? String | Number */value){ - // summary - // Changes properties in the normal-style. Also can be used to - // change most position and size props. - - // NOTE: JUST A SETTTER!! TODO! - - // WARNING: - // Not doing any Stencil-type checking here. Setting a height - // on a line or an angle on a rectangle will just not render. - - // FIXME - // 'width' attr is used for line width. How to change the width of a stencil? - var n = this.style.norm, - t = this.style.text, - ts = this.textSelected || {}, - o, - nm, - width, - styleWas = dojo.toJson(n), - textWas = dojo.toJson(t); - - var coords = { - x:true, - y:true, - r:true, - height:true, - width:true, - radius:true, - angle:true - }; - var propChange = false; - if(typeof(key)!="object"){ - o = {}; - o[key] = value; - }else{ - // prevent changing actual data - o = dojo.clone(key); - } - - if(o.width){ - // using width for size, - // borderWidth should be used - // for line thickness - width = o.width; - delete o.width; - } - - for(nm in o){ - if(nm in n){ n[nm] = o[nm]; } - if(nm in t){ t[nm] = o[nm]; } - if(nm in ts){ ts[nm] = o[nm]; } - - if(nm in coords){ - coords[nm] = o[nm]; - propChange = true; - if(nm == "radius" && o.angle===undefined){ - o.angle = coords.angle = this.getAngle(); - }else if(nm == "angle" && o.radius===undefined){ - o.radius = coords.radius = this.getRadius(); - } - - } - if(nm == "text"){ - this.setText(o.text); - } - if(nm == "label"){ - this.setLabel(o.label); - } - } - if(o.borderWidth!==undefined){ - n.width = o.borderWidth; - } - if(o.cosphi!=undefined) { - this.cosphi = o.cosphi; - this.style.zAxis = o.cosphi!=0 ? true : false; - } - if(this.useSelectedStyle){ - // using the orginal selected style copy as - // a reference map of what props to copy - for(nm in this.style.norm){ - if(this.selCopy[nm]===undefined){ - this.style.selected[nm] = this.style.norm[nm]; - } - } - this.textSelected.color = this.style.selected.color; - - } - - if(!this.created){ - return; - } - - // basic transform - if(o.x!==undefined || o.y!==undefined){ - var box = this.getBounds(true); - var mx = { dx:0, dy:0 }; - for(nm in o){ - if(nm=="x" || nm =="y" || nm =="r"){ - mx["d"+nm] = o[nm] - box[nm]; - } - } - this.transformPoints(mx); - } - - - var p = this.points; - if(o.angle!==undefined){ - this.dataToPoints({ - x:this.data.x1, - y:this.data.y1, - angle:o.angle, - radius:o.radius - }); - - } else if(width!==undefined){ - p[1].x = p[2].x = p[0].x + width; - this.pointsToData(p); - } - - if(o.height!==undefined && o.angle===undefined){ - console.log("Doing P2D-2"); - p[2].y = p[3].y = p[0].y + o.height; - this.pointsToData(p); - } - - if(o.r!==undefined){ - this.data.r = Math.max(0, o.r); - } - - //console.dir(this.data); - if(propChange || textWas!=dojo.toJson(t) || styleWas != dojo.toJson(n)){ - // to trigger the render - // other events will be called post render - this.onChangeStyle(this); - } - o.width = width; - }, - - exporter: function(){ - // summary: - // Exports Stencil data - // - var type = this.type.substring(this.type.lastIndexOf(".")+1).charAt(0).toLowerCase() - + this.type.substring(this.type.lastIndexOf(".")+2); - var o = dojo.clone(this.style.norm); - o.borderWidth = o.width; - delete o.width; - if(type=="path"){ - o.points = this.points; - }else{ - o = dojo.mixin(o, this.data); - } - o.type = type; - if(this.isText){ - o.text = this.getText(); - o = dojo.mixin(o, this.style.text); - delete o.minWidth; - delete o.deleteEmptyCreate; - delete o.deleteEmptyModify; - } - var lbl = this.getLabel(); - if(lbl){ - o.label = lbl; - } - return o; - }, - - - // TODO: - // Makes these all called by att() - // Should points and data be? - // - disable: function(){ - // summary: - // Disables Stencil so it is not selectable. - // Changes the color to the disabled style. - this.enabled = false; - this.renderHit = false; - this.onChangeStyle(this); - }, - - enable: function(){ - // summary: - // Enables Stencil so it is not selectable (if - // it was selectable to begin with). Changes the - // color to the current style. - this.enabled = true; - this.renderHit = true; - this.onChangeStyle(this); - }, - - select: function(){ - // summary: - // Called when the Stencil is selected. - // NOTE: Calling this will not select the Stencil - // calling this just sets the style to the 'selected' - // theme. 'manager.Stencil' should be used for selecting - // Stencils. - // - this.selected = true; - this.onChangeStyle(this); - }, - - deselect: function(/*Boolean*/useDelay){ - // summary: - // Called when the Stencil is deselected. - // NOTE: Calling this will not deselect the Stencil - // calling this just sets the style to the current - // theme. 'manager.Stencil' should be used for selecting - // and deselecting Stencils. - // - // arguments: - // useDelay: Boolean - // Adds slight delay before the style is set. - // - // should not have to render here because the deselection - // re-renders after the transform - // but... oh well. - if(useDelay){ - setTimeout(dojo.hitch(this, function(){ - this.selected = false; - this.onChangeStyle(this); - }),200); - }else{ - this.selected = false; - this.onChangeStyle(this); - } - }, - _toggleSelected: function(){ - if(!this.selected){ return; } - this.deselect(); - setTimeout(dojo.hitch(this, "select"), 0); - }, - - highlight: function(){ - // summary: - // Changes style to the highlight theme. - this.highlighted = true; - this.onChangeStyle(this); - }, - - unhighlight: function(){ - // summary: - // Changes style to the current theme. - this.highlighted = false; - this.onChangeStyle(this); - }, - - moveToFront: function(){ - // summary: - // Moves Stencil to the front of all other items - // on the canvas. - this.container && this.container.moveToFront(); - }, - - moveToBack: function(){ - // summary: - // Moves Stencil to the back of all other items - // on the canvas. - this.container && this.container.moveToBack(); - }, - - onTransformBegin: function(/* ? manager.Anchor */anchor){ - // summary: - // Fired at the start of a transform. This would be - // an anchor drag or a selection. - // - this._isBeingModified = true; - }, - - onTransformEnd: function(/* manager.Anchor */anchor){ - // summary: - // Called from anchor point up mouse up - this._isBeingModified = false; - this.onModify(this); - }, - - onTransform: function(/* ? manager.Anchor */anchor){ - // summary: - // Called from anchor point mouse drag - // also called from plugins.Pan.checkBounds - if(!this._isBeingModified){ - this.onTransformBegin(); - } - // this is not needed for anchor moves, but it - // is for stencil move: - this.setPoints(this.points); - this.render(); - }, - - transformPoints: function(mx){ - // summary: - // Moves object to a new X Y location - // mx is additive. So mx.dx=1 will move the stencil - // 1 pixel to the right from wherever it was. - // - // An attempt is made to prevent < 0 errors, but - // this won't work on all shapes (like Axes) - // - if(!mx.dx && !mx.dy){ - // no change - return; - } - var backup = dojo.clone(this.points), abort = false; - dojo.forEach(this.points, function(o){ - o.x += mx.dx; - o.y += mx.dy; - if(o.x 180, -90 -> 270 - angle<0 ? angle = 360 + angle : angle; - return angle; - }, - getRadius: function(){ - // summary: - // Gets radius (length) of Stencil - // NOTE: Only works for Lines, Arrows, Vectors and Axes - // (not for Ellipse) - // - var box = this.getBounds(true); - var line = {start:{x:box.x1, y:box.y1}, x:box.x2, y:box.y2}; - return this.util.length(line); - }, - getBounds: function(/* ? Boolean*/absolute){ - // summary: - // Returns the coordinates of the Stencil. This is often - // different than the data or the points. - // arguments: - // absolute: Boolean - // Keeps lines from flipping (see note). - // - // NOTE: Won't work for paths or annotations (labels, Axes, arrow tips) - // They should overwrite. - // NOTE: Primarily used for checking for if shape is off - // canvas. Therefore Lines could get flipped. Use absolute - // to prevent this. - // - var p = this.points, x1, y1, x2, y2; - if(p.length==2){ - if(absolute){ - x1 = p[0].x; - y1 = p[0].y; - x2 = p[1].x; - y2 = p[1].y - }else{ - x1 = p[0].x < p[1].x ? p[0].x : p[1].x; - y1 = p[0].y < p[1].y ? p[0].y : p[1].y; - x2 = p[0].x < p[1].x ? p[1].x : p[0].x; - y2 = p[0].y < p[1].y ? p[1].y : p[0].y; - } - return { - x1:x1, - y1:y1, - x2:x2, - y2:y2, - x:x1, - y:y1, - w:x2-x1, - h:y2-y1 - }; // Object - }else{ - return { - x1:p[0].x, - y1:p[0].y, - x2:p[2].x, - y2:p[2].y, - x:p[0].x, - y:p[0].y, - w:p[2].x - p[0].x, - h:p[2].y - p[0].y - }; // Object - } - }, - - - preventNegativePos: function(){ - // summary: - // Internal. Prevent item from being drawn/rendered less - // than zero on the X or Y. - // - // if being modified anchors will prevent less than zero. - if(this._isBeingModified){ return; } - // FIXME: why is this sometimes empty? - if(!this.points || !this.points.length){ return; } - - if(this.type=="dojox.drawing.tools.custom.Axes"){ - // this scenario moves all points if < 0 - var minY = this.marginZero, minX = this.marginZero; - dojo.forEach(this.points, function(p){ minY = Math.min(p.y, minY); }); - dojo.forEach(this.points, function(p){ minX = Math.min(p.x, minX); }); - - if(minY : this.editMode:", this.editMode) - this.onChangeData(this); - this._prevData = dojo.clone(this.data); - - }else if(!this._prevData && (!this.isText || this.getText())){ - //console.info("_Base no prevData.........................."); - this._prevData = dojo.clone(this.data); - - } - - }, - - _setNodeAtts: function(shape){ - // summary: - // Internal. Sets the rawNode attribute. (Or in Silverlight - // an "object attribute". "stencil" is - // used by the application to determine if - // something is selectable or not. This also - // sets the mouse custom events like: - // "onStencilUp". To disable the selectability, - // make the att "", which causes a standard - // mouse event. - var att = this.enabled && !this.annotation ? this.drawingType : ""; - this.util.attr(shape, "drawingType", att); - }, - - - destroy: function(){ - // summary: - // Destroys this Stencil - // Note: - // Can connect to this, but it's better to - // connect to onDelete - // - // prevent loops: - if(this.destroyed){ return; } - if(this.data || this.points && this.points.length){ - this.onDelete(this); - } - - this.disconnectMouse(); - this.disconnect(this._cons); - dojo.disconnect(this._postRenderCon); - this.remove(this.shape, this.hit); - this.destroyed = true; - }, - - remove: function(/*Shape...*/){ - // summary: - // Removes shape(s), typically before a re-render - // No args defaults to this.shape - // Pass in multiple args to remove multiple shapes - // - // FIXME: Use an Array of all shapes - // - var a = arguments; - if(!a.length){ - if(!this.shape){ return; } - a = [this.shape]; - } - for(var i=0;i1){ - // arguments are the connect params - this._cons.push(this.connect.apply(this, arguments)); - }else if(dojo.isArray(arguments[0][0])){ - // an array of arrays of params - dojo.forEach(arguments[0], function(ar){ - this._cons.push(this.connect.apply(this, ar)); - }, this); - }else{ - //one array of params - this._cons.push(this.connect.apply(this, arguments[0])); - } - - }, - - // TODO: connect to a Shape event from outside class - connect: function(o, e, s, m, /* Boolean*/once){ - // summary: - // Convenience method for quick connects - // See comments below for possiblities - // functions can be strings - // once: - // If true, the connection happens only - // once then disconnects. Five args are required - // for this functionality. - // - var c; - if(typeof(o)!="object"){ - if(s){ - // ** function object function ** - m = s; s = e; e=o; o = this; - }else{ - // ** function function ** - m = e; e = o; o = s = this; - } - }else if(!m){ - // ** object function function ** - m = s; s = this; - }else if (once){ - // ** object function object function Boolean ** - c = dojo.connect(o, e, function(evt){ - dojo.hitch(s, m)(evt); - dojo.disconnect(c); - }); - this._cons.push(c); - return c; - }else{ - // ** object function object function ** - } - c = dojo.connect(o, e, s, m); - this._cons.push(c); - return c; - }, - - disconnect: function(/*handle | Array*/handles){ - // summary: - // Removes connections based on passed - // handles arguments - if(!handles) { return } - if(!dojo.isArray(handles)){ handles=[handles]; } - dojo.forEach(handles, dojo.disconnect, dojo); - }, - - connectMouse: function(){ - // summary: - // Internal. Registers this Stencil to receive - // mouse events. - this._mouseHandle = this.mouse.register(this); - }, - disconnectMouse: function(){ - // summary: - // Internal. Unregisters this Stencil from receiving - // mouse events. - this.mouse.unregister(this._mouseHandle); - }, - - // Should be overwritten by sub class: - render: function(){ - // summary: - // This Stencil's render description. Often - // calls 'sub render' methods. - }, - //renderOutline: function(){}, - dataToPoints: function(/*Object*/data){ - // summary: - // Converts data to points. - }, - pointsToData: function(/*Array*/points){ - // summary: - // Converts points to data - }, - onDown: function(/*EventObject*/obj){ - // summary: - // Mouse event, fired on mousedown on canvas - // - // by default, object is ready to accept data - // turn this off for dragging or onRender will - // keep firing and register the shape - // NOTE: Not needed for all stencils. Axes needs it. - this._downOnCanvas = true; - dojo.disconnect(this._postRenderCon); - this._postRenderCon = null; - }, - onMove: function(/*EventObject*/obj){ - // summary: - // Mouse event, fired on mousemove while mouse - // is not down. - // NOTE: Not currently implemented - }, - onDrag: function(/*EventObject*/obj){ - // summary: - // Mouse event, fired on mousemove while mouse - // is down on canvas - }, - onUp: function(/*EventObject*/obj){ - // summary: - // Mouse event, fired on mouseup - } - } -); diff --git a/web-UI/dojox/drawing/tools/custom/Axes.js b/web-UI/dojox/drawing/tools/custom/Axes.js deleted file mode 100755 index 3739ab6d1..000000000 --- a/web-UI/dojox/drawing/tools/custom/Axes.js +++ /dev/null @@ -1,518 +0,0 @@ -dojo.provide("dojox.drawing.tools.custom.Axes"); -dojo.require("dojox.drawing.stencil.Path"); - - -dojox.drawing.tools.custom.Axes = dojox.drawing.util.oo.declare( - // summary: - // Draws a right-angle Axes (shaped like an L, not a +) - // description: - // This Stencil is created with a Path so that the L shape - // is one continuous piece. Arrow heads are placed at the end - // of each axis. The Axes can be rotated. There are custom - // label methods. - // - dojox.drawing.stencil.Path, - function(options){ - this.closePath = false; - - this.xArrow = new dojox.drawing.annotations.Arrow({stencil:this, idx1:0, idx2:1}); - this.yArrow = new dojox.drawing.annotations.Arrow({stencil:this, idx1:2, idx2:1}); - if(options.data) { this.style.zAxisEnabled = options.data.cosphi !=0 ? true : false; } - if(this.style.zAxisEnabled){ - this.cosphi = 1; - var ops = {}; - dojo.mixin(ops, dojo.mixin(options, { - container:this.container.createGroup(), - style: this.style, - showAngle: false, - label: null - })); - ops.style.zAxis = true; - this.zAxis = new dojox.drawing.tools.custom.Vector(ops); - //console.log("-----constructing axes: ",this.zAxis); - this.connectMult([ - [this, "onChangeStyle", this.zAxis, "onChangeStyle"], - [this, "select", this.zAxis, "select"], - [this, "deselect", this.zAxis, "deselect"], - [this, "onDelete", this.zAxis, "destroy"], - [this, "onDrag", this, "zSet"], - [this, "onTransform", this, "zSet"], - [this.zAxis, "onBeforeRender", this, "zSet"], - [this, "_onPostRender", this.zAxis, "render"] - ]); - - } - - if(this.points && this.points.length){ - this.setPoints = this._postSetPoints; - // need to call render again. It's already been called in the _Base - // constructor by the time we get to this constructor - this.render(); - // I don't know why Axes is different, but post-render calls won't - // happen with pre-data unless we call this here. It *should* happen - // on first render. - this.onRender(); - } - //console.warn("---info on zAxis: ", this.zAxis, ", and on this: ",this); - }, - { - draws:true, - type:"dojox.drawing.tools.custom.Axes", - minimumSize:30, - showAngle:true, - closePath:false, - baseRender:false, - cosphi:0, - zScale:.5, - - zPoints: function() { - var d = this.points[1]; - d.radius = this.getRadius(); - d.angle = this.style.zAngle; - - var pt = this.util.pointOnCircle(d.x, d.y, d.radius*this.zScale, d.angle); - var p = [ - {x:d.x, y:d.y}, - {x:pt.x, y:pt.y} - ]; - return p; - }, - - zSet: function() { - if (!this.zAxis || !this.zAxis.points[0]) { return; }; - var p = this.zPoints(); - - this.zAxis.setPoints(p); - this.zAxis.cosphi = 1; - }, - - createLabels: function(){ - // summary: - // Creates the label for each axis. - // - // NOTE: Not passing style into text because it's changing it - var props = {align:"middle", valign:"middle", util:this.util, annotation:true, container:this.container, mouse:this.mouse, stencil:this}; - this.labelX = new dojox.drawing.annotations.Label(dojo.mixin(props,{ - labelPosition:this.setLabelX - })); - this.labelY = new dojox.drawing.annotations.Label(dojo.mixin(props,{ - labelPosition:this.setLabelY - })); - if(this.style.zAxisEnabled){ - this.labelZ = new dojox.drawing.annotations.Label(dojo.mixin(props,{ - labelPosition:this.setLabelZ - })); - } - - }, - - setLabelX: function(){ - // summary: - // Custom placement for x-axis label - // - var ax = this.points[0]; - var c = this.points[1]; - - var dist = 40; - var offdist = 20; - var pt, px, py, pt2; - - pt = this.util.lineSub(c.x, c.y, ax.x, ax.y, dist); - px = pt.x + (pt.y -ax.y); - py = pt.y + (ax.x - pt.x); - pt2 = this.util.lineSub(pt.x, pt.y, px, py, (dist-offdist)); - - return { - x: pt2.x, - y: pt2.y, - width:20 - }; - }, - setLabelY: function(){ - // summary: - // Custom placement for y-axis label - // - var c = this.points[1]; - var ay = this.points[2]; - - var dist = 40; - var offdist = 20; - var pt, px, py, pt2; - pt = this.util.lineSub(c.x, c.y, ay.x, ay.y, dist); - px = pt.x + (ay.y - pt.y); - py = pt.y + (pt.x - ay.x); - pt2 = this.util.lineSub(pt.x, pt.y, px, py, (dist-offdist)); - return { - x: pt2.x, - y: pt2.y, - width:20 - }; - }, - setLabelZ: function(){ - // summary: - // Custom placement for z-axis label - // - var p = this.zPoints(); - - var dist = 40; - var offdist = 20; - var pt, px, py, pt2; - pt = this.util.lineSub(p[0].x, p[0].y, p[1].x, p[1].y, dist); - px = pt.x + (pt.y - p[1].y); - py = pt.y + (p[1].x - pt.x); - pt2 = this.util.lineSub(pt.x, pt.y, px, py, (dist-offdist)); - - return { - x:pt2.x, - y:pt2.y, - width:20 - } - }, - setLabel: function(/* ? String*/value){ - // summary: - // Set the text of the labels. The text would be - // broken up into the two labels. - // arguments: - // value: [optional] String - // If no argument is passed, defaults to two labels - // 'x' and 'y'. If an argument is passed, that - // text will be split on the word 'and' to determine - // the two labels. - // - if(this._labelsCreated){ return; } - !this.labelX && this.createLabels(); - var x = "x"; - var y = "y"; - var z = "z"; - if(value){ - // match first "and" or "&" and trim whitespace. - // Non-greedy matches are not supported in older - // browsers such as Netscape Navigator 4 or - // Microsoft Internet Explorer 5.0. - if(this.labelZ){ - var lbls = value.match(/(.*?)(and|&)(.*?)(and|&)(.*)/i); - if(lbls.length>4){ - x = lbls[1].replace(/^\s+/,"").replace(/\s+$/,""); - y = lbls[3].replace(/^\s+/,"").replace(/\s+$/,""); - z = lbls[5].replace(/^\s+/,"").replace(/\s+$/,""); - } - }else { - var lbls = value.match(/(.*?)(and|&)(.*)/i); - if(lbls.length>2){ - x = lbls[1].replace(/^\s+/,"").replace(/\s+$/,""); - y = lbls[3].replace(/^\s+/,"").replace(/\s+$/,""); - } - } - } - this.labelX.setLabel(x); - this.labelY.setLabel(y); - if(this.labelZ){ - this.labelZ.setLabel(z); - } - this._labelsCreated = true; - }, - getLabel: function(){ - // summary: - // Getter for the labels. returns an object. - // - if(!this.labelX){ return {}; } - return { - x:this.labelX._text, - y:this.labelY._text, - z:this.labelZ?this.labelZ._text:null - }; // Object - }, - - anchorPositionCheck: function(/*Number*/x, /*Number*/y, /*manager.Anchor*/anchor){ - // summary: - // Gets called from anchor to check if its current - // position is ok. If not, its x or y transform will - // be changed until this passes. - // - var pm = this.container.getParent().getTransform(); - var am = anchor.shape.getTransform(); - - // the xaxis point has changed and is not yet set as a point - // - but the center should be good (except for the transform). - // Now check the yaxis point. - - var p = this.points; - var o = {x:am.dx+anchor.org.x+pm.dx, y:am.dy+anchor.org.y+pm.dy}; - var c = {x:p[1].x+pm.dx, y:p[1].y+pm.dy}; - var ox = c.x - (c.y - o.y); - var oy = c.y - (o.x - c.x); - - return {x:ox, y:oy}; - - }, - - onTransformBegin: function(/*manager.Anchor*/anchor){ - // summary: - // Overwrites _Base.onTransformBegin - // - // called from anchor point up mouse down - this._isBeingModified = true; - }, - - onTransformEnd: function(/*manager.Anchor*/anchor){ - // summary: - // Overwrites _Base.onTransformEnd - // - // Gets called on anchor mouseup - // also gets called by checkBounds - we don't want that. - if(!anchor){ return; } - - // tell anchor to go to prev point if wrong - // called from anchor point up mouse up - - this._isBeingModified = false; - //this.deselect(); - this._toggleSelected(); - console.log("before:", Math.ceil(this.points[1].x), " x ", Math.ceil(this.points[1].y)) - - var o = this.points[0]; - var c = this.points[1]; - var pt = this.util.constrainAngle({start:{x:c.x, y:c.y}, x:o.x, y:o.y}, 0, 89); - - if(pt.x==o.x && pt.y == o.y){ - // we're within the constraint, so now we snap - var obj = {start:{x:c.x,y:c.y},x:o.x, y:o.y}; - pt = this.util.snapAngle(obj, this.angleSnap/180); - - obj.x = pt.x; - obj.y = pt.y; - var ox = obj.start.x - (obj.start.y - obj.y); - var oy = obj.start.y - (obj.x - obj.start.x); - - if(ox<0 || oy<0){ - console.warn("AXES ERROR LESS THAN ZERO - ABORT"); - return; - } - this.points = [{x:obj.x, y:obj.y}, {x:obj.start.x, y:obj.start.y, noAnchor:true}]; - this.points.push({x:ox, y:oy, noAnchor:true}); - this.setPoints(this.points); - - //this.select(); - this.onModify(this); - return; - } - - // we're outside of the constraint. Set to the low or high. - this.points[0].x = pt.x - this.points[0].y = pt.y; - o = this.points[0]; - - var ox = c.x - (c.y - o.y); - var oy = c.y - (o.x - c.x); - - this.points[2] = {x:ox, y:oy, noAnchor:true}; - this.setPoints(this.points); - - // reset handles render - //anchor.reset(this); - - this.labelX.setLabel(); - this.labelY.setLabel(); - if(this.labelZ){ - this.labelZ.setLabel(); - } - - //this.select(); - this.onModify(this); - - }, - - getBounds: function(/*Boolean*/absolute){ - // summary: - // Custom getBounds overwrites _Base.getBounds - // - var px = this.points[0], - pc = this.points[1], - py = this.points[2]; - - if(absolute){ - return { - x:pc.x, - y:pc.y, - x1:pc.x, - y1:pc.y, - x2:px.x, - y2:px.y, - x3:py.x, - y3:py.y - }; - } - - var x1 = py.x, - y1 = py.y < px.y ? py.y : px.y, - x2 = px.x, - y2 = pc.y; - - return { - x1:x1, - y1:y1, - x2:x2, - y2:y2, - x:x1, - y:y1, - w:x2-x1, - h:y2-y1 - }; - }, - - _postSetPoints: function(/*Array*/pts){ - // summary: - // Because Axes only has one anchor, - // we substitute a special setPoints method - // - //console.log("---points: ",pts); - this.points[0] = pts[0]; - if(this.pointsToData){ - this.data = this.pointsToData(); - } - }, - - onTransform: function(/*Number*/anchor){ - // summary: - // Overwrites _Base.onTransform - // - // the xaxis point has changed - the center will not. - // need to find the yaxis point. - var o = this.points[0]; - var c = this.points[1]; - var ox = c.x - (c.y - o.y); - var oy = c.y - (o.x - c.x); - - // 'noAnchor' on a point indicates an anchor should - // not be rendered. This is the Y point being set. - this.points[2] = {x:ox, y:oy, noAnchor:true}; - this.setPoints(this.points); - if(!this._isBeingModified){ - this.onTransformBegin(); - } - this.render(); - }, - - pointsToData: function(){ - //summary: - // Converts points to data. - var p = this.points; - return { - x1:p[1].x, - y1:p[1].y, - x2:p[0].x, - y2:p[0].y, - x3:p[2].x, - y3:p[2].y - }; - }, - - dataToPoints: function(/* ? Object*/o){ - //summary: - // Converts data to points. - o = o || this.data; - if(o.radius || o.angle){ - // instead of using x1,x2,y1,y1, - // it's been set as x,y,angle,radius - - var pt = this.util.pointOnCircle(o.x,o.y,o.radius,o.angle); - var ox = o.x - (o.y - pt.y); - var oy = o.y - (pt.x - o.x); - - this.data = o = { - x2:o.x, - y2:o.y, - x1:pt.x, - y1:pt.y, - x3:ox, - y3:oy - } - - } - this.points = [ - {x:o.x1, y:o.y1}, - {x:o.x2, y:o.y2, noAnchor:true}, - {x:o.x3, y:o.y3, noAnchor:true} - ]; - return this.points; - }, - - onDrag: function(/*EventObject*/obj){ - // summary: See stencil._Base.onDrag - // - var pt = this.util.constrainAngle(obj, 0, 89); - obj.x = pt.x; - obj.y = pt.y; - var ox = obj.start.x - (obj.start.y - obj.y); - var oy = obj.start.y - (obj.x - obj.start.x); - - if(ox<0 || oy<0){ - return; - } - this.points = [{x:obj.x, y:obj.y}, {x:obj.start.x, y:obj.start.y, noAnchor:true}]; - - this.points.push({x:ox, y:oy, noAnchor:true}); - this.render(); - }, - - onUp: function(/*EventObject*/obj){ - // summary: See stencil._Base.onUp - // - if(!this._downOnCanvas) { return; } - this._downOnCanvas = false; - var p = this.points; - if(!p.length){ - s = obj.start; - this.points = [ - {x:s.x+100, y:s.y+100}, - {x:s.x, y:s.y+100, noAnchor:true}, - {x:s.x, y:s.y, noAnchor:true} - ]; - this.pointsToData(); - this.render(); - var p = this.points; - } - - var len = this.util.distance(p[1].x ,p[1].y ,p[0].x ,p[0].y ); - if(!p || !p.length){ - return; - }else if(len < this.minimumSize){ - this.remove(this.shape, this.hit); - this.xArrow.remove(this.xArrow.shape, this.xArrow.hit); - this.yArrow.remove(this.yArrow.shape, this.yArrow.hit); - if(this.zArrow){ - this.zArrow.remove(this.zArrow.shape, this.zArrow.hit); - } - return; - } - - var o = p[0]; - var c = p[1]; - obj = {start:{x:c.x,y:c.y},x:o.x,y:o.y}; - var pt = this.util.snapAngle(obj, this.angleSnap/180); - obj.x = pt.x; - obj.y = pt.y; - var ox = obj.start.x - (obj.start.y - obj.y); - var oy = obj.start.y - (obj.x - obj.start.x); - - if(ox<0 || oy<0){ - return; - } - this.points = [{x:obj.x, y:obj.y}, {x:obj.start.x, y:obj.start.y, noAnchor:true}]; - - this.points.push({x:ox, y:oy, noAnchor:true}); - - this.onRender(this); - this.setPoints = this._postSetPoints; - } - } -); - -dojox.drawing.tools.custom.Axes.setup = { - // summary: See stencil._Base ToolsSetup - // - name:"dojox.drawing.tools.custom.Axes", - tooltip:"Axes Tool", - iconClass:"iconAxes" -}; -dojox.drawing.register(dojox.drawing.tools.custom.Axes.setup, "tool"); \ No newline at end of file diff --git a/web-UI/dojox/drawing/tools/custom/Vector.js b/web-UI/dojox/drawing/tools/custom/Vector.js deleted file mode 100755 index 9f80960a9..000000000 --- a/web-UI/dojox/drawing/tools/custom/Vector.js +++ /dev/null @@ -1,347 +0,0 @@ -dojo.provide("dojox.drawing.tools.custom.Vector"); -dojo.require("dojox.drawing.tools.Arrow"); -dojo.require("dojox.drawing.util.positioning"); - -dojox.drawing.tools.custom.Vector = dojox.drawing.util.oo.declare( - // summary: - // Creates a Vector Stencil. - // description: - // Generally the same as an arrow, except that the arrow - // head is only at the end. There is additionaly functionality - // to allow for a 'zero vector' - one with no length. - // - // TODO: Zero Vectors are less than the minimumSize. But if - // you get the radius, it will report a length. - // - dojox.drawing.tools.Arrow, - function(options){ - this.minimumSize = this.style.arrows.length; - if(this.style.zAxis || options.data.cosphi!=0) - { - this.cosphi = options.data.cosphi; - this.style.zAxis = "true"; - } - this.addShadow({size:3, mult:2}); - }, - { - draws:true, - type:"dojox.drawing.tools.custom.Vector", - minimumSize:30, - showAngle:true, - cosphi:0, - - labelPosition: function(){ - // summary: - // The custom position used for the label - // - var d = this.data; - var pt = dojox.drawing.util.positioning.label({x:d.x1,y:d.y1},{x:d.x2,y:d.y2}); - return { - x:pt.x, - y:pt.y - } - }, - - changeAxis: function(cosphi){ - cosphi = cosphi!=undefined?cosphi:this.style.zAxis? 0 : 1; - if (cosphi == 0){ - this.style.zAxis = false; - this.cosphi = 0; - } else { - this.style.zAxis = true; - var p = this.points; - var pt = this.zPoints(); - this.setPoints([ - {x:p[0].x, y:p[0].y}, - {x:pt.x, y:pt.y} - ]); - } - this.render(); - }, - - _createZeroVector: function(shp, d, sty){ - // summary: - // Special creation function for the zero-vector shape - // - var s = shp=="hit" ? this.minimumSize : this.minimumSize/6; - var f = shp=="hit" ? sty.fill : null; - d = { - cx:this.data.x1, - cy:this.data.y1, - rx:s, - ry:s - }; - - this.remove(this[shp]); - this[shp] = this.container.createEllipse(d) - .setStroke(sty) - .setFill(f); - this.util.attr(this[shp], "drawingType", "stencil"); - }, - - _create: function(/*String*/shp, /*StencilData*/d, /*Object*/sty){ - // summary: - // Creates a dojox.gfx.shape based on passed arguments. - // Can be called many times by implementation to create - // multiple shapes in one stencil. - // - this.remove(this[shp]); - this[shp] = this.container.createLine(d) - .setStroke(sty); - this._setNodeAtts(this[shp]); - }, - - onDrag: function(/*EventObject*/obj){ - // summary: See stencil._Base.onDrag - // - if(this.created){ return; } - - var x1 = obj.start.x, - y1 = obj.start.y, - x2 = obj.x, - y2 = obj.y; - - if(this.keys.shift && !this.style.zAxis){ - var pt = this.util.snapAngle(obj, 45/180); - x2 = pt.x; - y2 = pt.y; - } - - if(this.keys.alt){ - // FIXME: - // should double the length of the line - // FIXME: - // if alt dragging past ZERO it seems to work - // but select/deselect shows bugs - var dx = x2>x1 ? ((x2-x1)/2) : ((x1-x2)/-2); - var dy = y2>y1 ? ((y2-y1)/2) : ((y1-y2)/-2); - x1 -= dx; - x2 -= dx; - y1 -= dy; - y2 -= dy; - } - - if(this.style.zAxis) { - var pts = this.zPoints(obj); - x2 = pts.x; - y2 = pts.y; - } - - this.setPoints([ - {x:x1, y:y1}, - {x:x2, y:y2} - ]); - this.render(); - }, - - onTransform: function(/* ? manager.Anchor */anchor){ - // summary: - // Called from anchor point mouse drag - // also called from plugins.Pan.checkBounds - if(!this._isBeingModified){ - this.onTransformBegin(); - } - // this is not needed for anchor moves, but it - // is for stencil move: - - this.setPoints(this.points); - if(this.style.zAxis) { - var angle = this.getAngle(); - this.cosphi = angle>135 && angle<315 ? 1 : -1; - } - this.render(); - }, - - anchorConstrain: function(obj){ - if(!this.style.zAxis) { return; } - var radians = this.style.zAngle*Math.PI/180; - Math.min(Math.abs(obj.y),Math.abs(obj.org.y)); - //Constrain to angle - var dx = obj.x>-obj.y? obj.x : -obj.y/Math.tan(radians); - var dy = obj.x<-obj.y? obj.y : -Math.tan(radians)*obj.x; - //Constrain to canvas - if(dy 135 && angle < 315) { - //Out angle - angle = this.style.zAngle; - this.cosphi = 1; - } else { - //In Angle - angle = this.util.oppAngle(this.style.zAngle); - this.cosphi = -1; - } - - return this.util.pointOnCircle(obj.start.x, obj.start.y, radius, angle); - }, - - render: function(){ - // summary: - // Renders the 'hit' object (the shape used for an expanded - // hit area and for highlighting) and the'shape' (the actual - // display object). Additionally checks if Vector should be - // drawn as an arrow or a circle (zero-length) - // - this.onBeforeRender(this); - if(this.getRadius() >= this.minimumSize){ - this._create("hit", this.data, this.style.currentHit); - this._create("shape", this.data, this.style.current); - - }else{ - this.cosphi = 0; - this._createZeroVector("hit", this.data, this.style.currentHit); - this._createZeroVector("shape", this.data, this.style.current); - } - }, - onUp: function(/*EventObject*/obj){ - // summary: See stencil._Base.onUp - // - if(this.created || !this._downOnCanvas){ return; } - this._downOnCanvas = false; - //Default vector for single click - if(!this.shape){ - s = obj.start; - obj.y = obj.start.y + 100; - obj.x = obj.start.x - this.setPoints([ - {x:s.x, y:s.y}, - {x:s.x, y:s.y+100} - ]); - this.render(); - } - - // if too small, need to reset - // This sets the zero length vector to zero within the minimum size - - if(this.getRadius() - // - // - constructor: function(props, node){ - //console.warn("GFX Toolbar:", props, node) - this.util = dojox.drawing.util.common; - - // no mixin. painful. - if(props.drawing){ - // programmatic - this.toolDrawing = props.drawing; - this.drawing = this.toolDrawing; - this.width = this.toolDrawing.width; - this.height = this.toolDrawing.height; - this.strSelected = props.selected; - this.strTools = props.tools; - this.strPlugs = props.plugs; - this._mixprops(["padding", "margin", "size", "radius"], props); - this.addBack() - }else{ - // markup - var box = dojo.marginBox(node); - this.width = box.w; - this.height = box.h; - this.strSelected = dojo.attr(node, "selected"); - this.strTools = dojo.attr(node, "tools"); - this.strPlugs = dojo.attr(node, "plugs"); - this._mixprops(["padding", "margin", "size", "radius"], node); - this.toolDrawing = new dojox.drawing.Drawing({mode:"ui"}, node); - } - - this.horizontal = this.width > this.height; - - if(this.toolDrawing.ready){ - this.makeButtons(); - if(!this.strSelected && this.drawing.defaults.clickMode) { this.drawing.mouse.setCursor('default'); }; - }else{ - var c = dojo.connect(this.toolDrawing, "onSurfaceReady", this, function(){ - //console.log("TB built") - dojo.disconnect(c); - this.drawing = dojox.drawing.getRegistered("drawing", dojo.attr(node, "drawingId")); // - this.makeButtons(); - if(!this.strSelected && this.drawing.defaults.clickMode) { - var c = dojo.connect(this.drawing, "onSurfaceReady", this, function(){ - dojo.disconnect(c); - this.drawing.mouse.setCursor('default'); - }); - } - }); - } - - }, - - // padding:Number - // The amount of spce between the top and left of the toolbar and the buttons. - padding:10, - // margin: Number - // The space between each button. - margin:5, - // size: Number - // The width and height of the button - size:30, - // radius: Number - // The size of the button's rounded corner - radius:3, - // - // toolPlugGap: number - // The distnce between the tool buttons and plug buttons - toolPlugGap:20, - - // strSlelected | selected: String - // The button that should be selected at startup. - strSelected:"", - // strTools | tools: String - // A comma delineated list of the Stencil-tools to include in the Toolbar. - // If "all" is used, all registered tools are included. - strTools:"", - // strPlugs | plugs: String - // A comma delineated list of the plugins to include in the Toolbar. - // If "all" is used, all registered plugins are included. - strPlugs:"", - - makeButtons: function(){ - // summary: - // Internal. create buttons. - this.buttons = []; - this.plugins = []; - - var x = this.padding, y = this.padding, w = this.size, h = this.size, r = this.radius, g = this.margin, - sym = dojox.drawing.library.icons, - s = {place:"BR", size:2, mult:4}; - - if(this.strTools){ - var toolAr = []; - var tools = dojox.drawing.getRegistered("tool"); - var toolMap = {}; - for(var nm in tools){ - var tool = this.util.abbr(nm); - toolMap[tool] = tools[nm]; - if (this.strTools=="all"){ - toolAr.push(tool); - var details = dojox.drawing.getRegistered("tool",nm); - if (details.secondary){ - toolAr.push(details.secondary.name); - } - } - } - if(this.strTools!="all"){ - var toolTmp = this.strTools.split(","); - dojo.forEach(toolTmp, function(tool){ - tool = dojo.trim(tool); - toolAr.push(tool); - var details = dojox.drawing.getRegistered("tool",toolMap[tool].name); - if(details.secondary) { - toolAr.push(details.secondary.name); - } - }, this); - //dojo.map(toolAr, function(t){ return dojo.trim(t); }); - } - - dojo.forEach(toolAr, function(t){ - t = dojo.trim(t); - var secondary = false; - if(t.indexOf("Secondary")>-1){ - var prim = t.substring(0,t.indexOf("Secondary")); - var sec = dojox.drawing.getRegistered("tool",toolMap[prim].name).secondary; - var label = sec.label; - this[t] = sec.funct; - //console.warn("This.drawing.stencils: ",this.drawing); - if(sec.setup) { dojo.hitch(this, sec.setup)() }; - var btn = this.toolDrawing.addUI("button", {data:{x:x, y:y, width:w, height:h/2, r:r}, toolType:t, secondary:true, text:label, shadow:s, scope:this, callback:this[t]}); - if(sec.post) { dojo.hitch(this, sec.post, btn)() }; - secondary = true; - } else { - var btn = this.toolDrawing.addUI("button", {data:{x:x, y:y, width:w, height:h, r:r}, toolType:t, icon:sym[t], shadow:s, scope:this, callback:"onToolClick"}); - } - dojox.drawing.register(btn, "button"); - this.buttons.push(btn); - if(this.strSelected==t){ - btn.select(); - this.selected = btn; - this.drawing.setTool(btn.toolType); - } - if(this.horizontal){ - var space = secondary ? h/2 + g : h + g; - y += space; - }else{ - var space = secondary ? h/2 + g : h + g; - y += space; - } - }, this); - } - - if(this.horizontal){ - y += this.toolPlugGap; - }else{ - y += this.toolPlugGap; - } - - if(this.strPlugs){ - var plugAr = []; - var plugs = dojox.drawing.getRegistered("plugin"); - var plugMap = {}; - for(var nm in plugs){ - var abbr = this.util.abbr(nm); - plugMap[abbr] = plugs[nm]; - if (this.strPlugs=="all") { plugAr.push(abbr); } - } - if(this.strPlugs!="all"){ - plugAr = this.strPlugs.split(","); - dojo.map(plugAr, function(p){ return dojo.trim(p); }); - } - - dojo.forEach(plugAr, function(p){ - var t = dojo.trim(p); - //console.log(" plugin:", p); - if (plugMap[p].button != false) { - var btn = this.toolDrawing.addUI("button", {data:{x:x, y:y, width:w, height:h, r:r}, toolType:t, icon:sym[t], shadow:s, scope:this, callback:"onPlugClick"}); - dojox.drawing.register(btn, "button"); - this.plugins.push(btn); - - if(this.horizontal){ - y += h + g; - }else{ - y += h + g; - } - } - - var addPlug = {} - plugMap[p].button == false ? addPlug = {name:this.drawing.stencilTypeMap[p]} : addPlug = {name:this.drawing.stencilTypeMap[p], options:{button:btn}}; - this.drawing.addPlugin(addPlug); - }, this); - } - - dojo.connect(this.drawing, "onRenderStencil", this, "onRenderStencil"); - }, - - onRenderStencil: function(/* Object */stencil){ - // summary: - // Stencil render event. - if(this.drawing.defaults.clickMode){ - this.drawing.mouse.setCursor("default"); - this.selected && this.selected.deselect(); - this.selected = null; - } - - }, - - addTool: function(){ - // TODO: add button here - }, - - addPlugin: function(){ - // TODO: add button here - }, - - addBack: function(){ - // summary: - // Internal. Adds the back, behind the toolbar. - this.toolDrawing.addUI("rect", {data:{x:0, y:0, width:this.width, height:this.size + (this.padding*2), fill:"#ffffff", borderWidth:0}}); - }, - - onToolClick: function(/*Object*/button){ - // summary: - // Tool click event. May be connected to. - // - if(this.drawing.defaults.clickMode) { this.drawing.mouse.setCursor("crosshair"); } - dojo.forEach(this.buttons, function(b){ - if(b.id==button.id){ - b.select(); - this.selected = b; - this.drawing.setTool(button.toolType) - }else{ - if(!b.secondary) { b.deselect(); } - } - },this) - }, - - onPlugClick: function(/*Object*/button){ - // summary: - // Plugin click event. May be connected to. - }, - - _mixprops: function(/*Array*/props, /*Object | Node*/objNode){ - // summary: - // Internally used for mixing in props from an object or - // from a dom node. - dojo.forEach(props, function(p){ - this[p] = objNode.tagName - ? dojo.attr(objNode, p)===null ? this[p] : dojo.attr(objNode, p) - : objNode[p]===undefined ? this[p] : objNode[p]; - }, this); - } - -}); \ No newline at end of file diff --git a/web-UI/dojox/drawing/util/common.js b/web-UI/dojox/drawing/util/common.js deleted file mode 100755 index 1aa644809..000000000 --- a/web-UI/dojox/drawing/util/common.js +++ /dev/null @@ -1,288 +0,0 @@ -dojo.provide("dojox.drawing.util.common"); -dojo.require("dojox.math.round"); - -(function(){ - - var uidMap = {}; - var start = 0; - dojox.drawing.util.common = { - // summary: - // A collection of common methods used for DojoX Drawing. - // This singleton is accessible in most Drawing classes - // as this.util - // - // NOTE: - // A lot of functions use a EventObject - // as an argument. An attempt was made to accept - // either that object or a list of numbers. That wasn't - // finished (it didn't work well in all cases) but is - // likely to happen in the future. - // In cases where you are not sending a Mouse object, - // form your argument like so: - // var obj = { - // start:{ - // x:Number, // start x - // y:Number // start y - // }, - // x: Number, // end x - // y:Number // end y - // } - // - // - radToDeg: function(/*Numer*/n) { - // summary: - // Convert the passed number to degrees. - return (n*180)/Math.PI; // Number - }, - - degToRad: function(/*Numer*/n) { - // summary: - // Convert the passed number to radians. - return (n*Math.PI)/180; // Number - }, - - angle: function(/*EventObject*/obj, /* ? Float */snap){ - // summary: - // Return angle based on mouse object - // arguments: - // obj: EventObject - // Manager.Mouse event. - // snap: Float - // Returns nearest angle within snap limits - // - //obj = this.argsToObj.apply(this, arguments); - if(snap){ - snap = snap/180; - var radians = this.radians(obj), - seg = Math.PI * snap, - rnd = dojox.math.round(radians/seg), - new_radian = rnd*seg; - return dojox.math.round(this.radToDeg(new_radian)); // Whole Number - - }else{ - return this.radToDeg(this.radians(obj)); // Float - } - }, - - oppAngle: function(/*Angle*/ang){ - (ang+=180) > 360 ? ang = ang - 360 : ang; - return ang; - }, - - radians: function(/*EventObject*/o){ - // summary: - // Return the radians derived from the coordinates - // in the Mouse object. - // - //var o = this.argsToObj.apply(this, arguments); - return Math.atan2(o.start.y-o.y,o.x-o.start.x); - }, - - length: function(/*EventObject*/o){ - // summary: - // Return the length derived from the coordinates - // in the Mouse object. - // - return Math.sqrt(Math.pow(o.start.x-o.x, 2)+Math.pow(o.start.y-o.y, 2)); - }, - - lineSub: function(/*Number*/x1, /*Number*/y1, /*Number*/x2, /*Number*/y2, /*Number*/amt){ - // summary: - // Subtract an amount from a line - // description: - // x1,y1,x2,y2 represents the Line. 'amt' represnets the amount - // to subtract from it. - // - var len = this.distance(this.argsToObj.apply(this, arguments)); - len = len < amt ? amt : len; - var pc = (len-amt)/len; - var x = x1 - (x1-x2) * pc; - var y = y1 - (y1-y2) * pc; - return {x:x, y:y}; // Object - }, - - argsToObj: function(){ - // summary: - // Attempts to determine in a Mouse Object - // was passed or indiviual numbers. Returns - // an object. - // - var a = arguments; - if(a.length < 4){ return a[0]; } - return { - start:{ - x:a[0], - y:a[1] - }, - x:a[2], - y:a[3]//, - //snap:a[4] - }; // Object - }, - - distance: function(/*EventObject or x1,y1,x2,y2*/){ - // summary: - // Return the length derived from the coordinates - // in the Mouse object. Different from util.length - // in that this always returns an absolute value. - // - var o = this.argsToObj.apply(this, arguments); - return Math.abs(Math.sqrt(Math.pow(o.start.x-o.x, 2)+Math.pow(o.start.y-o.y, 2))); // Number - }, - - slope:function(/*Object*/p1, /*Object*/p2){ - // summary: - // Given two poits of a line, returns the slope. - if(!(p1.x-p2.x)){ return 0; } - return ((p1.y-p2.y)/(p1.x-p2.x)); // Number - }, - - pointOnCircle: function(/*Number*/cx, /*Number*/cy, /*Number*/radius, /*Number*/angle){ - // summary: - // A *very* helpful method. If you know the center - // (or starting) point, length and angle, find the - // x,y point at the end of that line. - // - var radians = angle * Math.PI / 180.0; - var x = radius * Math.cos(radians); - var y = radius * Math.sin(radians); - return { - x:cx+x, - y:cy-y - }; // Object - }, - - constrainAngle: function(/*EventObject*/obj, /*Number*/min, /*Number*/max){ - // summary: - // Ensures the angle in the Mouse Object is within the - // min and max limits. If not one of those limits is used. - // Returns an x,y point for the angle used. - // - var angle = this.angle(obj); - if(angle >= min && angle <= max){ - return obj; // Object - } - var radius = this.length(obj); - var new_angle = angle > max ? max : min - angle < 100 ? min : max; - return this.pointOnCircle(obj.start.x,obj.start.y,radius, new_angle); // Object - }, - - snapAngle: function(/*EventObject*/obj, /*Float*/ca){ - // summary: - // Snaps a line to the nearest angle - // obj: Mouse object (see dojox.drawing.Mouse) - // ca: Fractional amount to snap to - // A decimal number fraction of a half circle - // .5 would snap to 90 degrees - // .25 would snap to 45 degrees - // .125 would snap to 22.5 degrees, etc. - // - var radians = this.radians(obj), - radius = this.length(obj), - seg = Math.PI * ca, - rnd = Math.round(radians/seg), - new_radian = rnd*seg, - new_angle = this.radToDeg(new_radian), - pt = this.pointOnCircle(obj.start.x,obj.start.y,radius,new_angle); - return pt; // Object - }, - - // helpers - idSetStart: function(num){ - start=num; - }, - - uid: function(/* ? String */str){ - // summary: - // Creates a unique ID. - // arguments: - // str: String - // If provided, kept in a map, incremented - // and used in the id. Otherwise 'shape' is used. - // - str = str || "shape"; - uidMap[str] = uidMap[str]===undefined ? start : uidMap[str] + 1; - return str + uidMap[str]; // String - }, - groups: {}, - groupId: function(name, id){ - if(groups.name){ - - } else { - - } - }, - - abbr: function(type){ - // summary: - // Converts a namespace (typically a tool or a stencil) into - // an abbreviation - return type.substring(type.lastIndexOf(".")+1).charAt(0).toLowerCase() - + type.substring(type.lastIndexOf(".")+2); - }, - mixin: function(o1, o2){ - // TODO: make faster - //return dojo.mixin(dojo.clone(o1), dojo.clone(o2)); - }, - - objects:{}, //private? - register: function(/*Object*/obj){ - // summary: - // Since util is the only Singleton in Drawing (besides - // keys) it is used to help connect the Drawing object - // the Toolbar. Since multiple drawings can be on one - // page, this function serves a little more use than - // on first apearance. - this.objects[obj.id] = obj; - }, - byId: function(/*String*/id){ - // summary: - // Get an object that was registered with util.register - // - return this.objects[id]; - }, - attr: function(/* Object */ elem, /* property */ prop, /* ? value */ value, squelchErrors){ - // summary: - // Helper function to attach attributes to SVG and VML raw nodes. - // - - if(!elem) { return false; } - try{ - - // util is a crappy check, but we need to tell the diff - // between a Drawing shape and a GFX shape - if(elem.shape && elem.util){ - elem = elem.shape; - } - - if(!value && prop=="id" && elem.target){ - - var n = elem.target; - while(!dojo.attr(n, "id")){ - n = n.parentNode; - } - return dojo.attr(n, "id"); - } - - if(elem.rawNode || elem.target){ - var args = Array.prototype.slice.call(arguments); - args[0] = elem.rawNode || elem.target; - return dojo.attr.apply(dojo, args); - } - return dojo.attr(elem, "id"); - - - - }catch(e){ - if(!squelchErrors){ - // For debugging only. These errors actually cause errors in IE's console - //console.error("BAD ATTR: prop:", prop, "el:", elem) - //console.error(e) - //console.trace(); - } - return false; - } - } - }; - -})(); \ No newline at end of file