Lively Kernel canvas
// this script is evaluated on world load
MyConsole = WorldMorph.current().submorphs.detect(function(ea){return ea.name == "MyConsole"});
if(!MyConsole) return;
MyConsole = MyConsole.component;
MyConsole.setText("-- start --");
MyConsole.log = function(s) {
this.setText(this.formalModel.getText() + "\n" + s);
};
MyConsole.log("My Console initialized!");
MyConsole.morph.resetScrollPane = function() {
var sp = this.enclosingScrollPane();
if (sp) sp.scrollToBottom();
};
// console.consumers seems to be broken... so we go the hard waz
console.log = console.log.wrap(function(proceed, s) {
MyConsole.log(s)
proceed(s)})
console.log("wrapped console for MyConsole successfully")
10000.0010743743838553975Wikicontroltrue
10000.00003643576562444297Wikicontroltrue
null
null-1.3408571475988569nullfalse
true
null-1.7873738338738483nullfalse
true
null-1.6759520580807308nullfalse
true
null-2.385567030701238nullfalse
true
nulltrue
10001.765996010965256e-11Wikicontroltrue
-----falsetruefalse0
worldis1:WorldMorph([[0,0,2000,1000]])falsetruefalse0
Errorevaluatinginitializer:SyntaxError:Invalidreturnstatement.falsetruefalse0
startingWikiNavigatorfalsetruefalse0
status207onPROPFINDhttp://lively-kernel.org/repository/webwerkstatt/draft/GenerateNodes.xhtmlfalsetruefalse0
http://lively-kernel.org/repository/webwerkstatt/draft/../lib/anonymous_module_2loadedin29msfalsetruefalse0
http://lively-kernel.org/repository/webwerkstatt/draft/../lib/anonymous_module_1loadedin491msfalsetruefalse0
fontHelvetica16:spacewidth4from20xWidth8falsetruefalse0
fontHelvetica40:spacewidth11from51xWidth20falsetruefalse0
fitWidthfailureonTextMorph.getCharBoundsfalsetruefalse0
ResizingSVGcanvasfalsetruefalse0
Moduleloadcheckdone.29modulesloaded.falsetruefalse0
-------------------------------------------falsetruefalse0
invoke1:WorldMorph([[0,0,2000,1000]])falsetruefalse0
status200onGEThttp://lively-kernel.org/repository/webwerkstatt/draft/GenerateNodes.xhtmlfalsetruefalse0
extendForSerializationundefinedfalsetruefalse0824-1nulltrue0falsetruetruefalse
false1truefalse
nullfalse
nullfalse
nullfalse
nullfalsefalsetruetruefalse
truetrue100false
truefalse050
nullfalsetruenullfalse
Consolefalsenullfalse
false
false
falsenullfalsefalsenullnullnullnullfalse
10003.991986447834356e-13Wikicontroltrue
10003.6846487721929585e-18Wikicontroltrue
null-2.0178071111748457nullfalse
true
10000.93160079263659Wikicontroltrue
10000.2826261635314764Wikicontroltrue
10009.242298322399366e-13Wikicontroltrue
Node16
- null
SVGNode16null
Morph16
WorldMorph16
- null
Text16
Widget16
null1.1414788815974037null
Text16
Text16
LayoutMorphwithForce....40false
- null
PasteUpMorph16
- null
10002.94833051846644Wikicontroltrue
Wrapper16
Object.subclass('NodeMorphLayouter',{})NodeMorphLayouter.addMethods({maxDist:200,minDist:100,step:15,minStepLength:0,findOtherMorphsDelay:10,//optimizedcomparedtoisConnectedTo...areConnected:function(firstMorph,secondMorph){varconnectors=firstMorph.connectorMorphs;if(!connectors)returnfalse;for(vari=0;i<connectors.length;i++){varconnector=connectors[i];if(!connector)continue;varstart=connector.startMorph;varend=connector.endMorph;if(start===firstMorph&&end===secondMorph)returntrue;//forwardif(start===secondMorph&&end===firstMorph)returntrue;//back}returnfalse;},centerOf:function(morph){if(!morph._cached_node_center)morph._cached_node_center=morph.getCenter();returnmorph._cached_node_center},energy:function(morph){return0.1;},//deferemorphmorphmovement...moveMorphBy:function(morph,v){morph._cached_node_center=morph._cached_node_center.addPt(v);},applyMoveCacheToMorph:function(morph){if(!morph._cached_node_center)return;varv=morph._cached_node_center.subPt(morph.getCenter());morph.moveBy(v);this.ensureToStayInWorldBounds(morph);morph._cached_node_center=undefined;},forceOfMorphs:function(morph,morphs){varavg=pt(0,0);for(vari=0;i<morphs.length;i++){varea=morphs[i];if(ea===morph)continue;vard=this.centerOf(morph).subPt(this.centerOf(ea));vardist=d.fastR();varisConnected=this.areConnected(morph,ea);if(!isConnected&&dist>this.maxDist+150*this.energy(morph))continue;varforce=this.forceOfMorph(ea,d,dist,isConnected);avg=avg.addPt(force);}if(avg.eqPt(pt(0,0)))returnavg;returnPoint.polar(this.energy(morph)*this.step,avg.theta());},forceOfMorph:function(morph,vector,dist,isConnected){//effectpositive-->pushaway,negative->attractif(dist==0)returnpt(0,0);vareffect;if(dist<this.minDist){effect=1;}elseif(isConnected){if(dist<=this.maxDist)returnpt(0,0);effect=-1;}else{if(dist>=this.maxDist)returnpt(0,0);effect=1;}returnvector.fastNormalized().scaleBy(effect);},stepMorph:function(morph,nodes){if(this.energy(morph)<=0)return;if(!this.calls){this.calls=1;}this.calls++;varv=this.forceOfMorphs(morph,nodes);if(!v.x||!v.y)return;this.moveMorphBy(morph,v);},ensureToStayInWorldBounds:function(morph){if(!this.activeBoundsOfWorld){//Worldboundsaresometimeswrong???Usecanvas...varcanvas=Global.document.getElementById('canvas');this.activeBoundsOfWorld=pt(canvas.clientWidth,canvas.clientHeight).subPt(morph.getExtent()).extentAsRectangle();}if(!this.activeBoundsOfWorld.containsPoint(morph.getPosition())){varpos=this.activeBoundsOfWorld.closestPointToPt(morph.getPosition());morph.setPosition(pos);}}}) this.maxDist + 150 * this.energy(morph))\n\t\t\t\tcontinue;\n\t\t\tvar force = this.forceOfMorph(ea, d, dist, isConnected);\r\t\t\tavg = avg.addPt(force);\n\t\t}\n\t\tif (avg.eqPt(pt(0,0))) \r\t\t\treturn avg;\r\t\treturn Point.polar(this.energy(morph)*this.step, avg.theta());\n\t},\r\n\tforceOfMorph: function(morph, vector, dist, isConnected) {\n\t\t// effect positive --> push away, negative -> attract\n\t\tif (dist == 0) \r\t\t\treturn pt(0,0); \r\t\tvar effect;\n\t\tif (dist < this.minDist) {\n\t\t\teffect = 1;\n\t\t} else if (isConnected) {\n\t\t\tif (dist <= this.maxDist) return pt(0,0);\n\t\t\teffect = -1;\n\t\t} else {\n\t\t\tif (dist >= this.maxDist) return pt(0,0);\n\t\t\teffect = 1;\n\t\t}\n\t\treturn vector.fastNormalized().scaleBy(effect);\n\t},\r\r\r\tstepMorph: function(morph, nodes) {\n\t\tif (this.energy(morph) <= 0) return;\n\r\t\tif (!this.calls) {\n\t\t\tthis.calls = 1;\n\t\t}\n\t\tthis.calls++;\n\t\tvar v = this.forceOfMorphs(morph, nodes);\n\t\tif (!v.x || !v.y ) return; \n\t\tthis.moveMorphBy(morph, v);\n\t},\n\r\tensureToStayInWorldBounds: function(morph) {\n\t\tif (!this.activeBoundsOfWorld) {\n\t\t\t// World bounds are sometimes wrong??? Use canvas ...\n\t\t\tvar canvas = Global.document.getElementById('canvas');\n\t\t\tthis.activeBoundsOfWorld = pt(canvas.clientWidth,\r\t\t\t\tcanvas.clientHeight).subPt(morph.getExtent()).extentAsRectangle();\n\t\t}\n\t\tif (!this.activeBoundsOfWorld.containsPoint(morph.getPosition())) {\r\t\t\tvar pos = this.activeBoundsOfWorld.closestPointToPt(morph.getPosition());\r\t\t\tmorph.setPosition(pos);\r\t\t}\n\t}\n})\r\r\n"]]>114truetruefalsetruetruetruefalse
false1truefalsetruetruefalse
nullfalsetruenullfalse
Layouter...falsenullfalse
false
false
falsenullfalsefalsenullnullnullnullfalse
layerClass(NodeMorphLayer,Morph,{getisNodeMorph(){returntrue},connectedNodes:function(){returnthis.getConnectorMorphs().collect(function(ea){if(this===ea.startMorph)returnea.endMorphelsereturnea.startMorph},this)},isConnectedTo:function(proceed,otherNode){returnthis.connectedNodes().indexOf(otherNode)!=-1;},})19truetruefalsetruetruetruefalse
false1truefalsetruetruefalse
nullfalsetruenullfalse
falsenullfalse
false
false
falsenullfalsefalsenullnullnullnullfalse
timeToRun=function(func){vartime=newDate();func();returnnewDate()-time;}nodes=WorldMorph.current().submorphs.select(function(ea){returnea.isNodeMorph});l=newNodeMorphLayouter();l.stepMorph(nodes[0],nodes)timeToRun(function(){for(vari=0;i<100;i++){nodes.each(function(ea){l.stepMorph(ea,nodes)})}nodes.each(function(ea){l.applyMoveCacheToMorph(ea)})})truetruefalsefalse31truetruefalse
false1truefalsetruetruefalse
nullfalsetruenullfalse
workspacefalsenullfalse
false
false
falsenullfalsefalsenullnullnullnullfalse
10003.698988210000001Wikicontroltrue
Shape16
- null
null50