C_CanvasLink.js 3.8 KB

123456
  1. // Licensed Materials - Property of IBM
  2. // IBM Cognos Products: cchl
  3. // (C) Copyright IBM Corp. 2003, 2016.
  4. // US Government Users Restricted Rights - Use, duplication or disclosure restricted by GSA ADP Schedule Contract with IBM Corp.
  5. function C_CanvasLink(_c1V1, _cDK1, _cKN1, _c1H1, _cAW){this._cSK1=_cDK1;this._c1O1=_cKN1;this._cPK1=document.createElement('canvas');this._cPK1.height=_cDK1;this._cPK1.width=_cKN1;this._cPK1.id=_c1V1;this._cSB1=8;if(_c1H1){this._cPK1.setAttribute('onmousedown', _c1H1);}if(_cAW){this._cPK1.setAttribute('onMouseOver', _cAW);}};C_CanvasLink._c1R=1;C_CanvasLink._cW2=2;C_CanvasLink._cB2=3;C_CanvasLink._cB8=4;C_CanvasLink.prototype.F_AddLink=function(_cM61, _cNA1, _cXF, _cJM, _cTK1, _cN61, _c2O1){if(_cTK1){this._cUK1(_cM61, _cNA1,(_cN61||6), true, _cXF, _cJM);}else{var _cZQ1=this._cSB1;if(_cXF==C_CanvasLink._cB2){var _c0R1=[];_c0R1.push(new C_Position(_cM61[0].left, _cM61[0].top-_cZQ1/2));_c0R1.push(new C_Position(_cZQ1, _cZQ1));this._cVK1(_c0R1, _cNA1);}if(!_cN61){_cN61=_cNA1?3:1;}this._cUK1(_cM61, _cNA1, _cN61, true, _cXF, _cJM);var _c1R1=_cM61.length-1;if(_cJM==C_CanvasLink._cB2){var _c0R1=[];_c0R1.push(new C_Position(_cM61[_c1R1].left-_cZQ1, _cM61[_c1R1].top-_cZQ1/2));_c0R1.push(new C_Position(_cZQ1, _cZQ1));this._cVK1(_c0R1, _cNA1);}else if(_cJM==C_CanvasLink._cW2){var _c3O1=[];_c3O1.push(new C_Position(_cM61[_c1R1].left-_cZQ1, _cM61[_c1R1].top));_c3O1.push(new C_Position(_cM61[_c1R1].left-_cZQ1, _cM61[_c1R1].top-_cZQ1/2));_c3O1.push(new C_Position(_cM61[_c1R1].left, _cM61[_c1R1].top));_c3O1.push(new C_Position(_cM61[_c1R1].left-_cZQ1, _cM61[_c1R1].top+_cZQ1/2));_c3O1.push(new C_Position(_cM61[_c1R1].left-_cZQ1, _cM61[_c1R1].top));this._c2H1(_c3O1, _cNA1);}else if(_cJM==C_CanvasLink._cB8){var _c3O1=[];var _cK11=_cZQ1*2;_c3O1.push(new C_Position(0, 0-_cK11/2));_c3O1.push(new C_Position(_cZQ1, 0));_c3O1.push(new C_Position(0, _cK11/2));_c3O1.push(new C_Position(0, 0-_cK11/2));var _cTB1=new C_Position(_cM61[_c1R1].left, _cM61[_c1R1].top);this._c2H1(_c3O1, _cNA1, _cTB1, _c2O1);}}};C_CanvasLink.prototype._cUK1=function(_cM61,_cNA1,_cN61,_cWK1,_cXF,_cJM){var _cO61=this._cPK1.getContext('2d');var _c2R1=_cO61.strokeStyle;_cO61.strokeStyle=(_cNA1?"highlight":"black");_cO61.beginPath();var _c3R1=_cM61[0].left+',' + _cM61[0].top;_cO61.moveTo(_cM61[0].left, _cM61[0].top);for(var i=1; i<_cM61.length; i++){_cO61.lineTo(_cM61[i].left, _cM61[i].top);_c3R1=_c3R1+':' + _cM61[i].left + ',' + _cM61[i].top;}_cO61.lineWidth=_cN61;if(_cWK1){_cO61.stroke();}_cO61.strokeStyle=_c2R1;};C_CanvasLink.prototype._c2H1=function(_cFT1,_cNA1,_cGR,_c2O1){var _cO61=this._cPK1.getContext('2d');if(_c2O1||_cGR){_cO61.save();if(_cGR){_cO61.translate(_cGR.left, _cGR.top);}if(_c2O1){_cO61.rotate((360-_c2O1)*Math.PI/180);} }var _c2R1=_cO61.fillStyle;_cO61.fillStyle=(_cNA1?"highlight":"black");_cO61.beginPath();_cO61.moveTo(_cFT1[0].left, _cFT1[0].top);for(var i=1; i<_cFT1.length; i++){_cO61.lineTo(_cFT1[i].left, _cFT1[i].top);}_cO61.fill();_cO61.fillStyle=_c2R1;if(_c2O1||_cGR){_cO61.restore();}};C_CanvasLink.prototype._cVK1=function(_cM61,_cNA1){var _cO61=this._cPK1.getContext('2d');var _c2R1=_cO61.fillStyle;_cO61.fillStyle=(_cNA1?"highlight":"black");_cO61.fillRect(_cM61[0].left, _cM61[0].top, _cM61[1].left, _cM61[1].top);_cO61.fillStyle=_c2R1;};C_CanvasLink.prototype.F_Attach=function(_cXK1){return _cXK1.appendChild(this._cPK1);};C_CanvasLink.prototype.F_IsOnLine=function(_cLV1,_cKV1){_cLV1=Math.round(_cLV1);_cKV1=Math.round(_cKV1);var _cO61=this._cPK1.getContext('2d');var delta=10;for(var x=_cLV1-delta; x<=_cLV1+delta; x++){for(var y=_cKV1-delta; y<=_cKV1+delta; y++){if(_cO61.isPointInPath(x, y)){return true;}}}return false;};C_CanvasLink.prototype.F_Clear=function(){var _cO61=this._cPK1.getContext('2d');_cO61.clearRect(0, 0, this._c1O1, this._cSK1);};C_CanvasLink.prototype.F_Detach=function(){if(this._cPK1){delete this._cPK1;}};