diff options
| author | Tristan Zur <tzur@web.web.ccwn.org> | 2014-03-27 22:27:47 +0100 |
|---|---|---|
| committer | Tristan Zur <tzur@web.web.ccwn.org> | 2014-03-27 22:27:47 +0100 |
| commit | b62676ca5d3d6f6ba3f019ea3f99722e165a98d8 (patch) | |
| tree | 86722cb80f07d4569f90088eeaea2fc2f6e2ef94 /js/dojo-1.6/dojox/drawing/plugins/tools | |
Diffstat (limited to 'js/dojo-1.6/dojox/drawing/plugins/tools')
| -rw-r--r-- | js/dojo-1.6/dojox/drawing/plugins/tools/Iconize.js | 111 | ||||
| -rw-r--r-- | js/dojo-1.6/dojox/drawing/plugins/tools/Iconize.xd.js | 116 | ||||
| -rw-r--r-- | js/dojo-1.6/dojox/drawing/plugins/tools/Pan.js | 253 | ||||
| -rw-r--r-- | js/dojo-1.6/dojox/drawing/plugins/tools/Pan.xd.js | 258 | ||||
| -rw-r--r-- | js/dojo-1.6/dojox/drawing/plugins/tools/Zoom.js | 136 | ||||
| -rw-r--r-- | js/dojo-1.6/dojox/drawing/plugins/tools/Zoom.xd.js | 141 |
6 files changed, 1015 insertions, 0 deletions
diff --git a/js/dojo-1.6/dojox/drawing/plugins/tools/Iconize.js b/js/dojo-1.6/dojox/drawing/plugins/tools/Iconize.js new file mode 100644 index 0000000..d4f12dd --- /dev/null +++ b/js/dojo-1.6/dojox/drawing/plugins/tools/Iconize.js @@ -0,0 +1,111 @@ +/*
+ Copyright (c) 2004-2011, The Dojo Foundation All Rights Reserved.
+ Available via Academic Free License >= 2.1 OR the modified BSD license.
+ see: http://dojotoolkit.org/license for details
+*/
+
+
+if(!dojo._hasResource["dojox.drawing.plugins.tools.Iconize"]){ //_hasResource checks added by build. Do not use _hasResource directly in your code.
+dojo._hasResource["dojox.drawing.plugins.tools.Iconize"] = true;
+dojo.provide("dojox.drawing.plugins.tools.Iconize");
+dojo.require("dojox.drawing.plugins._Plugin");
+
+dojox.drawing.plugins.tools.Iconize = dojox.drawing.util.oo.declare(
+ // summary:
+ // Somewhat of internal use...
+ // Outputs a path to be used as an icon. Will end up being a
+ // sub-icon under Export options
+
+ dojox.drawing.plugins._Plugin,
+ function(options){
+
+ },
+ {
+ onClick: function(){
+ var item;
+ for(var nm in this.stencils.stencils){
+ console.log(" stanceil item:", this.stencils.stencils[nm].id, this.stencils.stencils[nm])
+ if(this.stencils.stencils[nm].shortType=="path"){
+ item = this.stencils.stencils[nm];
+ break;
+ }
+ }
+ if(item){
+ console.log("click Iconize plugin", item.points);
+ this.makeIcon(item.points);
+ }
+ },
+ makeIcon: function(/*Array*/p){
+ var rnd = function(n){
+ return Number(n.toFixed(1));
+ }
+
+ var x = 10000;
+ var y = 10000;
+ p.forEach(function(pt){
+ if(pt.x!==undefined && !isNaN(pt.x)){
+ x = Math.min(x, pt.x);
+ y = Math.min(y, pt.y);
+ }
+ });
+
+ var xmax = 0;
+ var ymax = 0;
+ p.forEach(function(pt){
+ if(pt.x!==undefined && !isNaN(pt.x)){
+ pt.x = rnd(pt.x - x);
+ //console.log("Y:", pt.y, y, pt.y - y)
+ pt.y = rnd(pt.y - y);
+ xmax = Math.max(xmax, pt.x);
+ ymax = Math.max(ymax, pt.y);
+ }
+ });
+
+ console.log("xmax:", xmax, "ymax:", ymax)
+
+ var s = 60
+ var m = 20
+
+ p.forEach(function(pt){
+ pt.x = rnd(pt.x / xmax) * s + m;
+ pt.y = rnd(pt.y / ymax) * s + m;
+ });
+
+ var txt = "[\n";
+ dojo.forEach(p, function(pt, i){
+ txt += "{\t"
+ if(pt.t){
+ txt += "t:'"+pt.t+"'"
+ }
+ if(pt.x!==undefined && !isNaN(pt.x)){
+ if(pt.t){
+ txt += ", ";
+ }
+ txt += "x:"+pt.x+",\t\ty:"+pt.y;
+ }
+ txt += "\t}";
+ if(i!=p.length-1){
+ txt += ","
+ }
+ txt += "\n"
+ });
+ txt+="]"
+
+ console.log(txt)
+ var n = dojo.byId("data");
+ if(n){
+ n.value = txt;
+ }
+ }
+ }
+);
+
+dojox.drawing.plugins.tools.Iconize.setup = {
+ name:"dojox.drawing.plugins.tools.Iconize",
+ tooltip:"Iconize Tool",
+ iconClass:"iconPan"
+};
+
+dojox.drawing.register(dojox.drawing.plugins.tools.Iconize.setup, "plugin");
+
+}
diff --git a/js/dojo-1.6/dojox/drawing/plugins/tools/Iconize.xd.js b/js/dojo-1.6/dojox/drawing/plugins/tools/Iconize.xd.js new file mode 100644 index 0000000..2826c9a --- /dev/null +++ b/js/dojo-1.6/dojox/drawing/plugins/tools/Iconize.xd.js @@ -0,0 +1,116 @@ +/*
+ Copyright (c) 2004-2011, The Dojo Foundation All Rights Reserved.
+ Available via Academic Free License >= 2.1 OR the modified BSD license.
+ see: http://dojotoolkit.org/license for details
+*/
+
+
+dojo._xdResourceLoaded(function(dojo, dijit, dojox){
+return {depends: [["provide", "dojox.drawing.plugins.tools.Iconize"],
+["require", "dojox.drawing.plugins._Plugin"]],
+defineResource: function(dojo, dijit, dojox){if(!dojo._hasResource["dojox.drawing.plugins.tools.Iconize"]){ //_hasResource checks added by build. Do not use _hasResource directly in your code.
+dojo._hasResource["dojox.drawing.plugins.tools.Iconize"] = true;
+dojo.provide("dojox.drawing.plugins.tools.Iconize");
+dojo.require("dojox.drawing.plugins._Plugin");
+
+dojox.drawing.plugins.tools.Iconize = dojox.drawing.util.oo.declare(
+ // summary:
+ // Somewhat of internal use...
+ // Outputs a path to be used as an icon. Will end up being a
+ // sub-icon under Export options
+
+ dojox.drawing.plugins._Plugin,
+ function(options){
+
+ },
+ {
+ onClick: function(){
+ var item;
+ for(var nm in this.stencils.stencils){
+ console.log(" stanceil item:", this.stencils.stencils[nm].id, this.stencils.stencils[nm])
+ if(this.stencils.stencils[nm].shortType=="path"){
+ item = this.stencils.stencils[nm];
+ break;
+ }
+ }
+ if(item){
+ console.log("click Iconize plugin", item.points);
+ this.makeIcon(item.points);
+ }
+ },
+ makeIcon: function(/*Array*/p){
+ var rnd = function(n){
+ return Number(n.toFixed(1));
+ }
+
+ var x = 10000;
+ var y = 10000;
+ p.forEach(function(pt){
+ if(pt.x!==undefined && !isNaN(pt.x)){
+ x = Math.min(x, pt.x);
+ y = Math.min(y, pt.y);
+ }
+ });
+
+ var xmax = 0;
+ var ymax = 0;
+ p.forEach(function(pt){
+ if(pt.x!==undefined && !isNaN(pt.x)){
+ pt.x = rnd(pt.x - x);
+ //console.log("Y:", pt.y, y, pt.y - y)
+ pt.y = rnd(pt.y - y);
+ xmax = Math.max(xmax, pt.x);
+ ymax = Math.max(ymax, pt.y);
+ }
+ });
+
+ console.log("xmax:", xmax, "ymax:", ymax)
+
+ var s = 60
+ var m = 20
+
+ p.forEach(function(pt){
+ pt.x = rnd(pt.x / xmax) * s + m;
+ pt.y = rnd(pt.y / ymax) * s + m;
+ });
+
+ var txt = "[\n";
+ dojo.forEach(p, function(pt, i){
+ txt += "{\t"
+ if(pt.t){
+ txt += "t:'"+pt.t+"'"
+ }
+ if(pt.x!==undefined && !isNaN(pt.x)){
+ if(pt.t){
+ txt += ", ";
+ }
+ txt += "x:"+pt.x+",\t\ty:"+pt.y;
+ }
+ txt += "\t}";
+ if(i!=p.length-1){
+ txt += ","
+ }
+ txt += "\n"
+ });
+ txt+="]"
+
+ console.log(txt)
+ var n = dojo.byId("data");
+ if(n){
+ n.value = txt;
+ }
+ }
+ }
+);
+
+dojox.drawing.plugins.tools.Iconize.setup = {
+ name:"dojox.drawing.plugins.tools.Iconize",
+ tooltip:"Iconize Tool",
+ iconClass:"iconPan"
+};
+
+dojox.drawing.register(dojox.drawing.plugins.tools.Iconize.setup, "plugin");
+
+}
+
+}};});
diff --git a/js/dojo-1.6/dojox/drawing/plugins/tools/Pan.js b/js/dojo-1.6/dojox/drawing/plugins/tools/Pan.js new file mode 100644 index 0000000..78a0b26 --- /dev/null +++ b/js/dojo-1.6/dojox/drawing/plugins/tools/Pan.js @@ -0,0 +1,253 @@ +/*
+ Copyright (c) 2004-2011, The Dojo Foundation All Rights Reserved.
+ Available via Academic Free License >= 2.1 OR the modified BSD license.
+ see: http://dojotoolkit.org/license for details
+*/
+
+
+if(!dojo._hasResource["dojox.drawing.plugins.tools.Pan"]){ //_hasResource checks added by build. Do not use _hasResource directly in your code.
+dojo._hasResource["dojox.drawing.plugins.tools.Pan"] = true;
+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:
+ // | <div dojoType="dojox.drawing.Toolbar" drawingId="drawingNode" class="drawingToolbar vertical">
+ // | <div tool="dojox.drawing.tools.Line" selected="true">Line</div>
+ // | <div plugin="dojox.drawing.plugins.tools.Pan" options="{}">Pan</div>
+ // | </div>
+ //
+ 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");
+
+}
diff --git a/js/dojo-1.6/dojox/drawing/plugins/tools/Pan.xd.js b/js/dojo-1.6/dojox/drawing/plugins/tools/Pan.xd.js new file mode 100644 index 0000000..d3c2c20 --- /dev/null +++ b/js/dojo-1.6/dojox/drawing/plugins/tools/Pan.xd.js @@ -0,0 +1,258 @@ +/*
+ Copyright (c) 2004-2011, The Dojo Foundation All Rights Reserved.
+ Available via Academic Free License >= 2.1 OR the modified BSD license.
+ see: http://dojotoolkit.org/license for details
+*/
+
+
+dojo._xdResourceLoaded(function(dojo, dijit, dojox){
+return {depends: [["provide", "dojox.drawing.plugins.tools.Pan"],
+["require", "dojox.drawing.plugins._Plugin"]],
+defineResource: function(dojo, dijit, dojox){if(!dojo._hasResource["dojox.drawing.plugins.tools.Pan"]){ //_hasResource checks added by build. Do not use _hasResource directly in your code.
+dojo._hasResource["dojox.drawing.plugins.tools.Pan"] = true;
+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:
+ // | <div dojoType="dojox.drawing.Toolbar" drawingId="drawingNode" class="drawingToolbar vertical">
+ // | <div tool="dojox.drawing.tools.Line" selected="true">Line</div>
+ // | <div plugin="dojox.drawing.plugins.tools.Pan" options="{}">Pan</div>
+ // | </div>
+ //
+ 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");
+
+}
+
+}};});
diff --git a/js/dojo-1.6/dojox/drawing/plugins/tools/Zoom.js b/js/dojo-1.6/dojox/drawing/plugins/tools/Zoom.js new file mode 100644 index 0000000..1410599 --- /dev/null +++ b/js/dojo-1.6/dojox/drawing/plugins/tools/Zoom.js @@ -0,0 +1,136 @@ +/*
+ Copyright (c) 2004-2011, The Dojo Foundation All Rights Reserved.
+ Available via Academic Free License >= 2.1 OR the modified BSD license.
+ see: http://dojotoolkit.org/license for details
+*/
+
+
+if(!dojo._hasResource["dojox.drawing.plugins.tools.Zoom"]){ //_hasResource checks added by build. Do not use _hasResource directly in your code.
+dojo._hasResource["dojox.drawing.plugins.tools.Zoom"] = true;
+dojo.provide("dojox.drawing.plugins.tools.Zoom");
+dojo.require("dojox.drawing.plugins._Plugin");
+
+(function(){
+ //
+ // zoomInc: Float
+ // The amount of zoom that will occur upon each click.
+ var zoomInc = Math.pow(2.0,0.25),
+ //
+ // maxZoom: Number
+ // The maximum the canvas can be zoomed in. 10 = 1000%
+ maxZoom = 10,
+ //
+ // minZoom: Float
+ // The most the canvas can be zoomed out. .1 = 10%
+ minZoom = 0.1,
+ //
+ // zoomFactor: [readonly] Float
+ // The current zoom amount
+ zoomFactor = 1,
+
+ dt = dojox.drawing.plugins.tools;
+
+ dt.ZoomIn = dojox.drawing.util.oo.declare(
+ // summary:
+ // A plugin that allows for zooming the canvas in and out. An
+ // action-tool is added to the toolbar with plus, minus and 100%
+ // buttons.
+ //
+ function(options){
+ // mix in private vars
+
+ },
+ {}
+ );
+
+
+ dt.ZoomIn = dojox.drawing.util.oo.declare(
+ // summary:
+ dojox.drawing.plugins._Plugin,
+ function(options){
+
+ },
+ {
+ type:"dojox.drawing.plugins.tools.ZoomIn",
+ onZoomIn: function(){
+ // summary:
+ // Handles zoom in.
+ //
+ zoomFactor *= zoomInc;
+ zoomFactor = Math.min(zoomFactor, maxZoom);
+ this.canvas.setZoom(zoomFactor);
+ this.mouse.setZoom(zoomFactor);
+ },
+ onClick: function(){
+ this.onZoomIn();
+ }
+ }
+ );
+
+ dt.Zoom100 = dojox.drawing.util.oo.declare(
+ // summary:
+ dojox.drawing.plugins._Plugin,
+ function(options){
+
+ },
+ {
+ type:"dojox.drawing.plugins.tools.Zoom100",
+ onZoom100: function(){
+ // summary:
+ // Zooms to 100%
+ //
+ zoomFactor = 1;
+ this.canvas.setZoom(zoomFactor);
+ this.mouse.setZoom(zoomFactor);
+ },
+ onClick: function(){
+ this.onZoom100();
+ }
+ }
+ );
+
+ dt.ZoomOut = dojox.drawing.util.oo.declare(
+ // summary:
+ dojox.drawing.plugins._Plugin,
+ function(options){
+
+ },
+ {
+ type:"dojox.drawing.plugins.tools.ZoomOut",
+ onZoomOut: function(){
+ // summary:
+ // Handles zoom out.
+ //
+ zoomFactor /= zoomInc;
+ zoomFactor = Math.max(zoomFactor, minZoom);
+ this.canvas.setZoom(zoomFactor);
+ this.mouse.setZoom(zoomFactor);
+ },
+ onClick: function(){
+ this.onZoomOut();
+ }
+ }
+ );
+
+
+ dt.ZoomIn.setup = {
+ name:"dojox.drawing.plugins.tools.ZoomIn",
+ tooltip:"Zoom In"
+ };
+ dojox.drawing.register(dt.ZoomIn.setup, "plugin");
+
+ dt.Zoom100.setup = {
+ name:"dojox.drawing.plugins.tools.Zoom100",
+ tooltip:"Zoom to 100%"
+ };
+ dojox.drawing.register(dt.Zoom100.setup, "plugin");
+
+ dt.ZoomOut.setup = {
+ name:"dojox.drawing.plugins.tools.ZoomOut",
+ tooltip:"Zoom In"
+ };
+ dojox.drawing.register(dt.ZoomOut.setup, "plugin");
+
+})();
+
+}
diff --git a/js/dojo-1.6/dojox/drawing/plugins/tools/Zoom.xd.js b/js/dojo-1.6/dojox/drawing/plugins/tools/Zoom.xd.js new file mode 100644 index 0000000..e58c6ae --- /dev/null +++ b/js/dojo-1.6/dojox/drawing/plugins/tools/Zoom.xd.js @@ -0,0 +1,141 @@ +/*
+ Copyright (c) 2004-2011, The Dojo Foundation All Rights Reserved.
+ Available via Academic Free License >= 2.1 OR the modified BSD license.
+ see: http://dojotoolkit.org/license for details
+*/
+
+
+dojo._xdResourceLoaded(function(dojo, dijit, dojox){
+return {depends: [["provide", "dojox.drawing.plugins.tools.Zoom"],
+["require", "dojox.drawing.plugins._Plugin"]],
+defineResource: function(dojo, dijit, dojox){if(!dojo._hasResource["dojox.drawing.plugins.tools.Zoom"]){ //_hasResource checks added by build. Do not use _hasResource directly in your code.
+dojo._hasResource["dojox.drawing.plugins.tools.Zoom"] = true;
+dojo.provide("dojox.drawing.plugins.tools.Zoom");
+dojo.require("dojox.drawing.plugins._Plugin");
+
+(function(){
+ //
+ // zoomInc: Float
+ // The amount of zoom that will occur upon each click.
+ var zoomInc = Math.pow(2.0,0.25),
+ //
+ // maxZoom: Number
+ // The maximum the canvas can be zoomed in. 10 = 1000%
+ maxZoom = 10,
+ //
+ // minZoom: Float
+ // The most the canvas can be zoomed out. .1 = 10%
+ minZoom = 0.1,
+ //
+ // zoomFactor: [readonly] Float
+ // The current zoom amount
+ zoomFactor = 1,
+
+ dt = dojox.drawing.plugins.tools;
+
+ dt.ZoomIn = dojox.drawing.util.oo.declare(
+ // summary:
+ // A plugin that allows for zooming the canvas in and out. An
+ // action-tool is added to the toolbar with plus, minus and 100%
+ // buttons.
+ //
+ function(options){
+ // mix in private vars
+
+ },
+ {}
+ );
+
+
+ dt.ZoomIn = dojox.drawing.util.oo.declare(
+ // summary:
+ dojox.drawing.plugins._Plugin,
+ function(options){
+
+ },
+ {
+ type:"dojox.drawing.plugins.tools.ZoomIn",
+ onZoomIn: function(){
+ // summary:
+ // Handles zoom in.
+ //
+ zoomFactor *= zoomInc;
+ zoomFactor = Math.min(zoomFactor, maxZoom);
+ this.canvas.setZoom(zoomFactor);
+ this.mouse.setZoom(zoomFactor);
+ },
+ onClick: function(){
+ this.onZoomIn();
+ }
+ }
+ );
+
+ dt.Zoom100 = dojox.drawing.util.oo.declare(
+ // summary:
+ dojox.drawing.plugins._Plugin,
+ function(options){
+
+ },
+ {
+ type:"dojox.drawing.plugins.tools.Zoom100",
+ onZoom100: function(){
+ // summary:
+ // Zooms to 100%
+ //
+ zoomFactor = 1;
+ this.canvas.setZoom(zoomFactor);
+ this.mouse.setZoom(zoomFactor);
+ },
+ onClick: function(){
+ this.onZoom100();
+ }
+ }
+ );
+
+ dt.ZoomOut = dojox.drawing.util.oo.declare(
+ // summary:
+ dojox.drawing.plugins._Plugin,
+ function(options){
+
+ },
+ {
+ type:"dojox.drawing.plugins.tools.ZoomOut",
+ onZoomOut: function(){
+ // summary:
+ // Handles zoom out.
+ //
+ zoomFactor /= zoomInc;
+ zoomFactor = Math.max(zoomFactor, minZoom);
+ this.canvas.setZoom(zoomFactor);
+ this.mouse.setZoom(zoomFactor);
+ },
+ onClick: function(){
+ this.onZoomOut();
+ }
+ }
+ );
+
+
+ dt.ZoomIn.setup = {
+ name:"dojox.drawing.plugins.tools.ZoomIn",
+ tooltip:"Zoom In"
+ };
+ dojox.drawing.register(dt.ZoomIn.setup, "plugin");
+
+ dt.Zoom100.setup = {
+ name:"dojox.drawing.plugins.tools.Zoom100",
+ tooltip:"Zoom to 100%"
+ };
+ dojox.drawing.register(dt.Zoom100.setup, "plugin");
+
+ dt.ZoomOut.setup = {
+ name:"dojox.drawing.plugins.tools.ZoomOut",
+ tooltip:"Zoom In"
+ };
+ dojox.drawing.register(dt.ZoomOut.setup, "plugin");
+
+})();
+
+}
+
+}};});
|
