otsdaq_utilities  v2_05_02_indev
JSRootPainter.min.js
1 (function(a){if(typeof define==="function"&&define.amd){define(["JSRootCore","d3"],a)}else{if(typeof JSROOT=="undefined"){throw new Error("JSROOT is not defined","JSRootPainter.js")}if(typeof d3!="object"){throw new Error("d3 is not defined","JSRootPainter.js")}if(typeof JSROOT.Painter=="object"){throw new Error("JSROOT.Painter already defined","JSRootPainter.js")}a(JSROOT,d3)}}(function(a,b){if(typeof define==="function"&&define.amd){a.loadScript("$$$style/JSRootPainter.css")}a.DrawFuncs={lst:[],cache:{}};a.addDrawFunc=function(c,d,e){if((arguments.length==1)&&(typeof arguments[0]=="object")){a.DrawFuncs.lst.push(arguments[0]);return arguments[0]}var f={name:c,func:d,opt:e};a.DrawFuncs.lst.push(f);return f};a.ToolbarIcons={camera:{path:"M 152.00,304.00c0.00,57.438, 46.562,104.00, 104.00,104.00s 104.00-46.562, 104.00-104.00s-46.562-104.00-104.00-104.00S 152.00,246.562, 152.00,304.00z M 480.00,128.00L 368.00,128.00 c-8.00-32.00-16.00-64.00-48.00-64.00L 192.00,64.00 c-32.00,0.00-40.00,32.00-48.00,64.00L 32.00,128.00 c-17.60,0.00-32.00,14.40-32.00,32.00l0.00,288.00 c0.00,17.60, 14.40,32.00, 32.00,32.00l 448.00,0.00 c 17.60,0.00, 32.00-14.40, 32.00-32.00L 512.00,160.00 C 512.00,142.40, 497.60,128.00, 480.00,128.00z M 256.00,446.00c-78.425,0.00-142.00-63.574-142.00-142.00c0.00-78.425, 63.575-142.00, 142.00-142.00c 78.426,0.00, 142.00,63.575, 142.00,142.00 C 398.00,382.426, 334.427,446.00, 256.00,446.00z M 480.00,224.00l-64.00,0.00 l0.00-32.00 l 64.00,0.00 L 480.00,224.00 z"},disk:{path:"M384,0H128H32C14.336,0,0,14.336,0,32v448c0,17.656,14.336,32,32,32h448c17.656,0,32-14.344,32-32V96L416,0H384z M352,160 V32h32v128c0,17.664-14.344,32-32,32H160c-17.664,0-32-14.336-32-32V32h128v128H352z M96,288c0-17.656,14.336-32,32-32h256 c17.656,0,32,14.344,32,32v192H96V288z"},question:{path:"M256,512c141.375,0,256-114.625,256-256S397.375,0,256,0S0,114.625,0,256S114.625,512,256,512z M256,64 c63.719,0,128,36.484,128,118.016c0,47.453-23.531,84.516-69.891,110.016C300.672,299.422,288,314.047,288,320 c0,17.656-14.344,32-32,32c-17.664,0-32-14.344-32-32c0-40.609,37.25-71.938,59.266-84.031 C315.625,218.109,320,198.656,320,182.016C320,135.008,279.906,128,256,128c-30.812,0-64,20.227-64,64.672 c0,17.664-14.336,32-32,32s-32-14.336-32-32C128,109.086,193.953,64,256,64z M256,449.406c-18.211,0-32.961-14.75-32.961-32.969 c0-18.188,14.75-32.953,32.961-32.953c18.219,0,32.969,14.766,32.969,32.953C288.969,434.656,274.219,449.406,256,449.406z"},undo:{path:"M450.159,48.042c8.791,9.032,16.983,18.898,24.59,29.604c7.594,10.706,14.146,22.207,19.668,34.489 c5.509,12.296,9.82,25.269,12.92,38.938c3.113,13.669,4.663,27.834,4.663,42.499c0,14.256-1.511,28.863-4.532,43.822 c-3.009,14.952-7.997,30.217-14.953,45.795c-6.955,15.577-16.202,31.52-27.755,47.826s-25.88,32.9-42.942,49.807 c-5.51,5.444-11.787,11.67-18.834,18.651c-7.033,6.98-14.496,14.366-22.39,22.168c-7.88,7.802-15.955,15.825-24.187,24.069 c-8.258,8.231-16.333,16.203-24.252,23.888c-18.3,18.13-37.354,37.016-57.191,56.65l-56.84-57.445 c19.596-19.472,38.54-38.279,56.84-56.41c7.75-7.685,15.772-15.604,24.108-23.757s16.438-16.163,24.33-24.057 c7.894-7.893,15.356-15.33,22.402-22.312c7.034-6.98,13.312-13.193,18.821-18.651c22.351-22.402,39.165-44.648,50.471-66.738 c11.279-22.09,16.932-43.567,16.932-64.446c0-15.785-3.217-31.005-9.638-45.671c-6.422-14.665-16.229-28.504-29.437-41.529 c-3.282-3.282-7.358-6.395-12.217-9.325c-4.871-2.938-10.381-5.503-16.516-7.697c-6.121-2.201-12.815-3.992-20.058-5.373 c-7.242-1.374-14.9-2.064-23.002-2.064c-8.218,0-16.802,0.834-25.788,2.507c-8.961,1.674-18.053,4.429-27.222,8.271 c-9.189,3.842-18.456,8.869-27.808,15.089c-9.358,6.219-18.521,13.819-27.502,22.793l-59.92,60.271l93.797,94.058H0V40.91 l93.27,91.597l60.181-60.532c13.376-15.018,27.222-27.248,41.536-36.697c14.308-9.443,28.608-16.776,42.89-21.992 c14.288-5.223,28.505-8.74,42.623-10.557C294.645,0.905,308.189,0,321.162,0c13.429,0,26.389,1.185,38.84,3.562 c12.478,2.377,24.2,5.718,35.192,10.029c11.006,4.311,21.126,9.404,30.374,15.265C434.79,34.724,442.995,41.119,450.159,48.042z"},arrow_right:{path:"M30.796,226.318h377.533L294.938,339.682c-11.899,11.906-11.899,31.184,0,43.084c11.887,11.899,31.19,11.893,43.077,0 l165.393-165.386c5.725-5.712,8.924-13.453,8.924-21.539c0-8.092-3.213-15.84-8.924-21.551L338.016,8.925 C332.065,2.975,324.278,0,316.478,0c-7.802,0-15.603,2.968-21.539,8.918c-11.899,11.906-11.899,31.184,0,43.084l113.391,113.384 H30.796c-16.822,0-30.463,13.645-30.463,30.463C0.333,212.674,13.974,226.318,30.796,226.318z"},arrow_up:{path:"M295.505,629.446V135.957l148.193,148.206c15.555,15.559,40.753,15.559,56.308,0c15.555-15.538,15.546-40.767,0-56.304 L283.83,11.662C276.372,4.204,266.236,0,255.68,0c-10.568,0-20.705,4.204-28.172,11.662L11.333,227.859 c-7.777,7.777-11.666,17.965-11.666,28.158c0,10.192,3.88,20.385,11.657,28.158c15.563,15.555,40.762,15.555,56.317,0 l148.201-148.219v493.489c0,21.993,17.837,39.82,39.82,39.82C277.669,669.267,295.505,651.439,295.505,629.446z"},arrow_diag:{path:"M279.875,511.994c-1.292,0-2.607-0.102-3.924-0.312c-10.944-1.771-19.333-10.676-20.457-21.71L233.97,278.348 L22.345,256.823c-11.029-1.119-19.928-9.51-21.698-20.461c-1.776-10.944,4.031-21.716,14.145-26.262L477.792,2.149 c9.282-4.163,20.167-2.165,27.355,5.024c7.201,7.189,9.199,18.086,5.024,27.356L302.22,497.527 C298.224,506.426,289.397,511.994,279.875,511.994z M118.277,217.332l140.534,14.294c11.567,1.178,20.718,10.335,21.878,21.896 l14.294,140.519l144.09-320.792L118.277,217.332z"},auto_zoom:{path:"M505.441,242.47l-78.303-78.291c-9.18-9.177-24.048-9.171-33.216,0c-9.169,9.172-9.169,24.045,0.006,33.217l38.193,38.188 H280.088V80.194l38.188,38.199c4.587,4.584,10.596,6.881,16.605,6.881c6.003,0,12.018-2.297,16.605-6.875 c9.174-9.172,9.174-24.039,0.011-33.217L273.219,6.881C268.803,2.471,262.834,0,256.596,0c-6.229,0-12.202,2.471-16.605,6.881 l-78.296,78.302c-9.178,9.172-9.178,24.045,0,33.217c9.177,9.171,24.051,9.171,33.21,0l38.205-38.205v155.4H80.521l38.2-38.188 c9.177-9.171,9.177-24.039,0.005-33.216c-9.171-9.172-24.039-9.178-33.216,0L7.208,242.464c-4.404,4.403-6.881,10.381-6.881,16.611 c0,6.227,2.477,12.207,6.881,16.61l78.302,78.291c4.587,4.581,10.599,6.875,16.605,6.875c6.006,0,12.023-2.294,16.61-6.881 c9.172-9.174,9.172-24.036-0.005-33.211l-38.205-38.199h152.593v152.063l-38.199-38.211c-9.171-9.18-24.039-9.18-33.216-0.022 c-9.178,9.18-9.178,24.059-0.006,33.222l78.284,78.302c4.41,4.404,10.382,6.881,16.611,6.881c6.233,0,12.208-2.477,16.611-6.881 l78.302-78.296c9.181-9.18,9.181-24.048,0-33.205c-9.174-9.174-24.054-9.174-33.21,0l-38.199,38.188v-152.04h152.051l-38.205,38.199 c-9.18,9.175-9.18,24.037-0.005,33.211c4.587,4.587,10.596,6.881,16.604,6.881c6.01,0,12.024-2.294,16.605-6.875l78.303-78.285 c4.403-4.403,6.887-10.378,6.887-16.611C512.328,252.851,509.845,246.873,505.441,242.47z"},statbox:{path:"M28.782,56.902H483.88c15.707,0,28.451-12.74,28.451-28.451C512.331,12.741,499.599,0,483.885,0H28.782 C13.074,0,0.331,12.741,0.331,28.451C0.331,44.162,13.074,56.902,28.782,56.902zM483.885,136.845H28.782c-15.708,0-28.451,12.741-28.451,28.451c0,15.711,12.744,28.451,28.451,28.451H483.88 c15.707,0,28.451-12.74,28.451-28.451C512.331,149.586,499.599,136.845,483.885,136.845zM483.885,273.275H28.782c-15.708,0-28.451,12.731-28.451,28.452c0,15.707,12.744,28.451,28.451,28.451H483.88 c15.707,0,28.451-12.744,28.451-28.451C512.337,286.007,499.599,273.275,483.885,273.275zM256.065,409.704H30.492c-15.708,0-28.451,12.731-28.451,28.451c0,15.707,12.744,28.451,28.451,28.451h225.585 c15.707,0,28.451-12.744,28.451-28.451C284.516,422.436,271.785,409.704,256.065,409.704z"}};a.Toolbar=function(c,d){if((c!==undefined)&&(typeof c.append=="function")){this.element=c.append("div").attr("class","jsroot");this.addButtons(d)}};a.Toolbar.prototype.addButtons=function(d){var c=this;this.buttonsNames=[];d.forEach(function(e){var f=c.element.append("div").attr("class","toolbar-group");e.forEach(function(h){var g=h.name;if(!g){throw new Error("must provide button 'name' in button config")}if(c.buttonsNames.indexOf(g)!==-1){throw new Error("button name '"+g+"' is taken")}c.buttonsNames.push(g);c.createButton(f,h)})})};a.Toolbar.prototype.createButton=function(e,c){var f=c.title;if(f===undefined){f=c.name}if(typeof c.click!=="function"){throw new Error("must provide button 'click' function in button config")}var d=e.append("a").attr("class","toolbar-btn").attr("rel","tooltip").attr("data-title",f).on("click",c.click);this.createIcon(d,c.icon||a.ToolbarIcons.question)};a.Toolbar.prototype.createIcon=function(f,d){var e=d.size||512;var i=d.scale||1;var c=f.append("svg:svg").attr("height","1em").attr("width","1em").attr("viewBox",[0,0,e,e].join(" "));if("recs" in d){var h={};for(var j=0;j<d.recs.length;++j){a.extend(h,d.recs[j]);c.append("rect").attr("x",h.x).attr("y",h.y).attr("width",h.w).attr("height",h.h).attr("fill",h.f)}}else{var g=c.append("svg:path").attr("d",d.path);if(i!==1){g.attr("transform","scale("+i+" "+i+")")}}};a.Toolbar.prototype.removeAllButtons=function(){this.element.remove()};a.Painter={};a.Painter.createMenu=function(c,d){document.body.style.cursor="wait";a.AssertPrerequisites("jq2d",function(){document.body.style.cursor="auto";a.Painter.createMenu(c,d)})};a.Painter.closeMenu=function(d){if(!d){d="root_ctx_menu"}var c=document.getElementById(d);if(c){c.parentNode.removeChild(c)}};a.Painter.readStyleFromURL=function(e){var i=a.GetUrlOption("optimize",e);if(i==""){a.gStyle.OptimizeDraw=2}else{if(i!==null){a.gStyle.OptimizeDraw=parseInt(i);if(isNaN(a.gStyle.OptimizeDraw)){a.gStyle.OptimizeDraw=2}}}var g=a.GetUrlOption("interactive",e);if((g=="")||(g=="1")){g="11111"}else{if(g=="0"){g="00000"}}if((g!==null)&&(g.length==5)){a.gStyle.Tooltip=parseInt(g.charAt(0));a.gStyle.ContextMenu=(g.charAt(1)!="0");a.gStyle.Zooming=(g.charAt(2)!="0");a.gStyle.MoveResize=(g.charAt(3)!="0");a.gStyle.DragAndDrop=(g.charAt(4)!="0")}var h=a.GetUrlOption("tooltip",e);if(h!==null){a.gStyle.Tooltip=parseInt(h)}var k=a.GetUrlOption("mathjax",e);if((k!==null)&&(k!="0")){a.gStyle.MathJax=1}if(a.GetUrlOption("nomenu",e)!=null){a.gStyle.ContextMenu=false}if(a.GetUrlOption("noprogress",e)!=null){a.gStyle.ProgressBox=false}if(a.GetUrlOption("notouch",e)!=null){a.touches=false}a.gStyle.OptStat=a.GetUrlOption("optstat",e,a.gStyle.OptStat);a.gStyle.OptFit=a.GetUrlOption("optfit",e,a.gStyle.OptFit);a.gStyle.StatFormat=a.GetUrlOption("statfmt",e,a.gStyle.StatFormat);a.gStyle.FitFormat=a.GetUrlOption("fitfmt",e,a.gStyle.FitFormat);var j=a.GetUrlOption("toolbar",e);if(j!==null){a.gStyle.ToolBar=(j!=="0")&&(j!=="false")}var f=a.GetUrlOption("palette",e);if(f!==null){f=parseInt(f);if(!isNaN(f)&&(f>0)&&(f<113)){a.gStyle.Palette=f}}var d=a.GetUrlOption("embed3d",e);if(d!==null){a.gStyle.Embed3DinSVG=parseInt(d)}var c=a.GetUrlOption("webgl",e);if((c==="0")||(c==="false")){a.gStyle.NoWebGL=false}else{if(c==="ie"){a.gStyle.NoWebGL=!a.browser.isIE}}};a.Painter.Coord={kCARTESIAN:1,kPOLAR:2,kCYLINDRICAL:3,kSPHERICAL:4,kRAPIDITY:5};a.Painter.root_colors=function(){var d=["white","black","red","green","blue","yellow","magenta","cyan","rgb(89,212,84)","rgb(89,84,217)","white"];d[110]="white";var g=[{col:11,str:"c1b7ad4d4d4d6666668080809a9a9ab3b3b3cdcdcde6e6e6f3f3f3cdc8accdc8acc3c0a9bbb6a4b3a697b8a49cae9a8d9c8f83886657b1cfc885c3a48aa9a1839f8daebdc87b8f9a768a926983976e7b857d9ad280809caca6c0d4cf88dfbb88bd9f83c89a7dc08378cf5f61ac8f94a6787b946971d45a549300ff7b00ff6300ff4b00ff3300ff1b00ff0300ff0014ff002cff0044ff005cff0074ff008cff00a4ff00bcff00d4ff00ecff00fffd00ffe500ffcd00ffb500ff9d00ff8500ff6d00ff5500ff3d00ff2600ff0e0aff0022ff003aff0052ff006aff0082ff009aff00b1ff00c9ff00e1ff00f9ff00ffef00ffd700ffbf00ffa700ff8f00ff7700ff6000ff4800ff3000ff1800ff0000"},{col:201,str:"5c5c5c7b7b7bb8b8b8d7d7d78a0f0fb81414ec4848f176760f8a0f14b81448ec4876f1760f0f8a1414b84848ec7676f18a8a0fb8b814ecec48f1f1768a0f8ab814b8ec48ecf176f10f8a8a14b8b848ecec76f1f1"},{col:390,str:"ffffcdffff9acdcd9affff66cdcd669a9a66ffff33cdcd339a9a33666633ffff00cdcd009a9a00666600333300"},{col:406,str:"cdffcd9aff9a9acd9a66ff6666cd66669a6633ff3333cd33339a3333663300ff0000cd00009a00006600003300"},{col:422,str:"cdffff9affff9acdcd66ffff66cdcd669a9a33ffff33cdcd339a9a33666600ffff00cdcd009a9a006666003333"},{col:590,str:"cdcdff9a9aff9a9acd6666ff6666cd66669a3333ff3333cd33339a3333660000ff0000cd00009a000066000033"},{col:606,str:"ffcdffff9affcd9acdff66ffcd66cd9a669aff33ffcd33cd9a339a663366ff00ffcd00cd9a009a660066330033"},{col:622,str:"ffcdcdff9a9acd9a9aff6666cd66669a6666ff3333cd33339a3333663333ff0000cd00009a0000660000330000"},{col:791,str:"ffcd9acd9a669a66339a6600cd9a33ffcd66ff9a00ffcd33cd9a00ffcd00ff9a33cd66006633009a3300cd6633ff9a66ff6600ff6633cd3300ff33009aff3366cd00336600339a0066cd339aff6666ff0066ff3333cd0033ff00cdff9a9acd66669a33669a009acd33cdff669aff00cdff339acd00cdff009affcd66cd9a339a66009a6633cd9a66ffcd00ff6633ffcd00cd9a00ffcd33ff9a00cd66006633009a3333cd6666ff9a00ff9a33ff6600cd3300ff339acdff669acd33669a00339a3366cd669aff0066ff3366ff0033cd0033ff339aff0066cd00336600669a339acd66cdff009aff33cdff009acd00cdffcd9aff9a66cd66339a66009a9a33cdcd66ff9a00ffcd33ff9a00cdcd00ff9a33ff6600cd33006633009a6633cd9a66ff6600ff6633ff3300cd3300ffff339acd00666600339a0033cd3366ff669aff0066ff3366cd0033ff0033ff9acdcd669a9a33669a0066cd339aff66cdff009acd009aff33cdff009a"},{col:920,str:"cdcdcd9a9a9a666666333333"}];for(var f=0;f<g.length;++f){var e=g[f];for(var h=0;h<e.str.length;h+=6){var c=parseInt(e.col)+parseInt(h/6);d[c]="rgb("+parseInt("0x"+e.str.slice(h,h+2))+","+parseInt("0x"+e.str.slice(h+2,h+4))+","+parseInt("0x"+e.str.slice(h+4,h+6))+")"}}return d}();a.Painter.MakeColorRGB=function(d){if((d==null)||(d._typename!="TColor")){return null}var c=Math.round(d.fRed*255)+","+Math.round(d.fGreen*255)+","+Math.round(d.fBlue*255);if((d.fAlpha===undefined)||(d.fAlpha==1)){c="rgb("+c+")"}else{c="rgba("+c+","+d.fAlpha.toFixed(3)+")"}switch(c){case"rgb(255,255,255)":c="white";break;case"rgb(0,0,0)":c="black";break;case"rgb(255,0,0)":c="red";break;case"rgb(0,255,0)":c="green";break;case"rgb(0,0,255)":c="blue";break;case"rgb(255,255,0)":c="yellow";break;case"rgb(255,0,255)":c="magenta";break;case"rgb(0,255,255)":c="cyan";break}return c};a.Painter.adoptRootColors=function(f){if(!f||!f.arr){return}for(var g=0;g<f.arr.length;++g){var e=f.arr[g];if((e==null)||(e._typename!="TColor")){continue}var d=e.fNumber;if((d<0)||(d>4096)){continue}var c=a.Painter.MakeColorRGB(e);if(c==null){continue}if(a.Painter.root_colors[d]!=c){a.Painter.root_colors[d]=c}}};a.Painter.root_line_styles=new Array("","","3,3","1,2","3,4,1,4","5,3,1,3","5,3,1,3,1,3,1,3","5,5","5,3,1,3,1,3","20,5","20,10,1,10","1,3");a.Painter.root_markers=new Array(0,100,8,7,0,9,100,100,100,100,100,100,100,100,100,100,100,100,100,100,100,103,105,104,0,3,4,2,1,106,6,7,5,102,101);a.Painter.createAttMarker=function(f,d){var e=a.Painter.root_colors[f.fMarkerColor];if((d===null)||(d===undefined)){d=f.fMarkerStyle}var c={x0:0,y0:0,color:e,style:d,size:8,stroke:true,fill:true,marker:"",ndig:0,used:true};c.Change=function(h,k,j){if(h!==undefined){this.color=h}if(k!==undefined){this.style=k}if(j!==undefined){this.size=j}else{j=this.size}this.x0=this.y0=0;this.reset_pos=function(){this.lastx=this.lasty=null};if((this.style===1)||(this.style===777)){this.fill=false;this.marker="h1";this.size=1;this.create=function(o,t){var r=Math.round(o),s=Math.round(t),q="M"+r+","+s+"h1";var p=(this.lastx===null)?q:("m"+(r-this.lastx)+","+(s-this.lasty)+"h1");this.lastx=r+1;this.lasty=s;return(p.length<q.length)?p:q};this.reset_pos();return true}var l=((this.style>0)&&(this.style<a.Painter.root_markers.length))?a.Painter.root_markers[this.style]:100;var g=l%100;this.fill=(l>=100);switch(this.style){case 1:j=this.size=1;break;case 6:j=this.size=2;break;case 7:j=this.size=3;break;default:this.size=j;j*=8}this.ndig=(j>7)?0:((j>2)?1:2);if(g==6){this.ndig++}var m=(j/2).toFixed(this.ndig),i=j.toFixed(this.ndig);switch(g){case 0:this.x0=-j/2;this.marker="a"+m+","+m+" 0 1,0 "+i+",0a"+m+","+m+" 0 1,0 -"+i+",0z";break;case 1:var n=(j/3).toFixed(c.ndig);this.x0=this.y0=j/6;this.marker="h"+n+"v-"+n+"h-"+n+"v-"+n+"h-"+n+"v"+n+"h-"+n+"v"+n+"h"+n+"v"+n+"h"+n+"z";break;case 2:this.x0=-j/2;this.marker="l"+m+",-"+m+"l"+m+","+m+"l-"+m+","+m+"z";break;case 3:this.x0=this.y0=-j/2;this.marker="v"+i+"h"+i+"v-"+i+"z";break;case 4:this.y0=j/2;this.marker="l-"+m+",-"+i+"h"+i+"z";break;case 5:this.y0=-j/2;this.marker="l-"+m+","+i+"h"+i+"z";break;case 6:this.y0=-j/2;this.marker="l"+(j/3).toFixed(c.ndig)+","+i+"l-"+(5/6*j).toFixed(c.ndig)+",-"+(5/8*j).toFixed(c.ndig)+"h"+i+"l-"+(5/6*j).toFixed(c.ndig)+","+(5/8*j).toFixed(c.ndig)+"z";break;case 7:this.x0=this.y0=-j/2;this.marker="l"+i+","+i+"m0,-"+i+"l-"+i+","+i+"m0,-"+m+"h"+i+"m-"+m+",-"+m+"v"+i;break;case 8:this.y0=-j/2;this.marker="v"+i+"m-"+m+",-"+m+"h"+i;break;case 9:this.x0=this.y0=-j/2;this.marker="l"+i+","+i+"m0,-"+i+"l-"+i+","+i;break;default:this.x0=-j/2;this.marker="l"+m+",-"+m+"l"+m+","+m+"l-"+m+","+m+"z";break}this.create=function(o,p){return"M"+(o+this.x0).toFixed(this.ndig)+","+(p+this.y0).toFixed(this.ndig)+this.marker};return true};c.Apply=function(g){g.style("stroke",this.stroke?this.color:"none");g.style("fill",this.fill?this.color:"none")};c.func=c.Apply.bind(c);c.Change(e,d,f.fMarkerSize);return c};a.Painter.createAttLine=function(i,g,f){var e=0,c=0,h=0;if(typeof i=="string"){if(i=="black"){e=1;c=1}else{if(i=="none"){c=0}}}else{if(typeof i=="object"){if("fLineColor" in i){e=i.fLineColor}if("fLineWidth" in i){c=i.fLineWidth}if("fLineStyle" in i){h=i.fLineStyle}}else{if((i!==undefined)&&!isNaN(i)){e=i}}}if(g!==undefined){c=g}var d={used:true,color:a.Painter.root_colors[e],width:c,dash:a.Painter.root_line_styles[h]};if((c==0)||(e==0)){d.color="none"}if(f){d.excl_side=0;d.excl_width=0;if(Math.abs(d.width)>99){d.excl_side=(d.width<0)?-1:1;d.excl_width=Math.floor(d.width/100)*5;d.width=d.width%100}}if((d.color===undefined)&&(e>0)){d.color="lightgrey"}d.Apply=function(j){this.used=true;if(this.color=="none"){j.style("stroke",null);j.style("stroke-width",null);j.style("stroke-dasharray",null)}else{j.style("stroke",this.color);j.style("stroke-width",this.width);if(this.dash&&(this.dash.length>0)){j.style("stroke-dasharray",this.dash)}}};d.func=d.Apply.bind(d);return d};a.Painter.clearCuts=function(c){var f=c.indexOf("[");var e=c.indexOf("]");if((f>=0)&&(e>=0)&&(f<e)){for(var d=f;d<=e;++d){c[d]=" "}}return c};a.Painter.root_fonts=new Array("Arial","Times New Roman","bTimes New Roman","biTimes New Roman","Arial","oArial","bArial","boArial","Courier New","oCourier New","bCourier New","boCourier New","Symbol","Times New Roman","Wingdings","Symbol","Verdana");a.Painter.getFontDetails=function(f,d){var e=a.Painter.root_fonts[Math.floor(f/10)];var c={name:"Arial",size:11,weight:null,style:null};if(d!=undefined){c.size=Math.round(d)}if(typeof e!="string"){e=""}while(e.length>0){if(e.charAt(0)==="b"){c.weight="bold"}else{if(e.charAt(0)==="i"){c.style="italic"}else{if(e.charAt(0)==="o"){c.style="oblique"}else{break}}}e=e.substr(1)}if(e=="Symbol"){c.weight=null;c.style=null}c.name=e;c.SetFont=function(g){g.attr("font-family",this.name).attr("font-size",this.size).attr("xml:space","preserve");if(this.weight!=null){g.attr("font-weight",this.weight)}if(this.style!=null){g.attr("font-style",this.style)}};c.asStyle=function(g){return((g!=null)?g:this.size)+"px "+this.name};c.stringWidth=function(i,h){var j=i.append("svg:text").attr("xml:space","preserve").style("opacity",0).text(h);this.SetFont(j);var g=j.node().getBBox().width;j.remove();return g};c.func=c.SetFont.bind(c);return c};a.Painter.chooseTimeFormat=function(d,c){if(d<0.5){return c?"%S.%L":"%M:%S.%L"}if(d<30){return c?"%Mm%S":"%H:%M:%S"}d/=60;if(d<30){return c?"%Hh%M":"%d/%m %H:%M"}d/=60;if(d<12){return c?"%d-%Hh":"%d/%m/%y %Hh"}d/=24;if(d<15.218425){return c?"%d/%m":"%d/%m/%y"}d/=30.43685;if(d<6){return"%d/%m/%y"}d/=12;if(d<2){return c?"%m/%y":"%d/%m/%y"}return"%Y"};a.Painter.getTimeFormat=function(c){var d=c.fTimeFormat.indexOf("%F");if(d>=0){return c.fTimeFormat.substr(0,d)}return c.fTimeFormat};a.Painter.getTimeOffset=function(d){var f=d.fTimeFormat.indexOf("%F");if(f<0){return a.gStyle.TimeOffset}var c=d.fTimeFormat.substr(f+2);if(c=="1995-01-01 00:00:00s0"){return 788918400000}if((c=="0")||(c=="")){return 0}var e=new Date(0);var g=c.indexOf("-");e.setFullYear(c.substr(0,g));c=c.substr(g+1);g=c.indexOf("-");e.setMonth(parseInt(c.substr(0,g))-1);c=c.substr(g+1);g=c.indexOf(" ");e.setDate(c.substr(0,g));c=c.substr(g+1);g=c.indexOf(":");e.setHours(c.substr(0,g));c=c.substr(g+1);g=c.indexOf(":");e.setMinutes(c.substr(0,g));c=c.substr(g+1);g=c.indexOf("s");e.setSeconds(c.substr(0,g));if(g>0){c=c.substr(g+1);e.setMilliseconds(c)}return e.getTime()};a.Painter.formatExp=function(l){var k=l;if(parseFloat(k)==1){return"1"}if(parseFloat(k)==10){return"10"}var k=k.replace("e+","x10@");var k=k.replace("e-","x10@-");var f=k.substring(0,k.indexOf("@"));var g=k.substr(k.indexOf("@"));f=f.replace("@","");g=g.replace("@","");var m,n=g.length;for(var d=0;d<n;++d){var m,i=g.charAt(d);if(i=="+"){m="\u207A"}else{if(i=="-"){m="\u207B"}else{var h=parseInt(i);if(h==1){m=String.fromCharCode(185)}else{if(h>1&&h<4){m=String.fromCharCode(176+h)}else{m=String.fromCharCode(8304+h)}}}}g=g.replace(i,m)}f=f.replace("1x","");return f+g};a.Painter.translateExp=function(m){var h=m.match(/\^{[0-9]*}/gi);if(h!=null){var d="";for(var g=0;g<h.length;++g){d=h[g].replace(" ","");d=d.replace("^{","");d=d.replace("}","");var o=d.length;for(var f=0;f<o;++f){var l=d.charAt(f);var n,k=parseInt(l);if(k==1){n=String.fromCharCode(185)}else{if(k>1&&k<4){n=String.fromCharCode(176+k)}else{n=String.fromCharCode(8304+k)}}d=d.replace(l,n)}m=m.replace(h[g],d)}}return m};a.Painter.symbols_map={"#alpha":"\u03B1","#beta":"\u03B2","#chi":"\u03C7","#delta":"\u03B4","#varepsilon":"\u03B5","#phi":"\u03C6","#gamma":"\u03B3","#eta":"\u03B7","#iota":"\u03B9","#varphi":"\u03C6","#kappa":"\u03BA","#lambda":"\u03BB","#mu":"\u03BC","#nu":"\u03BD","#omicron":"\u03BF","#pi":"\u03C0","#theta":"\u03B8","#rho":"\u03C1","#sigma":"\u03C3","#tau":"\u03C4","#upsilon":"\u03C5","#varomega":"\u03D6","#omega":"\u03C9","#xi":"\u03BE","#psi":"\u03C8","#zeta":"\u03B6","#Alpha":"\u0391","#Beta":"\u0392","#Chi":"\u03A7","#Delta":"\u0394","#Epsilon":"\u0395","#Phi":"\u03A6","#Gamma":"\u0393","#Eta":"\u0397","#Iota":"\u0399","#vartheta":"\u03D1","#Kappa":"\u039A","#Lambda":"\u039B","#Mu":"\u039C","#Nu":"\u039D","#Omicron":"\u039F","#Pi":"\u03A0","#Theta":"\u0398","#Rho":"\u03A1","#Sigma":"\u03A3","#Tau":"\u03A4","#Upsilon":"\u03A5","#varsigma":"\u03C2","#Omega":"\u03A9","#Xi":"\u039E","#Psi":"\u03A8","#Zeta":"\u0396","#varUpsilon":"\u03D2","#epsilon":"\u03B5","#sqrt":"\u221A","#leq":"\u2264","#/":"\u2044","#infty":"\u221E","#voidb":"\u0192","#club":"\u2663","#diamond":"\u2666","#heart":"\u2665","#spade":"\u2660","#leftrightarrow":"\u2194","#leftarrow":"\u2190","#uparrow":"\u2191","#rightarrow":"\u2192","#downarrow":"\u2193","#circ":"\u02C6","#pm":"\xB1","#doublequote":"\u2033","#geq":"\u2265","#times":"\xD7","#propto":"\u221D","#partial":"\u2202","#bullet":"\u2022","#divide":"\xF7","#neq":"\u2260","#equiv":"\u2261","#approx":"\u2248","#3dots":"\u2026","#cbar":"\u007C","#topbar":"\xAF","#downleftarrow":"\u21B5","#aleph":"\u2135","#Jgothic":"\u2111","#Rgothic":"\u211C","#voidn":"\u2118","#otimes":"\u2297","#oplus":"\u2295","#oslash":"\u2205","#cap":"\u2229","#cup":"\u222A","#supseteq":"\u2287","#supset":"\u2283","#notsubset":"\u2284","#subseteq":"\u2286","#subset":"\u2282","#int":"\u222B","#in":"\u2208","#notin":"\u2209","#angle":"\u2220","#nabla":"\u2207","#oright":"\xAE","#ocopyright":"\xA9","#trademark":"\u2122","#prod":"\u220F","#surd":"\u221A","#upoint":"\u22C5","#corner":"\xAC","#wedge":"\u2227","#vee":"\u2228","#Leftrightarrow":"\u21D4","#Leftarrow":"\u21D0","#Uparrow":"\u21D1","#Rightarrow":"\u21D2","#Downarrow":"\u21D3","#LT":"\x3C","#void1":"\xAE","#copyright":"\xA9","#void3":"\u2122","#sum":"\u2211","#arctop":"","#lbar":"","#arcbottom":"","#void8":"","#bottombar":"\u230A","#arcbar":"","#ltbar":"","#AA":"\u212B","#aa":"\u00E5","#void06":"","#GT":"\x3E","#forall":"\u2200","#exists":"\u2203","#bar":"","#vec":"","#dot":"\u22C5","#hat":"\xB7","#ddot":"","#acute":"acute","#grave":"","#check":"\u2713","#tilde":"\u02DC","#slash":"\u2044","#hbar":"\u0127","#box":"","#Box":"","#parallel":"","#perp":"\u22A5","#odot":"","#left":"","#right":""};a.Painter.translateLaTeX=function(d){var h=d;h=this.translateExp(h);while(h.indexOf("^{o}")!=-1){h=h.replace("^{o}","\xBA")}var f=h.match(/\#sqrt{(.*?)}/gi);if(f!=null){for(var e=0;e<f.length;++e){var g=f[e].replace(" ","");g=g.replace("#sqrt{","#sqrt");g=g.replace("}","");h=h.replace(f[e],g)}}f=h.match(/\_{(.*?)}/gi);if(f!=null){for(var e=0;e<f.length;++e){var g=f[e].replace(" ","");g=g.replace("_{","");g=g.replace("}","");h=h.replace(f[e],g)}}f=h.match(/\^{(.*?)}/gi);if(f!=null){for(e=0;e<f.length;++e){var g=f[e].replace(" ","");g=g.replace("^{","");g=g.replace("}","");h=h.replace(f[e],g)}}while(h.indexOf("#/")!=-1){h=h.replace("#/",a.Painter.symbols_map["#/"])}for(var c in a.Painter.symbols_map){while(h.indexOf(c)!=-1){h=h.replace(c,a.Painter.symbols_map[c])}}if((h.indexOf("#splitline{")==0)&&(h.charAt(h.length-1)=="}")){var j=h.indexOf("}{");if((j>0)&&(j==h.lastIndexOf("}{"))){h=h.replace("}{","\n");h=h.slice(11,h.length-1)}}return h};a.Painter.isAnyLatex=function(c){return(c.indexOf("#")>=0)||(c.indexOf("\\")>=0)||(c.indexOf("{")>=0)};a.Painter.translateMath=function(f,e,d){if(e!=2){f=f.replace(/#LT/g,"\\langle");f=f.replace(/#GT/g,"\\rangle");f=f.replace(/#club/g,"\\clubsuit");f=f.replace(/#spade/g,"\\spadesuit");f=f.replace(/#heart/g,"\\heartsuit");f=f.replace(/#diamond/g,"\\diamondsuit");f=f.replace(/#voidn/g,"\\wp");f=f.replace(/#voidb/g,"f");f=f.replace(/#copyright/g,"(c)");f=f.replace(/#ocopyright/g,"(c)");f=f.replace(/#trademark/g,"TM");f=f.replace(/#void3/g,"TM");f=f.replace(/#oright/g,"R");f=f.replace(/#void1/g,"R");f=f.replace(/#3dots/g,"\\ldots");f=f.replace(/#lbar/g,"\\mid");f=f.replace(/#void8/g,"\\mid");f=f.replace(/#divide/g,"\\div");f=f.replace(/#Jgothic/g,"\\Im");f=f.replace(/#Rgothic/g,"\\Re");f=f.replace(/#doublequote/g,'"');f=f.replace(/#plus/g,"+");f=f.replace(/#diamond/g,"\\diamondsuit");f=f.replace(/#voidn/g,"\\wp");f=f.replace(/#voidb/g,"f");f=f.replace(/#copyright/g,"(c)");f=f.replace(/#ocopyright/g,"(c)");f=f.replace(/#trademark/g,"TM");f=f.replace(/#void3/g,"TM");f=f.replace(/#oright/g,"R");f=f.replace(/#void1/g,"R");f=f.replace(/#3dots/g,"\\ldots");f=f.replace(/#lbar/g,"\\mid");f=f.replace(/#void8/g,"\\mid");f=f.replace(/#divide/g,"\\div");f=f.replace(/#Jgothic/g,"\\Im");f=f.replace(/#Rgothic/g,"\\Re");f=f.replace(/#doublequote/g,'"');f=f.replace(/#plus/g,"+");f=f.replace(/#minus/g,"-");f=f.replace(/#\//g,"/");f=f.replace(/#upoint/g,".");f=f.replace(/#aa/g,"\\mathring{a}");f=f.replace(/#AA/g,"\\mathring{A}");f=f.replace(/#omicron/g,"o");f=f.replace(/#Alpha/g,"A");f=f.replace(/#Beta/g,"B");f=f.replace(/#Epsilon/g,"E");f=f.replace(/#Zeta/g,"Z");f=f.replace(/#Eta/g,"H");f=f.replace(/#Iota/g,"I");f=f.replace(/#Kappa/g,"K");f=f.replace(/#Mu/g,"M");f=f.replace(/#Nu/g,"N");f=f.replace(/#Omicron/g,"O");f=f.replace(/#Rho/g,"P");f=f.replace(/#Tau/g,"T");f=f.replace(/#Chi/g,"X");f=f.replace(/#varomega/g,"\\varpi");f=f.replace(/#corner/g,"?");f=f.replace(/#ltbar/g,"?");f=f.replace(/#bottombar/g,"?");f=f.replace(/#notsubset/g,"?");f=f.replace(/#arcbottom/g,"?");f=f.replace(/#cbar/g,"?");f=f.replace(/#arctop/g,"?");f=f.replace(/#topbar/g,"?");f=f.replace(/#arcbar/g,"?");f=f.replace(/#downleftarrow/g,"?");f=f.replace(/#splitline/g,"\\genfrac{}{}{0pt}{}");f=f.replace(/#it/g,"\\textit");f=f.replace(/#bf/g,"\\textbf");f=f.replace(/#frac/g,"\\frac");f=f.replace(/#left{/g,"\\lbrace");f=f.replace(/#right}/g,"\\rbrace");f=f.replace(/#left\[/g,"\\lbrack");f=f.replace(/#right\]/g,"\\rbrack");f=f.replace(/#\[\]{/g,"\\lbrack");f=f.replace(/ } /g,"\\rbrack");f=f.replace(/#\[/g,"\\lbrack");f=f.replace(/#\]/g,"\\rbrack");f=f.replace(/#{/g,"\\lbrace");f=f.replace(/#}/g,"\\rbrace");f=f.replace(/ /g,"\\;");for(var c in a.Painter.symbols_map){var g="\\"+c.substr(1);f=f.replace(new RegExp(c,"g"),g)}}else{f=f.replace(/\\\^/g,"\\hat")}if(typeof d!="string"){return"\\("+f+"\\)"}if(d.indexOf("rgb(")>=0){d=d.replace(/rgb/g,"[RGB]").replace(/\(/g,"{").replace(/\)/g,"}")}return"\\(\\color{"+d+"}"+f+"\\)"};a.TBasePainter=function(){this.divid=null};a.TBasePainter.prototype.Cleanup=function(){};a.TBasePainter.prototype.DrawingReady=function(){this["_ready_called_"]=true;if("_ready_callback_" in this){a.CallBack(this["_ready_callback_"],this);delete this["_ready_callback_"];this["_ready_callback_"]=null}return this};a.TBasePainter.prototype.WhenReady=function(c){if("_ready_called_" in this){return a.CallBack(c,this)}this["_ready_callback_"]=c};a.TBasePainter.prototype.GetObject=function(){return null};a.TBasePainter.prototype.MatchObjectType=function(c){return false};a.TBasePainter.prototype.UpdateObject=function(c){return false};a.TBasePainter.prototype.RedrawPad=function(c){};a.TBasePainter.prototype.RedrawObject=function(d){if(this.UpdateObject(d)){var c=document.body.style.cursor;document.body.style.cursor="wait";this.RedrawPad();document.body.style.cursor=c}};a.TBasePainter.prototype.CheckResize=function(c){return false};a.TBasePainter.prototype.select_main=function(){if((this.divid===null)||(this.divid===undefined)){return b.select(null)}if((typeof this.divid=="string")&&(this.divid.charAt(0)!="#")){return b.select("#"+this.divid)}return b.select(this.divid)};a.TBasePainter.prototype.main_visible_rect=function(){var c=this.select_main();var e=c.node().getBoundingClientRect();var d={};d.width=Math.round(e.width-this.GetStyleValue(c,"padding-left")-this.GetStyleValue(c,"padding-right"));d.height=Math.round(e.height-this.GetStyleValue(c,"padding-top")-this.GetStyleValue(c,"padding-bottom"));return d};a.TBasePainter.prototype.SetDivId=function(e){if(arguments.length>0){this.divid=e}var c=this.select_main();var d=c.node()?c.node().firstChild:null;if(d){d.painter=this}};a.TBasePainter.prototype.SetItemName=function(c,d){if(typeof c==="string"){this._hitemname=c}else{delete this._hitemname}if(typeof d==="string"){this._hdrawopt=d}};a.TBasePainter.prototype.GetItemName=function(){return("_hitemname" in this)?this._hitemname:null};a.TBasePainter.prototype.GetItemDrawOpt=function(){return("_hdrawopt" in this)?this._hdrawopt:""};a.TBasePainter.prototype.CanZoomIn=function(d,e,c){return false};a.TBasePainter.prototype.GetStyleValue=function(c,d){var e=c.style(d);if(!e){return 0}e=parseFloat(e.replace("px",""));return isNaN(e)?0:e};a.TObjectPainter=function(c){a.TBasePainter.call(this);this.draw_g=null;this.pad_name="";this.main=null;this.draw_object=((c!==undefined)&&(typeof c=="object"))?c:null};a.TObjectPainter.prototype=Object.create(a.TBasePainter.prototype);a.TObjectPainter.prototype.GetObject=function(){return this.draw_object};a.TObjectPainter.prototype.MatchObjectType=function(c){if((c===undefined)||(c===null)||(this.draw_object===null)){return false}if(typeof c==="string"){return this.draw_object._typename===c}return(typeof c==="object")&&(this.draw_object._typename===c._typename)};a.TObjectPainter.prototype.SetItemName=function(c,d){a.TBasePainter.prototype.SetItemName.call(this,c,d);if(c==""){return}var e=this.svg_canvas();if(!e.empty()){e.select("title").text(c)}else{this.select_main().attr("title",c)}};a.TObjectPainter.prototype.UpdateObject=function(c){if(!this.MatchObjectType(c)){return false}a.extend(this.GetObject(),c);return true};a.TObjectPainter.prototype.GetTipName=function(c){var d=this.GetItemName();if(d===null){d=""}if((d.length===0)&&("fName" in this.GetObject())){d=this.GetObject().fName}if(d.lenght>20){d=d.substr(0,17)+"..."}if((d.length>0)&&(c!==undefined)){d+=c}return d};a.TObjectPainter.prototype.pad_painter=function(c){var d=c?this.svg_pad():this.svg_canvas();return d.empty()?null:d.property("pad_painter")};a.TObjectPainter.prototype.CheckResize=function(c){var d=this.pad_painter();if(d){return d.CheckCanvasResize(c,false)}return false};a.TObjectPainter.prototype.RemoveDrawG=function(){if(this.draw_g!=null){this.draw_g.remove();this.draw_g=null}};a.TObjectPainter.prototype.RecreateDrawG=function(c,d){if(this.draw_g){b.selectAll(this.draw_g.node().childNodes).remove()}else{if(c){if(typeof d!="string"){d="text_layer"}if(d.charAt(0)=="."){d=d.substr(1)}this.draw_g=this.svg_layer(d).append("svg:g")}else{if(typeof d!="string"){d=".main_layer"}if(d.charAt(0)!="."){d="."+d}this.draw_g=this.svg_frame().select(d).append("svg:g")}}if(this.draw_object!==null){this.draw_g.attr("objname",this.draw_object.fName);this.draw_g.attr("objtype",this.draw_object._typename)}return this.draw_g};a.TObjectPainter.prototype.svg_canvas=function(){return this.select_main().select(".root_canvas")};a.TObjectPainter.prototype.svg_pad=function(d){var e=this.svg_canvas();if(d===undefined){d=this.pad_name}if((d.length>0)&&!e.empty()){e=e.select(".subpads_layer").select("[pad="+d+"]")}return e};a.TObjectPainter.prototype.svg_layer=function(e,d){var c=this.svg_pad(d);if(c.empty()){return c}var g=c.node().firstChild;while(g!==null){var f=b.select(g);if(f.classed(e)){return f}g=g.nextSibling}return b.select(null)};a.TObjectPainter.prototype.root_pad=function(){var c=this.pad_painter(true);return c?c.pad:null};a.TObjectPainter.prototype.ConvertToNDC=function(d,e,c){var f=this.root_pad();if(c==null){c=false}if(c||(f==null)){return e}if(d=="y"){if(f.fLogy){e=(e>0)?a.log10(e):f.fUymin}return(e-f.fY1)/(f.fY2-f.fY1)}if(f.fLogx){e=(e>0)?a.log10(e):f.fUxmin}return(e-f.fX1)/(f.fX2-f.fX1)};a.TObjectPainter.prototype.AxisToSvg=function(e,f,d){var c=this.main_painter();if((c!=null)&&!d){return e=="y"?c.gry(f):c.grx(f)}if(!d){f=this.ConvertToNDC(e,f)}if(e=="y"){return(1-f)*this.pad_height()}return f*this.pad_width()};a.TObjectPainter.prototype.PadToSvg=function(d,e,c){return this.AxisToSvg(d,e,c)};a.TObjectPainter.prototype.svg_frame=function(){return this.svg_pad().select(".root_frame")};a.TObjectPainter.prototype.frame_painter=function(){var c=this.svg_frame().property("frame_painter");return(c===undefined)?null:c};a.TObjectPainter.prototype.pad_width=function(c){var d=this.svg_pad(c).property("draw_width");return isNaN(d)?0:d};a.TObjectPainter.prototype.pad_height=function(c){var d=this.svg_pad(c).property("draw_height");return isNaN(d)?0:d};a.TObjectPainter.prototype.frame_x=function(){var c=parseInt(this.svg_frame().attr("x"));return isNaN(c)?0:c};a.TObjectPainter.prototype.frame_y=function(){var c=parseInt(this.svg_frame().attr("y"));return isNaN(c)?0:c};a.TObjectPainter.prototype.frame_width=function(){var c=parseInt(this.svg_frame().attr("width"));return isNaN(c)?0:c};a.TObjectPainter.prototype.frame_height=function(){var c=parseInt(this.svg_frame().attr("height"));return isNaN(c)?0:c};a.TObjectPainter.prototype.embed_3d=function(){if(a.gStyle.Embed3DinSVG<2){return a.gStyle.Embed3DinSVG}if(a.browser.isFirefox){return a.gStyle.Embed3DinSVG}return 1};a.TObjectPainter.prototype.size_for_3d=function(g){if(g===undefined){g=this.embed_3d()}var h=this.svg_pad();var d=this.pad_name;if(d==""){d="canvas"}d="draw3d_"+d;if(h.empty()){var f=this.main_visible_rect();if((f.height<10)&&(f.width>10)){f.height=Math.round(0.66*f.width);this.select_main().style("height",f.height+"px")}f.x=0;f.y=0;f.clname=d;f.can3d=-1;return f}var e=h;if(g==0){e=this.svg_canvas()}var c={x:0,y:0,width:100,height:100,clname:d,can3d:g};if(this.frame_painter()!==null){e=this.svg_frame();c.x=e.property("draw_x");c.y=e.property("draw_y")}c.width=e.property("draw_width");c.height=e.property("draw_height");if((this.frame_painter()===null)&&(g>0)){c.x=Math.round(c.x+c.width*0.1);c.y=Math.round(c.y+c.height*0.1);c.width=Math.round(c.width*0.8);c.height=Math.round(c.height*0.8)}if(g===1){this.CalcAbsolutePosition(this.svg_pad(),c)}return c};a.TObjectPainter.prototype.clear_3d_canvas=function(){var d=this.svg_pad().property("can3d");if(d===null){return}this.svg_pad().property("can3d",null);var c=this.size_for_3d(d);if(c.can3d===0){b.select(this.svg_canvas().node().nextSibling).remove();this.svg_canvas().style("display",null)}else{if(this.svg_pad().empty()){return}this.apply_3d_size(c).remove();this.svg_frame().style("display",null)}};a.TObjectPainter.prototype.add_3d_canvas=function(d,f){if((f==null)||(d.can3d<-1)){return}if(d.can3d===-1){var c=this.select_main().node();if(c!==null){c.appendChild(f);f.painter=this}return}this.svg_pad().property("can3d",d.can3d);if(d.can3d===0){this.svg_canvas().style("display","none");this.svg_canvas().node().parentNode.appendChild(f)}else{if(this.svg_pad().empty()){return}this.svg_frame().style("display","none");var e=this.apply_3d_size(d);e.attr("title","").node().appendChild(f)}};a.TObjectPainter.prototype.apply_3d_size=function(d,f){if(d.can3d<0){return b.select(null)}var e;if(d.can3d>1){var c=this.svg_layer("special_layer");e=c.select("."+d.clname);if(f){return e}if(e.empty()){e=c.append("foreignObject").attr("class",d.clname)}e.attr("x",d.x).attr("y",d.y).attr("width",d.width).attr("height",d.height).attr("viewBox","0 0 "+d.width+" "+d.height).attr("preserveAspectRatio","xMidYMid")}else{e=b.select(this.svg_canvas().node().parentNode).select("."+d.clname);if(f){return e}this.svg_canvas().property("redraw_by_resize",true);if(e.empty()){e=b.select(this.svg_canvas().node().parentNode).append("div").attr("class",d.clname)}e.style("position","absolute").style("left",d.x+"px").style("top",d.y+"px").style("width",d.width+"px").style("height",d.height+"px")}return e};a.TObjectPainter.prototype.main_painter=function(){if(this.main===null){var c=this.svg_pad();if(!c.empty()){this.main=c.property("mainpainter");if(this.main===undefined){this.main=null}}}return this.main};a.TObjectPainter.prototype.is_main_painter=function(){return this===this.main_painter()};a.TObjectPainter.prototype.SetDivId=function(g,f){if(g!==undefined){this.divid=g}if((f===null)||(f===undefined)){f=0}this.create_canvas=false;var e=this.svg_canvas();if(e.empty()&&(f>0)&&(f!==5)){a.Painter.drawCanvas(g,null,((f==2)||(f==4))?"noframe":"");e=this.svg_canvas();this.create_canvas=true}if(e.empty()){if((f<0)||(f===5)||this.iscan){return}var c=this.select_main();if(c.node()&&c.node().firstChild){c.node().firstChild.painter=this}return}this.pad_name=e.property("current_pad");if(f<0){return}if(this.svg_frame().select(".main_layer").empty()&&((f==1)||(f==3))){a.Painter.drawFrame(g,null);if(this.svg_frame().empty()){return alert("Fail to draw dummy TFrame")}}var d=this.svg_pad();if(d.empty()){return}if(d.property("pad_painter")!==this){d.property("pad_painter").painters.push(this)}if(((f===1)||(f===4)||(f===5))&&(d.property("mainpainter")==null)){d.property("mainpainter",this)}};a.TObjectPainter.prototype.CalcAbsolutePosition=function(c,d){while(!c.empty()&&!c.classed("root_canvas")){if(c.classed("root_frame")||c.classed("root_pad")){d.x+=c.property("draw_x");d.y+=c.property("draw_y")}c=b.select(c.node().parentNode)}return d};a.TObjectPainter.prototype.createAttFill=function(e,f,c,d){var g={color:"none",colorindx:0,pattern:0,used:true,kind:2};if(d!==undefined){g.kind=d}g.Apply=function(h){this.used=true;h.style("fill",this.color);if("opacity" in this){h.style("opacity",this.opacity)}if("antialias" in this){h.style("antialias",this.antialias)}};g.func=g.Apply.bind(g);g.Change=function(j,m,i){if((j!==undefined)&&!isNaN(j)){this.colorindx=j}if((m!==undefined)&&!isNaN(m)){this.pattern=m;delete this.opacity;delete this.antialias}if(this.pattern<1001){this.color="none";return true}if((this.pattern===1001)&&(this.colorindx===0)&&(this.kind===1)){this.color="none";return true}this.color=a.Painter.root_colors[this.colorindx];if(typeof this.color!="string"){this.color="none"}if(this.pattern===1001){return true}if((this.pattern>=4000)&&(this.pattern<=4100)){this.opacity=(this.pattern-4000)/100;return true}if((i===undefined)||i.empty()||(this.pattern<3000)||(this.pattern>3025)){return false}var n="pat_"+this.pattern+"_"+this.colorindx;var h=i.select("defs");if(h.empty()){h=i.insert("svg:defs",":first-child")}var k=this.color;this.color="url(#"+n+")";this.antialias=false;if(!h.select("."+n).empty()){return true}var l=h.append("svg:pattern").attr("id",n).attr("class",n).attr("patternUnits","userSpaceOnUse");switch(this.pattern){case 3001:l.attr("width",2).attr("height",2);l.append("svg:rect").attr("x",0).attr("y",0).attr("width",1).attr("height",1);l.append("svg:rect").attr("x",1).attr("y",1).attr("width",1).attr("height",1);break;case 3002:l.attr("width",4).attr("height",2);l.append("svg:rect").attr("x",1).attr("y",0).attr("width",1).attr("height",1);l.append("svg:rect").attr("x",3).attr("y",1).attr("width",1).attr("height",1);break;case 3003:l.attr("width",4).attr("height",4);l.append("svg:rect").attr("x",2).attr("y",1).attr("width",1).attr("height",1);l.append("svg:rect").attr("x",0).attr("y",3).attr("width",1).attr("height",1);break;case 3005:l.attr("width",8).attr("height",8);l.append("svg:line").attr("x1",0).attr("y1",0).attr("x2",8).attr("y2",8);break;case 3006:l.attr("width",4).attr("height",4);l.append("svg:line").attr("x1",1).attr("y1",0).attr("x2",1).attr("y2",3);break;case 3007:l.attr("width",4).attr("height",4);l.append("svg:line").attr("x1",0).attr("y1",1).attr("x2",3).attr("y2",1);break;case 3010:l.attr("width",10).attr("height",10);l.append("svg:line").attr("x1",0).attr("y1",2).attr("x2",10).attr("y2",2);l.append("svg:line").attr("x1",0).attr("y1",7).attr("x2",10).attr("y2",7);l.append("svg:line").attr("x1",2).attr("y1",0).attr("x2",2).attr("y2",2);l.append("svg:line").attr("x1",7).attr("y1",2).attr("x2",7).attr("y2",7);l.append("svg:line").attr("x1",2).attr("y1",7).attr("x2",2).attr("y2",10);break;case 3021:case 3022:l.attr("width",10).attr("height",10);l.append("svg:line").attr("x1",0).attr("y1",5).attr("x2",5).attr("y2",5);l.append("svg:line").attr("x1",5).attr("y1",5).attr("x2",5).attr("y2",0);l.append("svg:line").attr("x1",5).attr("y1",10).attr("x2",10).attr("y2",10);l.append("svg:line").attr("x1",10).attr("y1",10).attr("x2",10).attr("y2",5);break;default:l.attr("width",8).attr("height",8);l.append("svg:line").attr("x1",8).attr("y1",0).attr("x2",0).attr("y2",8);break}l.selectAll("line").style("stroke",k).style("stroke-width",1);l.selectAll("rect").style("fill",k);return true};if((e!==null)&&(typeof e=="object")){if("fFillStyle" in e){f=e.fFillStyle}if("fFillColor" in e){c=e.fFillColor}}g.Change(c,f,this.svg_canvas());return g};a.TObjectPainter.prototype.ForEachPainter=function(f){var c=this.select_main();var d=(c.node()&&c.node().firstChild)?c.node().firstChild.painter:null;if(d!=null){return f(d)}var g=this.pad_painter(true);if(g==null){return}f(g);if("painters" in g){for(var e=0;e<g.painters.length;++e){f(g.painters[e])}}};a.TObjectPainter.prototype.Cleanup=function(){this.select_main().html("")};a.TObjectPainter.prototype.RedrawPad=function(){var c=this.pad_painter(true);if(c){c.Redraw()}};a.TObjectPainter.prototype.SwitchTooltip=function(c){var d=this.frame_painter();if(d){d.ProcessTooltipEvent(null,c)}};a.TObjectPainter.prototype.AddDrag=function(o){if(!a.gStyle.MoveResize){return}var d=this;var c=function(){return Number(d.draw_g.attr("width"))};var q=function(){return Number(d.draw_g.attr("height"))};var r=0,p=0,k=1,e=1,j=null;function m(s){if("buttons" in s){return s.buttons===2}else{if("which" in s){return s.which===3}else{if("button" in s){return s.button===2}}}return false}var g=this.draw_g.select(".resize_corner1");if(g.empty()){g=this.draw_g.append("path").attr("class","resize_corner1").attr("d","M2,2 h15 v-5 h-20 v20 h5 Z")}var f=this.draw_g.select(".resize_corner2");if(f.empty()){f=this.draw_g.append("path").attr("class","resize_corner2").attr("d","M-2,-2 h-15 v5 h20 v-20 h-5 Z")}g.style("opacity","0").style("cursor","nw-resize");f.style("opacity","0").style("cursor","se-resize").attr("transform","translate("+c()+","+q()+")");var i=null;function h(){i.style("cursor","auto");var w=Number(d.draw_g.attr("x")),v=Number(d.draw_g.attr("y")),z=Number(i.attr("x")),y=Number(i.attr("y")),s=Number(i.attr("width")),t=Number(i.attr("height"));var u=(s!==c())||(t!==q());var x=(z!==w)||(y!==v);d.draw_g.attr("x",z).attr("y",y).attr("transform","translate("+z+","+y+")").attr("width",s).attr("height",t);i.remove();i=null;d.SwitchTooltip(true);f.attr("transform","translate("+s+","+t+")");if(u||x){if(u&&("resize" in o)){o.resize(s,t)}if(x&&("move" in o)){o.move(z,y,z-oldxx,y-v)}if(u||x){if("obj" in o){o.obj.fX1NDC=z/d.pad_width();o.obj.fX2NDC=(z+s)/d.pad_width();o.obj.fY1NDC=1-(y+t)/d.pad_height();o.obj.fY2NDC=1-y/d.pad_height()}if("redraw" in o){o.redraw()}}}return u||x}var n=b.behavior.drag().origin(Object).on("dragstart",function(){if(m(b.event.sourceEvent)){return}a.Painter.closeMenu();d.SwitchTooltip(false);b.event.sourceEvent.preventDefault();b.event.sourceEvent.stopPropagation();r=0;p=0;k=d.pad_width()-c();e=d.pad_height()-q();j=new Date();i=b.select(d.draw_g.node().parentNode).append("rect").classed("zoom",true).attr("x",d.draw_g.attr("x")).attr("y",d.draw_g.attr("y")).attr("width",c()).attr("height",q()).style("cursor","move").style("pointer-events","none")}).on("drag",function(){if(i==null){return}b.event.sourceEvent.preventDefault();var s=Number(i.attr("x")),v=Number(i.attr("y"));var u=b.event.dx,t=b.event.dy;if((r<0)&&(u>0)){r+=u;u=0;if(r>0){u=r;r=0}}if((r>0)&&(u<0)){r+=u;u=0;if(r<0){u=r;r=0}}if((p<0)&&(t>0)){p+=t;t=0;if(p>0){t=p;p=0}}if((p>0)&&(t<0)){p+=t;t=0;if(p<0){t=p;p=0}}if(s+u<0){r+=(s+u);s=0}else{if(s+u>k){r+=(s+u-k);s=k}else{s+=u}}if(v+t<0){p+=(v+t);v=0}else{if(v+t>e){p+=(v+t-e);v=e}else{v+=t}}i.attr("x",s).attr("y",v);b.event.sourceEvent.stopPropagation()}).on("dragend",function(){if(i==null){return}b.event.sourceEvent.preventDefault();if(h()===false){if(o.ctxmenu&&((new Date()).getTime()-j.getTime()>600)){var s=f.node().getBoundingClientRect();d.ShowContextMenu("main",{clientX:s.left,clientY:s.top})}}});var l=b.behavior.drag().origin(Object).on("dragstart",function(){if(m(b.event.sourceEvent)){return}b.event.sourceEvent.stopPropagation();b.event.sourceEvent.preventDefault();d.SwitchTooltip(false);r=0;p=0;k=d.pad_width();e=d.pad_height();i=b.select(d.draw_g.node().parentNode).append("rect").classed("zoom",true).attr("x",d.draw_g.attr("x")).attr("y",d.draw_g.attr("y")).attr("width",c()).attr("height",q()).style("cursor",b.select(this).style("cursor"))}).on("drag",function(){if(i==null){return}b.event.sourceEvent.preventDefault();var u=Number(i.attr("width")),z=Number(i.attr("height")),s=Number(i.attr("x")),A=Number(i.attr("y"));var v=b.event.dx,t=b.event.dy;if((r<0)&&(v>0)){r+=v;v=0;if(r>0){v=r;r=0}}if((r>0)&&(v<0)){r+=v;v=0;if(r<0){v=r;r=0}}if((p<0)&&(t>0)){p+=t;t=0;if(p>0){t=p;p=0}}if((p>0)&&(t<0)){p+=t;t=0;if(p<0){t=p;p=0}}if(b.select(this).classed("resize_corner1")){if(s+v<0){r+=(s+v);u+=s;s=0}else{if(u-v<0){r-=(u-v);s+=u;u=0}else{s+=v;u-=v}}if(A+t<0){p+=(A+t);z+=A;A=0}else{if(z-t<0){p-=(z-t);A+=z;z=0}else{A+=t;z-=t}}}else{if(s+u+v>k){r+=(s+u+v-k);u=k-s}else{if(u+v<0){r+=(u+v);u=0}else{u+=v}}if(A+z+t>e){p+=(A+z+t-e);z=e-A}else{if(z+t<0){p+=(z+t);z=0}else{z+=t}}}i.attr("x",s).attr("y",A).attr("width",u).attr("height",z);b.event.sourceEvent.stopPropagation()}).on("dragend",function(){if(i==null){return}b.event.sourceEvent.preventDefault();h()});if(!("only_resize" in o)){this.draw_g.style("cursor","move").call(n)}g.call(l);f.call(l)};a.TObjectPainter.prototype.startTouchMenu=function(e){var c=b.touches(this.svg_frame().node());if(c.length!=1){return}if(!e||(e=="")){e="main"}var d="touch_"+e;b.event.preventDefault();b.event.stopPropagation();this[d]={dt:new Date(),pos:c[0]};this.svg_frame().on("touchcancel",this.endTouchMenu.bind(this,e)).on("touchend",this.endTouchMenu.bind(this,e))};a.TObjectPainter.prototype.endTouchMenu=function(d){var c="touch_"+d;if(!(c in this)){return}b.event.preventDefault();b.event.stopPropagation();var f=new Date().getTime()-this[c].dt.getTime();this.svg_frame().on("touchcancel",null).on("touchend",null);if(f>500){var e=this.svg_frame().node().getBoundingClientRect();this.ShowContextMenu(d,{clientX:e.left+this[c].pos[0],clientY:e.top+this[c].pos[1]})}delete this[c]};a.TObjectPainter.prototype.AddColorMenuEntry=function(e,d,j,i,c){if(j===undefined){return}e.add("sub:"+d,function(){var m=(typeof j!=="string");var l=prompt("Enter color "+(m?"(only id number)":"(name or id)"),j);if(l==null){return}var n=parseInt(l);if(!isNaN(n)&&(a.Painter.root_colors[n]!==undefined)){l=a.Painter.root_colors[n]}else{if(m){return}}i.bind(this)(m?n:l)});var k=(typeof j!=="string");for(var f=-1;f<11;++f){if((f<0)&&k){continue}if((f==10)&&(c!==1)){continue}var g=(f<0)?"none":a.Painter.root_colors[f];if((f==0)&&(c==1)){g="none"}var h="<svg width='100' height='18' style='margin:0px;background-color:"+g+"'><text x='4' y='12' style='font-size:12px' fill='"+(f==1?"white":"black")+"'>"+g+"</text></svg>";e.addchk((j==(k?f:g)),h,(k?f:g),i)}e.add("endsub:")};a.TObjectPainter.prototype.AddSizeMenuEntry=function(d,c,g,i,f,k,h){if(k===undefined){return}d.add("sub:"+c,function(){var l=k.toFixed(4);if(f>=0.1){l=k.toFixed(2)}if(f>=1){l=k.toFixed(0)}var m=prompt("Enter value of "+c,l);if(m==null){return}var m=parseFloat(m);if(!isNaN(m)){h.bind(this)((f>=1)?Math.round(m):m)}});for(var e=g;e<=i;e+=f){var j=e.toFixed(2);if(f>=0.1){j=e.toFixed(1)}if(f>=1){j=e.toFixed(0)}d.addchk((Math.abs(k-e)<f/2),j,e,h)}d.add("endsub:")};a.TObjectPainter.prototype.FillAttContextMenu=function(h,g){if(!g){g=""}if(this.lineatt&&this.lineatt.used){h.add("sub:"+g+"Line att");this.AddSizeMenuEntry(h,"width",1,10,1,this.lineatt.width,function(k){this.lineatt.width=parseInt(k);this.Redraw()}.bind(this));this.AddColorMenuEntry(h,"color",this.lineatt.color,function(k){this.lineatt.color=k;this.Redraw()}.bind(this));h.add("sub:style",function(){var k=prompt("Enter line style id (1-solid)",1);if(k==null){return}k=parseInt(k);if(isNaN(k)||(a.Painter.root_line_styles[k]===undefined)){return}this.lineatt.dash=a.Painter.root_line_styles[k];this.Redraw()}.bind(this));for(var j=1;j<11;++j){var f=a.Painter.root_line_styles[j];var d="<svg width='100' height='18'><text x='1' y='12' style='font-size:12px'>"+j+"</text><line x1='30' y1='8' x2='100' y2='8' stroke='black' stroke-width='3' stroke-dasharray='"+f+"'></line></svg>";h.addchk((this.lineatt.dash==f),d,f,function(k){this.lineatt.dash=k;this.Redraw()}.bind(this))}h.add("endsub:");h.add("endsub:");if(("excl_side" in this.lineatt)&&(this.lineatt.excl_side!==0)){h.add("sub:Exclusion");h.add("sub:side");for(var e=-1;e<=1;++e){h.addchk((this.lineatt.excl_side==e),e,e,function(k){this.lineatt.excl_side=parseInt(k);if((this.lineatt.excl_width===0)&&(this.lineatt.excl_side!=0)){this.lineatt.excl_width=20}this.Redraw()}.bind(this))}h.add("endsub:");this.AddSizeMenuEntry(h,"width",10,100,10,this.lineatt.excl_width,function(k){this.lineatt.excl_width=parseInt(k);this.Redraw()}.bind(this));h.add("endsub:")}}if(this.fillatt&&this.fillatt.used){h.add("sub:"+g+"Fill att");this.AddColorMenuEntry(h,"color",this.fillatt.colorindx,function(k){this.fillatt.Change(parseInt(k),undefined,this.svg_canvas());this.Redraw()}.bind(this),this.fillatt.kind);h.add("sub:style",function(){var k=prompt("Enter fill style id (1001-solid, 3000..3010)",this.fillatt.pattern);if(k==null){return}k=parseInt(k);if(isNaN(k)){return}this.fillatt.Change(undefined,k,this.svg_canvas());this.Redraw()}.bind(this));var c=[1,1001,3001,3002,3003,3004,3005,3006,3007,3010,3021,3022];var i=a.clone(this.fillatt);if(i.colorindx<=0){i.colorindx=1}for(var j=0;j<c.length;++j){i.Change(undefined,c[j],this.svg_canvas());var d="<svg width='100' height='18'><text x='1' y='12' style='font-size:12px'>"+c[j].toString()+"</text><rect x='40' y='0' width='60' height='18' stroke='none' fill='"+i.color+"'></rect></svg>";h.addchk(this.fillatt.pattern==c[j],d,c[j],function(k){this.fillatt.Change(undefined,parseInt(k),this.svg_canvas());this.Redraw()}.bind(this))}h.add("endsub:");h.add("endsub:")}if(this.markeratt&&this.markeratt.used){h.add("sub:"+g+"Marker att");this.AddColorMenuEntry(h,"color",this.markeratt.color,function(k){this.markeratt.Change(k);this.Redraw()}.bind(this));this.AddSizeMenuEntry(h,"size",0.5,6,0.5,this.markeratt.size,function(k){this.markeratt.Change(undefined,undefined,parseFloat(k));this.Redraw()}.bind(this));h.add("sub:style");var c=[1,2,3,4,5,6,7,8,21,22,23,24,25,26,27,28,29,30,31,32,33,34];var i=a.clone(this.markeratt);for(var j=0;j<c.length;++j){i.Change(undefined,c[j],1.7);i.reset_pos();var d="<svg width='60' height='18'><text x='1' y='12' style='font-size:12px'>"+c[j].toString()+"</text><path stroke='black' fill='"+(i.fill?"black":"none")+"' d='"+i.create(40,8)+"'></path></svg>";h.addchk(this.markeratt.style==c[j],d,c[j],function(k){this.markeratt.Change(undefined,parseInt(k));this.Redraw()}.bind(this))}h.add("endsub:");h.add("endsub:")}};a.TObjectPainter.prototype.TextAttContextMenu=function(g,e){var f=this.GetObject();if(!f||!("fTextColor" in f)){return}g.add("sub:"+(e?e:"Text"));this.AddColorMenuEntry(g,"color",f.fTextColor,function(j){this.GetObject().fTextColor=parseInt(j);this.Redraw()}.bind(this));var i=[11,12,13,21,22,23,31,32,33],d=["left","centered","right"],c=["bottom","centered","top"];g.add("sub:align");for(var h=0;h<i.length;++h){g.addchk(i[h]==f.fTextAlign,i[h],i[h],function(j){this.GetObject().fTextAlign=parseInt(j);this.Redraw()}.bind(this))}g.add("endsub:");g.add("sub:font");for(var h=1;h<16;++h){g.addchk(h==Math.floor(f.fTextFont/10),h,h,function(j){this.GetObject().fTextFont=parseInt(j)*10+2;this.Redraw()}.bind(this))}g.add("endsub:");g.add("endsub:")};a.TObjectPainter.prototype.FillContextMenu=function(d){var c=this.GetTipName();if(this.GetObject()&&("_typename" in this.GetObject())){c=this.GetObject()._typename+"::"+c}d.add("header:"+c);this.FillAttContextMenu(d);return d.size()>0};a.TObjectPainter.prototype.FindInPrimitives=function(f){var d=this.pad_painter(true);if((d===null)||(d.pad===null)){return null}if(d.pad.fPrimitives!==null){for(var e=0;e<d.pad.fPrimitives.arr.length;++e){var c=d.pad.fPrimitives.arr[e];if(("fName" in c)&&(c.fName===f)){return c}}}return null};a.TObjectPainter.prototype.FindPainterFor=function(d,g){var c=this.pad_painter(true);var f=(c===null)?null:c.painters;if(f===null){return null}for(var h=0;h<f.length;++h){var e=f[h].GetObject();if(e===null){continue}if(d&&(e===d)){return f[h]}if(g&&("fName" in e)&&(e.fName==g)){return f[h]}}return null};a.TObjectPainter.prototype.ConfigureUserTooltipCallback=function(d,c){if((d===undefined)||(typeof d!=="function")){delete this.UserTooltipCallback;return}if(c===undefined){c=500}this.UserTooltipCallback=d;this.UserTooltipTimeout=c};a.TObjectPainter.prototype.IsUserTooltipCallback=function(){return typeof this.UserTooltipCallback=="function"};a.TObjectPainter.prototype.ProvideUserTooltip=function(c){if(!this.IsUserTooltipCallback()){return}if(this.UserTooltipTimeout<=0){return this.UserTooltipCallback(c)}if(typeof this.UserTooltipTHandle!="undefined"){clearTimeout(this.UserTooltipTHandle);delete this.UserTooltipTHandle}if(c==null){return this.UserTooltipCallback(c)}this.UserTooltipTHandle=setTimeout(function(e){delete this.UserTooltipTHandle;this.UserTooltipCallback(e)}.bind(this,c),this.UserTooltipTimeout)};a.TObjectPainter.prototype.Redraw=function(){};a.TObjectPainter.prototype.StartTextDrawing=function(e,c,f){if(!f){f=this.draw_g}var d=a.Painter.getFontDetails(e,c);f.call(d.func);f.property("text_font",d);f.property("mathjax_use",false);f.property("text_factor",0);f.property("max_text_width",0)};a.TObjectPainter.prototype.TextScaleFactor=function(d,c){if(!c){c=this.draw_g}if(d&&(d>c.property("text_factor"))){c.property("text_factor",d)}};a.TObjectPainter.prototype.GetBoundarySizes=function(e){if(e===null){console.warn("empty node in GetBoundarySizes");return{width:0,height:0}}var d=e.getBoundingClientRect();if(parseInt(d.width)>0){d=e.getBBox()}var c={width:parseInt(d.width),height:parseInt(d.height)};if("left" in d){c.x=parseInt(d.left);c.y=parseInt(d.right)}else{if("x" in d){c.x=parseInt(d.x);c.y=parseInt(d.y)}}return c};a.TObjectPainter.prototype.FinishTextDrawing=function(l,i){if(!l){l=this.draw_g}var d=this;var k=null;if(l.property("mathjax_use")){l.property("mathjax_use",false);var g=false;k=l.selectAll(".math_svg");k.each(function(){var m=b.select(this);if(m.node().parentNode!==l.node()){return}var f=m.property("_element");if(b.select(f).select("svg").empty()){g=true}});if(g){a.AssertPrerequisites("mathjax",function(){if(typeof MathJax=="object"){MathJax.Hub.Queue(["FinishTextDrawing",d,l,i])}});return null}}if(k==null){k=l.selectAll(".math_svg")}var j=this,c=0;var h=l.property("text_factor");if((h>0)&&((h<0.9)||(h>1))){var e=l.property("text_font");e.size=Math.floor(e.size/h);l.call(e.func)}k.each(function(){var o=b.select(this);if(o.node().parentNode!==l.node()){return}var n=o.property("_element"),f=o.property("_rotate");o.property("_element",null);var p=b.select(n).select("svg");if(p.empty()){a.console("MathJax SVG ouptut error");return}p.remove();document.body.removeChild(n);o.append(function(){return p.node()});if(o.property("_scale")){var m=j.GetBoundarySizes(o.node());c=Math.max(c,1.05*m.width/o.property("_width"),1.05*m.height/o.property("_height"))}});k.each(function(){var z=b.select(this);if(z.node().parentNode!==l.node()){return}if(c>0){var n=z.select("svg");var w=n.attr("width"),t=n.attr("height");if((typeof w=="string")&&(typeof t=="string")&&(w.indexOf("ex")>0)&&(t.indexOf("ex")>0)){w=parseFloat(w.substr(0,w.length-2));t=parseFloat(t.substr(0,t.length-2));if((w>0)&&(t>0)){n.attr("width",(w/c).toFixed(2)+"ex");n.attr("height",(t/c).toFixed(2)+"ex")}}else{a.console("Fail to downscale MathJax output")}}var r=j.GetBoundarySizes(z.node()),u=z.property("_align"),p=z.property("_rotate"),o=z.property("_width"),x=z.property("_height"),v={x:z.property("_x"),y:z.property("_y")};var f={x:1,y:1},s="x",q="y";if(p==180){f.x=f.y=-1}else{if((p==270)||(p==90)){f.x=(p===270)?-1:1;f.y=-f.x;s="y";q="x"}}if(!z.property("_scale")){o=x=0}if(u[0]=="middle"){v[s]+=f.x*(o-r.width)/2}else{if(u[0]=="end"){v[s]+=f.x*(o-r.width)}}if(u[1]=="middle"){v[q]+=f.y*(x-r.height)/2}else{if(u[1]=="bottom"){v[q]+=f.y*(x-r.height)}}var y="translate("+v.x+","+v.y+")";if(p!==0){y+=" rotate("+p+",0,0)"}z.attr("transform",y).attr("visibility",null)});l.selectAll(".hidden_text").attr("opacity","1").classed("hidden_text",false);a.CallBack(i);return l.property("max_text_width")};a.TObjectPainter.prototype.DrawText=function(q,m,k,n,v,i,z,o,A){if(!A){A=this.draw_g}var s;if(typeof q=="string"){s=q.split(";");if(s.length==1){s.push("middle")}}else{s=["start","middle"];if((q/10)>=3){s[0]="end"}else{if((q/10)>=2){s[0]="middle"}}if((q%10)==0){s[1]="bottom"}else{if((q%10)==1){s[1]="bottom"}else{if((q%10)==3){s[1]="top"}}}}var B=(n>0)&&(v>0);if(o==null){o=1}if(o<2){if(!a.Painter.isAnyLatex(i)){o=0}}var u=((a.gStyle.MathJax<1)&&(o!==2))||(o<1);if(u){if(o>0){i=a.Painter.translateLaTeX(i)}var d=m.toFixed(1),c=k.toFixed(1),j=null,f=false;if(n>0){if(s[0]=="middle"){d=(m+n*0.5).toFixed(1)}else{if(s[0]=="end"){d=(m+n).toFixed(1)}}}if(v>0){if(s[1]=="bottom"){c=(k+v).toFixed(1)}else{if(s[1]=="top"){j=".8em"}else{c=(k+v/2).toFixed(1);if(a.browser.isIE){j=".4em"}else{f=true}}}}else{if(s[1]=="top"){j=".8em"}else{if(s[1]=="middle"){if(a.browser.isIE){j=".4em"}else{f=true}}}}var g="translate("+d+","+c+")";if(!B&&(v<0)){g+=" rotate("+(-v)+",0,0)"}var p=A.append("text").attr("text-anchor",s[0]).attr("x",0).attr("y",0).attr("fill",z?z:null).attr("transform",g).text(i);if(j!=null){p.attr("dy",j)}if(f){p.attr("dominant-baseline","middle")}var l=this.GetBoundarySizes(p.node());if(B){p.classed("hidden_text",true).attr("opacity","0")}if(l.width>A.property("max_text_width")){A.property("max_text_width",l.width)}if((n>0)&&B){this.TextScaleFactor(1.05*l.width/n,A)}if((v>0)&&B){this.TextScaleFactor(1*l.height/v,A)}return l.width}n=Math.round(n);v=Math.round(v);m=Math.round(m);k=Math.round(k);var t=0;if(!B&&v<0){t=Math.abs(v);v=0}var r=A.append("svg:g").attr("class","math_svg").attr("visibility","hidden").property("_x",m).property("_y",k).property("_width",n).property("_height",v).property("_scale",B).property("_rotate",t).property("_align",s);var e=document.createElement("div");b.select(e).style("visibility","hidden").style("overflow","hidden").style("position","absolute").html(a.Painter.translateMath(i,o,z));document.body.appendChild(e);A.property("mathjax_use",true);r.property("_element",e);a.AssertPrerequisites("mathjax",function(){if(typeof MathJax=="object"){MathJax.Hub.Queue(["Typeset",MathJax.Hub,e])}});return 0};a.TFramePainter=function(c){a.TObjectPainter.call(this,c);this.tooltip_enabled=true};a.TFramePainter.prototype=Object.create(a.TObjectPainter.prototype);a.TFramePainter.prototype.Shrink=function(d,c){this.fX1NDC+=d;this.fX2NDC-=c};a.TFramePainter.prototype.Redraw=function(){var x=this.pad_width(),v=this.pad_height(),D=this.GetObject(),J=this.root_pad(),t=this.createAttFill(null,1001,0),I=a.Painter.createAttLine("black"),j=0,l=0,s=("fX1NDC" in this);if(!s){if(J===null){a.extend(this,a.gStyle.FrameNDC)}else{a.extend(this,{fX1NDC:J.fLeftMargin,fX2NDC:1-J.fRightMargin,fY1NDC:J.fTopMargin,fY2NDC:1-J.fBottomMargin})}}if(D!==null){j=D.fBorderMode;l=D.fBorderSize;I=a.Painter.createAttLine(D);t=this.createAttFill(D);if(!s&&(J!==null)){var E=x/Math.abs(J.fX2-J.fX1),o=v/Math.abs(J.fY2-J.fY1),B=(D.fX1-J.fX1)*E,e=(D.fY1-J.fY1)*o,A=(D.fX2-J.fX1)*E,d=(D.fY2-J.fY1)*o,r,n,F,y;if(B<A){r=B;n=A}else{r=A;n=B}if(e<d){F=e;y=d}else{F=d;y=e}this.fX1NDC=r/x;this.fY1NDC=F/v;this.fX2NDC=n/x;this.fY2NDC=y/v}}else{if(J){t=this.createAttFill(null,J.fFrameFillStyle,J.fFrameFillColor)}}if(t.color=="none"){t.color="white"}if(this.fillatt===undefined){this.fillatt=t}if(this.lineatt===undefined){this.lineatt=I}var p=Math.round(x*this.fX1NDC),q=Math.round(x*(this.fX2NDC-this.fX1NDC)),i=Math.round(v*(1-this.fY2NDC)),C=Math.round(v*(this.fY2NDC-this.fY1NDC));this.draw_g=this.svg_frame();if(this.draw_g.empty()){return console.error("did not found frame layer")}var k=this.draw_g.select("rect"),g=this.draw_g.select(".main_layer");if(g.empty()){this.draw_g.append("svg:title").text("");k=this.draw_g.append("svg:rect");this.draw_g.append("svg:g").attr("class","grid_layer");g=this.draw_g.append("svg:svg").attr("class","main_layer").attr("x",0).attr("y",0).attr("overflow","hidden");this.draw_g.append("svg:g").attr("class","axis_layer");this.draw_g.append("svg:g").attr("class","upper_layer")}this.draw_g.property("frame_painter",this);this.draw_g.attr("x",p).attr("y",i).attr("width",q).attr("height",C).property("draw_x",p).property("draw_y",i).property("draw_width",q).property("draw_height",C).attr("transform","translate("+p+","+i+")");k.attr("x",0).attr("y",0).attr("width",q).attr("height",C).call(this.fillatt.func).call(this.lineatt.func);g.attr("width",q).attr("height",C).attr("viewBox","0 0 "+q+" "+C);this.AddDrag({obj:this,only_resize:true,redraw:this.RedrawPad.bind(this)});var u=this.draw_g.select(".interactive_rect");if(a.gStyle.Tooltip===0){return u.remove()}var G=this;function H(){var h=b.mouse(u.node());G.ProcessTooltipEvent({x:h[0],y:h[1],touch:false})}function m(){G.ProcessTooltipEvent(null)}function z(){var h=b.touches(u.node());if(!h||h.length!==1){return G.ProcessTooltipEvent(null)}G.ProcessTooltipEvent({x:h[0][0],y:h[0][1],touch:true})}function f(){G.ProcessTooltipEvent(null)}if(u.empty()){u=this.draw_g.append("rect").attr("class","interactive_rect").style("opacity","0").style("fill","none").style("pointer-events","visibleFill").on("mouseenter",H).on("mousemove",H).on("mouseleave",m);if(a.touches){u.on("touchstart",z).on("touchmove",z).on("touchend",f).on("touchcancel",f)}}u.attr("x",0).attr("y",0).attr("width",q).attr("height",C);var c=this.svg_layer("stat_layer").select(".objects_hints");if(!c.empty()&&(a.gStyle.Tooltip>0)){setTimeout(this.ProcessTooltipEvent.bind(this,c.property("last_point")),10)}};a.TFramePainter.prototype.FillContextMenu=function(e){var c=this.main_painter(),d=e.size()==0;if(d){e.add("header:Frame")}else{e.add("separator")}if(c){if(c.zoom_xmin!==c.zoom_xmax){e.add("Unzoom X",c.Unzoom.bind(c,"x"))}if(c.zoom_ymin!==c.zoom_ymax){e.add("Unzoom Y",c.Unzoom.bind(c,"y"))}if(c.zoom_zmin!==c.zoom_zmax){e.add("Unzoom Z",c.Unzoom.bind(c,"z"))}e.add("Unzoom all",c.Unzoom.bind(c,"xyz"));if(c.options){e.addchk(c.options.Logx,"SetLogx",c.ToggleLog.bind(c,"x"));e.addchk(c.options.Logy,"SetLogy",c.ToggleLog.bind(c,"y"));if(c.Dimension()==2){e.addchk(c.options.Logz,"SetLogz",c.ToggleLog.bind(c,"z"))}}e.add("separator")}e.addchk(this.tooltip_enabled,"Show tooltips",function(){this.tooltip_enabled=!this.tooltip_enabled}.bind(this));this.FillAttContextMenu(e,d?"":"Frame ");e.add("separator");e.add("Save as frame.png",function(f){var g=this.svg_frame();if(!g.empty()){a.AssertPrerequisites("savepng",function(){saveSvgAsPng(g.node(),"frame.png")})}}.bind(this));return true};a.TFramePainter.prototype.IsTooltipShown=function(){if(a.gStyle.Tooltip<1){return false}return !(this.svg_layer("stat_layer").select(".objects_hints").empty())};a.TFramePainter.prototype.ProcessTooltipEvent=function(J,m){if(m!==undefined){this.tooltip_enabled=m}if((J===undefined)||(a.gStyle.Tooltip<1)||!this.tooltip_enabled){J=null}var D=[],e=0,I=0,x=0,d=false,t=11,i=3,k=3,p=1.2,w=this.frame_height(),z=this.frame_width(),F=this.pad_painter(true);if(F!==null){D=F.GetTooltips(J)}if(J&&J.touch){t=15}D.forEach(function(r){if(r===null){return}e++;for(var n=0;n<r.lines.length;++n){I=Math.max(I,r.lines[n].length)}r.height=r.lines.length*t*p+2*i-t*(p-1);if((r.color1!==undefined)&&(r.color1!=="none")){if((x!==0)&&(x!==r.color1)){d=true}x=r.color1}});var L=this.svg_layer("stat_layer"),c=L.select(".objects_hints");if((J===null)||(D.length===0)||(I===0)){c.remove();return}if(c.empty()){c=L.append("svg:g").attr("class","objects_hints").style("pointer-events","none")}c.attr("transform",this.draw_g.attr("transform"));c.property("last_point",J);var K=c.property("viewmode");if(K===undefined){K=""}var E=0,B=J.x+15;if(e>1){var A=0.5,H=0.5;if(K=="left"){H=0.7}else{if(K=="right"){A=0.3}}if(J.x<=A*z){K="left";B=20}else{if(J.x>=H*z){K="right";B=z-100}else{B=c.property("startx")}}}else{K="single"}if(K!==c.property("viewmode")){c.property("viewmode",K);c.selectAll("*").remove()}var v=a.Painter.getFontDetails(160,t);var G=10;for(var y=0;y<D.length;++y){var s=D[y];var j=c.select(".painter_hint_"+y);if(s===null){j.remove();continue}var h=j.empty();if(h){j=c.append("svg:svg").attr("class","painter_hint_"+y).style("overflow","hidden").attr("opacity","0").style("pointer-events","none")}if(K=="single"){G=J.touch?J.y-D[y].height-5:J.y+15}j.attr("x",B).attr("y",G);G+=D[y].height+5;if(!h){j.selectAll("*").remove()}j.attr("width",100).attr("height",s.height);var u=j.append("rect").attr("x",0).attr("y",0).attr("width",100).attr("height",s.height).attr("fill","lightgrey").style("pointer-events","none");if(e>1){var g=d?s.color1:s.color2;if((g!==undefined)&&(g!=="none")){u.attr("stroke",g).attr("stroke-width",s.exact?3:1)}}if(s.lines!=null){for(var C=0;C<s.lines.length;C++){if(s.lines[C]!==null){var q=j.append("svg:text").attr("text-anchor","start").attr("x",k).attr("y",i+C*t*p).attr("dy",".8em").attr("fill","black").style("pointer-events","none").call(v.func).text(s.lines[C]);var o=this.GetBoundarySizes(q.node());E=Math.max(E,o.width)}}}function f(){return function(r,n,l){return function(M){return M<0.8?"0":(M-0.8)*5}}}if(h){j.transition().duration(500).attrTween("opacity",f())}}E+=2*k;if((K=="right")&&(B+E>z)){B=z-E-20;c.selectAll("svg").attr("x",B)}if(E>10){c.selectAll("svg").attr("width",E).select("rect").attr("width",E)}c.property("startx",B)};a.Painter.drawFrame=function(e,d){var c=new a.TFramePainter(d);c.SetDivId(e,2);c.Redraw();return c.DrawingReady()};a.TPavePainter=function(c){a.TObjectPainter.call(this,c);this.Enabled=true;this.UseContextMenu=true;this.UseTextColor=false};a.TPavePainter.prototype=Object.create(a.TObjectPainter.prototype);a.TPavePainter.prototype.DrawPave=function(g){this.UseTextColor=false;if(!this.Enabled){return this.RemoveDrawG()}var i=this.GetObject();if(i.fInit===0){i.fInit=1;var h=this.root_pad();if(i.fOption.indexOf("NDC")>=0){i.fX1NDC=i.fX1;i.fX2NDC=i.fX2;i.fY1NDC=i.fY1;i.fY2NDC=i.fY2}else{if(h!==null){if(h.fLogx){if(i.fX1>0){i.fX1=a.log10(i.fX1)}if(i.fX2>0){i.fX2=a.log10(i.fX2)}}if(h.fLogy){if(i.fY1>0){i.fY1=a.log10(i.fY1)}if(i.fY2>0){i.fY2=a.log10(i.fY2)}}i.fX1NDC=(i.fX1-h.fX1)/(h.fX2-h.fX1);i.fY1NDC=(i.fY1-h.fY1)/(h.fY2-h.fY1);i.fX2NDC=(i.fX2-h.fX1)/(h.fX2-h.fX1);i.fY2NDC=(i.fY2-h.fY1)/(h.fY2-h.fY1)}else{i.fX1NDC=i.fY1NDC=0.1;i.fX2NDC=i.fY2NDC=0.9}}}var e=Math.round(i.fX1NDC*this.pad_width()),d=Math.round((1-i.fY2NDC)*this.pad_height()),f=Math.round((i.fX2NDC-i.fX1NDC)*this.pad_width()),c=Math.round((i.fY2NDC-i.fY1NDC)*this.pad_height()),j=i.fBorderSize;this.RecreateDrawG(true,this.IsStats()?"stat_layer":"text_layer");this.draw_g.attr("x",e).attr("y",d).attr("width",f).attr("height",c).attr("transform","translate("+e+","+d+")");if((j>1)&&(i.fShadowColor>0)){this.draw_g.append("svg:path").attr("d","M"+f+","+c+" v"+(-c+j)+" h"+j+" v"+c+" h"+(-f)+" v"+(-j)+" Z").style("fill",a.Painter.root_colors[i.fShadowColor]).style("stroke",a.Painter.root_colors[i.fShadowColor]).style("stroke-width","1px")}if(this.lineatt===undefined){this.lineatt=a.Painter.createAttLine(i,j>0?1:0)}if(this.fillatt===undefined){this.fillatt=this.createAttFill(i)}this.draw_g.append("rect").attr("x",0).attr("y",0).attr("width",f).attr("height",c).style("pointer-events","visibleFill").call(this.fillatt.func).call(this.lineatt.func);if("PaveDrawFunc" in this){this.PaveDrawFunc(f,c,g)}this.AddDrag({obj:i,redraw:this.DrawPave.bind(this),ctxmenu:a.touches&&a.gStyle.ContextMenu&&this.UseContextMenu});if(this.UseContextMenu&&a.gStyle.ContextMenu){this.draw_g.on("contextmenu",this.ShowContextMenu.bind(this))}};a.TPavePainter.prototype.DrawPaveLabel=function(e,c){this.UseTextColor=true;var d=this.GetObject();this.StartTextDrawing(d.fTextFont,c/1.2);this.DrawText(d.fTextAlign,0,0,e,c,d.fLabel,a.Painter.root_colors[d.fTextColor]);this.FinishTextDrawing()};a.TPavePainter.prototype.DrawPaveText=function(A,q,e){if(e&&this.IsStats()){this.FillStatistic()}var u=this.GetObject(),J=a.Painter.root_colors[u.fTextColor],H=u.fBorderSize,I=0,F=0,p=u.fLines.arr.length,d=[],G=0;for(var D=0;D<p;++D){var o=u.fLines.arr[D].fTitle;d.push(o);if(D>0){G=Math.max(G,o.length)}if(!this.IsStats()||(D==0)||(o.indexOf("|")<0)){continue}if(I===0){I=D}var z=o.split("|");if(z.length>F){F=z.length}}var v=q/p,g=false,K=u.fMargin*A;this.StartTextDrawing(u.fTextFont,q/(p*1.2));if(p==1){this.DrawText(u.fTextAlign,0,0,A,q,d[0],J);this.UseTextColor=true}else{for(var D=0;D<p;++D){var t=D*v,C=a.Painter.root_colors[u.fLines.arr[D].fTextColor];if((u.fLines.arr[D].fTextColor==0)||(C===undefined)){C=J;this.UseTextColor=true}if(this.IsStats()){if((I>0)&&(D>=I)){var z=d[D].split("|");for(var s=0;s<z.length;++s){this.DrawText("middle",A*s/F,t,A/F,v,z[s],C)}}else{if(d[D].indexOf("=")<0){if(D==0){g=true;if(d[D].length>G+5){d[D]=d[D].substr(0,G+2)+"..."}}this.DrawText((D==0)?"middle":"start",K,t,A-2*K,v,d[D],C)}else{var z=d[D].split("="),k=0;for(var s=0;s<2;++s){k+=this.DrawText((s==0)?"start":"end",K,t,A-2*K,v,z[s],C)}this.TextScaleFactor(1.05*k/(A-2*K),this.draw_g)}}}else{this.DrawText(u.fTextAlign,K,t,A-2*K,v,d[D],C)}}}var c=this.FinishTextDrawing();if((H>0)&&g){this.draw_g.append("svg:line").attr("x1",0).attr("y1",v.toFixed(1)).attr("x2",A).attr("y2",v.toFixed(1)).call(this.lineatt.func)}if((I>0)&&(F>1)){for(var B=I;B<p;++B){this.draw_g.append("svg:line").attr("x1",0).attr("y1",(B*v).toFixed(1)).attr("x2",A).attr("y2",(B*v).toFixed(1)).call(this.lineatt.func)}for(var r=0;r<F-1;++r){this.draw_g.append("svg:line").attr("x1",(A/F*(r+1)).toFixed(1)).attr("y1",(I*v).toFixed(1)).attr("x2",(A/F*(r+1)).toFixed(1)).attr("y2",q).call(this.lineatt.func)}}if((u.fLabel.length>0)&&!this.IsStats()){var l=Math.round(A*0.25),i=Math.round(-q*0.02),m=Math.round(A*0.5),E=Math.round(q*0.04);var f=this.draw_g.append("svg:g");f.append("rect").attr("x",l).attr("y",i).attr("width",m).attr("height",E).call(this.fillatt.func).call(this.lineatt.func);this.StartTextDrawing(u.fTextFont,E/1.5,f);this.DrawText(22,l,i,m,E,u.fLabel,J,1,f);this.FinishTextDrawing(f);this.UseTextColor=true}};a.TPavePainter.prototype.Format=function(f,c){if(!c){c="stat"}var e=this.GetObject();if(c=="stat"){c=e.fStatFormat;if(!c){c=a.gStyle.StatFormat}}else{if(c=="fit"){c=e.fFitFormat;if(!c){c=a.gStyle.FitFormat}}else{if(c=="entries"){if(f<1000000000){return f.toFixed(0)}c="14.7g"}else{if(c=="last"){c=this["lastformat"]}}}}delete this["lastformat"];if(!c){c="6.4g"}var d=a.FFormat(f,c);this["lastformat"]=a.lastFFormat;return d};a.TPavePainter.prototype.ShowContextMenu=function(e){if(!e){b.event.stopPropagation();b.event.preventDefault();e=b.event}var c=this,d=this.GetObject();a.Painter.createMenu(function(g){g.painter=c;g.add("header: "+d._typename+"::"+d.fName);if(c.IsStats()){g.add("SetStatFormat",function(){var h=prompt("Enter StatFormat",d.fStatFormat);if(h!=null){d.fStatFormat=h;c.Redraw()}});g.add("SetFitFormat",function(){var h=prompt("Enter FitFormat",d.fFitFormat);if(h!=null){d.fFitFormat=h;c.Redraw()}});g.add("separator");g.add("sub:SetOptStat",function(){var h=prompt("Enter OptStat",d.fOptStat);if(h!=null){d.fOptStat=parseInt(h);c.Redraw()}});function f(j,h){var i=(j<10)?d.fOptStat:d.fOptFit;i=parseInt(parseInt(i)/parseInt(Math.pow(10,j%10)))%10;g.addchk(i,h,i*100+j,function(k){var m=(k%100<10)?d.fOptStat:d.fOptFit;var l=parseInt(k/100);m-=(l>0?l:-1)*parseInt(Math.pow(10,k%10));if(k%100<10){d.fOptStat=m}else{d.fOptFit=m}c.Redraw()})}f(0,"Histogram name");f(1,"Entries");f(2,"Mean");f(3,"Std Dev");f(4,"Underflow");f(5,"Overflow");f(6,"Integral");f(7,"Skewness");f(8,"Kurtosis");g.add("endsub:");g.add("sub:SetOptFit",function(){var h=prompt("Enter OptStat",d.fOptFit);if(h!=null){d.fOptFit=parseInt(h);c.Redraw()}});f(10,"Fit parameters");f(11,"Par errors");f(12,"Chi square / NDF");f(13,"Probability");g.add("endsub:");g.add("separator")}if(c.UseTextColor){c.TextAttContextMenu(g)}c.FillAttContextMenu(g);g.show(e)})};a.TPavePainter.prototype.IsStats=function(){return this.MatchObjectType("TPaveStats")};a.TPavePainter.prototype.FillStatistic=function(){var e=this.GetObject(),c=this.main_painter();if(e.fName!=="stats"){return false}if((c===null)||!("FillStatistic" in c)){return false}if(c.IsDummyHisto()){return true}var d=new Number(e.fOptStat);var f=new Number(e.fOptFit);if(!d){d=a.gStyle.OptStat}if(!f){f=a.gStyle.OptFit}e.Clear();c.FillStatistic(this,d,f);return true};a.TPavePainter.prototype.UpdateObject=function(d){if(!this.MatchObjectType(d)){return false}var c=this.GetObject();if(d._typename==="TPaveText"){c.fLines=a.clone(d.fLines);return true}else{if(d._typename==="TPaveLabel"){c.fLabel=d.fLabel;return true}}return false};a.TPavePainter.prototype.Redraw=function(){this.DrawPave(true)};a.Painter.drawPaveText=function(f,e,d){var c=new a.TPavePainter(e);c.SetDivId(f,2);if((typeof d=="string")&&(d.indexOf("onpad:")==0)){c.pad_name=d.substr(6)}switch(e._typename){case"TPaveLabel":c.PaveDrawFunc=c.DrawPaveLabel;break;case"TPaveStats":case"TPaveText":c.PaveDrawFunc=c.DrawPaveText;break}c.Redraw();return c.DrawingReady()};a.TPadPainter=function(d,c){a.TObjectPainter.call(this,d);this.pad=d;this.iscan=c;this.this_pad_name="";if(!this.iscan&&(d!==null)&&("fName" in d)){this.this_pad_name=d.fName.replace(" ","_")}this.painters=new Array;this.has_canvas=true};a.TPadPainter.prototype=Object.create(a.TObjectPainter.prototype);a.TPadPainter.prototype.ButtonSize=function(c){return Math.round((!c?1:c)*(this.iscan||!this.has_canvas?16:12))};a.TPadPainter.prototype.CreateCanvasSvg=function(f,d){var e=this.select_main();var l=this.main_visible_rect();var m=l.width,g=l.height;if((typeof d=="object")&&(d!==null)&&("width" in d)&&("height" in d)){m=d.width;g=d.height}var k=null,i=null;if(f>0){i=this.svg_canvas();var j=i.property("draw_width"),c=i.property("draw_height");if((m<=0)&&(g<=0)){i.attr("visibility","hidden");return false}else{i.attr("visibility","visible");i.select(".canvas_fillrect").call(this.fillatt.func)}if(f==1){if((j==m)&&(c==g)){return false}}k=i.property("height_factor");if(k!=null){g=Math.round(m*k);e.style("height",g+"px")}if((f==1)&&(j>0)&&(c>0)&&!i.property("redraw_by_resize")){if((m/j>0.66)&&(m/j<1.5)&&(g/c>0.66)&&(g/c<1.5)){return false}}}else{if((g<10)&&(m>0)){k=0.66;if((this.pad!==null)&&("fCw" in this.pad)&&("fCh" in this.pad)&&(this.pad.fCw>0)){k=this.pad.fCh/this.pad.fCw;if((k<0.1)||(k>10)){k=0.66}}g=Math.round(m*k);e.style("height",g+"px")}i=this.select_main().append("svg").attr("class","jsroot root_canvas").property("pad_painter",this).property("mainpainter",null).property("current_pad","").property("redraw_by_resize",false);i.append("svg:title").text("ROOT canvas");i.append("svg:rect").attr("class","canvas_fillrect").attr("x",0).attr("y",0);i.append("svg:g").attr("class","root_frame");i.append("svg:g").attr("class","subpads_layer");i.append("svg:g").attr("class","special_layer");i.append("svg:g").attr("class","text_layer");i.append("svg:g").attr("class","stat_layer");i.append("svg:g").attr("class","btns_layer");this.fillatt=this.createAttFill(this.pad,1001,0);if(a.gStyle.ContextMenu){i.select(".canvas_fillrect").on("contextmenu",this.ShowContextMenu.bind(this))}}if((m<=0)||(g<=0)){i.attr("visibility","hidden");m=200;g=100}else{i.attr("visibility","visible")}i.attr("x",0).attr("y",0).attr("width","100%").attr("height","100%").attr("viewBox","0 0 "+m+" "+g).attr("preserveAspectRatio","none").property("height_factor",k).property("draw_x",0).property("draw_y",0).property("draw_width",m).property("draw_height",g);i.select(".canvas_fillrect").attr("width",m).attr("height",g).call(this.fillatt.func);this.svg_layer("btns_layer").attr("transform","translate(2,"+(g-this.ButtonSize(1.25))+")");return true};a.TPadPainter.prototype.CreatePadSvg=function(m){if(!this.has_canvas){return this.CreateCanvasSvg(m?2:0)}var c=this.svg_canvas().property("draw_width"),l=this.svg_canvas().property("draw_height"),k=Math.round(this.pad.fAbsWNDC*c),g=Math.round(this.pad.fAbsHNDC*l),j=Math.round(this.pad.fAbsXlowNDC*c),i=Math.round(l-this.pad.fAbsYlowNDC*l)-g;var d=null,f=null,e=null;if(m){d=this.svg_pad(this.this_pad_name);f=d.select(".root_pad_border");e=this.svg_layer("btns_layer",this.this_pad_name)}else{d=this.svg_canvas().select(".subpads_layer").append("g").attr("class","root_pad").attr("pad",this.this_pad_name).property("pad_painter",this).property("mainpainter",null);f=d.append("svg:rect").attr("class","root_pad_border");d.append("svg:g").attr("class","root_frame");d.append("svg:g").attr("class","special_layer");d.append("svg:g").attr("class","text_layer");d.append("svg:g").attr("class","stat_layer");e=d.append("svg:g").attr("class","btns_layer").property("nextx",0);if(a.gStyle.ContextMenu){d.select(".root_pad_border").on("contextmenu",this.ShowContextMenu.bind(this))}this.fillatt=this.createAttFill(this.pad,1001,0);this.lineatt=a.Painter.createAttLine(this.pad);if(this.pad.fBorderMode==0){this.lineatt.color="none"}}d.attr("transform","translate("+j+","+i+")").property("draw_x",j).property("draw_y",i).property("draw_width",k).property("draw_height",g);f.attr("x",0).attr("y",0).attr("width",k).attr("height",g).call(this.fillatt.func).call(this.lineatt.func);e.attr("transform","translate("+(k-e.property("nextx")-this.ButtonSize(0.25))+","+(g-this.ButtonSize(1.25))+")")};a.TPadPainter.prototype.CheckColors=function(d){if(d==null){return}for(var c=0;c<d.fPrimitives.arr.length;++c){var e=d.fPrimitives.arr[c];if(e==null){continue}if((e._typename=="TObjArray")&&(e.name=="ListOfColors")){a.Painter.adoptRootColors(e);d.fPrimitives.arr.splice(c,1);d.fPrimitives.opt.splice(c,1);return}}};a.TPadPainter.prototype.RemovePrimitive=function(d){if((this.pad===null)||(this.pad.fPrimitives===null)){return}var c=this.pad.fPrimitives.arr.indexOf(d);if(c>=0){this.pad.fPrimitives.RemoveAt(c)}};a.TPadPainter.prototype.FindPrimitive=function(g,f,c){if((this.pad===null)||(this.pad.fPrimitives===null)){return null}for(var d=0;d<this.pad.fPrimitives.arr.length;d++){var e=this.pad.fPrimitives.arr[d];if((g!==null)&&(e!==g)){continue}if((f!==undefined)&&(f!==null)){if(e._typename!==f){continue}}if((c!==undefined)&&(c!==null)){if(e.fName!==c){continue}}return e}return null};a.TPadPainter.prototype.HasObjectsToDraw=function(){if((this.pad===null)||!this.pad.fPrimitives||(this.pad.fPrimitives.arr.length==0)){return false}for(var c=0;c<this.pad.fPrimitives.arr.length;++c){if(this.pad.fPrimitives.arr[c]&&this.pad.fPrimitives.arr[c]._typename!="TPad"){return true}}return false};a.TPadPainter.prototype.DrawPrimitive=function(d,e){if((this.pad===null)||(d>=this.pad.fPrimitives.arr.length)){return a.CallBack(e)}var c=a.draw(this.divid,this.pad.fPrimitives.arr[d],this.pad.fPrimitives.opt[d]);if(c===null){return this.DrawPrimitive(d+1,e)}c._primitive=true;c.WhenReady(this.DrawPrimitive.bind(this,d+1,e))};a.TPadPainter.prototype.GetTooltips=function(e){var c=[],d=[];if(this.painters!==null){this.painters.forEach(function(f){if("ProcessTooltip" in f){c.push(f)}})}if(e){e.nproc=c.length}c.forEach(function(f){var g=f.ProcessTooltip(e);d.push(g);if(g&&e.painters){g.painter=f}});return d};a.TPadPainter.prototype.ShowContextMenu=function(e){if(!e){var d=b.mouse(this.svg_pad(this.this_pad_name).node());if(d&&(d.length==2)&&(d[0]>0)&&(d[0]<10)&&(d[1]>0)&&d[1]<10){return}b.event.stopPropagation();b.event.preventDefault();e=b.event}var c=this;a.Painter.createMenu(function(f){f.painter=c;if(c.pad){f.add("header: "+c.pad._typename+"::"+c.pad.fName)}else{f.add("header: Canvas")}if(c.iscan){f.addchk((a.gStyle.Tooltip>0),"Show tooltips",function(){a.gStyle.Tooltip=(a.gStyle.Tooltip===0)?1:-a.gStyle.Tooltip})}c.FillAttContextMenu(f);f.add("separator");var g="canvas.png";if(!c.iscan){g=c.this_pad_name+".png"}f.add("Save as "+g,g,function(h){var i=this.svg_pad(this.this_pad_name);if(!i.empty()){a.AssertPrerequisites("savepng",function(){console.log("create",h);i.selectAll(".btns_layer").style("display","none");saveSvgAsPng(i.node(),h);i.selectAll(".btns_layer").style("display","")})}});f.show(e)})};a.TPadPainter.prototype.Redraw=function(c){if(this.iscan){this.CreateCanvasSvg(2)}else{this.CreatePadSvg(true)}for(var d=0;d<this.painters.length;++d){this.painters[d].Redraw(c)}};a.TPadPainter.prototype.NumDrawnSubpads=function(){if(this.painters===undefined){return 0}var c=0;for(var d=0;d<this.painters.length;++d){var e=this.painters[d].GetObject();if((e!==null)&&(e._typename==="TPad")){c++}}return c};a.TPadPainter.prototype.CheckCanvasResize=function(d,e){if(!this.iscan){return false}if((d!==null)&&(typeof d==="object")&&d.force){e=true}var f=this.CreateCanvasSvg(e?2:1,d);if(f){for(var c=0;c<this.painters.length;++c){this.painters[c].Redraw(true)}}return f};a.TPadPainter.prototype.UpdateObject=function(f){if((f==null)||!("fPrimitives" in f)){return false}if(this.iscan){this.CheckColors(f)}if(f.fPrimitives.arr.length!==this.pad.fPrimitives.arr.length){return false}var d=false,e=0;for(var g=0;g<f.fPrimitives.arr.length;++g){while(e<this.painters.length){var c=this.painters[e++];if(!("_primitive" in c)){continue}if(c.UpdateObject(f.fPrimitives.arr[g])){d=true}break}}return d};a.TPadPainter.prototype.ItemContextMenu=function(d){var g=this.svg_pad(this.this_pad_name).node().getBoundingClientRect();var h={clientX:g.left+10,clientY:g.top+10};if(d=="pad"){return setTimeout(this.ShowContextMenu.bind(this,h),50)}var c=null,f;switch(d){case"xaxis":c=this.main_painter();f="x";break;case"yaxis":c=this.main_painter();f="y";break;case"frame":c=this.frame_painter();break;default:var e=parseInt(d);if(!isNaN(e)){c=this.painters[e]}}if(!c||(typeof c.FillContextMenu!=="function")){return}a.Painter.createMenu(function(i){i.painter=c;if(c.FillContextMenu(i,f)){setTimeout(i.show.bind(i,h),50)}})};a.TPadPainter.prototype.PadButtonClick=function(g){var f=null,c="";if(g=="CanvasSnapShot"){f=this.svg_canvas();c=(this.pad?this.pad.fName:"jsroot_canvas")+".png"}else{if(g=="PadSnapShot"){f=this.svg_pad(this.this_pad_name);c=this.this_pad_name+".png"}}if((f!==null)&&!f.empty()){var h=f.property("mainpainter");if((f.property("can3d")===1)&&(h!==undefined)&&(h.renderer!==undefined)){var l=h.renderer.domElement.toDataURL("image/png");l.replace("image/png","image/octet-stream");var m=document.createElement("a");if(typeof m.download==="string"){document.body.appendChild(m);m.download=c;m.href=l;m.click();document.body.removeChild(m)}}else{a.AssertPrerequisites("savepng",function(){f.selectAll(".btns_layer").style("display","none");saveSvgAsPng(f.node(),c);f.selectAll(".btns_layer").style("display","")})}return}if(g=="PadContextMenus"){var d=this,n=b.event;b.event.preventDefault();b.event.stopPropagation();a.Painter.createMenu(function(r){r.painter=d;r.add("header:Menus");if(d.iscan){r.add("Canvas","pad",d.ItemContextMenu)}else{r.add("Pad","pad",d.ItemContextMenu)}if(d.frame_painter()){r.add("Frame","frame",d.ItemContextMenu)}if(d.main_painter()){r.add("X axis","xaxis",d.ItemContextMenu);r.add("Y axis","yaxis",d.ItemContextMenu)}if(d.painters&&(d.painters.length>0)){r.add("separator");var p=[];for(var s=0;s<d.painters.length;++s){var i=d.painters[s];var q=i?i.GetObject():null;if(!q||(p.indexOf(q)>=0)){continue}var o=("_typename" in q)?(q._typename+"::"):"";if("fName" in q){o+=q.fName}if(o.length==0){o="item"+s}r.add(o,s,d.ItemContextMenu)}}r.show(n)});return}var j=false;for(var k=0;k<this.painters.length;++k){var e=this.painters[k];if(typeof e.PadButtonClick=="function"){e.PadButtonClick(g)}if(!j&&(typeof e.ButtonClick=="function")){j=e.ButtonClick(g)}}};a.TPadPainter.prototype.AddButton=function(c,k,f){if(!a.gStyle.ToolBar){return}var i=this.svg_layer("btns_layer",this.this_pad_name);if(i.empty()){return}if(!i.select("[name="+f+"]").empty()){return}var h=i.property("nextx");if(h===undefined){h=0}var j=this.iscan||!this.has_canvas;var g=i.append("svg:svg").attr("class","svg_toolbar_btn").attr("name",f).attr("x",h).attr("y",0).attr("width",this.ButtonSize()+"px").attr("height",this.ButtonSize()+"px").attr("viewBox","0 0 512 512").style("overflow","hidden");g.append("svg:title").text(k+(j?"":(" on pad "+this.this_pad_name)));if("recs" in c){var e={};for(var d=0;d<c.recs.length;++d){a.extend(e,c.recs[d]);g.append("rect").attr("x",e.x).attr("y",e.y).attr("width",e.w).attr("height",e.h).attr("fill",e.f)}}else{g.append("svg:path").attr("d",c.path)}g.append("svg:rect").attr("x",0).attr("y",0).attr("width",512).attr("height",512).style("opacity","0").style("fill","none").style("pointer-events","visibleFill");g.on("click",this.PadButtonClick.bind(this,f));i.property("nextx",h+this.ButtonSize(1.25));if(!j){i.attr("transform","translate("+(this.pad_width(this.this_pad_name)-i.property("nextx")-this.ButtonSize(0.25))+","+(this.pad_height(this.this_pad_name)-this.ButtonSize(1.25))+")")}if(!j&&(f.indexOf("Pad")!=0)&&(this.pad_painter()!==this)){this.pad_painter().AddButton(c,k,f)}};a.Painter.drawCanvas=function(f,e,d){var c=new a.TPadPainter(e,true);if(e&&d&&(d.indexOf("white")>=0)){e.fFillColor=0}c.SetDivId(f,-1);c.CheckColors(e);c.CreateCanvasSvg(0);c.SetDivId(f);c.AddButton(a.ToolbarIcons.camera,"Create PNG","CanvasSnapShot");c.AddButton(a.ToolbarIcons.question,"Access context menus","PadContextMenus");if(e==null){if(d.indexOf("noframe")<0){a.Painter.drawFrame(f,null)}return c.DrawingReady()}c.DrawPrimitive(0,function(){c.DrawingReady()});return c};a.Painter.drawPad=function(g,f,d){var c=new a.TPadPainter(f,false);if(f&&d&&(d.indexOf("white")>=0)){f.fFillColor=0}c.SetDivId(g);if(c.svg_canvas().empty()){c.has_canvas=false;c.this_pad_name=""}c.CreatePadSvg();if(c.MatchObjectType("TPad")&&(!c.has_canvas||c.HasObjectsToDraw())){c.AddButton(a.ToolbarIcons.camera,"Create PNG","PadSnapShot");c.AddButton(a.ToolbarIcons.question,"Access context menus","PadContextMenus")}var e="";if(c.has_canvas){e=c.svg_canvas().property("current_pad");c.svg_canvas().property("current_pad",f.fName)}c.DrawPrimitive(0,function(){c.svg_canvas().property("current_pad",e);c.DrawingReady()});return c};a.TAxisPainter=function(d,c){a.TObjectPainter.call(this,d);this.embedded=c;this.name="yaxis";this.kind="normal";this.func=null;this.order=0;this.full_min=0;this.full_max=1;this.scale_min=0;this.scale_max=1;this.ticks=[]};a.TAxisPainter.prototype=Object.create(a.TObjectPainter.prototype);a.TAxisPainter.prototype.SetAxisConfig=function(e,g,h,f,d,c,i){this.name=e;this.kind=g;this.func=h;this.full_min=f;this.full_max=d;this.scale_min=c;this.scale_max=i};a.TAxisPainter.prototype.CreateFormatFuncs=function(){var e=this.GetObject(),d=(e&&e._typename==="TGaxis");delete this.format;var i=508;if(e!==null){i=Math.max(d?e.fNdiv:e.fNdivisions,4)}this.nticks=i%100;this.nticks2=(i%10000-this.nticks)/100;this.nticks3=Math.floor(i/10000);if(e&&!d&&(this.nticks>7)){this.nticks=7}var f=Math.abs(this.func.range()[1]-this.func.range()[0]);if(f<=0){f=100}if(this.kind=="time"){if(this.nticks>8){this.nticks=8}var c=this.scale_max-this.scale_min;var h=a.Painter.getTimeFormat(e);if((h.length==0)||(c<0.1*(this.full_max-this.full_min))){h=a.Painter.chooseTimeFormat(c/this.nticks,true)}var g=a.Painter.chooseTimeFormat(c/f,false);this.tfunc1=this.tfunc2=b.time.format(h);if(g!==h){this.tfunc2=b.time.format(g)}this.format=function(k,j){return j?this.tfunc1(k):this.tfunc2(k)}}else{if(this.kind=="log"){this.nticks2=1;this.noexp=e?e.TestBit(a.EAxisBits.kNoExponent):false;if((this.scale_max<300)&&(this.scale_min>0.3)){this.noexp=true}this.moreloglabels=e?e.TestBit(a.EAxisBits.kMoreLogLabels):false;this.format=function(o,j,m){var n=parseFloat(o);if(!j){var l=Math.round(n);return((l===n)&&(Math.abs(l)<1000000000))?l.toString():n.toExponential(4)}if(n<=0){return null}var k=a.log10(n);if(this.moreloglabels||(Math.abs(k-Math.round(k))<0.001)){if(!this.noexp&&!m){return a.Painter.formatExp(n.toExponential(0))}else{if(k<0){return n.toFixed(Math.round(-k+0.5))}else{return n.toFixed(0)}}}return null}}else{if(this.kind=="labels"){this.nticks=50;var c=this.scale_max-this.scale_min;if(this.nticks>c){this.nticks=Math.round(c)}this.nticks2=1;this.axis=e;this.format=function(m){var l=Math.round(parseInt(m))+1;if((l<1)||(l>this.axis.fNbins)){return null}for(var k=0;k<this.axis.fLabels.arr.length;++k){var j=this.axis.fLabels.arr[k];if(j.fUniqueID==l){return j.fString}}return null}}else{this.range=Math.abs(this.scale_max-this.scale_min);if(this.range<=0){this.ndig=-3}else{this.ndig=Math.round(a.log10(this.nticks/this.range)+0.7)}this.format=function(m,j){var l=parseFloat(m),k=Math.round(l);if(j){if(this.order===0){if(l===k){return k.toString()}if(Math.abs(l)<1e-10*this.range){return 0}l=l.toFixed(this.ndig>0?this.ndig:0);if((typeof m=="string")&&(m.length<=l.length+1)){return m}return l}l=l/Math.pow(10,this.order);k=Math.round(l);if(l===k){return k.toString()}return l.toFixed(this.ndig+this.order>0?this.ndig+this.order:0)}if(l===k){return(Math.abs(k)<1000000000)?k.toString():l.toExponential(4)}return l.toFixed(this.ndig+2>0?this.ndig+2:0)}}}}};a.TAxisPainter.prototype.CreateTicks=function(){var d={nminor:0,nmiddle:0,nmajor:0,func:this.func};d.minor=d.middle=d.major=this.func.ticks(this.nticks);if(this.nticks2>1){d.minor=d.middle=this.func.ticks(d.major.length*this.nticks2);var c=Math.abs(this.func.range()[1]-this.func.range()[0]);if((d.middle.length<=d.major.length)||(d.middle.length>c/3.5)){d.minor=d.middle=d.major}else{if((this.nticks3>1)&&(this.kind!=="log")){d.minor=this.func.ticks(d.middle.length*this.nticks3);if((d.minor.length<=d.middle.length)||(d.minor.length>c/1.7)){d.minor=d.middle}}}}d.reset=function(){this.nminor=this.nmiddle=this.nmajor=0};d.next=function(e){if(this.nminor>=this.minor.length){return false}this.tick=this.minor[this.nminor++];this.grpos=this.func(this.tick);if(e){this.grpos=Math.round(this.grpos)}this.kind=3;if((this.nmiddle<this.middle.length)&&(Math.abs(this.grpos-this.func(this.middle[this.nmiddle]))<1)){this.nmiddle++;this.kind=2}if((this.nmajor<this.major.length)&&(Math.abs(this.grpos-this.func(this.major[this.nmajor]))<1)){this.nmajor++;this.kind=1}return true};d.last_major=function(){return(this.kind!==1)?false:this.nmajor==this.major.length};return d};a.TAxisPainter.prototype.DrawAxis=function(i,P,X,I,S){var C=this.GetObject(),U=(C&&C._typename==="TGaxis"),B=(this.name!=="xaxis"),s=(this.name==="zaxis")?-1:1,Y=0,aa=i,l=10,m=100,n=100;if(U){if(!this.lineatt){this.lineatt=a.Painter.createAttLine(C)}m=(B?this.pad_width():this.pad_height());n=Math.min(this.pad_width(),this.pad_height());l=Math.round(C.fTickSize*m)}else{if(!this.lineatt){this.lineatt=a.Painter.createAttLine(C.fAxisColor,1)}m=(B?P:X);l=Math.round(C.fTickLength*m);n=Math.min(P,X)}if(!U||(this.name==="zaxis")){aa=i.select("."+this.name+"_container");if(aa.empty()){aa=i.append("svg:g").attr("class",this.name+"_container")}else{aa.selectAll("*").remove()}}else{if((C.fChopt.indexOf("-")>=0)&&(C.fChopt.indexOf("+")<0)){s=-1}else{if(B&&C.fChopt=="+L"){s=-1}else{if((C.fChopt.indexOf("-")>=0)&&(C.fChopt.indexOf("+")>=0)){s=1;Y=1}}}aa.append("svg:line").attr("x1",0).attr("y1",0).attr("x1",B?0:P).attr("y1",B?X:0).call(this.lineatt.func)}if(I!==undefined){aa.attr("transform",I)}this.CreateFormatFuncs();var d=(this.kind=="labels")||(this.kind!=="log"&&C.TestBit(a.EAxisBits.kCenterLabels));var M="",f=0,ac=0,j=1;this.ticks=[];var x=this.CreateTicks();while(x.next(true)){var H=Math.round(l/4),F=0;if(x.kind<3){H=Math.round(l/2)}if(x.kind==1){if(!("format" in this)||(this.format(x.tick,true)!==null)){H=l}this.ticks.push(x.grpos)}if(Y>0){F=-H}else{if(s<0){F=-H;H=0}else{F=0}}if(M.length==0){M+=B?("M"+H+","+x.grpos):("M"+x.grpos+","+-H)}else{M+=B?("m"+(H-ac)+","+(x.grpos-f)):("m"+(x.grpos-f)+","+(ac-H))}M+=B?("h"+(F-H)):("v"+(H-F));f=x.grpos;ac=F}if(M.length>0){aa.append("svg:path").attr("d",M).call(this.lineatt.func)}var q=B?X:0,p=a.Painter.getFontDetails(C.fLabelFont,Math.round(C.fLabelSize*(U?this.pad_height():X))),V=a.Painter.root_colors[C.fLabelColor],ab=3+Math.round(C.fLabelOffset*m),u=aa.append("svg:g").attr("class","axis_labels").call(p.func);this.order=0;if((this.kind=="normal")&&B&&!C.TestBit(a.EAxisBits.kNoExponent)){var E=Math.max(Math.abs(x.major[0]),Math.abs(x.major[x.major.length-1]));for(var N=18;N>-18;N-=3){if(N===0){continue}if((N<0)&&((this.range>=0.1)||(E>=1))){break}var O=Math.pow(10,N);if((this.range>O*9.99999)||((E>O*50)&&(this.range>O*0.05))){this.order=N;break}}}for(var g=0;g<x.major.length;++g){var L=Math.round(this.func(x.major[g]));var v=this.format(x.major[g],true);if(v===null){continue}var R=u.append("svg:text").attr("fill",V).text(v);if(B){R.attr("x",-ab*s).attr("y",L).style("text-anchor",(s>0)?"end":"start").style("dominant-baseline","middle")}else{R.attr("x",L).attr("y",2+ab*s+Y*l).attr("dy",(s>0)?".7em":"-.3em").style("text-anchor","middle")}var A=this.GetBoundarySizes(R.node());var c=(g>0)?(L-q):(B?X/2:P/2);var K=(g<x.major.length-1)?(Math.round(this.func(x.major[g+1]))-L):c;var W=Math.min(Math.abs(c),Math.abs(K));if(B){if((W>0)&&(A.height>5)&&(this.kind!=="log")){j=Math.min(j,W/A.height)}if(d){if(L+K/2-j*A.height/2<-10){R.remove()}else{R.attr("y",Math.round(L+K/2))}}}else{if((W>0)&&(A.width>10)&&(this.kind!=="log")){j=Math.min(j,W/A.width)}if(d){if(L+K/2-j*A.width/2>P-10){R.remove()}else{R.attr("x",Math.round(L+K/2))}}}q=L}if(this.order!==0){var G=Math.pow(10,this.order).toExponential(0);var R=u.append("svg:text").attr("fill",V).text("\xD7"+a.Painter.formatExp(G));if(B){R.attr("x",ab).attr("y",0).style("text-anchor","start").style("dominant-baseline","middle").attr("dy","-.5em")}}if((j>0)&&(j<1)){if((j<0.7)&&!B&&(s>0)){u.selectAll("text").each(function(){var r=b.select(this),h=r.attr("x"),t=r.attr("y")-5;r.attr("transform","translate("+h+","+t+") rotate(25)").style("text-anchor","start").attr("x",null).attr("y",null)});j*=3.5}p.size=Math.floor(p.size*j+0.7);u.call(p.func)}if(C.fTitle.length>0){var o=aa.append("svg:g").attr("class","axis_title"),Q=Math.round(C.fTitleSize*n),d=C.TestBit(a.EAxisBits.kCenterTitle),Z=C.TestBit(a.EAxisBits.kRotateTitle)?-1:1,k=a.Painter.root_colors[C.fTitleColor];this.StartTextDrawing(C.fTitleFont,Q,o);var D=((Z<0)&&!S)||((Z>=0)&&S);if(B){var e=-s*Math.round(ab+(2-s/10)*C.fTitleOffset*Q);if((this.name=="zaxis")&&U&&("getBoundingClientRect" in aa.node())){var J=aa.node().getBoundingClientRect();if(e<J.width-l){e=Math.round(J.width-l)}}this.DrawText((d?"middle":(D?"begin":"end"))+";middle",e,Math.round(d?X/2:(S?X:0)),0,(Z<0?-90:-270),C.fTitle,k,1,o)}else{this.DrawText((d?"middle":(D?"begin":"end"))+";middle",Math.round(d?P/2:(S?0:P)),Math.round(s*(ab+1.9*Q*C.fTitleOffset)),0,(Z<0?-180:0),C.fTitle,k,1,o)}this.FinishTextDrawing(o)}if(a.gStyle.Zooming){var T=aa.append("svg:rect").attr("class","axis_zoom").style("opacity","0").style("cursor","crosshair");if(B){T.attr("x",(s>0)?(-2*p.size-3):3).attr("y",0).attr("width",2*p.size+3).attr("height",X)}else{T.attr("x",0).attr("y",0).attr("width",P).attr("height",p.size+3)}}this.position=0;if("getBoundingClientRect" in aa.node()){var z=aa.node().getBoundingClientRect(),y=this.svg_pad().node().getBoundingClientRect();this.position=z.left-y.left}};a.TAxisPainter.prototype.Redraw=function(){var j=this.GetObject(),f=Math.round(this.AxisToSvg("x",j.fX1)),q=Math.round(this.AxisToSvg("y",j.fY1)),e=Math.round(this.AxisToSvg("x",j.fX2)),p=Math.round(this.AxisToSvg("y",j.fY2)),r=e-f,l=q-p;var c=r<5?"yaxis":"xaxis",i="normal",g=null,k=j.fWmin,o=j.fWmax,m=false;if(j.fChopt.indexOf("G")>=0){g=b.scale.log();i="log"}else{g=b.scale.linear()}g.domain([k,o]);if(c=="yaxis"){if(l>0){g.range([l,0])}else{var n=q;q=p;p=n;l=-l;m=true;g.range([0,l])}}else{if(r>0){g.range([0,r])}else{var n=f;f=e;e=n;r=-r;m=true;g.range([r,0])}}this.SetAxisConfig(c,i,g,k,o,k,o);this.RecreateDrawG(true,"text_layer");this.DrawAxis(this.draw_g,r,l,"translate("+f+","+p+")",m)};a.drawGaxis=function(f,e,d){var c=new a.TAxisPainter(e,false);c.SetDivId(f);c.Redraw();return c.DrawingReady()};a.THistPainter=function(c){a.TObjectPainter.call(this,c);this.histo=c;this.shrink_frame_left=0;this.draw_content=true;this.nbinsx=0;this.nbinsy=0;this.x_kind="normal";this.y_kind="normal"};a.THistPainter.prototype=Object.create(a.TObjectPainter.prototype);a.THistPainter.prototype.IsDummyHisto=function(){return(this.histo==null)||!this.draw_content||(this.options.Axis>0)};a.THistPainter.prototype.IsTProfile=function(){return this.MatchObjectType("TProfile")};a.THistPainter.prototype.IsTH2Poly=function(){return this.histo&&this.histo._typename.match(/^TH2Poly/)};a.THistPainter.prototype.Dimension=function(){if(!this.histo){return 0}if(this.histo._typename.indexOf("TH2")==0){return 2}if(this.histo._typename.indexOf("TH3")==0){return 3}return 1};a.THistPainter.prototype.DecodeOptions=function(d){if((d==null)||(d=="")){d=this.histo.fOption}var j=this.Dimension();var o={Axis:0,Bar:0,Curve:0,Error:0,Hist:0,Line:0,Mark:0,Fill:0,Same:0,Scat:0,Func:0,Star:0,Arrow:0,Box:0,Text:0,Char:0,Color:0,Contour:0,Lego:0,Surf:0,Off:0,Tri:0,Proj:0,AxisPos:0,Spec:0,Pie:0,List:0,Zscale:0,FrontBox:1,BackBox:1,System:a.Painter.Coord.kCARTESIAN,AutoColor:0,NoStat:0,AutoZoom:false,HighRes:0,Zero:0,Logx:0,Logy:0,Logz:0,Gridx:0,Gridy:0,Palette:0,Optimize:a.gStyle.OptimizeDraw};var k=d.toUpperCase();k=a.Painter.clearCuts(k);if((j===1)&&(this.histo.fSumw2.length>0)){for(var e=0;e<this.histo.fSumw2.length;++e){if(this.histo.fSumw2[e]>0){o.Error=2;break}}}if(this.histo.fFunctions!==null){o.Func=1}var m=k.indexOf("PAL");if(m>=0){var h=m+3;while((h<k.length)&&(k.charCodeAt(h)>=48)&&(k.charCodeAt(h)<58)){++h}if(h>m+3){o.Palette=parseInt(k.substring(m+3,h));k=k.replace(k.substring(m,h),"")}}if(k.indexOf("NOOPTIMIZE")!=-1){o.Optimize=0;k=k.replace("NOOPTIMIZE","")}if(k.indexOf("OPTIMIZE")!=-1){o.Optimize=2;k=k.replace("OPTIMIZE","")}if(k.indexOf("AUTOCOL")!=-1){o.AutoColor=1;o.Hist=1;k=k.replace("AUTOCOL","")}if(k.indexOf("AUTOZOOM")!=-1){o.AutoZoom=1;o.Hist=1;k=k.replace("AUTOZOOM","")}if(k.indexOf("NOSTAT")!=-1){o.NoStat=1;k=k.replace("NOSTAT","")}if(k.indexOf("LOGX")!=-1){o.Logx=1;k=k.replace("LOGX","")}if(k.indexOf("LOGY")!=-1){o.Logy=1;k=k.replace("LOGY","")}if(k.indexOf("LOGZ")!=-1){o.Logz=1;k=k.replace("LOGZ","")}k=k.trim();while((k.length>0)&&(k[0]==","||k[0]==";")){k=k.substr(1)}var q=k.length;if(!q){o.Hist=1}var g=k.indexOf("SPEC");if(g!=-1){o.Scat=0;k=k.replace("SPEC"," ");var p=0;g=k.indexOf("BF(");if(g!=-1){p=parseInt(k)}o.Spec=Math.max(1600,p);return o}if(k.indexOf("GL")!=-1){k=k.replace("GL"," ")}if(k.indexOf("X+")!=-1){o.AxisPos=10;k=k.replace("X+"," ")}if(k.indexOf("Y+")!=-1){o.AxisPos+=1;k=k.replace("Y+"," ")}if((o.AxisPos==10||o.AxisPos==1)&&(q==2)){o.Hist=1}if(o.AxisPos==11&&q==4){o.Hist=1}if(k.indexOf("SAMES")!=-1){if(q==5){o.Hist=1}o.Same=2;k=k.replace("SAMES"," ")}if(k.indexOf("SAME")!=-1){if(q==4){o.Hist=1}o.Same=1;k=k.replace("SAME"," ")}if(k.indexOf("PIE")!=-1){o.Pie=1;k=k.replace("PIE"," ")}g=k.indexOf("LEGO");if(g!=-1){o.Scat=0;o.Lego=1;k=k.replace("LEGO"," ");if(k[g+4]=="1"){o.Lego=11;k[g+4]=" "}if(k[g+4]=="2"){o.Lego=12;k[g+4]=" "}if(k[g+4]=="3"){o.Lego=13;k[g+4]=" "}g=k.indexOf("FB");if(g!=-1){o.FrontBox=0;k=k.replace("FB"," ")}g=k.indexOf("BB");if(g!=-1){o.BackBox=0;k=k.replace("BB"," ")}g=k.indexOf("0");if(g!=-1){o.Zero=1;k=k.replace("0"," ")}}g=k.indexOf("SURF");if(g!=-1){o.Scat=0;o.Surf=1;k=k.replace("SURF"," ");if(k[g+4]=="1"){o.Surf=11;k[g+4]=" "}if(k[g+4]=="2"){o.Surf=12;k[g+4]=" "}if(k[g+4]=="3"){o.Surf=13;k[g+4]=" "}if(k[g+4]=="4"){o.Surf=14;k[g+4]=" "}if(k[g+4]=="5"){o.Surf=15;k[g+4]=" "}if(k[g+4]=="6"){o.Surf=16;k[g+4]=" "}if(k[g+4]=="7"){o.Surf=17;k[g+4]=" "}g=k.indexOf("FB");if(g!=-1){o.FrontBox=0;k=k.replace("FB"," ")}g=k.indexOf("BB");if(g!=-1){o.BackBox=0;k=k.replace("BB"," ")}}g=k.indexOf("TF3");if(g!=-1){g=k.indexOf("FB");if(g!=-1){o.FrontBox=0;k=k.replace("FB"," ")}g=k.indexOf("BB");if(g!=-1){o.BackBox=0;k=k.replace("BB"," ")}}g=k.indexOf("ISO");if(g!=-1){g=k.indexOf("FB");if(g!=-1){o.FrontBox=0;k=k.replace("FB"," ")}g=k.indexOf("BB");if(g!=-1){o.BackBox=0;k=k.replace("BB"," ")}}g=k.indexOf("LIST");if(g!=-1){o.List=1;k=k.replace("LIST"," ")}g=k.indexOf("CONT");if(g!=-1){k=k.replace("CONT"," ");if(j>1){o.Scat=0;o.Contour=1;if(k[g+4]=="1"){o.Contour=11;k[g+4]=" "}if(k[g+4]=="2"){o.Contour=12;k[g+4]=" "}if(k[g+4]=="3"){o.Contour=13;k[g+4]=" "}if(k[g+4]=="4"){o.Contour=14;k[g+4]=" "}if(k[g+4]=="5"){o.Contour=15;k[g+4]=" "}}else{o.Hist=1}}g=k.indexOf("HBAR");if(g!=-1){o.Hist=0;o.Bar=20;k=k.replace("HBAR"," ");if(k[g+4]=="1"){o.Bar=21;k[g+4]=" "}if(k[g+4]=="2"){o.Bar=22;k[g+4]=" "}if(k[g+4]=="3"){o.Bar=23;k[g+4]=" "}if(k[g+4]=="4"){o.Bar=24;k[g+4]=" "}}g=k.indexOf("BAR");if(g!=-1){o.Hist=0;o.Bar=10;k=k.replace("BAR"," ");if(k[g+3]=="1"){o.Bar=11;k[g+3]=" "}if(k[g+3]=="2"){o.Bar=12;k[g+3]=" "}if(k[g+3]=="3"){o.Bar=13;k[g+3]=" "}if(k[g+3]=="4"){o.Bar=14;k[g+3]=" "}}g=k.indexOf("ARR");if(g!=-1){k=k.replace("ARR"," ");if(j>1){o.Arrow=1;o.Scat=0}else{o.Hist=1}}g=k.indexOf("BOX");if(g!=-1){k=k.replace("BOX"," ");if(j>1){o.Scat=0;o.Box=1;if(k[g+3]=="1"){o.Box=11;k[g+3]=" "}}else{o.Hist=1}}g=k.indexOf("COL");if(g!=-1){var c="COL";if(k.charAt(g+3)=="0"){o.Color=111;c+="0";++g}else{if(k.charAt(g+3)=="1"){o.Color=1;c+="1";++g}else{if(k.charAt(g+3)=="2"){o.Color=2;c+="2";++g}else{if(k.charAt(g+3)=="3"){o.Color=3;c+="3";++g}else{o.Color=1}}}}if(k.charAt(g+4)=="Z"){o.Zscale=1;c+="Z"}k=k.replace(c,"");if(j==1){o.Hist=1}else{o.Scat=0}}if(k.indexOf("CHAR")!=-1){o.Char=1;k=k.replace("CHAR"," ");o.Scat=0}g=k.indexOf("FUNC");if(g!=-1){o.Func=2;k=k.replace("FUNC"," ");o.Hist=0}g=k.indexOf("HIST");if(g!=-1){o.Hist=2;k=k.replace("HIST"," ");o.Func=0;o.Error=0}if(k.indexOf("AXIS")!=-1){o.Axis=1;k=k.replace("AXIS"," ")}if(k.indexOf("AXIG")!=-1){o.Axis=2;k=k.replace("AXIG"," ")}if(k.indexOf("TEXT")!=-1){var f=parseInt(k);if(!isNaN(f)){if(f<0){f=0}if(f>90){f=90}o.Text=1000+f}else{o.Text=1}k=k.replace("TEXT"," ");g=k.indexOf("N");if(g!=-1&&this.IsTH2Poly()){o.Text+=3000}o.Scat=0}if(k.indexOf("SCAT")!=-1){o.Scat=1;k=k.replace("SCAT"," ")}if(k.indexOf("POL")!=-1){o.System=a.Painter.Coord.kPOLAR;k=k.replace("POL"," ")}if(k.indexOf("CYL")!=-1){o.System=a.Painter.Coord.kCYLINDRICAL;k=k.replace("CYL"," ")}if(k.indexOf("SPH")!=-1){o.System=a.Painter.Coord.kSPHERICAL;k=k.replace("SPH"," ")}g=k.indexOf("PSR");if(g!=-1){o.System=a.Painter.Coord.kRAPIDITY;k=k.replace("PSR"," ")}g=k.indexOf("TRI");if(g!=-1){o.Scat=0;o.Color=0;o.Tri=1;k=k.replace("TRI"," ");g=k.indexOf("FB");if(g!=-1){o.FrontBox=0;k=k.replace("FB"," ")}g=k.indexOf("BB");if(g!=-1){o.BackBox=0;k=k.replace("BB"," ")}g=k.indexOf("ERR");if(g!=-1){k=k.replace("ERR"," ")}}g=k.indexOf("AITOFF");if(g!=-1){o.Proj=1;k=k.replace("AITOFF"," ")}g=k.indexOf("MERCATOR");if(g!=-1){o.Proj=2;k=k.replace("MERCATOR"," ")}g=k.indexOf("SINUSOIDAL");if(g!=-1){o.Proj=3;k=k.replace("SINUSOIDAL"," ")}g=k.indexOf("PARABOLIC");if(g!=-1){o.Proj=4;k=k.replace("PARABOLIC"," ")}if(o.Proj>0){o.Scat=0;o.Contour=14}if(k.indexOf("A")!=-1){o.Axis=-1}if(k.indexOf("B")!=-1){o.Bar=1}if(k.indexOf("C")!=-1){o.Curve=1;o.Hist=-1}if(k.indexOf("F")!=-1){o.Fill=1}if(k.indexOf("][")!=-1){o.Off=1;o.Hist=1}if(k.indexOf("F2")!=-1){o.Fill=2}if(k.indexOf("L")!=-1){o.Line=1;o.Hist=-1}if(k.indexOf("P")!=-1){o.Mark=1;o.Hist=-1;if(k.indexOf("P0")!=-1){o.Mark=10}}if(k.indexOf("Z")!=-1){o.Zscale=1}if(k.indexOf("*")!=-1){o.Star=1}if(k.indexOf("H")!=-1){o.Hist=2}if(this.IsTH2Poly()){if(o.Fill+o.Line+o.Mark!=0){o.Scat=0}}if(k.indexOf("E")!=-1){if(j==1){o.Error=1;if(k.indexOf("E0")!=-1){o.Error=10}if(k.indexOf("E1")!=-1){o.Error=11}if(k.indexOf("E2")!=-1){o.Error=12}if(k.indexOf("E3")!=-1){o.Error=13}if(k.indexOf("E4")!=-1){o.Error=14}if(k.indexOf("E5")!=-1){o.Error=15}if(k.indexOf("E6")!=-1){o.Error=16}if(k.indexOf("X0")!=-1){if(o.Error==1){o.Error+=20}o.Error+=10}if(o.Text&&this.IsTProfile()){o.Text+=2000;o.Error=0}}else{if(o.Error==0){o.Error=100;o.Scat=0}if(o.Text){o.Text+=2000;o.Error=0}}}if(k.indexOf("9")!=-1){o.HighRes=1}if(o.Surf==15){if(o.System==a.Painter.Coord.kPOLAR||o.System==a.Painter.Coord.kCARTESIAN){o.Surf=13}}if(o.Bar==1){o.Hist=-1}return o};a.THistPainter.prototype.GetAutoColor=function(c){if(this.options.AutoColor<=0){return c}var d=this.options.AutoColor;this.options.AutoColor=d%8+1;return a.Painter.root_colors[d]};a.THistPainter.prototype.ScanContent=function(){alert("HistPainter.prototype.ScanContent not implemented")};a.THistPainter.prototype.CheckPadOptions=function(){this.fillatt=this.createAttFill(this.histo,undefined,undefined,1);this.lineatt=a.Painter.createAttLine(this.histo);var d=this.main_painter();if(d!==null){this.lineatt.color=d.GetAutoColor(this.lineatt.color)}var f=this.root_pad();if(f!=null){this.options.Logx=f.fLogx;this.options.Logy=f.fLogy;this.options.Logz=f.fLogz;this.options.Gridx=f.fGridx;this.options.Gridy=f.fGridy}if(this.main_painter()!==this){return}this.zoom_xmin=this.zoom_xmax=0;this.zoom_ymin=this.zoom_ymax=0;this.zoom_zmin=this.zoom_zmax=0;if((f==null)||!("fUxmin" in f)||this.create_canvas){return}var e=f.fUxmin,c=f.fUxmax;if((this.Dimension()<3)&&((e!==0)||(c!==1))){if(f.fLogx>0){e=Math.exp(e*Math.log(10));c=Math.exp(c*Math.log(10))}if(e!==this.histo.fXaxis.fXmin||c!==this.histo.fXaxis.fXmax){if(e>=this.histo.fXaxis.fXmin&&c<=this.histo.fXaxis.fXmax){this.zoom_xmin=e;this.zoom_xmax=c}}}e=f.fUymin;c=f.fUymax;if((this.Dimension()==2)&&((e!==0)||(c!==1))){if(f.fLogy>0){e=Math.exp(e*Math.log(10));c=Math.exp(c*Math.log(10))}if(e!==this.histo.fYaxis.fXmin||c!==this.histo.fYaxis.fXmax){if(e>=this.histo.fYaxis.fXmin&&c<=this.histo.fYaxis.fXmax){this.zoom_ymin=e;this.zoom_ymax=c}}}};a.THistPainter.prototype.UpdateObject=function(d){if(!this.MatchObjectType(d)){alert("JSROOT.THistPainter.UpdateObject - wrong class "+d._typename+" expected "+this.histo._typename);return false}var c=this.GetObject();c.fEntries=d.fEntries;c.fTsumw=d.fTsumw;c.fTsumwx=d.fTsumwx;c.fTsumwx2=d.fTsumwx2;if(this.Dimension()==2){c.fTsumwy=d.fTsumwy;c.fTsumwy2=d.fTsumwy2;c.fTsumwxy=d.fTsumwxy}c.fArray=d.fArray;c.fNcells=d.fNcells;c.fTitle=d.fTitle;c.fMinimum=d.fMinimum;c.fMaximum=d.fMaximum;c.fXaxis.fNbins=d.fXaxis.fNbins;c.fXaxis.fXmin=d.fXaxis.fXmin;c.fXaxis.fXmax=d.fXaxis.fXmax;c.fYaxis.fXmin=d.fYaxis.fXmin;c.fYaxis.fXmax=d.fYaxis.fXmax;c.fSumw2=d.fSumw2;if(this.IsTProfile()){c.fBinEntries=d.fBinEntries}this.ScanContent();return true};a.THistPainter.prototype.CreateAxisFuncs=function(d,c){this.xmin=this.histo.fXaxis.fXmin;this.xmax=this.histo.fXaxis.fXmax;if(this.histo.fXaxis.fXbins.length==this.nbinsx+1){this.regularx=false;this.GetBinX=function(f){var g=Math.round(f);if(g<=0){return this.xmin}if(g>this.nbinsx){this.xmax}if(g==f){return this.histo.fXaxis.fXbins[g]}var e=(f<g)?g-1:g+1;return this.histo.fXaxis.fXbins[g]*Math.abs(f-e)+this.histo.fXaxis.fXbins[e]*Math.abs(f-g)};this.GetIndexX=function(e,g){for(var f=1;f<this.histo.fXaxis.fXbins.length;++f){if(e<this.histo.fXaxis.fXbins[f]){return Math.floor(f-1+g)}}return this.nbinsx}}else{this.regularx=true;this.binwidthx=(this.xmax-this.xmin);if(this.nbinsx>0){this.binwidthx=this.binwidthx/this.nbinsx}this.GetBinX=function(e){return this.xmin+e*this.binwidthx};this.GetIndexX=function(e,f){return Math.floor((e-this.xmin)/this.binwidthx+f)}}this.ymin=this.histo.fYaxis.fXmin;this.ymax=this.histo.fYaxis.fXmax;if(!d||(this.nbinsy==0)){return}if(this.histo.fYaxis.fXbins.length==this.nbinsy+1){this.regulary=false;this.GetBinY=function(f){var g=Math.round(f);if(g<=0){return this.ymin}if(g>this.nbinsy){this.ymax}if(g==f){return this.histo.fYaxis.fXbins[g]}var e=(f<g)?g-1:g+1;return this.histo.fYaxis.fXbins[g]*Math.abs(f-e)+this.histo.fYaxis.fXbins[e]*Math.abs(f-g)};this.GetIndexY=function(g,f){for(var e=1;e<this.histo.fYaxis.fXbins.length;++e){if(g<this.histo.fYaxis.fXbins[e]){return Math.floor(e-1+f)}}return this.nbinsy}}else{this.regulary=true;this.binwidthy=(this.ymax-this.ymin);if(this.nbinsy>0){this.binwidthy=this.binwidthy/this.nbinsy}this.GetBinY=function(e){return this.ymin+e*this.binwidthy};this.GetIndexY=function(f,e){return Math.floor((f-this.ymin)/this.binwidthy+e)}}if(!c||(this.nbinsz==0)){return}if(this.histo.fZaxis.fXbins.length==this.nbinsz+1){this.regularz=false;this.GetBinZ=function(f){var g=Math.round(f);if(g<=0){return this.zmin}if(g>this.nbinsz){this.zmax}if(g==f){return this.histo.fZaxis.fXbins[g]}var e=(f<g)?g-1:g+1;return this.histo.fZaxis.fXbins[g]*Math.abs(f-e)+this.histo.fZaxis.fXbins[e]*Math.abs(f-g)};this.GetIndexZ=function(g,f){for(var e=1;e<this.histo.fZaxis.fXbins.length;++e){if(g<this.histo.fZaxis.fXbins[e]){return Math.floor(e-1+f)}}return this.nbinsz}}else{this.regularz=true;this.binwidthz=(this.zmax-this.zmin);if(this.nbinsz>0){this.binwidthz=this.binwidthz/this.nbinsz}this.GetBinZ=function(e){return this.zmin+e*this.binwidthz};this.GetIndexZ=function(f,e){return Math.floor((f-this.zmin)/this.binwidthz+e)}}};a.THistPainter.prototype.CreateXY=function(){if(!this.is_main_painter()){this.x=this.main_painter().x;this.y=this.main_painter().y;return}var c=this.frame_width(),e=this.frame_height();if(this.histo.fXaxis.fTimeDisplay){this.x_kind="time";this.timeoffsetx=a.Painter.getTimeOffset(this.histo.fXaxis);this.ConvertX=function(f){return new Date(this.timeoffsetx+f*1000)};this.RevertX=function(f){return(this.x.invert(f)-this.timeoffsetx)/1000}}else{this.x_kind=(this.histo.fXaxis.fLabels==null)?"normal":"labels";this.ConvertX=function(f){return f};this.RevertX=function(f){return this.x.invert(f)}}this.scale_xmin=this.xmin;this.scale_xmax=this.xmax;if(this.zoom_xmin!=this.zoom_xmax){this.scale_xmin=this.zoom_xmin;this.scale_xmax=this.zoom_xmax}if(this.x_kind=="time"){this.x=b.time.scale()}else{if(this.options.Logx){if(this.scale_xmax<=0){this.scale_xmax=0}if((this.scale_xmin<=0)&&(this.nbinsx>0)){for(var d=0;d<this.nbinsx;++d){this.scale_xmin=Math.max(this.scale_xmin,this.GetBinX(d));if(this.scale_xmin>0){break}}}if((this.scale_xmin<=0)||(this.scale_xmin>=this.scale_xmax)){this.scale_xmin=this.scale_xmax*0.0001}this.x=b.scale.log()}else{this.x=b.scale.linear()}}this.x.domain([this.ConvertX(this.scale_xmin),this.ConvertX(this.scale_xmax)]).range([0,c]);if(this.x_kind=="time"){this.grx=function(f){return this.x(this.ConvertX(f))}}else{if(this.options.Logx){this.grx=function(f){return(f<this.scale_xmin)?-5:this.x(f)}}else{this.grx=this.x}}this.scale_ymin=this.ymin;this.scale_ymax=this.ymax;if(this.zoom_ymin!=this.zoom_ymax){this.scale_ymin=this.zoom_ymin;this.scale_ymax=this.zoom_ymax}if(this.histo.fYaxis.fTimeDisplay){this.y_kind="time";this.timeoffsety=a.Painter.getTimeOffset(this.histo.fYaxis);this.ConvertY=function(f){return new Date(this.timeoffsety+f*1000)};this.RevertY=function(f){return(this.y.invert(f)-this.timeoffsety)/1000}}else{this.y_kind=((this.Dimension()==2)&&(this.histo.fYaxis.fLabels!=null))?"labels":"normal";this.ConvertY=function(f){return f};this.RevertY=function(f){return this.y.invert(f)}}if(this.options.Logy){if(this.scale_ymax<=0){this.scale_ymax=1}else{if((this.zoom_ymin===this.zoom_ymax)&&(this.Dimension()==1)){this.scale_ymax*=1.8}}if((this.scale_ymin<=0)&&(this.nbinsy>0)){for(var d=0;d<this.nbinsy;++d){this.scale_ymin=Math.max(this.scale_ymin,this.GetBinY(d));if(this.scale_ymin>0){break}}}if((this.scale_ymin<=0)&&("ymin_nz" in this)&&(this.ymin_nz>0)){this.scale_ymin=0.3*this.ymin_nz}if((this.scale_ymin<=0)||(this.scale_ymin>=this.scale_ymax)){this.scale_ymin=0.000001*this.scale_ymax}this.y=b.scale.log()}else{if(this.y_kind=="time"){this.y=b.time.scale()}else{this.y=b.scale.linear()}}this.y.domain([this.ConvertY(this.scale_ymin),this.ConvertY(this.scale_ymax)]).range([e,0]);if(this.y_kind=="time"){this.gry=function(f){return this.y(this.ConvertY(f))}}else{if(this.options.Logy){this.gry=function(f){return(f<this.scale_ymin)?e+5:this.y(f)}}else{this.gry=this.y}}};a.THistPainter.prototype.DrawGrids=function(){if(!this.is_main_painter()){return}var d=this.svg_frame().select(".grid_layer");d.selectAll(".xgrid").remove();d.selectAll(".ygrid").remove();if(this.options.Gridx&&this.x_handle){var e=this.frame_height();d.selectAll(".xgrid").data(this.x_handle.ticks).enter().append("svg:line").attr("class","xgrid").attr("x1",function(f){return f}).attr("y1",e).attr("x2",function(f){return f}).attr("y2",0).style("stroke","black").style("stroke-width",1).style("stroke-dasharray",a.Painter.root_line_styles[11])}if(this.options.Gridy&&this.y_handle){var c=this.frame_width();d.selectAll(".ygrid").data(this.y_handle.ticks).enter().append("svg:line").attr("class","ygrid").attr("x1",0).attr("y1",function(f){return f}).attr("x2",c).attr("y2",function(f){return f}).style("stroke","black").style("stroke-width",1).style("stroke-dasharray",a.Painter.root_line_styles[11])}};a.THistPainter.prototype.DrawBins=function(){alert("HistPainter.DrawBins not implemented")};a.THistPainter.prototype.AxisAsText=function(c,d){if(c=="x"){if(this.x_kind=="time"){d=this.ConvertX(d)}if(this.x_handle!==null){if("format" in this.x_handle){return this.x_handle.format(d)}}return d.toPrecision(4)}if(c=="y"){if(this.y_kind=="time"){d=this.ConvertY(d)}if(this.y_handle!==null){if("format" in this.y_handle){return this.y_handle.format(d)}}return d.toPrecision(4)}return d.toPrecision(4)};a.THistPainter.prototype.DrawAxes=function(g){if(!this.is_main_painter()){return}var e=this.svg_frame().select(".axis_layer"),c=this.frame_width(),f=this.frame_height();this.x_handle=new a.TAxisPainter(this.histo.fXaxis,true);this.x_handle.SetDivId(this.divid,-1);this.x_handle.SetAxisConfig("xaxis",(this.options.Logx&&this.x_kind!=="time")?"log":this.x_kind,this.x,this.xmin,this.xmax,this.scale_xmin,this.scale_xmax);this.x_handle.DrawAxis(e,c,f,"translate(0,"+f+")");this.y_handle=new a.TAxisPainter(this.histo.fYaxis,true);this.y_handle.SetDivId(this.divid,-1);this.y_handle.SetAxisConfig("yaxis",(this.options.Logy&&this.y_kind!=="time")?"log":this.y_kind,this.y,this.ymin,this.ymax,this.scale_ymin,this.scale_ymax);this.y_handle.DrawAxis(e,c,f);if(g){return}var d=0,i=this.y_handle.position;if(i<0){d=-i/c+0.001;this.shrink_frame_left+=d}else{if((this.shrink_frame_left>0)&&(i/c>this.shrink_frame_left)){d=-this.shrink_frame_left;this.shrink_frame_left=0}}if(d!=0){this.frame_painter().Shrink(d,0);this.frame_painter().Redraw();this.CreateXY();this.DrawAxes(true)}};a.THistPainter.prototype.DrawTitle=function(){if(!this.is_main_painter()){return}var d=this.FindPainterFor(null,"title");var e=(d!==null)?d.GetObject():null;if(e===null){e=this.FindInPrimitives("title")}if((e!==null)&&(e._typename!=="TPaveText")){e=null}var c=!this.histo.TestBit(a.TH1StatusBits.kNoTitle);if(e!==null){e.Clear();if(c){e.AddText(this.histo.fTitle)}}else{if(c&&(d===null)){e=a.Create("TPaveText");a.extend(e,{fName:"title",fX1NDC:0.28,fY1NDC:0.94,fX2NDC:0.72,fY2NDC:0.99});e.AddText(this.histo.fTitle);a.Painter.drawPaveText(this.divid,e)}}};a.THistPainter.prototype.ToggleStat=function(c){var d=this.FindStat(),e=null;if(d==null){if(c=="only-check"){return false}d=this.CreateStat()}else{e=this.FindPainterFor(d)}if(c=="only-check"){return e?e.Enabled:false}if(e){e.Enabled=!e.Enabled;e.Redraw();return e.Enabled}a.draw(this.divid,d,"onpad:"+this.pad_name);return true};a.THistPainter.prototype.IsAxisZoomed=function(c){var d=this.main_painter();if(d==null){d=this}if(c==="x"){return d.zoom_xmin!=d.zoom_xmax}if(c==="y"){return d.zoom_ymin!=d.zoom_ymax}return false};a.THistPainter.prototype.GetSelectIndex=function(e,l,k){var i=0,h=this.main_painter();if(h==null){h=this}var f=this["nbins"+e];if(!f){f=0}if(!k){k=0}var d="GetIndex"+e.toUpperCase(),g=h["zoom_"+e+"min"],j=h["zoom_"+e+"max"];if((g!=j)&&(d in this)){if(l=="left"){i=this[d](g,k)}else{i=this[d](j,k+0.5)}}else{i=(l=="left")?0:f}var c;if(this.histo){c=this.histo["f"+e.toUpperCase()+"axis"]}if(c){if((c.fFirst===c.fLast)||!c.TestBit(a.EAxisBits.kAxisRange)||((c.fFirst<=1)&&(c.fLast>=f))){c=undefined}}if(l=="left"){if(i<0){i=0}if(c&&c.fFirst>1&&(i<c.fFirst)){i=c.fFirst-1}}else{if(i>f){i=f}if(c&&(c.fLast<=f)&&(i>c.fLast)){i=c.fLast}}return i};a.THistPainter.prototype.FindStat=function(){if(this.histo.fFunctions!==null){for(var c=0;c<this.histo.fFunctions.arr.length;++c){var d=this.histo.fFunctions.arr[c];if((d._typename=="TPaveStats")&&(d.fName=="stats")){return d}}}return null};a.THistPainter.prototype.CreateStat=function(){if(!this.draw_content){return null}var c=this.FindStat();if(c!=null){return c}c=a.Create("TPaveStats");a.extend(c,{fName:"stats",fOptStat:a.gStyle.OptStat,fOptFit:a.gStyle.OptFit,fBorderSize:1});a.extend(c,a.gStyle.StatNDC);a.extend(c,a.gStyle.StatText);a.extend(c,a.gStyle.StatFill);if(this.histo._typename.match(/^TProfile/)||this.histo._typename.match(/^TH2/)){c.fY1NDC=0.67}c.AddText(this.histo.fName);if(this.histo.fFunctions===null){this.histo.fFunctions=a.Create("TList")}this.histo.fFunctions.Add(c,"");return c};a.THistPainter.prototype.FindF1=function(){if(this.histo.fFunctions==null){return null}for(var c=0;c<this.histo.fFunctions.arr.length;++c){var d=this.histo.fFunctions.arr[c];if(d._typename=="TF1"){return d}}return null};a.THistPainter.prototype.DrawNextFunction=function(h,i){if(this.options.Same||(this.histo.fFunctions===null)||(h>=this.histo.fFunctions.arr.length)){return a.CallBack(i)}var g=this.histo.fFunctions.arr[h],d=this.histo.fFunctions.opt[h],f=false,e=this.FindPainterFor(g);if(e===null){if(g._typename=="TPaveText"||g._typename=="TPaveStats"){f=!this.histo.TestBit(a.TH1StatusBits.kNoStats)&&(this.options.NoStat!=1)}else{if(g._typename=="TF1"){f=!g.TestBit(a.BIT(9))}else{f=true}}}else{if(("CompleteDraw" in e)&&(typeof e.CompleteDraw=="function")){e.CompleteDraw()}}if(f){var c=a.draw(this.divid,g,d);if(c){return c.WhenReady(this.DrawNextFunction.bind(this,h+1,i))}}this.DrawNextFunction(h+1,i)};a.THistPainter.prototype.UnzoomUserRange=function(g,f,e){if(!this.histo){return false}function c(h){if(!h){return false}if(!h.TestBit(a.EAxisBits.kAxisRange)){return false}if(h.fFirst===h.fLast){return false}if((h.fFirst<=1)&&(h.fLast>=h.fNbins)){return false}h.InvertBit(a.EAxisBits.kAxisRange);return true}var d=false;if(g){d|=c(this.histo.fXaxis)}if(f){d|=c(this.histo.fYaxis)}if(e){d|=c(this.histo.fZaxis)}return d};a.THistPainter.prototype.ToggleLog=function(c){var e=this.main_painter();if(!e){e=this}var d=e.options["Log"+c];if(!d&&(this[c+"_kind"]=="labels")){return}e.options["Log"+c]=d?0:1;e.RedrawPad()};a.THistPainter.prototype.Zoom=function(d,m,o,h,n,p){var k=this.main_painter(),j=(d!==m),g=(o!==h),e=(n!==p),c=false,r=false,q=false;if(j){var i=0;if(d<=k.xmin){d=k.xmin;i++}if(m>=k.xmax){m=k.xmax;i++}if(i===2){j=false;c=true}}else{c=(d===m)&&(d===0)}if(g){var i=0;if(o<=k.ymin){o=k.ymin;i++}if(h>=k.ymax){h=k.ymax;i++}if(i===2){g=false;r=true}}else{r=(o===h)&&(o===0)}if(e){var i=0;if(n<=k.zmin){n=k.zmin;i++}if(p>=k.zmax){p=k.zmax;i++}if(i===2){e=false;q=true}}else{q=(n===p)&&(n===0)}var l=false;if(j||g||e){k.ForEachPainter(function(s){if(j&&s.CanZoomIn("x",d,m)){k.zoom_xmin=d;k.zoom_xmax=m;l=true;j=false}if(g&&s.CanZoomIn("y",o,h)){k.zoom_ymin=o;k.zoom_ymax=h;l=true;g=false}if(e&&s.CanZoomIn("z",n,p)){k.zoom_zmin=n;k.zoom_zmax=p;l=true;e=false}})}if(c||r||q){if(c){if(k.zoom_xmin!==k.zoom_xmax){l=true}k.zoom_xmin=k.zoom_xmax=0}if(r){if(k.zoom_ymin!==k.zoom_ymax){l=true}k.zoom_ymin=k.zoom_ymax=0}if(q){if(k.zoom_zmin!==k.zoom_zmax){l=true}k.zoom_zmin=k.zoom_zmax=0}if(!l){l=k.UnzoomUserRange(c,r,q);var f=this.pad_painter(true);if(f&&f.painters){f.painters.forEach(function(s){if(s&&(s!==k)&&(typeof s.UnzoomUserRange=="function")){if(s.UnzoomUserRange(c,r,q)){l=true}}})}}}if(l){this.RedrawPad()}return l};a.THistPainter.prototype.Unzoom=function(e,d,c){if(typeof e==="undefined"){e=true;d=true;c=true}else{if(typeof e==="string"){c=e.indexOf("z")>=0;d=e.indexOf("y")>=0;e=e.indexOf("x")>=0}}return this.Zoom(e?0:undefined,e?0:undefined,d?0:undefined,d?0:undefined,c?0:undefined,c?0:undefined)};a.THistPainter.prototype.clearInteractiveElements=function(){a.Painter.closeMenu();if(this.zoom_rect!=null){this.zoom_rect.remove();this.zoom_rect=null}this.zoom_kind=0;this.SwitchTooltip(true)};a.THistPainter.prototype.mouseDoubleClick=function(){b.event.preventDefault();var c=b.mouse(this.svg_frame().node());this.clearInteractiveElements();var d="xyz";if(c[0]<0){d="y"}else{if(c[1]>this.frame_height()){d="x"}}this.Unzoom(d)};a.THistPainter.prototype.startRectSel=function(){if(this.zoom_kind>100){return}if((b.event.which||b.event.button)!==1){return}b.event.preventDefault();this.clearInteractiveElements();this.zoom_origin=b.mouse(this.svg_frame().node());this.zoom_curr=[Math.max(0,Math.min(this.frame_width(),this.zoom_origin[0])),Math.max(0,Math.min(this.frame_height(),this.zoom_origin[1]))];if(this.zoom_origin[0]<0){this.zoom_kind=3;this.zoom_origin[0]=0;this.zoom_origin[1]=this.zoom_curr[1];this.zoom_curr[0]=this.frame_width();this.zoom_curr[1]+=1}else{if(this.zoom_origin[1]>this.frame_height()){this.zoom_kind=2;this.zoom_origin[0]=this.zoom_curr[0];this.zoom_origin[1]=0;this.zoom_curr[0]+=1;this.zoom_curr[1]=this.frame_height()}else{this.zoom_kind=1;this.zoom_origin[0]=this.zoom_curr[0];this.zoom_origin[1]=this.zoom_curr[1]}}b.select(window).on("mousemove.zoomRect",this.moveRectSel.bind(this)).on("mouseup.zoomRect",this.endRectSel.bind(this),true);this.zoom_rect=null;this.SwitchTooltip(false);b.event.stopPropagation()};a.THistPainter.prototype.moveRectSel=function(){if((this.zoom_kind==0)||(this.zoom_kind>100)){return}b.event.preventDefault();var c=b.mouse(this.svg_frame().node());c[0]=Math.max(0,Math.min(this.frame_width(),c[0]));c[1]=Math.max(0,Math.min(this.frame_height(),c[1]));switch(this.zoom_kind){case 1:this.zoom_curr[0]=c[0];this.zoom_curr[1]=c[1];break;case 2:this.zoom_curr[0]=c[0];break;case 3:this.zoom_curr[1]=c[1];break}if(this.zoom_rect===null){this.zoom_rect=this.svg_frame().append("rect").attr("class","zoom").attr("pointer-events","none")}this.zoom_rect.attr("x",Math.min(this.zoom_origin[0],this.zoom_curr[0])).attr("y",Math.min(this.zoom_origin[1],this.zoom_curr[1])).attr("width",Math.abs(this.zoom_curr[0]-this.zoom_origin[0])).attr("height",Math.abs(this.zoom_curr[1]-this.zoom_origin[1]))};a.THistPainter.prototype.endRectSel=function(){if((this.zoom_kind==0)||(this.zoom_kind>100)){return}b.event.preventDefault();b.select(window).on("mousemove.zoomRect",null).on("mouseup.zoomRect",null);var d=b.mouse(this.svg_frame().node());d[0]=Math.max(0,Math.min(this.frame_width(),d[0]));d[1]=Math.max(0,Math.min(this.frame_height(),d[1]));switch(this.zoom_kind){case 1:this.zoom_curr[0]=d[0];this.zoom_curr[1]=d[1];break;case 2:this.zoom_curr[0]=d[0];break;case 3:this.zoom_curr[1]=d[1];break}var h,e,f,c,g=false;if((this.zoom_kind!=3)&&(Math.abs(this.zoom_curr[0]-this.zoom_origin[0])>10)){h=Math.min(this.RevertX(this.zoom_origin[0]),this.RevertX(this.zoom_curr[0]));e=Math.max(this.RevertX(this.zoom_origin[0]),this.RevertX(this.zoom_curr[0]));g=true}if((this.zoom_kind!=2)&&(Math.abs(this.zoom_curr[1]-this.zoom_origin[1])>10)){f=Math.min(this.RevertY(this.zoom_origin[1]),this.RevertY(this.zoom_curr[1]));c=Math.max(this.RevertY(this.zoom_origin[1]),this.RevertY(this.zoom_curr[1]));g=true}this.clearInteractiveElements();if(g){this.Zoom(h,e,f,c)}};a.THistPainter.prototype.startTouchZoom=function(){if(this.zoom_kind!=0){b.event.preventDefault();b.event.stopPropagation();return}var d=b.touches(this.svg_frame().node());this.touch_cnt+=1;if(d.length==1){var e=new Date();var f=e.getTime()-this.last_touch.getTime();this.last_touch=e;if((f<300)&&(this.zoom_curr!=null)&&(Math.abs(this.zoom_curr[0]-d[0][0])<30)&&(Math.abs(this.zoom_curr[1]-d[0][1])<30)){b.event.preventDefault();b.event.stopPropagation();this.clearInteractiveElements();this.Unzoom("xyz");this.last_touch=new Date(0);this.svg_frame().on("touchcancel",null).on("touchend",null,true)}else{if(a.gStyle.ContextMenu){this.zoom_curr=d[0];this.svg_frame().on("touchcancel",this.endTouchSel.bind(this)).on("touchend",this.endTouchSel.bind(this));b.event.preventDefault();b.event.stopPropagation()}}}if(d.length!=2){return}b.event.preventDefault();b.event.stopPropagation();this.clearInteractiveElements();this.svg_frame().on("touchcancel",null).on("touchend",null);var c=d[0],g=d[1];this.zoom_curr=[Math.min(c[0],g[0]),Math.min(c[1],g[1])];this.zoom_origin=[Math.max(c[0],g[0]),Math.max(c[1],g[1])];if(this.zoom_curr[0]<0){this.zoom_kind=103;this.zoom_curr[0]=0;this.zoom_origin[0]=this.frame_width()}else{if(this.zoom_origin[1]>this.frame_height()){this.zoom_kind=102;this.zoom_curr[1]=0;this.zoom_origin[1]=this.frame_height()}else{this.zoom_kind=101}}this.SwitchTooltip(false);this.zoom_rect=this.svg_frame().append("rect").attr("class","zoom").attr("id","zoomRect").attr("x",this.zoom_curr[0]).attr("y",this.zoom_curr[1]).attr("width",this.zoom_origin[0]-this.zoom_curr[0]).attr("height",this.zoom_origin[1]-this.zoom_curr[1]);b.select(window).on("touchmove.zoomRect",this.moveTouchSel.bind(this)).on("touchcancel.zoomRect",this.endTouchSel.bind(this)).on("touchend.zoomRect",this.endTouchSel.bind(this))};a.THistPainter.prototype.moveTouchSel=function(){if(this.zoom_kind<100){return}b.event.preventDefault();var d=b.touches(this.svg_frame().node());if(d.length!=2){return this.clearInteractiveElements()}var c=d[0],e=d[1];if(this.zoom_kind!=103){this.zoom_curr[0]=Math.min(c[0],e[0]);this.zoom_origin[0]=Math.max(c[0],e[0])}if(this.zoom_kind!=102){this.zoom_curr[1]=Math.min(c[1],e[1]);this.zoom_origin[1]=Math.max(c[1],e[1])}this.zoom_rect.attr("x",this.zoom_curr[0]).attr("y",this.zoom_curr[1]).attr("width",this.zoom_origin[0]-this.zoom_curr[0]).attr("height",this.zoom_origin[1]-this.zoom_curr[1]);if((this.zoom_origin[0]-this.zoom_curr[0]>10)||(this.zoom_origin[1]-this.zoom_curr[1]>10)){this.SwitchTooltip(false)}b.event.stopPropagation()};a.THistPainter.prototype.endTouchSel=function(){this.svg_frame().on("touchcancel",null).on("touchend",null);if(this.zoom_kind===0){b.event.preventDefault();var e=new Date();var i=e.getTime()-this.last_touch.getTime();if((i>500)&&(i<2000)&&!this.frame_painter().IsTooltipShown()){this.ShowContextMenu("main",{clientX:this.zoom_curr[0],clientY:this.zoom_curr[1]});this.last_touch=new Date(0)}else{this.clearInteractiveElements()}}if(this.zoom_kind<100){return}b.event.preventDefault();b.select(window).on("touchmove.zoomRect",null).on("touchend.zoomRect",null).on("touchcancel.zoomRect",null);var h,d,f,c,g=false;if((this.zoom_kind!=103)&&(Math.abs(this.zoom_curr[0]-this.zoom_origin[0])>10)){h=Math.min(this.RevertX(this.zoom_origin[0]),this.RevertX(this.zoom_curr[0]));d=Math.max(this.RevertX(this.zoom_origin[0]),this.RevertX(this.zoom_curr[0]));g=true}if((this.zoom_kind!=102)&&(Math.abs(this.zoom_curr[1]-this.zoom_origin[1])>10)){f=Math.min(this.RevertY(this.zoom_origin[1]),this.RevertY(this.zoom_curr[1]));c=Math.max(this.RevertY(this.zoom_origin[1]),this.RevertY(this.zoom_curr[1]));g=true}this.clearInteractiveElements();this.last_touch=new Date(0);if(g){this.Zoom(h,d,f,c)}b.event.stopPropagation()};a.THistPainter.prototype.mouseWheel=function(){b.event.stopPropagation();var k=0;switch(b.event.deltaMode){case 0:k=b.event.deltaY/this.pad_height()*2;break;case 1:k=b.event.deltaY/this.pad_height()*40;break;case 2:k=b.event.deltaY/this.pad_height()*200;break}if(k===0){return}b.event.preventDefault();this.clearInteractiveElements();if(k<-0.2){k=-0.2}else{if(k>0.2){k=0.2}}var d=this.scale_xmin,h=this.scale_xmax,j=undefined,f=undefined;if((d===h)&&(k<0)){d=this.xmin;h=this.xmax}var l=b.mouse(this.svg_frame().node());if(d<h){var g=l[0]/this.frame_width();if((g>0)&&(g<1)){if(this.options.Logx){var i=(d>0)?a.log10(h/d):2;if(i>10){i=10}else{if(i<1.5){i=1.5}}d=d/Math.pow(i,k*g);h=h*Math.pow(i,k*(1-g))}else{var e=(h-d);if(k>0){e=1.001*e/(1-k)}d+=-k*g*e;h-=-k*(1-g)*e}if(d>=h){d=h=undefined}}else{d=h=undefined}}if((this.Dimension()>1)||(l[0]<0)){j=this.scale_ymin;f=this.scale_ymax;if((j===f)&&(k<0)){j=this.ymin;f=this.ymax}var g=1-l[1]/this.frame_height();if((j<f)&&(g>0)&&(g<1)){if(this.options.Logy){var i=(j>0)?a.log10(f/j):2;if(i>10){i=10}else{if(i<1.5){i=1.5}}j=j/Math.pow(i,k*g);f=f*Math.pow(i,k*(1-g))}else{var c=(f-j);if(k>0){c=1.001*c/(1-k)}j+=-k*g*c;f-=-k*(1-g)*c}if(j>=f){j=f=undefined}}else{j=f=undefined}}this.Zoom(d,h,j,f)};a.THistPainter.prototype.AddInteractive=function(){if((!a.gStyle.Zooming&&!a.gStyle.ContextMenu)||!this.is_main_painter()){return}this.last_touch=new Date(0);this.zoom_kind=0;this.zoom_rect=null;this.zoom_origin=null;this.zoom_curr=null;this.touch_cnt=0;if(a.gStyle.Zooming){this.svg_frame().on("mousedown",this.startRectSel.bind(this));this.svg_frame().on("dblclick",this.mouseDoubleClick.bind(this));this.svg_frame().on("wheel",this.mouseWheel.bind(this))}if(a.touches&&(a.gStyle.Zooming||a.gStyle.ContextMenu)){this.svg_frame().on("touchstart",this.startTouchZoom.bind(this))}if(a.gStyle.ContextMenu){if(a.touches){this.svg_frame().selectAll(".xaxis_container").on("touchstart",this.startTouchMenu.bind(this,"x"));this.svg_frame().selectAll(".yaxis_container").on("touchstart",this.startTouchMenu.bind(this,"y"))}this.svg_frame().on("contextmenu",this.ShowContextMenu.bind(this));this.svg_frame().selectAll(".xaxis_container").on("contextmenu",this.ShowContextMenu.bind(this,"x"));this.svg_frame().selectAll(".yaxis_container").on("contextmenu",this.ShowContextMenu.bind(this,"y"))}};a.THistPainter.prototype.ShowContextMenu=function(j,r,k){if(("zoom_kind" in this)&&(this.zoom_kind>100)){return}var p=this,l=false;if(!r){b.event.preventDefault();b.event.stopPropagation();r=b.event;if(j===undefined){var d=b.mouse(this.svg_frame().node());var i=b.touches(this.svg_frame().node());var c=null,g=this.pad_painter(true),m=this.frame_painter(),f=null;if(i.length===1){c={x:i[0][0],y:i[0][1],touch:true}}else{if(d.length===2){c={x:d[0],y:d[1],touch:false}}}if((c!==null)&&(g!==null)){c.painters=true;var e=g.GetTooltips(c);var q=1000;for(var h=0;h<e.length;++h){if(e[h]&&e[h].menu){var o=("menu_dist" in e[h])?e[h].menu_dist:7;if(o<q){f=e[h].painter;q=o}}}}if(f!==null){p=f}else{if(m!==null){j="frame"}}if(c!==null){l=(c.x>0)&&(c.x<20)&&(c.y>0)&&(c.y<20)}}}p.ctx_menu_evnt=r;a.Painter.createMenu(function(s){s.painter=this;var n=this.FillContextMenu(s,j,k);if(m&&(!n||(l&&(j!=="frame")))){n=m.FillContextMenu(s)}if(n){this.SwitchTooltip(false);s.show(this.ctx_menu_evnt,this.SwitchTooltip.bind(this,true))}delete this.ctx_menu_evnt}.bind(p))};a.THistPainter.prototype.ChangeUserRange=function(c){var g=this.histo["f"+c+"axis"];if(!g){return}var f="[1,"+g.fNbins+"]";if(g.TestBit(a.EAxisBits.kAxisRange)){f="["+g.fFirst+","+g.fLast+"]"}var e=prompt("Enter user range for axis "+c+" like [1,"+g.fNbins+"]",f);if(e==null){return}e=JSON.parse(e);if(!e||(e.length!=2)||isNaN(e[0])||isNaN(e[1])){return}g.fFirst=parseInt(e[0]);g.fLast=parseInt(e[1]);var d=(g.fFirst<g.fLast)&&(g.fFirst>=1)&&(g.fLast<=g.fNbins);if(d!=g.TestBit(a.EAxisBits.kAxisRange)){g.InvertBit(a.EAxisBits.kAxisRange)}this.Redraw()};a.THistPainter.prototype.FillContextMenu=function(g,e,f){this.clearInteractiveElements();if((e=="x")||(e=="y")||(e=="z")){var c=this.histo.fXaxis;if(e=="y"){c=this.histo.fYaxis}else{if(e=="z"){c=f?f:this.histo.fZaxis}}g.add("header: "+e.toUpperCase()+" axis");g.add("Unzoom",this.Unzoom.bind(this,e));g.addchk(this.options["Log"+e],"SetLog"+e,this.ToggleLog.bind(this,e));g.addchk(c.TestBit(a.EAxisBits.kMoreLogLabels),"More log",function(){c.InvertBit(a.EAxisBits.kMoreLogLabels);this.RedrawPad()});g.addchk(c.TestBit(a.EAxisBits.kNoExponent),"No exponent",function(){c.InvertBit(a.EAxisBits.kNoExponent);this.RedrawPad()});if(c!=null){g.add("sub:Labels");g.addchk(c.TestBit(a.EAxisBits.kCenterLabels),"Center",function(){c.InvertBit(a.EAxisBits.kCenterLabels);this.RedrawPad()});this.AddColorMenuEntry(g,"Color",c.fLabelColor,function(h){c.fLabelColor=parseInt(h);this.RedrawPad()});this.AddSizeMenuEntry(g,"Offset",0,3,0.2,c.fLabelOffset,function(h){c.fLabelOffset=parseFloat(h);this.RedrawPad()});this.AddSizeMenuEntry(g,"Size",0.02,0.11,0.01,c.fLabelSize,function(h){c.fLabelSize=parseFloat(h);this.RedrawPad()});g.add("endsub:");g.add("sub:Title");g.add("SetTitle",function(){var h=prompt("Enter axis title",c.fTitle);if(h!==null){c.fTitle=h;this.RedrawPad()}});g.addchk(c.TestBit(a.EAxisBits.kCenterTitle),"Center",function(){c.InvertBit(a.EAxisBits.kCenterTitle);this.RedrawPad()});g.addchk(c.TestBit(a.EAxisBits.kRotateTitle),"Rotate",function(){c.InvertBit(a.EAxisBits.kRotateTitle);this.RedrawPad()});this.AddColorMenuEntry(g,"Color",c.fTitleColor,function(h){c.fTitleColor=parseInt(h);this.RedrawPad()});this.AddSizeMenuEntry(g,"Offset",0,3,0.2,c.fTitleOffset,function(h){c.fTitleOffset=parseFloat(h);this.RedrawPad()});this.AddSizeMenuEntry(g,"Size",0.02,0.11,0.01,c.fTitleSize,function(h){c.fTitleSize=parseFloat(h);this.RedrawPad()});g.add("endsub:")}g.add("sub:Ticks");this.AddColorMenuEntry(g,"Color",c.fLineColor,function(h){c.fLineColor=parseInt(h);this.RedrawPad()});this.AddColorMenuEntry(g,"Color",c.fAxisColor,function(h){c.fAxisColor=parseInt(h);this.RedrawPad()});this.AddSizeMenuEntry(g,"Size",-0.05,0.055,0.01,c.fTickLength,function(h){c.fTickLength=parseFloat(h);this.RedrawPad()});g.add("endsub:");return true}if(e=="frame"){var d=this.frame_painter();if(d){return d.FillContextMenu(g)}}g.add("header:"+this.histo._typename+"::"+this.histo.fName);if(this.draw_content){g.addchk(this.ToggleStat("only-check"),"Show statbox",function(){this.ToggleStat()});if(this.Dimension()==1){g.add("User range X","X",this.ChangeUserRange)}else{g.add("sub:User ranges");g.add("X","X",this.ChangeUserRange);g.add("Y","Y",this.ChangeUserRange);if(this.Dimension()>2){g.add("Z","Z",this.ChangeUserRange)}g.add("endsub:")}}if("FillHistContextMenu" in this){this.FillHistContextMenu(g)}this.FillAttContextMenu(g);return true};a.THistPainter.prototype.ButtonClick=function(c){if(!this.is_main_painter()){return false}switch(c){case"ToggleZoom":if((this.zoom_xmin!==this.zoom_xmax)||(this.zoom_ymin!==this.zoom_ymax)||(this.zoom_zmin!==this.zoom_zmax)){this.Unzoom();return true}if(this.draw_content&&("AutoZoom" in this)&&(this.Dimension()<3)){this.AutoZoom();return true}break;case"ToggleLogX":this.ToggleLog("x");break;case"ToggleLogY":this.ToggleLog("y");break;case"ToggleLogZ":this.ToggleLog("z");break;case"ToggleStatBox":this.ToggleStat();return true;break}return false};a.THistPainter.prototype.FillToolbar=function(){var c=this.pad_painter(true);if(c===null){return}c.AddButton(a.ToolbarIcons.auto_zoom,"Toggle between unzoom and autozoom-in","ToggleZoom");c.AddButton(a.ToolbarIcons.arrow_right,"Toggle log x","ToggleLogX");c.AddButton(a.ToolbarIcons.arrow_up,"Toggle log y","ToggleLogY");if(this.Dimension()>1){c.AddButton(a.ToolbarIcons.arrow_diag,"Toggle log z","ToggleLogZ")}if(this.draw_content){c.AddButton(a.ToolbarIcons.statbox,"Toggle stat box","ToggleStatBox")}};a.TH1Painter=function(c){a.THistPainter.call(this,c)};a.TH1Painter.prototype=Object.create(a.THistPainter.prototype);a.TH1Painter.prototype.ScanContent=function(){var e=0,c=0,k=0,j=0;var d=this.IsTProfile();this.nbinsx=this.histo.fXaxis.fNbins;this.nbinsy=0;for(var h=0;h<this.nbinsx;++h){var l=this.histo.getBinContent(h+1),f=0;j+=d?this.histo.fBinEntries[h+1]:l;if(l>0){if((c==0)||(l<c)){c=l}}if(this.options.Error>0){f=this.histo.getBinError(h+1)}if(h==0){e=l-f;k=l+f}else{e=Math.min(e,l-f);k=Math.max(k,l+f)}}if(d){j+=this.histo.fBinEntries[0]+this.histo.fBinEntries[this.nbinsx+1]}else{j+=this.histo.getBinContent(0)+this.histo.getBinContent(this.nbinsx+1)}this.stat_entries=j;if(this.histo.fEntries>1){this.stat_entries=this.histo.fEntries}this.CreateAxisFuncs(false);this.hmin=e;this.hmax=k;this.ymin_nz=c;if((this.nbinsx==0)||((Math.abs(e)<1e-300&&Math.abs(k)<1e-300))){this.draw_content=false;e=this.ymin;k=this.ymax}else{this.draw_content=true}if(e>=k){if(e==0){this.ymin=0;this.ymax=1}else{if(e<0){this.ymin=2*e;this.ymax=0}else{this.ymin=0;this.ymax=e*2}}}else{var m=(k-e)*0.05;this.ymin=e-m;if((this.ymin<0)&&(e>=0)){this.ymin=0}this.ymax=k+m}e=k=null;var g=false;if(this.histo.fMinimum!=-1111){e=this.histo.fMinimum;if(e<this.ymin){this.ymin=e}else{g=true}}if(this.histo.fMaximum!=-1111){k=this.histo.fMaximum;if(k>this.ymax){this.ymax=k}else{g=true}}if(g){this.zoom_ymin=(e==null)?this.ymin:e;this.zoom_ymax=(k==null)?this.ymax:k}if(this.is_main_painter()&&(this.zoom_xmin===this.zoom_xmax)&&this.histo.fXaxis.TestBit(a.EAxisBits.kAxisRange)&&(this.histo.fXaxis.fFirst!==this.histo.fXaxis.fLast)&&((this.histo.fXaxis.fFirst>1)||(this.histo.fXaxis.fLast<=this.nbinsx))){this.zoom_xmin=this.histo.fXaxis.fFirst>1?this.GetBinX(this.histo.fXaxis.fFirst-1):this.xmin;this.zoom_xmax=this.histo.fXaxis.fLast<=this.nbinsx?this.GetBinX(this.histo.fXaxis.fLast):this.xmax}if(this.options.Bar==0&&this.options.Hist==0&&this.options.Error==0&&this.options.Same==0){this.draw_content=false}if(this.options.Axis>0){this.draw_content=false}};a.TH1Painter.prototype.CountStat=function(o){var e=this.IsTProfile();var f=0,l=0,r=0,k=0,j=0;var d=this.GetSelectIndex("x","left");var q=this.GetSelectIndex("x","right");var c=0,p=0,h=null,n=null;for(var g=d;g<q;++g){c=this.GetBinX(g+0.5);if((o!=null)&&!o(c)){continue}if(e){p=this.histo.fBinEntries[g+1];k+=this.histo.fArray[g+1];j+=this.histo.fSumw2[g+1]}else{p=this.histo.getBinContent(g+1)}if((h==null)||(p>n)){h=c;n=p}f+=p;l+=p*c;r+=p*c*c}if(!this.IsAxisZoomed("x")&&(this.histo.fTsumw>0)){f=this.histo.fTsumw;l=this.histo.fTsumwx;r=this.histo.fTsumwx2}var m={meanx:0,meany:0,rmsx:0,rmsy:0,integral:f,entries:this.stat_entries,xmax:0,wmax:0};if(f>0){m.meanx=l/f;m.meany=k/f;m.rmsx=Math.sqrt(r/f-m.meanx*m.meanx);m.rmsy=Math.sqrt(j/f-m.meany*m.meany)}if(h!=null){m.xmax=h;m.wmax=n}return m};a.TH1Painter.prototype.FillStatistic=function(w,k,x){if(!this.histo){return false}var f=w.GetObject(),A=this.CountStat(),t=k%10,g=Math.floor(k/10)%10,m=Math.floor(k/100)%10,y=Math.floor(k/1000)%10,h=Math.floor(k/10000)%10,l=Math.floor(k/100000)%10,r=Math.floor(k/1000000)%10,C=Math.floor(k/10000000)%10,u=Math.floor(k/100000000)%10;if(t>0){f.AddText(this.histo.fName)}if(this.IsTProfile()){if(g>0){f.AddText("Entries = "+w.Format(A.entries,"entries"))}if(m>0){f.AddText("Mean = "+w.Format(A.meanx));f.AddText("Mean y = "+w.Format(A.meany))}if(y>0){f.AddText("Std Dev = "+w.Format(A.rmsx));f.AddText("Std Dev y = "+w.Format(A.rmsy))}}else{if(g>0){f.AddText("Entries = "+w.Format(A.entries,"entries"))}if(m>0){f.AddText("Mean = "+w.Format(A.meanx))}if(y>0){f.AddText("Std Dev = "+w.Format(A.rmsx))}if(h>0){var B=(this.histo.fArray.length>0)?this.histo.fArray[0]:0;f.AddText("Underflow = "+w.Format(B))}if(l>0){var B=(this.histo.fArray.length>0)?this.histo.fArray[this.histo.fArray.length-1]:0;f.AddText("Overflow = "+w.Format(B))}if(r>0){f.AddText("Integral = "+w.Format(A.integral,"entries"))}if(C>0){f.AddText("Skew = <not avail>")}if(u>0){f.AddText("Kurt = <not avail>")}}if(x!=0){var p=this.FindF1();if(p!=null){var c=x%10;var q=Math.floor(x/10)%10;var d=Math.floor(x/100)%10;var j=Math.floor(x/1000)%10;if(d>0){f.AddText("#chi^2 / ndf = "+w.Format(p.fChisquare,"fit")+" / "+p.fNDF)}if(j>0){f.AddText("Prob = "+(("Math" in a)?w.Format(a.Math.Prob(p.fChisquare,p.fNDF)):"<not avail>"))}if(c>0){for(var o=0;o<p.fNpar;++o){var z=p.GetParName(o);var v=p.GetParValue(o);if(v!=null){v=w.Format(Number(v),"fit")}else{v="<not avail>"}var s="";if(p.fParErrors!=null){s=w.Format(p.fParErrors[o],"last");if((Number(s)==0)&&(p.fParErrors[o]!=0)){s=w.Format(p.fParErrors[o],"4.2g")}}if((q>0)&&(s.length>0)){f.AddText(z+" = "+v+" #pm "+s)}else{f.AddText(z+" = "+v)}}}}}var i=f.fLines.arr.length,e=i*a.gStyle.StatFontSize;if((e<=0)||(a.gStyle.StatFont%10===3)){e=0.25*i*a.gStyle.StatH;f.fY1NDC=0.93-e;f.fY2NDC=0.93}return true};a.TH1Painter.prototype.DrawBins=function(){var c=this.frame_width(),d=this.frame_height();if(!this.draw_content||(c<=0)||(d<=0)){return this.RemoveDrawG()}this.RecreateDrawG(false,"main_layer");var g=this.GetSelectIndex("x","left",-1),M=this.GetSelectIndex("x","right",2),r=this.main_painter(),s=this,C="",G=false,e,k,j,J,B,I,A,l,L,D,E,P,n,S=(this.options.Error!==10)&&(this.options.Mark!==10),f=(this.options.Error>0),u=(this.options.Mark>0),z=null,m=null,K=null,O="",N="",o=0,h,q,p,U,R,H,F,T="";if(f&&!u&&(this.histo.fMarkerStyle>1)){u=true}if(this.options.Error==12){if(this.fillatt.color=="none"){u=true}else{z=""}}else{if(this.options.Error>0){m=""}}if(u){if(!this.markeratt){this.markeratt=a.Painter.createAttMarker(this.histo)}if(this.markeratt.size>0){K="";this.markeratt.reset_pos()}else{u=false}}var w=((M-g)>3*c);if(this.options.Error==11){var t=this.lineatt.width+a.gStyle.EndErrorSize;O="m0,"+t+"v-"+2*t+"m0,"+t;N="m"+t+",0h-"+2*t+"m"+t+",0";o=Math.floor((this.lineatt.width-1)/2)}var Q=f||u;if(Q){w=true}for(P=g;P<=M;++P){J=this.GetBinX(P);if(this.options.Logx&&(J<=0)){continue}B=Math.round(r.grx(J));G=(P===M);if(G&&(g<M)){A=j}else{I=this.histo.getBinContent(P+1);if(this.options.Logy&&(I<this.scale_ymin)){A=d+1}else{A=Math.round(r.gry(I))}}if(C.length===0){n=P;E=e=k=B;D=l=L=j=A;C="M"+k+","+j}else{if(w){if((B===k)&&!G){if(A<l){n=P}l=Math.min(l,A);L=Math.max(L,A);j=A}else{if(Q){U=this.histo.getBinContent(n+1);if(!S||(U!==0)){H=Math.round(r.grx(this.GetBinX(n)));F=Math.round(r.grx(this.GetBinX(n+1)));h=Math.round(r.gry(U));q=p=20;if(f){R=this.histo.getBinError(n+1);q=Math.round(h-r.gry(U+R));p=Math.round(r.gry(U-R)-h)}if((h>=-q)&&(h<=d+p)){if(z!==null){z+="M"+H+","+(h-q)+"h"+(F-H)+"v"+(q+p+1)+"h-"+(F-H)+"z"}if(m!==null){m+="M"+(H+o)+","+h+O+"h"+(F-H-2*o)+O+"M"+Math.round((H+F)/2)+","+(h-q+o)+N+"v"+(q+p-2*o)+N}if(K!==null){K+=this.markeratt.create((H+F)/2,h)}}}}if(!Q&&((l!==L)||(D!==l))){if(E!==k){C+="h"+(k-E)}if(j===l){if(L!==D){C+="v"+(L-D)}if(l!==L){C+="v"+(l-L)}}else{if(l!==D){C+="v"+(l-D)}if(L!==l){C+="v"+(L-l)}if(j!==L){C+="v"+(j-L)}}E=k;D=j}if(G&&(E!==B)){C+="h"+(B-E)}n=P;l=L=j=A;k=B}}else{if((A!==j)||G){if(B!==k){C+="h"+(B-k)}if(A!==j){C+="v"+(A-j)}j=A;k=B}}}}if((this.fillatt.color!=="none")&&(C.length>0)){var v=(d+3);if((this.hmin>=0)&&(r.gry(0)<d)){v=Math.round(r.gry(0))}C+="L"+k+","+v+"L"+e+","+v+"Z"}if(Q){if((z!==null)&&(z.length>0)){this.draw_g.append("svg:path").attr("d",z).call(this.fillatt.func)}if((m!==null)&&(m.length>0)){this.draw_g.append("svg:path").attr("d",m).call(this.lineatt.func)}if((K!==null)&&(K.length>0)){this.draw_g.append("svg:path").attr("d",K).call(this.markeratt.func)}}else{if(C.length>0){this.draw_g.append("svg:path").attr("d",C).style("stroke-linejoin","miter").call(this.lineatt.func).call(this.fillatt.func)}}};a.TH1Painter.prototype.GetBinTips=function(k,g){var i=[],c=this.GetTipName(),h=this.main_painter();if(c.length>0){i.push(c)}var e=this.GetBinX(k),d=this.GetBinX(k+1),l=this.histo.getBinContent(k+1);if((this.options.Error>0)||(this.options.Mark>0)){i.push("x = "+h.AxisAsText("x",(e+d)/2));i.push("y = "+h.AxisAsText("y",l));if(this.options.Error>0){i.push("error x = "+((d-e)/2).toPrecision(4));i.push("error y = "+this.histo.getBinError(k+1).toPrecision(4))}}else{i.push("bin = "+(k+1));if(h.x_kind==="labels"){i.push("x = "+h.AxisAsText("x",e))}else{if(h.x_kind==="time"){i.push("x = "+h.AxisAsText("x",(e+d)/2))}else{i.push("x = ["+h.AxisAsText("x",e)+", "+h.AxisAsText("x",d)+")")}}if(l===Math.round(l)){i.push("entries = "+l)}else{i.push("entries = "+a.FFormat(l,a.gStyle.StatFormat))}}if(!g){return i}var j="";for(var f=0;f<i.length;++f){j+=(f>0?"\n":"")+i[f]}return j};a.TH1Painter.prototype.ProcessTooltip=function(G){if((G===null)||!this.draw_content){if(this.draw_g!==null){this.draw_g.select(".tooltip_bin").remove()}this.ProvideUserTooltip(null);return null}var w=this.frame_width(),t=this.frame_height(),o=this.main_painter(),F=this,v=null,D=true,h,A,e,q,z,p,g=this.GetSelectIndex("x","left",-1),C=this.GetSelectIndex("x","right",2),y=g,s=C;function k(m){var l=F.GetBinX(m);if((l<0)&&F.options.Logx){return null}return o.grx(l)}function j(l){var m=F.histo.getBinContent(l+1);if(F.options.Logy&&(m<F.scale_ymin)){return 10*t}return Math.round(o.gry(m))}while(y<s-1){var x=Math.round((y+s)*0.5);var i=k(x);if(i===null){y=x;continue}if(i<G.x-0.5){y=x}else{if(i>G.x+0.5){s=x}else{y++;s--}}}v=s=y;h=k(v);while((y>g)&&(k(y-1)>h-1)){--y}while((s<C)&&(k(s+1)<h+1)){++s}if(y<s){var d=t;for(var x=y;x<=s;x++){var u=Math.abs(j(x)-G.y);if(u<d){d=u;v=x}}if(d>t/10){v=Math.round(y+(s-y)/t*G.y)}h=k(v)}h=Math.round(h);e=Math.round(k(v+1));A=Math.round((h+e)/2);z=q=p=j(v);if((this.options.Error>0)||(this.options.Mark>0)){D=true;var B=3;if(this.markeratt){B=Math.max(B,2+Math.round(this.markeratt.size*4))}if(e-h<2*B){h=A-B;e=A+B}if(this.options.Error>0){var c=this.histo.getBinContent(v+1);var n=this.histo.getBinError(v+1);q=Math.round(o.gry(c+n));p=Math.round(o.gry(c-n))}q=Math.min(q,z-B);p=Math.max(p,z+B);if(!G.touch&&(G.nproc===1)){if((G.y<q)||(G.y>p)){v=null}}}else{D=(G.nproc===1)&&(C-g<w);if(D){if((G.y<q)&&!G.touch){v=null}p=t;if((this.fillatt.color!=="none")&&(this.hmin>=0)){p=Math.round(o.gry(0));if((p>t)||(p<=q)){p=t}}}}if(v!==null){if((v===g)&&(h>G.x+2)){v=null}else{if((v===C-1)&&(e<G.x-2)){v=null}}}var E=this.draw_g.select(".tooltip_bin");if((v===null)||((p<=0)||(q>=t))){E.remove();this.ProvideUserTooltip(null);return null}var H={x:A,y:z,color1:this.lineatt.color,color2:this.fillatt.color,lines:this.GetBinTips(v)};if(D){if(E.empty()){E=this.draw_g.append("svg:rect").attr("class","tooltip_bin h1bin").style("pointer-events","none")}H.changed=E.property("current_bin")!==v;if(H.changed){E.attr("x",h).attr("width",e-h).attr("y",q).attr("height",p-q).style("opacity","0.3").property("current_bin",v)}H.exact=(Math.abs(z-G.y)<=5)||((G.y>=q)&&(G.y<=p));H.menu=true;H.menu_dist=Math.sqrt((A-G.x)*(A-G.x)+(z-G.y)*(z-G.y))}else{var f=this.lineatt.width+3;if(E.empty()){E=this.draw_g.append("svg:circle").attr("class","tooltip_bin").style("pointer-events","none").attr("r",f).call(this.lineatt.func).call(this.fillatt.func)}H.exact=(Math.abs(A-G.x)<=f)&&(Math.abs(z-G.y)<=f);H.menu=H.exact;H.menu_dist=Math.sqrt((A-G.x)*(A-G.x)+(z-G.y)*(z-G.y));H.changed=E.property("current_bin")!==v;if(H.changed){E.attr("cx",A).attr("cy",z).property("current_bin",v)}}if(this.IsUserTooltipCallback()&&H.changed){this.ProvideUserTooltip({obj:this.histo,name:this.histo.fName,bin:v,cont:this.histo.getBinContent(v+1),grx:A,gry:z})}return H};a.TH1Painter.prototype.FillHistContextMenu=function(c){if(!this.draw_content){return}c.add("Auto zoom-in",this.AutoZoom.bind(this));c.addDrawMenu("Draw with",["hist","p","e","e1","pe2"],function(d){this.options=this.DecodeOptions(d);this.Redraw()})};a.TH1Painter.prototype.AutoZoom=function(){var f=this.GetSelectIndex("x","left",-1),d=this.GetSelectIndex("x","right",1),g=d-f;if(g==0){return}var c=this.histo.getBinContent(f+1);for(var e=f;e<d;++e){if(this.histo.getBinContent(e+1)<c){c=this.histo.getBinContent(e+1)}}if(c>0){return}while((f<d)&&(this.histo.getBinContent(f+1)<=c)){++f}while((f<d)&&(this.histo.getBinContent(d)<=c)){--d}if((d-f<g)&&(f<d)){this.Zoom(this.GetBinX(f),this.GetBinX(d))}};a.TH1Painter.prototype.CanZoomIn=function(e,d,c){if((e=="x")&&(this.GetIndexX(c,0.5)-this.GetIndexX(d,0)>1)){return true}if((e=="y")&&(Math.abs(c-d)>Math.abs(this.ymax-this.ymin)*0.000001)){return true}return false};a.TH1Painter.prototype.Redraw=function(){this.CreateXY();this.DrawAxes();this.DrawGrids();this.DrawBins();this.DrawTitle()};a.Painter.drawHistogram1D=function(f,d,e){var c=new a.TH1Painter(d);c.SetDivId(f,1);c.options=c.DecodeOptions(e);c.CheckPadOptions();c.ScanContent();c.CreateXY();c.DrawAxes();c.DrawGrids();c.DrawBins();c.DrawTitle();if(a.gStyle.AutoStat&&c.create_canvas){c.CreateStat()}c.DrawNextFunction(0,function(){c.AddInteractive();c.FillToolbar();if(c.options.AutoZoom){c.AutoZoom()}c.DrawingReady()});return c};a.Painter.drawText=function(e,d){var c=new a.TObjectPainter(d);c.SetDivId(e,2);c.Redraw=function(){var l=this.GetObject(),k=this.pad_width(),j=this.pad_height(),g=l.fX,o=l.fY,m=a.Painter.root_colors[l.fTextColor],i=true,f=0,n=1;if(l.TestBit(a.BIT(14))){g=g*k;o=(1-o)*j}else{if(this.main_painter()!==null){k=this.frame_width();j=this.frame_height();i=false;g=this.main_painter().grx(g);o=this.main_painter().gry(o)}else{if(this.root_pad()!==null){g=this.ConvertToNDC("x",g)*k;o=(1-this.ConvertToNDC("y",o))*j}else{l.fTextAlign=22;g=k/2;o=j/2;if(l.fTextSize===0){l.fTextSize=0.05}if(l.fTextColor===0){l.fTextColor=1}}}}this.RecreateDrawG(i,i?"text_layer":"upper_layer");if(l._typename=="TLatex"){f=1;n=0.9}else{if(l._typename=="TMathText"){f=2;n=0.8}}this.StartTextDrawing(l.fTextFont,Math.round(l.fTextSize*Math.min(k,j)*n));this.DrawText(l.fTextAlign,Math.round(g),Math.round(o),0,0,l.fTitle,m,f);this.FinishTextDrawing()};c.Redraw();return c.DrawingReady()};a.RawTextPainter=function(c){a.TBasePainter.call(this);this.txt=c;return this};a.RawTextPainter.prototype=Object.create(a.TBasePainter.prototype);a.RawTextPainter.prototype.RedrawObject=function(c){this.txt=c;this.Draw();return true};a.RawTextPainter.prototype.Draw=function(){var e=this.txt.value;if(e==null){e="<undefined>"}var h="mathjax" in this.txt;if(!h&&!("as_is" in this.txt)){var d=e.split("\n");e="";for(var g=0;g<d.length;++g){e+="<pre>"+d[g]+"</pre>"}}var j=this.select_main();var c=j.select("div");if(c.empty()){c=j.append("div").style("max-width","100%").style("max-height","100%").style("overflow","auto")}c.html(e);this.SetDivId(this.divid);if(h){if(this["loading_mathjax"]){return}this["loading_mathjax"]=true;var f=this;a.AssertPrerequisites("mathjax",function(){f.loading_mathjax=false;if(typeof MathJax=="object"){MathJax.Hub.Queue(["Typeset",MathJax.Hub,j.node()])}})}};a.Painter.drawRawText=function(f,c,e){var d=new a.RawTextPainter(c);d.SetDivId(f);d.Draw();return d.DrawingReady()};a.Painter.FolderHierarchy=function(d,f){if((f==null)||!("fFolders" in f)||(f.fFolders==null)){return false}if(f.fFolders.arr.length===0){d._more=false;return true}d._childs=[];for(var c=0;c<f.fFolders.arr.length;++c){var e=f.fFolders.arr[c];d._childs.push({_name:e.fName,_kind:"ROOT."+e._typename,_obj:e})}return true};a.Painter.TaskHierarchy=function(d,f){if((f==null)||!("fTasks" in f)||(f.fTasks==null)){return false}a.Painter.ObjectHierarchy(d,f,{exclude:["fTasks","fName"]});if((f.fTasks.arr.length===0)&&(d._childs.length==0)){d._more=false;return true}for(var c=0;c<f.fTasks.arr.length;++c){var e=f.fTasks.arr[c];d._childs.push({_name:e.fName,_kind:"ROOT."+e._typename,_obj:e})}return true};a.Painter.ListHierarchy=function(f,c){if(c._typename!="TList"&&c._typename!="TObjArray"&&c._typename!="TClonesArray"){return false}if((c.arr===undefined)||(c.arr.length===0)){f._more=false;return true}f._childs=[];for(var d=0;d<c.arr.length;++d){var g=c.arr[d];var e;if(g===null){e={_name:d.toString(),_kind:"ROOT.NULL",_title:"NULL",_obj:null}}else{e={_name:g.fName,_kind:"ROOT."+g._typename,_title:g.fTitle,_obj:g};if((e._name===undefined)||(!isNaN(parseInt(e._name))&&(parseInt(e._name)!==d))||(c.arr.indexOf(g)<d)){e._name=d.toString()}if(e._title===undefined){e._title=g._typename?e._kind:e._name}}f._childs.push(e)}return true};a.Painter.TreeHierarchy=function(h,l){if(l._typename!="TTree"&&l._typename!="TNtuple"){return false}h._childs=[];for(var f=0;f<l.fBranches.arr.length;++f){var g=l.fBranches.arr[f];var c=g.fLeaves.arr.length;if(c==1&&g.fLeaves.arr[0].fName==g.fName){c=0}var d={_name:g.fName,_kind:c>0?"ROOT.TBranch":"ROOT.TLeafF"};h._childs.push(d);if(c>0){d._childs=[];for(var e=0;e<c;++e){var k={_name:g.fLeaves.arr[e].fName,_kind:"ROOT.TLeafF"};d._childs.push(k)}}}return true};a.Painter.KeysHierarchy=function(j,h,f,k){if(h===undefined){return false}j._childs=[];for(var e=0;e<h.length;++e){var d=h[e];var g={_name:d.fName+";"+d.fCycle,_cycle:d.fCycle,_kind:"ROOT."+d.fClassName,_title:d.fTitle,_keyname:d.fName,_readobj:null,_parent:j};if("fRealName" in d){g._realname=d.fRealName+";"+d.fCycle}if(d.fClassName=="TDirectory"||d.fClassName=="TDirectoryFile"){var c=null;if((k!=null)&&(f!=null)){c=f.GetDir(k+d.fName)}if(c==null){g._more=true;g._expand=function(i,l){return a.Painter.KeysHierarchy(i,l.fKeys)}}else{g._name=d.fName;a.Painter.KeysHierarchy(g,c.fKeys,f,k+d.fName+"/")}}else{if((d.fClassName=="TList")&&(d.fName=="StreamerInfo")){g._name="StreamerInfo";g._kind="ROOT.TStreamerInfoList";g._title="List of streamer infos for binary I/O";g._readobj=f.fStreamerInfos}}j._childs.push(g)}return true};a.Painter.ObjectHierarchy=function(k,f,i){if((k==null)||(f==null)){return false}var h=true,d=k;while(d){if("_nosimple" in d){h=d._nosimple;break}d=d._parent}k._childs=[];if(!("_obj" in k)){k._obj=f}else{if(k._obj!==f){alert("object missmatch")}}if(!("_title" in k)&&("_typename" in f)){k._title="ROOT."+f._typename}for(var l in f){if(l=="_typename"){continue}var e=f[l];if(typeof e=="function"){continue}if(i&&i.exclude&&(i.exclude.indexOf(l)>=0)){continue}var m={_parent:k,_name:l};if(e===null){m._value=m._title="null";if(!h){k._childs.push(m)}continue}var g=Object.prototype.toString.apply(e);var c=false;if((g.lastIndexOf("Array]")==g.length-6)&&(g.indexOf("[object")==0)){m._title=m._kind+" len="+e.length;c=(g!="[object Array]");if(e.length===0){m._value="[ ]";m._more=false}else{m._value="[...]";m._more=true;m._expand=a.Painter.ObjectHierarchy;m._obj=e}}else{if(typeof e=="object"){if("_typename" in e){m._kind=m._title="ROOT."+e._typename}var n=k,j=false;while(n&&!j){j=(n._obj===e);n=n._parent}if(j){m._value="{ prnt }";c=true}else{m._obj=e;m._value="{ }";if(e._typename=="TColor"){m._value=a.Painter.MakeColorRGB(e)}}}else{if((typeof e=="number")||(typeof e=="boolean")){c=true;if(l=="fBits"){m._value="0x"+e.toString(16)}else{m._value=e.toString()}m._vclass="h_value_num"}else{if(typeof e=="string"){c=true;m._value='"'+e+'"';m._vclass="h_value_str"}else{c=true;alert("miss "+l+" "+typeof e)}}}}if(!c||!h){k._childs.push(m)}}return true};a.hpainter=null;a.HierarchyPainter=function(c,d,e){a.TBasePainter.call(this);this.name=c;this.h=null;this.with_icons=true;this.background=e;this.files_monitoring=(d==null);if(d!=null){this.SetDivId(d)}if(a.hpainter==null){a.hpainter=this}};a.HierarchyPainter.prototype=Object.create(a.TBasePainter.prototype);a.HierarchyPainter.prototype.Cleanup=function(){this.clear(true)};a.HierarchyPainter.prototype.FileHierarchy=function(d){var c=this;var e={_name:d.fFileName,_kind:"ROOT.TFile",_file:d,_fullurl:d.fFullURL,_had_direct_read:false,_get:function(g,j,i){var f=this;if((g!=null)&&(g._readobj!=null)){return a.CallBack(i,g,g._readobj)}if(g!=null){j=c.itemFullName(g,f)}function h(k){if(f._file==null){f._file=k}if(k==null){return a.CallBack(i,g,null)}k.ReadObject(j,function(n){if((g==null)&&(n!=null)){var o=c.Find({name:j,top:f,last_exists:true,check_keys:true});if((o!=null)&&("last" in o)&&(o.last!=f)){var l=k.GetDir(c.itemFullName(o.last,f));if(l){o.last._name=o.last._keyname;var m=c.itemFullName(o.last,f);a.Painter.KeysHierarchy(o.last,l.fKeys,k,m+"/")}}else{a.Painter.KeysHierarchy(f,k.fKeys,k,"")}g=c.Find({name:j,top:f})}if(g!=null){g._readobj=n;if("_expand" in g){g._name=g._keyname}}a.CallBack(i,g,n)})}if(f._file!=null){h(f._file)}else{new a.TFile(f._fullurl,h)}}};a.Painter.KeysHierarchy(e,d.fKeys,d,"");return e};a.HierarchyPainter.prototype.ForEach=function(e,d){if(d==null){d=this.h}if((d==null)||(typeof e!="function")){return}function c(f){e(f);if("_childs" in f){for(var g=0;g<f._childs.length;++g){f._childs[g]._parent=f;c(f._childs[g])}}}c(d)};a.HierarchyPainter.prototype.Find=function(c){function d(l,g){if(!g||(g.length==0)||(l==null)){return l}var o=-1;function m(i){i._parent=l;if((o+1==g.length)||(o<0)){return i}return d(i,g.substr(o+1))}do{o=g.indexOf("/",o+1);var j=(o<0)?g:g.substr(0,o);if(typeof l._childs!="undefined"){for(var h=0;h<l._childs.length;++h){if(l._childs[h]._name==j){return m(l._childs[h])}}}if(("check_keys" in c)&&(typeof l._childs!="undefined")){for(var h=0;h<l._childs.length;++h){if(l._childs[h]._name.indexOf(j+";")==0){return m(l._childs[h])}}}if("force" in c){if(!("_childs" in l)){l._childs=[]}var n={_name:j};l._childs.push(n);return m(n)}if(c.allow_index&&(typeof l._childs!="undefined")){var k=parseInt(j);if(!isNaN(k)&&(k>=0)&&(k<l._childs.length)){return m(l._childs[k])}}}while(o>0);return("last_exists" in c)&&(l!=null)?{last:l,rest:g}:null}var e=this.h;var f="";if(typeof c=="string"){f=c;c={}}else{if(typeof c=="object"){f=c.name;if("top" in c){e=c.top}}else{return null}}return d(e,f)};a.HierarchyPainter.prototype.itemFullName=function(d,e){var c="";while(d&&("_parent" in d)){if(c.length>0){c="/"+c}c=d._name+c;d=d._parent;if(e&&(d===e)){break}}return c};a.HierarchyPainter.prototype.ExecuteCommand=function(g,j){var k=this.Find(g);var c=g+"/cmd.json";var d=this;var f=b.select((typeof j=="function")?null:j);if("_numargs" in k){for(var e=0;e<k._numargs;++e){var h="arg"+(e+1);var i=null;if(e+2<arguments.length){i=arguments[e+2]}if((i==null)&&(typeof j=="object")){i=prompt("Input argument "+h+" for command "+k._name,"")}if(i==null){return}c+=((e==0)?"?":"&")+h+"="+i}}if(!f.empty()){f.style("background","yellow");if(k&&k._title){f.attr("title","Executing "+k._title)}}a.NewHttpRequest(c,"text",function(m){if(typeof j=="function"){return j(m)}if(f.empty()){return}var l=((m!=null)&&(m!="false"))?"green":"red";if(k&&k._title){f.attr("title",k._title+" lastres="+m)}f.style("background",l).transition().duration(2000).each("end",function(){f.style("background","")});if((l=="green")&&("_hreload" in k)){d.reload()}if((l=="green")&&("_update_item" in k)){d.updateItems(k._update_item.split(";"))}}).send()};a.HierarchyPainter.prototype.RefreshHtml=function(d){if(this.divid==null){return a.CallBack(d)}var c=this;a.AssertPrerequisites("jq2d",function(){c.RefreshHtml(d)})};a.HierarchyPainter.prototype.toggle=function(c,f){var d=(f==null)?this.h:f;if(!("_childs" in d)){if(!c||this.with_icons||((typeof d._expand)!=="function")){return}this.expand(this.itemFullName(d));if("_childs" in d){d._isopen=true}return}if(d!=this.h){if(c){d._isopen=true}else{delete d._isopen}}for(var e=0;e<d._childs.length;++e){this.toggle(c,d._childs[e])}if(f==null){this.RefreshHtml()}};a.HierarchyPainter.prototype.get=function(i,e,l){var f=(typeof i=="object")?i.arg:i;var h=this.Find({name:f,allow_index:true});var g=(h!=null)?null:this.Find({name:f,last_exists:true,check_keys:true,allow_index:true});if((g!==null)&&("last" in g)&&(g.last!==null)){var c=this;var j=this.itemFullName(g.last);if((typeof i=="object")&&("rest" in i)){if((i.rest==g.rest)||(i.rest.length<=g.rest.length)){return a.CallBack(e)}}return this.expand(j,function(m){if(!m){a.CallBack(e)}var d=c.itemFullName(g.last);c.get({arg:d+"/"+g.rest,rest:g.rest},e,l)})}if((h!==null)&&(typeof h._obj=="object")){return a.CallBack(e,h,h._obj)}var k=h;while(k!=null){if(("_get" in k)&&(typeof k._get=="function")){return k._get(h,null,e,l)}k=("_parent" in k)?k._parent:null}a.CallBack(e,h,null)};a.HierarchyPainter.prototype.draw=function(e,d,c){return a.draw(e,d,c)};a.HierarchyPainter.prototype.redraw=function(e,d,c){return a.redraw(e,d,c)};a.HierarchyPainter.prototype.player=function(h,d,g){var e=this.Find(h);if(!e||!("_player" in e)){return a.CallBack(g,null)}var f=this;var c=("_prereq" in e)?e._prereq:"";a.AssertPrerequisites(c,function(){var i=a.findFunction(e._player);if(i==null){return a.CallBack(g,null)}f.CreateDisplay(function(k){var j=null;if(k){j=i(f,h,d)}a.CallBack(g,j)})})};a.HierarchyPainter.prototype.canDisplay=function(d,c){if(d==null){return false}if("_player" in d){return true}if(c=="inspect"){return true}var e=a.getDrawHandle(d._kind,c);return(e!=null)&&("func" in e)};a.HierarchyPainter.prototype.display=function(j,d,i){var f=this,c=null,e=false;function g(){if(c){c.SetItemName(j,e?null:d)}a.CallBack(i,c,j)}f.CreateDisplay(function(m){if(!m){return g()}var h=f.Find(j);if((h!=null)&&("_player" in h)){return f.player(j,d,g)}e=(typeof(d)=="string")&&(d.indexOf("update:")==0);if(e){d=d.substr(7);if((h==null)||("_doing_update" in h)){return g()}h._doing_update=true}if(h!=null){if(!f.canDisplay(h,d)){return g()}}var l="";if((typeof(d)=="string")&&(d.indexOf("divid:")>=0)){var k=d.indexOf("divid:");l=d.slice(k+6);d=d.slice(0,k)}a.progress("Loading "+j);f.get(j,function(n,o){a.progress();if(e&&n){delete n._doing_update}if(o==null){return g()}a.progress("Drawing "+j);if(l.length>0){c=e?f.redraw(l,o,d):f.draw(l,o,d)}else{m.ForEachPainter(function(q,r){if(q.GetItemName()!=j){return}if(!e&&(d!=null)&&(q.GetItemDrawOpt()!=d)){return}c=q;m.ActivateFrame(r);c.RedrawObject(o)})}if(c==null){if(e){a.console("something went wrong - did not found painter when doing update of "+j)}else{var p=m.FindFrame(j,true);b.select(p).html("");m.ActivateFrame(p);c=f.draw(b.select(p).attr("id"),o,d);if(a.gStyle.DragAndDrop){f.enable_dropping(p,j)}}}a.progress();if(c===null){return g()}c.WhenReady(g)},d)})};a.HierarchyPainter.prototype.enable_dragging=function(c,d){};a.HierarchyPainter.prototype.enable_dropping=function(c,d){};a.HierarchyPainter.prototype.dropitem=function(f,e,d){var c=this;c.get(f,function(h,i){if(i!=null){var g=c.draw(e,i,"same");if(g){g.WhenReady(function(){g.SetItemName(f)})}}a.CallBack(d)});return true};a.HierarchyPainter.prototype.updateItems=function(c){if((this.disp==null)||(c==null)){return}var d=[],e=[];this.disp.ForEachPainter(function(f){var g=f.GetItemName();if((g==null)||(d.indexOf(g)>=0)){return}if(typeof c=="array"){if(c.indexOf(g)<0){return}}else{if(c!=g){return}}d.push(g);e.push("update:"+f.GetItemDrawOpt())},true);if(d.length>0){this.displayAll(d,e)}};a.HierarchyPainter.prototype.updateAll=function(e,f){if(this.disp==null){return}var h=[],d=[],g=this;this.disp.ForEachPainter(function(m){var n=m.GetItemName();var i=m.GetItemDrawOpt();if((n==null)||(h.indexOf(n)>=0)){return}var k=g.Find(n);if((k==null)||("_not_monitor" in k)||("_player" in k)){return}var j=false;if("_always_monitor" in k){j=true}else{var l=a.getDrawHandle(k._kind);if(l&&("monitor" in l)){if((l.monitor===false)||(l.monitor=="never")){return}if(l.monitor==="always"){j=true}}}if(j||!e){h.push(n);d.push("update:"+i)}},true);var c=this;if(this.files_monitoring){this.ForEachRootFile(function(i){c.ForEach(function(j){delete j._readobj},i);delete i._file})}this.displayAll(h,d)};a.HierarchyPainter.prototype.displayAll=function(l,q,e){if((l==null)||(l.length==0)){return a.CallBack(e)}var k=this;if(q==null){q=[]}while(q.length<l.length){q.push("")}if((q.length==1)&&(q[0]=="iotest")){k.clear();b.select("#"+k.disp_frameid).html("<h2>Start I/O test "+("IO" in a?"Mode="+a.IO.Mode:"")+"</h2>");var d=new Date();return k.get(l[0],function(i,j){var h=new Date();b.select("#"+k.disp_frameid).append("h2").html("Item "+l[0]+" reading time = "+(h.getTime()-d.getTime())+"ms");return a.CallBack(e)})}var p=new Array(l.length);for(var g=0;g<l.length;++g){p[g]=null;if(k.Find(l[g])){continue}if(k.Find(l[g]+";1")){l[g]+=";1";continue}var m=l[g].indexOf("+");if(m>0){p[g]=l[g].split("+");l[g]=p[g].shift();for(var f=0;f<p[g].length;++f){var m=p[g][f].indexOf("_same_");if((m>0)&&(k.Find(p[g][f])==null)){p[g][f]=p[g][f].substr(0,m)+l[g].substr(m)}}}var m=l[g].indexOf("_same_");if((m>0)&&!k.Find(l[g])&&(g>0)){l[g]=l[g].substr(0,m)+l[0].substr(m)}}for(var c=l.length-1;c>=0;c--){var o=k.Find(l[c]);if((o==null)||k.canDisplay(o,q[c])){continue}k.expand(l[c]);l.splice(c,1);q.splice(c,1);p.splice(c,1)}if(l.length==0){return a.CallBack(e)}k.CreateDisplay(function(j){if(!j){return a.CallBack(e)}for(var h=0;h<l.length;++h){if(q[h].indexOf("update:")!=0){j.CreateFrame(l[h])}}for(var h=0;h<l.length;++h){k.display(l[h],q[h],function(i,s){var r=l.indexOf(s);if(r<0){return a.console("did not found item "+s)}l[r]="---";function n(){if((i!=null)&&(p[r]!=null)&&(p[r].length>0)){return k.dropitem(p[r].shift(),i.divid,n)}var u=false;for(var t=0;t<l.length;++t){if(l[t]!="---"){u=true}}if(!u){a.CallBack(e)}}n()})}})};a.HierarchyPainter.prototype.reload=function(){var c=this;if("_online" in this.h){this.OpenOnline(this.h._online,function(){c.RefreshHtml()})}};a.HierarchyPainter.prototype.expand=function(h,e,g){var d=this;var c=this.Find(h);if(!c&&g){return a.CallBack(e)}function f(j,l,i){if(!i){i=d.itemFullName(j)}if(l&&j&&typeof j._expand=="function"){if(j._expand(j,l)){j._isopen=true;if(typeof d.UpdateTreeNode=="function"){d.UpdateTreeNode(j,g)}a.CallBack(e,j);return true}}if(!("_expand" in j)){var k=a.getDrawHandle(j._kind);if(k&&("expand" in k)){a.AssertPrerequisites(k.prereq,function(){j._expand=a.findFunction(k.expand);if(typeof j._expand!="function"){delete j._expand;return}d.expand(i,e,g)});return true}}if(l&&a.Painter.ObjectHierarchy(j,l)){j._isopen=true;if(typeof d.UpdateTreeNode=="function"){d.UpdateTreeNode(j,g)}a.CallBack(e,j);return true}return false}if(c){if(("_more" in c)&&!c._more){return a.CallBack(e)}if(f(c,c._obj,h)){return}}a.progress("Loading "+h);this.get(h,function(i,j){a.progress();if(j&&f(i,j)){return}a.CallBack(e)},"hierarchy_expand")};a.HierarchyPainter.prototype.GetTopOnlineItem=function(c){if(c!=null){while((c!=null)&&(!("_online" in c))){c=c._parent}return c}if(this.h==null){return null}if("_online" in this.h){return this.h}if((this.h._childs!=null)&&("_online" in this.h._childs[0])){return this.h._childs[0]}return null};a.HierarchyPainter.prototype.ForEachJsonFile=function(d){if(this.h==null){return}if("_jsonfile" in this.h){return a.CallBack(d,this.h)}if(this.h._childs!=null){for(var e=0;e<this.h._childs.length;++e){var c=this.h._childs[e];if("_jsonfile" in c){a.CallBack(d,c)}}}};a.HierarchyPainter.prototype.OpenJsonFile=function(f,e){var d=false;this.ForEachJsonFile(function(g){if(g._jsonfile==f){d=true}});if(d){return a.CallBack(e)}var c=this;a.NewHttpRequest(f,"object",function(i){if(i==null){return a.CallBack(e)}var h={_jsonfile:f,_kind:"ROOT."+i._typename,_jsontmp:i,_name:f.split("/").pop()};if("fTitle" in i){h._title=i.fTitle}h._get=function(l,n,m){if("_jsontmp" in l){var k=l._jsontmp;delete l._jsontmp;return a.CallBack(m,l,k)}a.NewHttpRequest(l._jsonfile,"object",function(o){return a.CallBack(m,l,o)}).send(null)};if(c.h==null){c.h=h}else{if(c.h._kind=="TopFolder"){c.h._childs.push(h)}else{var j=c.h;var g=("_jsonfile" in j)?"Files":"Items";c.h={_name:g,_kind:"TopFolder",_childs:[j,h]}}}c.RefreshHtml(e)}).send(null)};a.HierarchyPainter.prototype.ForEachRootFile=function(d){if(this.h==null){return}if((this.h._kind=="ROOT.TFile")&&(this.h._file!=null)){return a.CallBack(d,this.h)}if(this.h._childs!=null){for(var e=0;e<this.h._childs.length;++e){var c=this.h._childs[e];if((c._kind=="ROOT.TFile")&&("_fullurl" in c)){a.CallBack(d,c)}}}};a.HierarchyPainter.prototype.OpenRootFile=function(f,e){var d=false;this.ForEachRootFile(function(g){if(g._fullurl==f){d=true}});if(d){return a.CallBack(e)}var c=this;a.OpenFile(f,function(i){if(i==null){return a.CallBack(e)}var h=c.FileHierarchy(i);h._isopen=true;if(c.h==null){c.h=h}else{if(c.h._kind=="TopFolder"){c.h._childs.push(h)}else{var j=c.h;var g=(j._kind=="ROOT.TFile")?"Files":"Items";c.h={_name:g,_kind:"TopFolder",_childs:[j,h]}}}c.RefreshHtml(e)})};a.HierarchyPainter.prototype.GetFileProp=function(e){var c=this.Find(e);if(c==null){return null}var d=c._name;while(c._parent!=null){c=c._parent;if("_file" in c){return{fileurl:c._file.fURL,itemname:d}}d=c._name+"/"+d}return null};a.MarkAsStreamerInfo=function(c,d,e){if((e!=null)&&(e._typename=="TList")){e._typename="TStreamerInfoList"}};a.HierarchyPainter.prototype.GetOnlineItemUrl=function(d){if((d!=null)&&(typeof d=="string")){d=this.Find(d)}var e=this.GetTopOnlineItem(d);if(d==null){return null}var c=this.itemFullName(d,e);if(e&&("_online" in e)&&(e._online!="")){c=e._online+c}return c};a.HierarchyPainter.prototype.GetOnlineItem=function(o,k,m,i){var d=k,g=false,l="",p="object",c=this,f=null;if(i==="hierarchy_expand"){g=true;i=undefined}if(o!=null){d=this.GetOnlineItemUrl(o);var e=null;if("_kind" in o){f=a.getDrawHandle(o._kind)}if(g){l="h.json?compact=3";o._expand=a.Painter.OnlineHierarchy}else{if("_make_request" in o){e=a.findFunction(o._make_request)}else{if((f!=null)&&("make_request" in f)){e=f.make_request}}}if(typeof e=="function"){var j=e(c,o,d,i);if(j!=null){if(typeof j=="string"){l=j}else{if("req" in j){l=j.req}if("kind" in j){p=j.kind}}}}if((l.length==0)&&(o._kind.indexOf("ROOT.")!=0)){l="item.json.gz?compact=3"}}if((k==null)&&(o!=null)&&("_cached_draw_object" in this)&&(l.length==0)){var h=this._cached_draw_object;delete this._cached_draw_object;return a.CallBack(m,o,h)}if(l.length==0){l="root.json.gz?compact=3"}if(d.length>0){d+="/"}d+=l;var n=a.NewHttpRequest(d,p,function(s){var r=null;if(!g&&(o!=null)&&("_after_request" in o)){r=a.findFunction(o._after_request)}else{if((f!=null)&&("after_request" in f)){r=f.after_request}}if(typeof r=="function"){var q=r(c,o,s,i,n);if((q!=null)&&(typeof q=="object")){s=q}}a.CallBack(m,o,s)});n.send(null)};a.Painter.OnlineHierarchy=function(c,d){if((d!=null)&&(c!=null)&&("_childs" in d)){for(var e=0;e<d._childs.length;++e){if(d._childs[e]._more||d._childs[e]._childs){d._childs[e]._expand=a.Painter.OnlineHierarchy}}c._childs=d._childs;d._childs=null;return true}return false};a.HierarchyPainter.prototype.OpenOnline=function(e,f){var c=this;function g(i){c.h=i;if(c.h==null){return}if(("_title" in c.h)&&(c.h._title!="")){document.title=c.h._title}i._isopen=true;c.h._online=e;c.h._get=function(l,n,m,k){c.GetOnlineItem(l,n,m,k)};c.h._expand=a.Painter.OnlineHierarchy;var h="",j="";c.ForEach(function(l){if("_childs" in l){l._expand=a.Painter.OnlineHierarchy}if("_autoload" in l){var k=l._autoload.split(";");for(var m=0;m<k.length;++m){if((k[m].length>3)&&((k[m].lastIndexOf(".js")==k[m].length-3)||(k[m].lastIndexOf(".css")==k[m].length-4))){if(h.indexOf(k[m])<0){h+=k[m]+";"}}else{if(j.indexOf(k[m])<0){j+=k[m]+";"}}}}});if(h.length>0){h="user:"+h}a.AssertPrerequisites(j+h,function(){c.ForEach(function(m){if(!("_drawfunc" in m)||!("_kind" in m)){return}var l="kind:"+m._kind;if(m._kind.indexOf("ROOT.")==0){l=m._kind.slice(5)}var k=m._drawopt;if(!a.canDraw(l)||(k!=null)){a.addDrawFunc({name:l,func:m._drawfunc,script:m._drawscript,opt:k})}});a.CallBack(f,c)})}if(!e){e=""}if(typeof e=="object"){var d=e;e="";return g(d)}a.NewHttpRequest(e+"h.json?compact=3","object",g).send(null)};a.HierarchyPainter.prototype.GetOnlineProp=function(e){var c=this.Find(e);if(c==null){return null}var d=c._name;while(c._parent!=null){c=c._parent;if("_online" in c){return{server:c._online,itemname:d}}d=c._name+"/"+d}return null};a.HierarchyPainter.prototype.FillOnlineMenu=function(d,k,i){var l=this;var e=this.Find(i);var c=a.getDrawOptions(e._kind,"nosame");var g=a.getDrawHandle(e._kind);var h=("_kind" in e)?e._kind.indexOf("ROOT.")==0:false;if(c!=null){d.addDrawMenu("Draw",c,function(m){l.display(i,m)})}if((e._childs==null)&&(e._more||h)){d.add("Expand",function(){l.expand(i)})}if(g&&("execute" in g)){d.add("Execute",function(){l.ExecuteCommand(i,d.tree_node)})}var j=k.server+k.itemname+"/draw.htm";var f="?";if(this.IsMonitoring()){j+=f+"monitoring="+this.MonitoringInterval();f="&"}if(c!=null){d.addDrawMenu("Draw in new window",c,function(m){window.open(j+f+"opt="+m)})}if((c!=null)&&(c.length>0)&&h){d.addDrawMenu("Draw as png",c,function(m){window.open(k.server+k.itemname+"/root.png?w=400&h=300&opt="+m)})}if("_player" in e){d.add("Player",function(){l.player(i)})}};a.HierarchyPainter.prototype.Adopt=function(c){this.h=c;this.RefreshHtml()};a.HierarchyPainter.prototype.SetMonitoring=function(c){this._monitoring_on=false;this._monitoring_interval=3000;c=(c===undefined)?0:parseInt(c);if(!isNaN(c)&&(c>0)){this._monitoring_on=true;this._monitoring_interval=Math.max(100,c)}};a.HierarchyPainter.prototype.MonitoringInterval=function(c){return("_monitoring_interval" in this)?this._monitoring_interval:3000};a.HierarchyPainter.prototype.EnableMonitoring=function(c){this._monitoring_on=c};a.HierarchyPainter.prototype.IsMonitoring=function(){return this._monitoring_on};a.HierarchyPainter.prototype.SetDisplay=function(d,c){if((c==null)&&(typeof d=="object")){this.disp=d;this.disp_kind="custom";this.disp_frameid=null}else{this.disp_kind=d;this.disp_frameid=c}};a.HierarchyPainter.prototype.GetLayout=function(){return this.disp_kind};a.HierarchyPainter.prototype.clear=function(c){if("disp" in this){this.disp.Reset();delete this.disp}if(c){this.select_main().html("");delete this.h}else{this.ForEach(function(d){if(("clear" in d)&&(typeof d.clear=="function")){d.clear()}})}};a.HierarchyPainter.prototype.GetDisplay=function(){return("disp" in this)?this.disp:null};a.HierarchyPainter.prototype.CreateDisplay=function(d){var c=this;if("disp" in this){if((c.disp.NumDraw()>0)||(c.disp_kind=="custom")){return a.CallBack(d,c.disp)}c.disp.Reset();delete c.disp}if(document.getElementById(this.disp_frameid)==null){return a.CallBack(d,null)}if(c.disp_kind=="simple"){c.disp=new a.SimpleDisplay(c.disp_frameid)}else{if(c.disp_kind.search("grid")==0){c.disp=new a.GridDisplay(c.disp_frameid,c.disp_kind)}else{return a.AssertPrerequisites("jq2d",function(){c.CreateDisplay(d)})}}a.CallBack(d,c.disp)};a.HierarchyPainter.prototype.updateOnOtherFrames=function(c,e){var f=this.disp;if(f==null){return false}var d=false;f.ForEachPainter(function(g,h){if((g===c)||(g.GetItemName()!=c.GetItemName())){return}f.ActivateFrame(h);g.RedrawObject(e);d=true});return d};a.HierarchyPainter.prototype.CheckResize=function(c){if("disp" in this){this.disp.CheckMDIResize(null,c)}};a.HierarchyPainter.prototype.StartGUI=function(n,h){var g=this;var j=a.GetUrlOptionAsArray("file;files");var q=a.GetUrlOptionAsArray("json");var f=a.GetUrlOption("path");var o=a.GetUrlOptionAsArray("expand");if(o.length==0&&(a.GetUrlOption("expand")=="")){o.push("")}if(f!=null){for(var k=0;k<j.length;++k){j[k]=f+j[k]}for(var k=0;k<q.length;++k){q[k]=f+q[k]}}var c=a.GetUrlOptionAsArray("item;items");if((c.length==0)&&a.GetUrlOption("item")==""){c.push("")}var e=a.GetUrlOptionAsArray("opt;opts");var p=a.GetUrlOption("monitoring");if((q.length==1)&&(c.length==0)&&(o.length==0)){c.push("")}if(!this.disp_kind){var l=a.GetUrlOption("layout");if((typeof l=="string")&&(l.length>0)){this.disp_kind=l}else{switch(c.length){case 0:case 1:this.disp_kind="simple";break;case 2:this.disp_kind="grid 1x2";break;default:this.disp_kind="flex"}}}if(a.GetUrlOption("files_monitoring")!=null){this.files_monitoring=true}this.SetMonitoring(p);function m(){if(q.length>0){g.OpenJsonFile(q.shift(),m)}else{if(j.length>0){g.OpenRootFile(j.shift(),m)}else{if(o.length>0){g.expand(o.shift(),m)}else{g.displayAll(c,e,function(){g.RefreshHtml();a.RegisterForResize(g);setInterval(function(){g.updateAll(!g.IsMonitoring())},g.MonitoringInterval());a.CallBack(h)})}}}}function d(){if(("_monitoring" in g.h)&&(p==null)){g.SetMonitoring(g.h._monitoring)}if(("_layout" in g.h)&&(l==null)){g.disp_kind=g.h._layout}if(("_loadfile" in g.h)&&(j.length==0)){j=a.ParseAsArray(g.h._loadfile)}if(("_drawitem" in g.h)&&(c.length==0)){c=a.ParseAsArray(g.h._drawitem);e=a.ParseAsArray(g.h._drawopt)}m()}if(n!=null){g.OpenOnline(n,d)}else{m()}};a.BuildNobrowserGUI=function(){var c=b.select("#simpleGUI");var d=false,e=false;if(c.empty()){d=true;c=b.select("#onlineGUI");if(c.empty()){c=b.select("#drawGUI");e=true}if(c.empty()){return alert("no div for simple nobrowser gui found")}}a.Painter.readStyleFromURL();b.select("html").style("height","100%");b.select("body").style({"min-height":"100%",margin:"0px",overflow:"hidden"});c.style({position:"absolute",left:"1px",top:"1px",bottom:"1px",right:"1px"});var h=new a.HierarchyPainter("root",null);h.SetDisplay(a.GetUrlOption("layout",null,"simple"),c.attr("id"));var f=null;if(d){var g=a.findFunction("GetCachedHierarchy");if(typeof g=="function"){f=g()}if(typeof f!="object"){f=""}}h.StartGUI(f,function(){if(!e){return}var j=a.findFunction("GetCachedObject");var k=(typeof j=="function")?a.JSONR_unref(j()):null;if(k!=null){h._cached_draw_object=k}var i=a.GetUrlOption("opt");h.display("",i)})};a.Painter.drawStreamerInfo=function(h,g){var j=new a.HierarchyPainter("sinfo",h,"white");j.h={_name:"StreamerInfo",_childs:[]};for(var f=0;f<g.arr.length;++f){var k=g.arr[f];if(k._typename=="TList"){continue}if(typeof(k.fName)=="undefined"){a.console("strange element in StreamerInfo with type "+k._typename);continue}var m={_name:k.fName+";"+k.fClassVersion,_kind:"class "+k.fName,_title:"class:"+k.fName+" version:"+k.fClassVersion+" checksum:"+k.fCheckSum,_icon:"img_class",_childs:[]};if(k.fTitle!=""){m._title+=" "+k.fTitle}j.h._childs.push(m);if(typeof k.fElements=="undefined"){continue}for(var e=0;e<k.fElements.arr.length;++e){var d=k.fElements.arr[e];if((d==null)||(typeof(d.fName)=="undefined")){continue}var c=d.fTypeName+" "+d.fName+";";if(d.fTitle!=""){c+=" // "+d.fTitle}m._childs.push({_name:c,_title:d.fTypeName,_kind:d.fTypeName,_icon:(d.fTypeName=="BASE")?"img_class":"img_member"})}if(m._childs.length==0){delete m._childs}}j.RefreshHtml(function(){j.SetDivId(h);j.DrawingReady()});return j};a.Painter.drawInspector=function(e,d){var c=new a.HierarchyPainter("inspector",e,"white");c.default_by_click="expand";c.with_icons=false;c.h={_name:"Object",_title:"ROOT."+d._typename,_click_action:"expand",_nosimple:false};if((typeof d.fName==="string")&&(d.fName.length>0)){c.h._name=d.fName}a.Painter.ObjectHierarchy(c.h,d);c.RefreshHtml(function(){c.SetDivId(e);c.DrawingReady()});return c};a.MDIDisplay=function(c){this.frameid=c;b.select("#"+this.frameid).property("mdi",this)};a.MDIDisplay.prototype.ForEachFrame=function(c,d){console.warn("ForEachFrame not implemented in MDIDisplay")};a.MDIDisplay.prototype.ForEachPainter=function(c,d){this.ForEachFrame(function(f){var e=new a.TObjectPainter();e.SetDivId(b.select(f).attr("id"),-1);e.ForEachPainter(function(g){c(g,f)})},d)};a.MDIDisplay.prototype.NumDraw=function(){var c=0;this.ForEachFrame(function(){++c});return c};a.MDIDisplay.prototype.FindFrame=function(d,e){var c=null;this.ForEachFrame(function(f){if(b.select(f).attr("frame_title")==d){c=f}});if((c==null)&&e){c=this.CreateFrame(d)}return c};a.MDIDisplay.prototype.ActivateFrame=function(c){};a.MDIDisplay.prototype.CheckMDIResize=function(d,e){var c=null;this.ForEachPainter(function(f,g){if((d!==null)&&(b.select(g).attr("id")!=d)){return}if((f.GetItemName()!==null)&&(typeof f.CheckResize=="function")){if(c===g){return}f.CheckResize(e);c=g}})};a.MDIDisplay.prototype.Reset=function(){this.ForEachFrame(function(c){a.cleanup(c)});b.select("#"+this.frameid).html("").property("mdi",null)};a.MDIDisplay.prototype.Draw=function(f,d,c){if(!d){return}if(!a.canDraw(d._typename,c)){return}var e=this.FindFrame(f,true);this.ActivateFrame(e);return a.redraw(b.select(e).attr("id"),d,c)};a.CustomDisplay=function(){a.MDIDisplay.call(this,"dummy");this.frames={}};a.CustomDisplay.prototype=Object.create(a.MDIDisplay.prototype);a.CustomDisplay.prototype.AddFrame=function(d,c){if(!(d in this.frames)){this.frames[d]=""}this.frames[d]+=(c+";")};a.CustomDisplay.prototype.ForEachFrame=function(d,g){var f=Object.keys(this.frames);for(var c=0;c<f.length;++c){var e=b.select("#"+f[c]);if(!e.empty()){a.CallBack(d,e.node())}}};a.CustomDisplay.prototype.CreateFrame=function(e){var f=Object.keys(this.frames);for(var d=0;d<f.length;++d){var c=this.frames[f[d]];if(c.indexOf(e+";")>=0){return b.select("#"+f[d]).node()}}return null};a.CustomDisplay.prototype.Reset=function(){a.MDIDisplay.prototype.Reset.call(this);this.ForEachFrame(function(c){b.select(c).html("")})};a.SimpleDisplay=function(c){a.MDIDisplay.call(this,c)};a.SimpleDisplay.prototype=Object.create(a.MDIDisplay.prototype);a.SimpleDisplay.prototype.ForEachFrame=function(c,e){var d=b.select("#"+this.frameid+"_simple_display");if(!d.empty()){a.CallBack(c,d.node())}};a.SimpleDisplay.prototype.CreateFrame=function(c){a.cleanup(this.frameid+"_simple_display");return b.select("#"+this.frameid).html("").append("div").attr("id",this.frameid+"_simple_display").style("width","100%").style("height","100%").style("overflow","hidden").attr("frame_title",c).node()};a.SimpleDisplay.prototype.Reset=function(){a.MDIDisplay.prototype.Reset.call(this);b.select("#"+this.frameid).html("")};a.GridDisplay=function(e,d,c){a.MDIDisplay.call(this,e);this.cnt=0;if(typeof d=="string"){if(d.search("grid")==0){d=d.slice(4).trim()}var f=d.search("x");if(f>0){c=parseInt(d.slice(f+1));d=parseInt(d.slice(0,f))}else{d=parseInt(d);c=d}if(isNaN(d)){d=3}if(isNaN(c)){c=3}}if(!d){d=3}if(!c){c=d}this.sizex=d;this.sizey=c};a.GridDisplay.prototype=Object.create(a.MDIDisplay.prototype);a.GridDisplay.prototype.NumGridFrames=function(){return this.sizex*this.sizey};a.GridDisplay.prototype.IsSingle=function(){return(this.sizex==1)&&(this.sizey==1)};a.GridDisplay.prototype.ForEachFrame=function(c,f){for(var d=0;d<this.sizex*this.sizey;++d){var e=this.IsSingle()?b.select("#"+this.frameid):b.select("#"+this.frameid+"_grid_"+d);if(!e.empty()&&e.attr("frame_title")!=""){a.CallBack(c,e.node())}}};a.GridDisplay.prototype.CreateFrame=function(o){var d=b.select("#"+this.frameid);if(d.empty()){return null}var k=this.frameid;if(!this.IsSingle()){var g=this.frameid+"_grid";if(b.select("#"+g).empty()){var n=d.node().getBoundingClientRect();var l=Math.floor(n.height/this.sizey)-1;var p=Math.floor(n.width/this.sizex)-1;var m="<div style='width:100%; height:100%; margin:0; padding:0; border:0; overflow:hidden'><table id='"+g+"' style='width:100%; height:100%; table-layout:fixed; border-collapse: collapse;'>";var c=0;for(var f=0;f<this.sizey;++f){m+="<tr>";for(var e=0;e<this.sizex;++e){m+="<td><div id='"+g+"_"+c+++"' class='grid_cell'></div></td>"}m+="</tr>"}m+="</table></div>";d.html(m);d.selectAll(".grid_cell").style({width:p+"px",height:l+"px",overflow:"hidden"})}k=g+"_"+this.cnt;if(++this.cnt>=this.sizex*this.sizey){this.cnt=0}}a.cleanup(k);return b.select("#"+k).html("").attr("frame_title",o).node()};a.GridDisplay.prototype.Reset=function(){a.MDIDisplay.prototype.Reset.call(this);if(this.IsSingle()){b.select("#"+this.frameid).attr("frame_title",null)}this.cnt=0};a.GridDisplay.prototype.CheckMDIResize=function(g,e){if(!this.IsSingle()){var c=b.select("#"+this.frameid);var i=c.node().getBoundingClientRect();var f=Math.floor(i.height/this.sizey)-1;var d=Math.floor(i.width/this.sizex)-1;c.selectAll(".grid_cell").style({width:d+"px",height:f+"px"})}a.MDIDisplay.prototype.CheckMDIResize.call(this,g,e)};a.RegisterForResize=function(f,d){if((f===null)||(f===undefined)){return}var g=null,c=d?d:300;if(c<20){c=20}function e(){g=null;document.body.style.cursor="wait";if(typeof f=="function"){f()}else{if((typeof f=="object")&&(typeof f.CheckResize=="function")){f.CheckResize()}else{if(typeof f=="string"){var i=b.select("#"+f);if(!i.empty()){var j=i.property("mdi");if(j){j.CheckMDIResize()}else{a.resize(i.node())}}}}}document.body.style.cursor="auto"}function h(){if(g!==null){clearTimeout(g)}g=setTimeout(e,c)}window.addEventListener("resize",h)};a.addDrawFunc({name:"TCanvas",icon:"img_canvas",func:a.Painter.drawCanvas});a.addDrawFunc({name:"TPad",icon:"img_canvas",func:a.Painter.drawPad});a.addDrawFunc({name:"TSlider",icon:"img_canvas",func:a.Painter.drawPad});a.addDrawFunc({name:"TFrame",icon:"img_frame",func:a.Painter.drawFrame});a.addDrawFunc({name:"TPaveText",icon:"img_pavetext",func:a.Painter.drawPaveText});a.addDrawFunc({name:"TPaveStats",icon:"img_pavetext",func:a.Painter.drawPaveText});a.addDrawFunc({name:"TPaveLabel",icon:"img_pavelabel",func:a.Painter.drawPaveText});a.addDrawFunc({name:"TLatex",icon:"img_text",func:a.Painter.drawText});a.addDrawFunc({name:"TMathText",icon:"img_text",func:a.Painter.drawText});a.addDrawFunc({name:"TText",icon:"img_text",func:a.Painter.drawText});a.addDrawFunc({name:/^TH1/,icon:"img_histo1d",func:a.Painter.drawHistogram1D,opt:";hist;P;P0;E;E1;E2;same"});a.addDrawFunc({name:"TProfile",icon:"img_profile",func:a.Painter.drawHistogram1D,opt:";E0;E1;E2;p;hist"});a.addDrawFunc({name:/^TH2/,icon:"img_histo2d",prereq:"more2d",func:"JSROOT.Painter.drawHistogram2D",opt:";COL;COLZ;COL0Z;BOX;SCAT;TEXT;LEGO;same"});a.addDrawFunc({name:/^TH3/,icon:"img_histo3d",prereq:"3d",func:"JSROOT.Painter.drawHistogram3D"});a.addDrawFunc({name:"THStack",prereq:"more2d",func:"JSROOT.Painter.drawHStack"});a.addDrawFunc({name:"TPolyMarker3D",icon:"img_histo3d",prereq:"3d",func:"JSROOT.Painter.drawPolyMarker3D"});a.addDrawFunc({name:"TGraphPolargram"});a.addDrawFunc({name:/^TGraph/,icon:"img_graph",prereq:"more2d",func:"JSROOT.Painter.drawGraph",opt:";L;P"});a.addDrawFunc({name:"TCutG",icon:"img_graph",prereq:"more2d",func:"JSROOT.Painter.drawGraph",opt:";L;P"});a.addDrawFunc({name:/^RooHist/,icon:"img_graph",prereq:"more2d",func:"JSROOT.Painter.drawGraph",opt:";L;P"});a.addDrawFunc({name:/^RooCurve/,icon:"img_graph",prereq:"more2d",func:"JSROOT.Painter.drawGraph",opt:";L;P"});a.addDrawFunc({name:"TMultiGraph",icon:"img_mgraph",prereq:"more2d",func:"JSROOT.Painter.drawMultiGraph"});a.addDrawFunc({name:"TStreamerInfoList",icon:"img_question",func:a.Painter.drawStreamerInfo});a.addDrawFunc({name:"TPaletteAxis",icon:"img_colz",prereq:"more2d",func:"JSROOT.Painter.drawPaletteAxis"});a.addDrawFunc({name:"kind:Text",icon:"img_text",func:a.Painter.drawRawText});a.addDrawFunc({name:"TF1",icon:"img_graph",prereq:"math;more2d",func:"JSROOT.Painter.drawFunction"});a.addDrawFunc({name:"TEllipse",icon:"img_graph",prereq:"more2d",func:"JSROOT.Painter.drawEllipse"});a.addDrawFunc({name:"TLine",icon:"img_graph",prereq:"more2d",func:"JSROOT.Painter.drawLine"});a.addDrawFunc({name:"TArrow",icon:"img_graph",prereq:"more2d",func:"JSROOT.Painter.drawArrow"});a.addDrawFunc({name:"TGaxis",icon:"img_graph",func:a.drawGaxis});a.addDrawFunc({name:"TLegend",icon:"img_pavelabel",prereq:"more2d",func:"JSROOT.Painter.drawLegend"});a.addDrawFunc({name:"TBox",icon:"img_graph",prereq:"more2d",func:"JSROOT.Painter.drawBox"});a.addDrawFunc({name:"TWbox",icon:"img_graph",prereq:"more2d",func:"JSROOT.Painter.drawBox"});a.addDrawFunc({name:"TSliderBox",icon:"img_graph",prereq:"more2d",func:"JSROOT.Painter.drawBox"});a.addDrawFunc({name:"TGeoVolume",icon:"img_histo3d",prereq:"geom",func:"JSROOT.Painter.drawGeometry",expand:"JSROOT.expandGeoVolume",opt:"all;count;limit;maxlvl2;"});a.addDrawFunc({name:"TEveGeoShapeExtract",icon:"img_histo3d",prereq:"geom",func:"JSROOT.Painter.drawGeometry",opt:";count;limit;maxlvl2"});a.addDrawFunc({name:"TGeoManager",icon:"img_histo3d",prereq:"geom",expand:"JSROOT.expandGeoManagerHierarchy"});a.addDrawFunc({name:/^TGeo/,icon:"img_histo3d",prereq:"geom",func:"JSROOT.Painter.drawGeoObject",opt:"all"});a.addDrawFunc({name:"kind:Command",icon:"img_execute",execute:true});a.addDrawFunc({name:"TFolder",icon:"img_folder",icon2:"img_folderopen",noinspect:true,expand:a.Painter.FolderHierarchy});a.addDrawFunc({name:"TTask",icon:"img_task",expand:a.Painter.TaskHierarchy,for_derived:true});a.addDrawFunc({name:"TTree",icon:"img_tree",noinspect:true,expand:a.Painter.TreeHierarchy});a.addDrawFunc({name:"TNtuple",icon:"img_tree",noinspect:true,expand:a.Painter.TreeHierarchy});a.addDrawFunc({name:"TBranch",icon:"img_branch",noinspect:true});a.addDrawFunc({name:/^TLeaf/,icon:"img_leaf"});a.addDrawFunc({name:"TList",icon:"img_list",noinspect:true,expand:a.Painter.ListHierarchy});a.addDrawFunc({name:"TObjArray",icon:"img_list",noinspect:true,expand:a.Painter.ListHierarchy});a.addDrawFunc({name:"TClonesArray",icon:"img_list",noinspect:true,expand:a.Painter.ListHierarchy});a.addDrawFunc({name:"TColor",icon:"img_color"});a.addDrawFunc({name:"TFile",icon:"img_file",noinspect:true});a.addDrawFunc({name:"TMemFile",icon:"img_file",noinspect:true});a.addDrawFunc({name:"Session",icon:"img_globe"});a.addDrawFunc({name:"kind:TopFolder",icon:"img_base"});a.addDrawFunc({name:"kind:Folder",icon:"img_folder",icon2:"img_folderopen",noinspect:true});a.getDrawHandle=function(e,f){if(typeof e!="string"){return null}if(f===""){f=null}var l=null;if((f===null)&&(e in a.DrawFuncs.cache)){return a.DrawFuncs.cache[e]}var n=(e.indexOf("ROOT.")==0)?e.substr(5):"kind:"+e;var d=0;for(var k=0;k<a.DrawFuncs.lst.length;++k){var m=a.DrawFuncs.lst[k];if(typeof m.name=="string"){if(m.name!=n){continue}}else{if(!n.match(m.name)){continue}}if(f==null){if(!(e in a.DrawFuncs.cache)){a.DrawFuncs.cache[e]=m}return m}else{if(typeof f=="string"){if(l==null){l=m}if("opt" in m){var c=m.opt.split(";");for(var g=0;g<c.length;++g){c[g]=c[g].toLowerCase()}if(c.indexOf(f.toLowerCase())>=0){return m}}}else{if(f===d){return m}}}++d}return l};a.addStreamerInfos=function(d){if(d===null){return}function c(n,m){if(n.fElements==null){return null}if(m>10){return null}for(var l=0;l<n.fElements.arr.length;++l){var o=n.fElements.arr[l];if(o.fTypeName!=="BASE"){continue}var p=a.getDrawHandle("ROOT."+o.fName);if(p&&!p.for_derived){p=null}if(p===null){for(var i=0;i<d.arr.length;++i){if(d.arr[i].fName===o.fName){p=c(d.arr[i],m+1);break}}}if(p&&p.for_derived){return p}}return null}for(var h=0;h<d.arr.length;++h){var e=d.arr[h];if(a.getDrawHandle("ROOT."+e.fName)!==null){continue}var f=c(e,0);if(!f){continue}var g=a.extend({},f);g.name=e.fName;a.DrawFuncs.lst.push(g)}};a.getDrawOptions=function(e,f){if(typeof e!="string"){return null}var g=null,k=false,m=false;for(var d=0;d<1000;++d){var l=a.getDrawHandle(e,d);if(l==null){break}if(l.noinspect){m=true}if(!("func" in l)){break}k=true;if(!("opt" in l)){continue}var c=l.opt.split(";");for(var j=0;j<c.length;++j){c[j]=c[j].toLowerCase();if((f=="nosame")&&(c[j].indexOf("same")==0)){continue}if(g===null){g=[]}if(g.indexOf(c[j])<0){g.push(c[j])}}}if(k&&(g===null)){g=[""]}if(!k&&e.indexOf("ROOT.")==0){g=[]}if(!m&&g){g.push("inspect")}return g};a.canDraw=function(c){return a.getDrawOptions("ROOT."+c)!==null};a.draw=function(i,g,d){if((g===null)||(typeof g!=="object")){return null}if(d=="inspect"){return a.Painter.drawInspector(i,g)}var h=null,j=null;if("_typename" in g){h=a.getDrawHandle("ROOT."+g._typename,d)}else{if("_kind" in g){h=a.getDrawHandle(g._kind,d)}}if((h==null)||!("func" in h)){return null}function c(){if((j===null)&&("painter_kind" in h)){j=(h.painter_kind=="base")?new a.TBasePainter():new a.TObjectPainter(g)}if(j==null){return h.func(i,g,d)}return h.func.bind(j)(i,g,d,j)}if(typeof h.func=="function"){return c()}var f="",k="";if(typeof h.func=="object"){if("func" in h.func){f=h.func.func}if("script" in h.func){k="user:"+h.func.script}}else{if(typeof h.func=="string"){f=h.func;if(("prereq" in h)&&(typeof h.prereq=="string")){k=h.prereq}if(("script" in h)&&(typeof h.script=="string")){k+=";user:"+h.script}}}if(f.length==0){return null}if(k.length>0){if(!("painter_kind" in h)){h.painter_kind=(f.indexOf("JSROOT.Painter")==0)?"object":"base"}j=(h.painter_kind=="base")?new a.TBasePainter():new a.TObjectPainter(g);a.AssertPrerequisites(k,function(){var m=a.findFunction(f);if(m==null){alert("Fail to find function "+f+" after loading "+k);return null}h.func=m;var l=c();if(l!==j){alert("Painter function "+f+" do not follow rules of dynamicaly loaded painters")}});return j}var e=a.findFunction(f);if(e==null){return null}h.func=e;return c()};a.redraw=function(j,h,f){if(h==null){return}var g=new a.TObjectPainter();g.SetDivId(j,-1);var d=g.pad_painter();if(d!==null){if(h._typename==="TCanvas"){d.RedrawObject(h);return d}for(var e=0;e<d.painters.length;++e){var c=d.painters[e];if(c.MatchObjectType(h._typename)){if(c.UpdateObject(h)){d.RedrawPad();return c}}}}if(d){a.console("Cannot find painter to update object of type "+h._typename)}a.cleanup(j);return a.draw(j,h,f)};a.resize=function(f,c){if(c===true){c={force:true}}else{if(typeof c!=="object"){c=null}}var e=new a.TObjectPainter(),d=false;e.SetDivId(f,-1);e.ForEachPainter(function(g){if(!d&&typeof g.CheckResize=="function"){d=g.CheckResize(c)}})};a.CheckElementResize=a.resize;a.cleanup=function(d){var c=new a.TObjectPainter();c.SetDivId(d,-1);c.ForEachPainter(function(e){if(typeof e.Cleanup==="function"){e.Cleanup()}});c.select_main().html("")};a.progress=function(d){var e="jsroot_progressbox";var c=b.select("#"+e);if(!a.gStyle.ProgressBox){return c.remove()}if((arguments.length==0)||(d===undefined)||(d===null)){return c.remove()}if(c.empty()){c=b.select(document.body).append("div").attr("id",e);c.append("p")}c.select("p").html(d)};return a}));