{"id":0,"registry":{"0":{"submorphs":[],"scripts":[],"id":"65599172-424C-4417-AD91-807C39604CC9","shape":{"__isSmartRef__":true,"id":1},"droppingEnabled":true,"halosEnabled":true,"registeredForMouseEvents":true,"showsHalos":false,"name":"Circuit","partsBinMetaInfo":{"__isSmartRef__":true,"id":2},"eventHandler":{"__isSmartRef__":true,"id":25},"derivationIds":[127,"F0291F62-F100-480C-AEBF-0230398F7983","AE8B5ED7-E305-45BC-BE4A-1C28A49EE12B","39BA345C-17FA-45A0-BAC2-F0CF5654ACF8","FE91EA31-D8AE-461B-8A49-95DA5FBAE5B4","F38439A3-2F4E-4AC2-BF73-2633C00B1393","6748F5B5-2284-4748-A6EE-F1A261CBAD0B","BBAFB862-93AE-4F89-BCFF-9F1C67B7FE4C","7EC17E78-593A-4CC8-B7E3-859BCBBFE785","BD8BECDB-A9A1-4009-B433-C925F0AFCCFC","F2677A9D-5855-4DF2-B248-94545B34B762","D52188B3-7DC0-410E-96B1-50892AC00A37","5B709A10-A4A5-4784-979B-D103A06E867C","727C08D8-48AF-4E46-9D08-0A39CC3E6D92","02E63776-5AAB-468E-95CC-9A4D62ACF9F5","7FD5CF23-F99B-43EA-917C-DB04377F8460","007CEDAA-F9F1-484B-A46B-3DE526084459"],"partTests":{"__isSmartRef__":true,"id":26},"_ClipMode":"visible","moved":true,"isBeingDragged":false,"__startTime":1386182489674,"__evaluator":{"__isSmartRef__":true,"id":31},"magnets":[],"__serializedExpressions__":["distanceToDragEvent","_Position"],"_Rotation":0,"_Scale":1,"__serializedLivelyClosures__":{"__isSmartRef__":true,"id":37},"__LivelyClassName__":"lively.morphic.Box","__SourceModuleName__":"Global.lively.morphic.Core","distanceToDragEvent":"lively.pt(297.0,10.0)","_Position":"lively.pt(0.0,0.0)"},"1":{"_BorderWidth":1,"_ClipMode":"visible","_BorderRadius":0,"_Opacity":1,"_BorderStyle":"solid","_AppearanceStylingMode":false,"_BorderStylingMode":false,"__serializedExpressions__":["position","_Extent","_BorderColor","_Fill","_Padding"],"__LivelyClassName__":"lively.morphic.Shapes.Rectangle","__SourceModuleName__":"Global.lively.morphic.Shapes","position":"lively.pt(0.0,0.0)","_Extent":"lively.pt(435.0,548.0)","_BorderColor":"Color.rgb(0,0,0)","_Fill":"Color.rgb(250,250,251)","_Padding":"lively.rect(0,0,0,0)"},"2":{"partsSpaceName":"PartsBin/ElectricalComponents/","comment":"The circuit board.","migrationLevel":8,"partName":"Circuit","changes":[{"__isSmartRef__":true,"id":3},{"__isSmartRef__":true,"id":4},{"__isSmartRef__":true,"id":5},{"__isSmartRef__":true,"id":6},{"__isSmartRef__":true,"id":7},{"__isSmartRef__":true,"id":8},{"__isSmartRef__":true,"id":9},{"__isSmartRef__":true,"id":10},{"__isSmartRef__":true,"id":11},{"__isSmartRef__":true,"id":12},{"__isSmartRef__":true,"id":13},{"__isSmartRef__":true,"id":14},{"__isSmartRef__":true,"id":15},{"__isSmartRef__":true,"id":16},{"__isSmartRef__":true,"id":17},{"__isSmartRef__":true,"id":18},{"__isSmartRef__":true,"id":19},{"__isSmartRef__":true,"id":20},{"__isSmartRef__":true,"id":21},{"__isSmartRef__":true,"id":22},{"__isSmartRef__":true,"id":23},{"__isSmartRef__":true,"id":24}],"requiredModules":["users.ohshima.ElectricalComponents"],"__serializedExpressions__":["lastModifiedDate"],"__LivelyClassName__":"lively.PartsBin.PartsBinMetaInfo","__SourceModuleName__":"Global.lively.PartsBin","lastModifiedDate":"new Date(\"Mon Dec 09 2013 15:43:23 GMT-0800 (PST)\")"},"3":{"author":"robertkrahn","message":"no comment","id":"FBBB9C99-B61C-4D5F-8750-6E2987DF0C9C","__serializedExpressions__":["date"],"date":"new Date(\"Thu Jun 20 2013 15:16:24 GMT-0700 (PDT)\")"},"4":{"author":"robertkrahn","message":"no comment","id":"67FD74CD-7AE4-4050-ADC7-4DF73804258D","__serializedExpressions__":["date"],"date":"new Date(\"Thu May 30 2013 00:18:06 GMT-0700 (PDT)\")"},"5":{"author":"jenslincke","message":"no comment","id":"AEB2F41B-2C88-4BBA-8875-93CD17CBA1C8","__serializedExpressions__":["date"],"date":"new Date(\"Wed Jan 23 2013 03:57:18 GMT-0800 (PST)\")"},"6":{"author":"undefined","message":"whoopsie","id":"3F17A2D2-3C24-424B-B0FA-E43112267D23","__serializedExpressions__":["date"],"date":"new Date(\"Thu May 03 2012 06:51:36 GMT-0700 (PDT)\")"},"7":{"author":"undefined","message":"whoopsie","id":"CEA5DCD5-2DB7-40AD-A776-262A7A0666FC","__serializedExpressions__":["date"],"date":"new Date(\"Thu May 03 2012 06:51:30 GMT-0700 (PDT)\")"},"8":{"author":"undefined","message":"sorry","id":"44B56D2E-9B59-4C67-A305-49A6E10E66C2","__serializedExpressions__":["date"],"date":"new Date(\"Wed Mar 14 2012 02:53:45 GMT-0700 (PDT)\")"},"9":{"author":"fbo","message":"","id":"BD1C654D-9100-4B66-BC62-B15FF2498B2B","__serializedExpressions__":["date"],"date":"new Date(\"Fri Feb 24 2012 17:59:09 GMT-0800 (PST)\")"},"10":{"author":"undefined","message":"css transitions","id":"1004E0FC-D96B-4F40-B3E0-F514A3FCFFD7","__serializedExpressions__":["date"],"date":"new Date(\"Wed Mar 14 2012 02:42:26 GMT-0700 (PDT)\")"},"11":{"author":"undefined","message":"suddenly, the rectangle became a CarDemo","id":"B5083AA8-9BAE-48DD-A6B4-FD7DB3998350","__serializedExpressions__":["date"],"date":"new Date(\"Mon Apr 09 2012 04:42:07 GMT-0700 (PDT)\")"},"12":{"author":"bgnauk","message":"no comment","id":"0124E570-50B7-4CE3-83A1-6E7BA89B5CD8","__serializedExpressions__":["date"],"date":"new Date(\"Mon Jun 18 2012 10:35:08 GMT-0700 (PDT)\")"},"13":{"author":"jenslincke","message":"I want my blue rectangle back!","id":"5AA9291A-869F-4D36-8095-4721B5A5B205","__serializedExpressions__":["date"],"date":"new Date(\"Thu Nov 22 2012 01:35:51 GMT-0800 (PST)\")"},"14":{"author":"jenslincke","message":"no comment","id":"A4B86A7E-A398-4C29-BEE0-4AA045ABABD2","__serializedExpressions__":["date"],"date":"new Date(\"Fri Jan 18 2013 07:42:31 GMT-0800 (PST)\")"},"15":{"author":"jenslincke","message":"added legend","id":"7ADA3049-56C1-4D32-874B-F664A79DDB20","__serializedExpressions__":["date"],"date":"new Date(\"Fri Jan 18 2013 07:47:05 GMT-0800 (PST)\")"},"16":{"author":"SAPLivelyScreen","message":"no comment","id":"EF145198-0649-41BD-A92E-521D98FEC49D","__serializedExpressions__":["date"],"date":"new Date(\"Wed May 29 2013 15:36:50 GMT-0700 (PDT)\")"},"17":{"author":"SAPLivelyScreen","message":"no comment","id":"7A44D8CA-6D5F-42A3-A4B4-4D7F51EECA52","__serializedExpressions__":["date"],"date":"new Date(\"Tue Jun 18 2013 11:49:27 GMT-0700 (PDT)\")"},"18":{"author":"robertkrahn","message":"no comment","id":"A452871F-4EB9-45D1-94B8-6065CBA7B8FD","__serializedExpressions__":["date"],"date":"new Date(\"Mon Jul 29 2013 23:20:51 GMT-0700 (PDT)\")"},"19":{"author":"robertkrahn","message":"no comment","id":"3B847AB1-0680-4EA5-A902-706E47E73665","__serializedExpressions__":["date"],"date":"new Date(\"Wed Dec 04 2013 15:51:16 GMT-0800 (PST)\")"},"20":{"author":"robertkrahn","message":"no comment","id":"D4BEE572-D73F-4926-A0D9-3A624262C032","__serializedExpressions__":["date"],"date":"new Date(\"Wed Dec 04 2013 16:23:59 GMT-0800 (PST)\")"},"21":{"author":"ohshima","message":"no comment","id":"68748970-30FE-4025-8039-035C605269EE","__serializedExpressions__":["date"],"date":"new Date(\"Wed Dec 04 2013 20:12:18 GMT-0800 (PST)\")"},"22":{"author":"ohshima","message":"no comment","id":"366FFD15-29F2-4E96-B7CD-564B627F9DF6","__serializedExpressions__":["date"],"date":"new Date(\"Thu Dec 05 2013 20:15:33 GMT-0800 (PST)\")"},"23":{"__serializedExpressions__":["date"],"author":"robertkrahn","message":"no comment","id":"5B97D4F9-7B36-4494-92C4-8FFEC2A24637","date":"new Date(\"Mon Dec 09 2013 15:43:22 GMT-0800 (PST)\")"},"24":{"__serializedExpressions__":["date"],"author":"robertkrahn","message":"no comment","id":"507B86E9-5B36-4265-B999-9C5BE78DD9EC","date":"new Date(\"Mon Dec 09 2013 16:41:38 GMT-0800 (PST)\")"},"25":{"morph":{"__isSmartRef__":true,"id":0},"__LivelyClassName__":"lively.morphic.EventHandler","__SourceModuleName__":"Global.lively.morphic.Events"},"26":{"__serializedLivelyClosures__":{"__isSmartRef__":true,"id":27}},"27":{"test01IsMorph":{"__isSmartRef__":true,"id":28}},"28":{"varMapping":{"__isSmartRef__":true,"id":29},"source":"function test01IsMorph(aPart) {\n    this.assert(aPart.isMorph, 'rectangle should be a morph');\n}","funcProperties":{"__isSmartRef__":true,"id":30},"__LivelyClassName__":"lively.Closure","__SourceModuleName__":"Global.lively.lang.Closure"},"29":{"this":{"__isSmartRef__":true,"id":26}},"30":{},"31":{"sources":{"__isSmartRef__":true,"id":32},"arguments":{"__isSmartRef__":true,"id":33},"dependencies":{"__isSmartRef__":true,"id":34},"endNodes":{"__isSmartRef__":true,"id":35},"continuity":{"__isSmartRef__":true,"id":36},"changedExternally":false,"deletedNode":null,"timers":[],"syncWithRealTime":true,"object":{"__isSmartRef__":true,"id":0},"__LivelyClassName__":"lively.bindings.FRPCore.Evaluator","__SourceModuleName__":"Global.lively.bindings.FRPCore"},"32":{},"33":{},"34":{},"35":{},"36":{},"37":{"connectLeads":{"__isSmartRef__":true,"id":38},"buildCircuit":{"__isSmartRef__":true,"id":41},"createArrayOfSets":{"__isSmartRef__":true,"id":44},"removeConnections":{"__isSmartRef__":true,"id":47},"allConnections":{"__isSmartRef__":true,"id":50},"allComponents":{"__isSmartRef__":true,"id":53},"connectionBetween":{"__isSmartRef__":true,"id":56},"reset":{"__isSmartRef__":true,"id":59}},"38":{"varMapping":{"__isSmartRef__":true,"id":39},"source":"function connectLeads(leadA, leadB) {\n    var existing = this.connectionBetween(leadA, leadB);\n    if (existing) {\n        // remove a connection if it exists\n        existing.remove();\n    } else {\n        // otherwise, create a new one\n        var a = this.localize(leadA.globalBounds().center());\n        var b = this.localize(leadB.globalBounds().center());\n        var line = lively.morphic.Morph.makeLine([a, b], 4, Color.black);\n        line.leadA = leadA;\n        line.leadB = leadB;\n        line.disableGrabbing();\n        line.disableDropping();\n        this.addMorphBack(line);\n        line.getControlPoints().first().setConnectedMagnet(leadA.getMagnets().last());\n        line.getControlPoints().last().setConnectedMagnet(leadB.getMagnets().last());\n    }\n    this.buildCircuit();\n}","funcProperties":{"__isSmartRef__":true,"id":40},"__LivelyClassName__":"lively.Closure","__SourceModuleName__":"Global.lively.lang.Closure"},"39":{"this":{"__isSmartRef__":true,"id":0}},"40":{"user":"robertkrahn","tags":[],"__serializedExpressions__":["timestamp"],"timestamp":"new Date(\"Mon Dec 09 2013 12:18:37 GMT-0800 (PST)\")"},"41":{"varMapping":{"__isSmartRef__":true,"id":42},"source":"function buildCircuit() {\n    // create each Babelsberg component in this circuit\n    this.allComponents().forEach(function(component){\n       component.setupComponent();\n    });\n    // find disjoint sets of connected leads\n    var setsOfLeads = this.createArrayOfSets();\n    this.allConnections().forEach(function(connection){\n        var setA = setsOfLeads.removeSetContaining(connection.leadA);\n        var setB = setsOfLeads.removeSetContaining(connection.leadB);\n        setsOfLeads.addSetJoining(setA, setB);\n    });\n    // connect leads in each set\n    setsOfLeads.forEach(function(leadMorphs){\n        var leads = leadMorphs.pluck(\"lead\");\n        users.ohshima.ElectricalComponents.Lead.connectAll(leads);\n    });\n    // update meters\n    this.allComponents().forEach(function(component) {\n       if (component.updateMeter) {\n           component.updateMeter()\n       }\n    });\n}","funcProperties":{"__isSmartRef__":true,"id":43},"__LivelyClassName__":"lively.Closure","__SourceModuleName__":"Global.lively.lang.Closure"},"42":{"this":{"__isSmartRef__":true,"id":0}},"43":{"__serializedExpressions__":["timestamp"],"user":"robertkrahn","tags":[],"timestamp":"new Date(\"Mon Dec 09 2013 13:34:08 GMT-0800 (PST)\")"},"44":{"varMapping":{"__isSmartRef__":true,"id":45},"source":"function createArrayOfSets() {\n    // make a helper object with the functions we need\n    var arrayOfSets = [];\n    arrayOfSets.removeSetContaining = function(item) {\n        // find set with item, remove and answer set, otherwise make a new set\n        var foundIndex = -1;\n        for (var i = 0; i < arrayOfSets.length; i++)\n            if (arrayOfSets[i].indexOf(item) !== -1) {\n                foundIndex = i;\n                break;\n            }\n        var setContainingItem;\n        if (foundIndex >= 0) {\n            // remove existing set\n            setContainingItem = arrayOfSets[foundIndex];\n            arrayOfSets.splice(foundIndex, 1);  \n        } else {\n            // or make new set\n            setContainingItem = [item];\n        }\n        return setContainingItem;\n    };\n    arrayOfSets.addSetJoining = function(setA, setB) {\n        // join setA and setB, add it to array\n        for (var i = 0; i < setB.length; i++)\n            if (setA.indexOf(setB[i]) === -1)\n                setA.push(setB[i]);\n        arrayOfSets.push(setA);\n    }\n    return arrayOfSets;\n}","funcProperties":{"__isSmartRef__":true,"id":46},"__LivelyClassName__":"lively.Closure","__SourceModuleName__":"Global.lively.lang.Closure"},"45":{"this":{"__isSmartRef__":true,"id":0}},"46":{"user":"undefined","tags":[],"__serializedExpressions__":["timestamp"],"timestamp":"new Date(\"Sun Nov 17 2013 21:30:23 GMT-0800 (PST)\")"},"47":{"varMapping":{"__isSmartRef__":true,"id":48},"source":"function removeConnections() {\n    this.allConnections().forEach(function(each){each.remove()});\n    this.buildCircuit();\n}","funcProperties":{"__isSmartRef__":true,"id":49},"__LivelyClassName__":"lively.Closure","__SourceModuleName__":"Global.lively.lang.Closure"},"48":{"this":{"__isSmartRef__":true,"id":0}},"49":{"user":"undefined","tags":[],"__serializedExpressions__":["timestamp"],"timestamp":"new Date(\"Mon Nov 18 2013 14:26:59 GMT-0800 (PST)\")"},"50":{"varMapping":{"__isSmartRef__":true,"id":51},"source":"function allConnections() {\n    return this.submorphs.filter(function(submorph){\n        return 'leadA' in submorph;\n    });\n}","funcProperties":{"__isSmartRef__":true,"id":52},"__LivelyClassName__":"lively.Closure","__SourceModuleName__":"Global.lively.lang.Closure"},"51":{"this":{"__isSmartRef__":true,"id":0}},"52":{"user":"undefined","tags":[],"__serializedExpressions__":["timestamp"],"timestamp":"new Date(\"Mon Nov 18 2013 14:20:35 GMT-0800 (PST)\")"},"53":{"varMapping":{"__isSmartRef__":true,"id":54},"source":"function allComponents() {\n    return this.submorphs.filter(function(submorph){\n        return 'setupComponent' in submorph;\n    });\n}","funcProperties":{"__isSmartRef__":true,"id":55},"__LivelyClassName__":"lively.Closure","__SourceModuleName__":"Global.lively.lang.Closure"},"54":{"this":{"__isSmartRef__":true,"id":0}},"55":{"user":"undefined","tags":[],"__serializedExpressions__":["timestamp"],"timestamp":"new Date(\"Mon Nov 18 2013 14:04:11 GMT-0800 (PST)\")"},"56":{"varMapping":{"__isSmartRef__":true,"id":57},"source":"function connectionBetween(leadA, leadB) {\n    return this.allConnections().detect(function(each){\n        return (each.leadA === leadA && each.leadB === leadB) ||\n            (each.leadA === leadB && each.leadB === leadA);\n    });\n}","funcProperties":{"__isSmartRef__":true,"id":58},"__LivelyClassName__":"lively.Closure","__SourceModuleName__":"Global.lively.lang.Closure"},"57":{"this":{"__isSmartRef__":true,"id":0}},"58":{"user":"undefined","tags":[],"__serializedExpressions__":["timestamp"],"timestamp":"new Date(\"Mon Nov 18 2013 14:11:53 GMT-0800 (PST)\")"},"59":{"varMapping":{"__isSmartRef__":true,"id":60},"source":"function reset() {\n        this.getPartsBinMetaInfo().addRequiredModule('users.ohshima.ElectricalComponents');\n    }","funcProperties":{"__isSmartRef__":true,"id":61},"__LivelyClassName__":"lively.Closure","__SourceModuleName__":"Global.lively.lang.Closure"},"60":{"this":{"__isSmartRef__":true,"id":0}},"61":{},"isSimplifiedRegistry":true}}