mxElectrical.js 154 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462146314641465146614671468146914701471147214731474147514761477147814791480148114821483148414851486148714881489149014911492149314941495149614971498149915001501150215031504150515061507150815091510151115121513151415151516151715181519152015211522152315241525152615271528152915301531153215331534153515361537153815391540154115421543154415451546154715481549155015511552155315541555155615571558155915601561156215631564156515661567156815691570157115721573157415751576157715781579158015811582158315841585158615871588158915901591159215931594159515961597159815991600160116021603160416051606160716081609161016111612161316141615161616171618161916201621162216231624162516261627162816291630163116321633163416351636163716381639164016411642164316441645164616471648164916501651165216531654165516561657165816591660166116621663166416651666166716681669167016711672167316741675167616771678167916801681168216831684168516861687168816891690169116921693169416951696169716981699170017011702170317041705170617071708170917101711171217131714171517161717171817191720172117221723172417251726172717281729173017311732173317341735173617371738173917401741174217431744174517461747174817491750175117521753175417551756175717581759176017611762176317641765176617671768176917701771177217731774177517761777177817791780178117821783178417851786178717881789179017911792179317941795179617971798179918001801180218031804180518061807180818091810181118121813181418151816181718181819182018211822182318241825182618271828182918301831183218331834183518361837183818391840184118421843184418451846184718481849185018511852185318541855185618571858185918601861186218631864186518661867186818691870187118721873187418751876187718781879188018811882188318841885188618871888188918901891189218931894189518961897189818991900190119021903190419051906190719081909191019111912191319141915191619171918191919201921192219231924192519261927192819291930193119321933193419351936193719381939194019411942194319441945194619471948194919501951195219531954195519561957195819591960196119621963196419651966196719681969197019711972197319741975197619771978197919801981198219831984198519861987198819891990199119921993199419951996199719981999200020012002200320042005200620072008200920102011201220132014201520162017201820192020202120222023202420252026202720282029203020312032203320342035203620372038203920402041204220432044204520462047204820492050205120522053205420552056205720582059206020612062206320642065206620672068206920702071207220732074207520762077207820792080208120822083208420852086208720882089209020912092209320942095209620972098209921002101210221032104210521062107210821092110211121122113211421152116211721182119212021212122212321242125212621272128212921302131213221332134213521362137213821392140214121422143214421452146214721482149215021512152215321542155215621572158215921602161216221632164216521662167216821692170217121722173217421752176217721782179218021812182218321842185218621872188218921902191219221932194219521962197219821992200220122022203220422052206220722082209221022112212221322142215221622172218221922202221222222232224222522262227222822292230223122322233223422352236223722382239224022412242224322442245224622472248224922502251225222532254225522562257225822592260226122622263226422652266226722682269227022712272227322742275227622772278227922802281228222832284228522862287228822892290229122922293229422952296229722982299230023012302230323042305230623072308230923102311231223132314231523162317231823192320232123222323232423252326232723282329233023312332233323342335233623372338233923402341234223432344234523462347234823492350235123522353235423552356235723582359236023612362236323642365236623672368236923702371237223732374237523762377237823792380238123822383238423852386238723882389239023912392239323942395239623972398239924002401240224032404240524062407240824092410241124122413241424152416241724182419242024212422242324242425242624272428242924302431243224332434243524362437243824392440244124422443244424452446244724482449245024512452245324542455245624572458245924602461246224632464246524662467246824692470247124722473247424752476247724782479248024812482248324842485248624872488248924902491249224932494249524962497249824992500250125022503250425052506250725082509251025112512251325142515251625172518251925202521252225232524252525262527252825292530253125322533253425352536253725382539254025412542254325442545254625472548254925502551255225532554255525562557255825592560256125622563256425652566256725682569257025712572257325742575257625772578257925802581258225832584258525862587258825892590259125922593259425952596259725982599260026012602260326042605260626072608260926102611261226132614261526162617261826192620262126222623262426252626262726282629263026312632263326342635263626372638263926402641264226432644264526462647264826492650265126522653265426552656265726582659266026612662266326642665266626672668266926702671267226732674267526762677267826792680268126822683268426852686268726882689269026912692269326942695269626972698269927002701270227032704270527062707270827092710271127122713271427152716271727182719272027212722272327242725272627272728272927302731273227332734273527362737273827392740274127422743274427452746274727482749275027512752275327542755275627572758275927602761276227632764276527662767276827692770277127722773277427752776277727782779278027812782278327842785278627872788278927902791279227932794279527962797279827992800280128022803280428052806280728082809281028112812281328142815281628172818281928202821282228232824282528262827282828292830283128322833283428352836283728382839284028412842284328442845284628472848284928502851285228532854285528562857285828592860286128622863286428652866286728682869287028712872287328742875287628772878287928802881288228832884288528862887288828892890289128922893289428952896289728982899290029012902290329042905290629072908290929102911291229132914291529162917291829192920292129222923292429252926292729282929293029312932293329342935293629372938293929402941294229432944294529462947294829492950295129522953295429552956295729582959296029612962296329642965296629672968296929702971297229732974297529762977297829792980298129822983298429852986298729882989299029912992299329942995299629972998299930003001300230033004300530063007300830093010301130123013301430153016301730183019302030213022302330243025302630273028302930303031303230333034303530363037303830393040304130423043304430453046304730483049305030513052305330543055305630573058305930603061306230633064306530663067306830693070307130723073307430753076307730783079308030813082308330843085308630873088308930903091309230933094309530963097309830993100310131023103310431053106310731083109311031113112311331143115311631173118311931203121312231233124312531263127312831293130313131323133313431353136313731383139314031413142314331443145314631473148314931503151315231533154315531563157315831593160316131623163316431653166316731683169317031713172317331743175317631773178317931803181318231833184318531863187318831893190319131923193319431953196319731983199320032013202320332043205320632073208320932103211321232133214321532163217321832193220322132223223322432253226322732283229323032313232323332343235323632373238323932403241324232433244324532463247324832493250325132523253325432553256325732583259326032613262326332643265326632673268326932703271327232733274327532763277327832793280328132823283328432853286328732883289329032913292329332943295329632973298329933003301330233033304330533063307330833093310331133123313331433153316331733183319332033213322332333243325332633273328332933303331333233333334333533363337333833393340334133423343334433453346334733483349335033513352335333543355335633573358335933603361336233633364336533663367336833693370337133723373337433753376337733783379338033813382338333843385338633873388338933903391339233933394339533963397339833993400340134023403340434053406340734083409341034113412341334143415341634173418341934203421342234233424342534263427342834293430343134323433343434353436343734383439344034413442344334443445344634473448344934503451345234533454345534563457345834593460346134623463346434653466346734683469347034713472347334743475347634773478347934803481348234833484348534863487348834893490349134923493349434953496349734983499350035013502350335043505350635073508350935103511351235133514351535163517351835193520352135223523352435253526352735283529353035313532353335343535353635373538353935403541354235433544354535463547354835493550355135523553355435553556355735583559356035613562356335643565356635673568356935703571357235733574357535763577357835793580358135823583358435853586358735883589359035913592359335943595359635973598359936003601360236033604360536063607360836093610361136123613361436153616361736183619362036213622362336243625362636273628362936303631363236333634363536363637363836393640364136423643364436453646364736483649365036513652365336543655365636573658365936603661366236633664366536663667366836693670367136723673367436753676367736783679368036813682368336843685368636873688368936903691369236933694369536963697369836993700370137023703370437053706370737083709371037113712371337143715371637173718371937203721372237233724372537263727372837293730373137323733373437353736373737383739374037413742374337443745374637473748374937503751375237533754375537563757375837593760376137623763376437653766376737683769377037713772377337743775377637773778377937803781378237833784378537863787378837893790379137923793379437953796379737983799380038013802380338043805380638073808380938103811381238133814381538163817381838193820382138223823382438253826382738283829383038313832383338343835383638373838383938403841384238433844384538463847384838493850385138523853385438553856385738583859386038613862386338643865386638673868386938703871387238733874387538763877387838793880388138823883388438853886388738883889389038913892389338943895389638973898389939003901390239033904390539063907390839093910391139123913391439153916391739183919392039213922392339243925392639273928392939303931393239333934393539363937393839393940394139423943394439453946394739483949395039513952395339543955395639573958395939603961396239633964396539663967396839693970397139723973397439753976397739783979398039813982398339843985398639873988398939903991399239933994399539963997399839994000400140024003400440054006400740084009401040114012401340144015401640174018401940204021402240234024402540264027402840294030403140324033403440354036403740384039404040414042404340444045404640474048404940504051405240534054405540564057405840594060406140624063406440654066406740684069407040714072407340744075407640774078407940804081408240834084408540864087408840894090409140924093409440954096409740984099410041014102410341044105410641074108410941104111411241134114411541164117411841194120412141224123412441254126412741284129413041314132413341344135413641374138413941404141414241434144414541464147414841494150415141524153415441554156415741584159416041614162416341644165416641674168416941704171417241734174417541764177417841794180418141824183418441854186418741884189419041914192419341944195419641974198419942004201420242034204420542064207420842094210421142124213421442154216421742184219422042214222422342244225422642274228422942304231423242334234423542364237423842394240424142424243424442454246424742484249425042514252425342544255425642574258425942604261426242634264426542664267426842694270427142724273427442754276427742784279428042814282428342844285428642874288428942904291429242934294429542964297429842994300430143024303430443054306430743084309431043114312431343144315431643174318431943204321432243234324432543264327432843294330433143324333433443354336433743384339434043414342434343444345434643474348434943504351435243534354435543564357435843594360436143624363436443654366436743684369437043714372437343744375437643774378437943804381438243834384438543864387438843894390439143924393439443954396439743984399440044014402440344044405440644074408440944104411441244134414441544164417441844194420442144224423442444254426442744284429443044314432443344344435443644374438443944404441444244434444444544464447444844494450445144524453445444554456445744584459446044614462446344644465446644674468446944704471447244734474447544764477447844794480448144824483448444854486448744884489449044914492449344944495449644974498449945004501450245034504450545064507450845094510451145124513451445154516451745184519452045214522452345244525452645274528452945304531453245334534453545364537453845394540454145424543454445454546454745484549455045514552455345544555455645574558455945604561456245634564456545664567456845694570457145724573457445754576457745784579458045814582458345844585458645874588458945904591459245934594459545964597459845994600460146024603460446054606460746084609461046114612461346144615461646174618461946204621462246234624462546264627462846294630463146324633463446354636463746384639464046414642464346444645464646474648464946504651465246534654465546564657465846594660466146624663466446654666466746684669467046714672467346744675467646774678467946804681468246834684468546864687468846894690469146924693469446954696469746984699470047014702470347044705470647074708470947104711471247134714471547164717471847194720472147224723472447254726472747284729473047314732473347344735473647374738473947404741474247434744474547464747474847494750475147524753475447554756475747584759476047614762476347644765476647674768476947704771477247734774477547764777477847794780478147824783478447854786478747884789479047914792479347944795479647974798479948004801480248034804480548064807480848094810481148124813481448154816481748184819482048214822482348244825482648274828482948304831483248334834483548364837483848394840484148424843484448454846484748484849485048514852485348544855485648574858485948604861486248634864486548664867486848694870487148724873487448754876487748784879488048814882488348844885488648874888488948904891489248934894489548964897489848994900490149024903490449054906490749084909491049114912491349144915491649174918491949204921492249234924492549264927492849294930493149324933493449354936493749384939494049414942494349444945494649474948494949504951495249534954495549564957495849594960496149624963496449654966496749684969497049714972497349744975497649774978497949804981498249834984498549864987498849894990499149924993499449954996499749984999500050015002500350045005500650075008500950105011501250135014501550165017501850195020502150225023502450255026502750285029503050315032503350345035503650375038503950405041504250435044504550465047504850495050505150525053505450555056505750585059506050615062506350645065506650675068506950705071507250735074507550765077507850795080508150825083508450855086508750885089509050915092509350945095509650975098509951005101510251035104510551065107510851095110511151125113511451155116511751185119512051215122512351245125512651275128512951305131513251335134513551365137513851395140514151425143514451455146514751485149515051515152515351545155515651575158515951605161516251635164516551665167516851695170517151725173517451755176517751785179518051815182518351845185518651875188518951905191519251935194519551965197519851995200520152025203520452055206520752085209521052115212521352145215521652175218521952205221522252235224522552265227522852295230523152325233523452355236523752385239524052415242524352445245524652475248524952505251525252535254525552565257525852595260526152625263526452655266526752685269527052715272527352745275527652775278527952805281528252835284528552865287528852895290529152925293529452955296529752985299530053015302530353045305530653075308530953105311531253135314531553165317531853195320532153225323532453255326532753285329533053315332533353345335533653375338533953405341534253435344534553465347534853495350535153525353535453555356535753585359536053615362536353645365536653675368536953705371537253735374537553765377537853795380538153825383538453855386538753885389539053915392539353945395539653975398539954005401540254035404540554065407540854095410541154125413541454155416541754185419542054215422542354245425542654275428542954305431543254335434543554365437543854395440544154425443544454455446544754485449545054515452545354545455545654575458545954605461546254635464546554665467546854695470547154725473547454755476547754785479548054815482548354845485548654875488548954905491549254935494549554965497549854995500550155025503550455055506550755085509551055115512551355145515551655175518551955205521552255235524552555265527552855295530553155325533553455355536553755385539554055415542554355445545554655475548554955505551555255535554555555565557555855595560556155625563556455655566556755685569557055715572557355745575557655775578557955805581558255835584558555865587558855895590559155925593559455955596559755985599560056015602560356045605560656075608560956105611561256135614561556165617561856195620562156225623562456255626562756285629563056315632563356345635563656375638563956405641564256435644564556465647564856495650565156525653565456555656565756585659566056615662566356645665566656675668566956705671567256735674567556765677567856795680568156825683568456855686
  1. /**
  2. * Copyright (c) 2006-2016, JGraph Holdings Ltd
  3. */
  4. //**********************************************************************************************************************************************************
  5. //Test Point
  6. //**********************************************************************************************************************************************************
  7. /**
  8. * Extends mxShape.
  9. */
  10. function mxShapeElectricalTestPoint(bounds, fill, stroke, strokewidth)
  11. {
  12. mxShape.call(this);
  13. this.bounds = bounds;
  14. this.fill = fill;
  15. this.stroke = stroke;
  16. this.strokewidth = (strokewidth != null) ? strokewidth : 1;
  17. };
  18. /**
  19. * Extends mxShape.
  20. */
  21. mxUtils.extend(mxShapeElectricalTestPoint, mxShape);
  22. mxShapeElectricalTestPoint.prototype.cst = {
  23. SHAPE_TEST_POINT : 'mxgraph.electrical.transmission.testPoint'
  24. };
  25. /**
  26. * Function: paintVertexShape
  27. *
  28. * Paints the vertex shape.
  29. */
  30. mxShapeElectricalTestPoint.prototype.paintVertexShape = function(c, x, y, w, h)
  31. {
  32. c.translate(x, y);
  33. var strokeColor = mxUtils.getValue(this.style, mxConstants.STYLE_STROKECOLOR, '#000000');
  34. var size = Math.min(w, h);
  35. c.setFillColor(strokeColor);
  36. c.begin();
  37. c.ellipse(w * 0.5 - size / 2, 0, size, size);
  38. c.fillAndStroke();
  39. if (h > w)
  40. {
  41. c.begin();
  42. c.moveTo(w * 0.5, size);
  43. c.lineTo(w * 0.5, h);
  44. c.stroke();
  45. }
  46. };
  47. mxCellRenderer.registerShape(mxShapeElectricalTestPoint.prototype.cst.SHAPE_TEST_POINT, mxShapeElectricalTestPoint);
  48. mxShapeElectricalTestPoint.prototype.constraints = [
  49. new mxConnectionConstraint(new mxPoint(0.5, 0), true),
  50. new mxConnectionConstraint(new mxPoint(0.5, 1), true)
  51. ];
  52. //**********************************************************************************************************************************************************
  53. //Straight Bus
  54. //**********************************************************************************************************************************************************
  55. /**
  56. * Extends mxShape.
  57. */
  58. function mxShapeElectricalStraightBus(bounds, fill, stroke, strokewidth)
  59. {
  60. mxShape.call(this);
  61. this.bounds = bounds;
  62. this.fill = fill;
  63. this.stroke = stroke;
  64. this.strokewidth = (strokewidth != null) ? strokewidth : 1;
  65. };
  66. /**
  67. * Extends mxShape.
  68. */
  69. mxUtils.extend(mxShapeElectricalStraightBus, mxShape);
  70. mxShapeElectricalStraightBus.prototype.cst = {
  71. SHAPE_STRAIGHT_BUS : 'mxgraph.electrical.transmission.straightBus'
  72. };
  73. /**
  74. * Function: paintVertexShape
  75. *
  76. * Paints the vertex shape.
  77. */
  78. mxShapeElectricalStraightBus.prototype.paintVertexShape = function(c, x, y, w, h)
  79. {
  80. c.translate(x, y);
  81. var x1 = w * 0.2;
  82. var y1 = 0;
  83. if (w > h)
  84. {
  85. y1 = h * 0.5;
  86. }
  87. else
  88. {
  89. y1 = w / 2;
  90. }
  91. c.begin();
  92. c.moveTo(w - x1, 0);
  93. c.lineTo(w - x1, h - y1);
  94. c.lineTo(w, h - y1);
  95. c.lineTo(w * 0.5, h);
  96. c.lineTo(0, h - y1);
  97. c.lineTo(x1, h - y1);
  98. c.lineTo(x1, 0);
  99. c.fillAndStroke();
  100. };
  101. mxCellRenderer.registerShape(mxShapeElectricalStraightBus.prototype.cst.SHAPE_STRAIGHT_BUS, mxShapeElectricalStraightBus);
  102. mxShapeElectricalStraightBus.prototype.constraints = [
  103. new mxConnectionConstraint(new mxPoint(0.5, 0), true),
  104. new mxConnectionConstraint(new mxPoint(0.5, 1), true)
  105. ];
  106. //**********************************************************************************************************************************************************
  107. //Two-Line Bus Elbow
  108. //**********************************************************************************************************************************************************
  109. /**
  110. * Extends mxShape.
  111. */
  112. function mxShapeElectricalTwoLineBusElbow(bounds, fill, stroke, strokewidth)
  113. {
  114. mxShape.call(this);
  115. this.bounds = bounds;
  116. this.fill = fill;
  117. this.stroke = stroke;
  118. this.strokewidth = (strokewidth != null) ? strokewidth : 1;
  119. this.notch = 0;
  120. };
  121. /**
  122. * Extends mxShape.
  123. */
  124. mxUtils.extend(mxShapeElectricalTwoLineBusElbow, mxShape);
  125. mxShapeElectricalTwoLineBusElbow.prototype.cst = {
  126. SHAPE_TWO_LINE_BUS_ELBOW : 'mxgraph.electrical.transmission.twoLineBusElbow'
  127. };
  128. mxShapeElectricalTwoLineBusElbow.prototype.customProperties = [
  129. {name:'notch', dispName:'Spacing', type:'float', min:0, defVal:25}
  130. ];
  131. /**
  132. * Function: paintVertexShape
  133. *
  134. * Paints the vertex shape.
  135. */
  136. mxShapeElectricalTwoLineBusElbow.prototype.paintVertexShape = function(c, x, y, w, h)
  137. {
  138. var notch = Math.max(0, Math.min(w, parseFloat(mxUtils.getValue(this.style, 'notch', this.notch))));
  139. c.translate(x, y);
  140. c.begin();
  141. c.moveTo(0, h);
  142. c.lineTo(w, h);
  143. c.lineTo(w, 0);
  144. c.stroke();
  145. var wn = Math.min(w, notch);
  146. var hn = Math.min(h, notch);
  147. c.begin();
  148. c.moveTo(0, h - hn);
  149. c.lineTo(w - wn, h - hn);
  150. c.lineTo(w - wn, 0);
  151. c.stroke();
  152. };
  153. mxCellRenderer.registerShape(mxShapeElectricalTwoLineBusElbow.prototype.cst.SHAPE_TWO_LINE_BUS_ELBOW, mxShapeElectricalTwoLineBusElbow);
  154. mxShapeElectricalTwoLineBusElbow.prototype.constraints = null;
  155. Graph.handleFactory[mxShapeElectricalTwoLineBusElbow.prototype.cst.SHAPE_TWO_LINE_BUS_ELBOW] = function(state)
  156. {
  157. var handles = [Graph.createHandle(state, ['notch'], function(bounds)
  158. {
  159. var notch = Math.max(Math.min(bounds.height, parseFloat(mxUtils.getValue(this.state.style, 'notch', this.notch))), 0);
  160. return new mxPoint(bounds.x + bounds.width / 4, bounds.y + bounds.height - notch);
  161. }, function(bounds, pt)
  162. {
  163. this.state.style['notch'] = Math.round(0.2 * Math.max(0, bounds.width - pt.y + bounds.y)) / 0.2;
  164. })];
  165. return handles;
  166. }
  167. //**********************************************************************************************************************************************************
  168. //Three-Line Bus Elbow
  169. //**********************************************************************************************************************************************************
  170. /**
  171. * Extends mxShape.
  172. */
  173. function mxShapeElectricalThreeLineBusElbow(bounds, fill, stroke, strokewidth)
  174. {
  175. mxShape.call(this);
  176. this.bounds = bounds;
  177. this.fill = fill;
  178. this.stroke = stroke;
  179. this.strokewidth = (strokewidth != null) ? strokewidth : 1;
  180. this.notch = 0;
  181. };
  182. /**
  183. * Extends mxShape.
  184. */
  185. mxUtils.extend(mxShapeElectricalThreeLineBusElbow, mxShape);
  186. mxShapeElectricalThreeLineBusElbow.prototype.cst = {
  187. SHAPE_THREE_LINE_BUS_ELBOW : 'mxgraph.electrical.transmission.threeLineBusElbow'
  188. };
  189. mxShapeElectricalThreeLineBusElbow.prototype.customProperties = [
  190. {name:'notch', dispName:'Spacing', type:'float', min:0, defVal:30}
  191. ];
  192. /**
  193. * Function: paintVertexShape
  194. *
  195. * Paints the vertex shape.
  196. */
  197. mxShapeElectricalThreeLineBusElbow.prototype.paintVertexShape = function(c, x, y, w, h)
  198. {
  199. var notch = Math.max(0, Math.min(w, parseFloat(mxUtils.getValue(this.style, 'notch', this.notch))));
  200. c.translate(x, y);
  201. c.begin();
  202. c.moveTo(0, h);
  203. c.lineTo(w, h);
  204. c.lineTo(w, 0);
  205. c.stroke();
  206. var wn = Math.min(w, notch);
  207. var hn = Math.min(h, notch);
  208. c.begin();
  209. c.moveTo(0, h - hn);
  210. c.lineTo(w - wn, h - hn);
  211. c.lineTo(w - wn, 0);
  212. c.stroke();
  213. c.begin();
  214. c.moveTo(0, h - hn / 2);
  215. c.lineTo(w - wn / 2, h - hn / 2);
  216. c.lineTo(w - wn / 2, 0);
  217. c.stroke();
  218. };
  219. mxCellRenderer.registerShape(mxShapeElectricalThreeLineBusElbow.prototype.cst.SHAPE_THREE_LINE_BUS_ELBOW, mxShapeElectricalThreeLineBusElbow);
  220. mxShapeElectricalThreeLineBusElbow.prototype.constraints = null;
  221. Graph.handleFactory[mxShapeElectricalThreeLineBusElbow.prototype.cst.SHAPE_THREE_LINE_BUS_ELBOW] = function(state)
  222. {
  223. var handles = [Graph.createHandle(state, ['notch'], function(bounds)
  224. {
  225. var notch = Math.max(Math.min(bounds.height, parseFloat(mxUtils.getValue(this.state.style, 'notch', this.notch))), 0);
  226. return new mxPoint(bounds.x + bounds.width / 4, bounds.y + bounds.height - notch);
  227. }, function(bounds, pt)
  228. {
  229. this.state.style['notch'] = Math.round(0.2 * Math.max(0, bounds.width - pt.y + bounds.y)) / 0.2;
  230. })];
  231. return handles;
  232. }
  233. //**********************************************************************************************************************************************************
  234. //Four-Line Bus Elbow
  235. //**********************************************************************************************************************************************************
  236. /**
  237. * Extends mxShape.
  238. */
  239. function mxShapeElectricalFourLineBusElbow(bounds, fill, stroke, strokewidth)
  240. {
  241. mxShape.call(this);
  242. this.bounds = bounds;
  243. this.fill = fill;
  244. this.stroke = stroke;
  245. this.strokewidth = (strokewidth != null) ? strokewidth : 1;
  246. this.notch = 0;
  247. };
  248. /**
  249. * Extends mxShape.
  250. */
  251. mxUtils.extend(mxShapeElectricalFourLineBusElbow, mxShape);
  252. mxShapeElectricalFourLineBusElbow.prototype.cst = {
  253. SHAPE_FOUR_LINE_BUS_ELBOW : 'mxgraph.electrical.transmission.fourLineBusElbow'
  254. };
  255. mxShapeElectricalFourLineBusElbow.prototype.customProperties = [
  256. {name:'notch', dispName:'Spacing', type:'float', min:0, defVal:75}
  257. ];
  258. /**
  259. * Function: paintVertexShape
  260. *
  261. * Paints the vertex shape.
  262. */
  263. mxShapeElectricalFourLineBusElbow.prototype.paintVertexShape = function(c, x, y, w, h)
  264. {
  265. var notch = Math.max(0, Math.min(w, parseFloat(mxUtils.getValue(this.style, 'notch', this.notch))));
  266. c.translate(x, y);
  267. c.begin();
  268. c.moveTo(0, h);
  269. c.lineTo(w, h);
  270. c.lineTo(w, 0);
  271. c.stroke();
  272. var wn = Math.min(w, notch);
  273. var hn = Math.min(h, notch);
  274. c.begin();
  275. c.moveTo(0, h - hn);
  276. c.lineTo(w - wn, h - hn);
  277. c.lineTo(w - wn, 0);
  278. c.stroke();
  279. c.begin();
  280. c.moveTo(0, h - hn / 3);
  281. c.lineTo(w - wn / 3, h - hn / 3);
  282. c.lineTo(w - wn / 3, 0);
  283. c.stroke();
  284. c.begin();
  285. c.moveTo(0, h - hn * 2 / 3);
  286. c.lineTo(w - wn * 2 / 3, h - hn * 2 / 3);
  287. c.lineTo(w - wn * 2 / 3, 0);
  288. c.stroke();
  289. };
  290. mxCellRenderer.registerShape(mxShapeElectricalFourLineBusElbow.prototype.cst.SHAPE_FOUR_LINE_BUS_ELBOW, mxShapeElectricalFourLineBusElbow);
  291. mxShapeElectricalFourLineBusElbow.prototype.constraints = null;
  292. Graph.handleFactory[mxShapeElectricalFourLineBusElbow.prototype.cst.SHAPE_FOUR_LINE_BUS_ELBOW] = function(state)
  293. {
  294. var handles = [Graph.createHandle(state, ['notch'], function(bounds)
  295. {
  296. var notch = Math.max(Math.min(bounds.height, parseFloat(mxUtils.getValue(this.state.style, 'notch', this.notch))), 0);
  297. return new mxPoint(bounds.x + bounds.width / 4, bounds.y + bounds.height - notch);
  298. }, function(bounds, pt)
  299. {
  300. this.state.style['notch'] = Math.round(0.2 * Math.max(0, bounds.width - pt.y + bounds.y)) / 0.2;
  301. })];
  302. return handles;
  303. }
  304. //**********************************************************************************************************************************************************
  305. //Four-Line Bus Elbow
  306. //**********************************************************************************************************************************************************
  307. /**
  308. * Extends mxShape.
  309. */
  310. function mxShapeElectricalEightLineBusElbow(bounds, fill, stroke, strokewidth)
  311. {
  312. mxShape.call(this);
  313. this.bounds = bounds;
  314. this.fill = fill;
  315. this.stroke = stroke;
  316. this.strokewidth = (strokewidth != null) ? strokewidth : 1;
  317. this.notch = 0;
  318. };
  319. /**
  320. * Extends mxShape.
  321. */
  322. mxUtils.extend(mxShapeElectricalEightLineBusElbow, mxShape);
  323. mxShapeElectricalEightLineBusElbow.prototype.cst = {
  324. SHAPE_EIGHT_LINE_BUS_ELBOW : 'mxgraph.electrical.transmission.eightLineBusElbow'
  325. };
  326. mxShapeElectricalEightLineBusElbow.prototype.customProperties = [
  327. {name:'notch', dispName:'Spacing', type:'float', min:0, defVal:180}
  328. ];
  329. /**
  330. * Function: paintVertexShape
  331. *
  332. * Paints the vertex shape.
  333. */
  334. mxShapeElectricalEightLineBusElbow.prototype.paintVertexShape = function(c, x, y, w, h)
  335. {
  336. var notch = Math.max(0, Math.min(w, parseFloat(mxUtils.getValue(this.style, 'notch', this.notch))));
  337. c.translate(x, y);
  338. c.begin();
  339. c.moveTo(0, h);
  340. c.lineTo(w, h);
  341. c.lineTo(w, 0);
  342. c.stroke();
  343. var wn = Math.min(w, notch);
  344. var hn = Math.min(h, notch);
  345. c.begin();
  346. c.moveTo(0, h - hn);
  347. c.lineTo(w - wn, h - hn);
  348. c.lineTo(w - wn, 0);
  349. c.stroke();
  350. c.begin();
  351. c.moveTo(0, h - hn / 7);
  352. c.lineTo(w - wn / 7, h - hn / 7);
  353. c.lineTo(w - wn / 7, 0);
  354. c.stroke();
  355. c.begin();
  356. c.moveTo(0, h - hn * 2 / 7);
  357. c.lineTo(w - wn * 2 / 7, h - hn * 2 / 7);
  358. c.lineTo(w - wn * 2 / 7, 0);
  359. c.stroke();
  360. c.begin();
  361. c.moveTo(0, h - hn * 3 / 7);
  362. c.lineTo(w - wn * 3 / 7, h - hn * 3 / 7);
  363. c.lineTo(w - wn * 3 / 7, 0);
  364. c.stroke();
  365. c.begin();
  366. c.moveTo(0, h - hn * 4 / 7);
  367. c.lineTo(w - wn * 4 / 7, h - hn * 4 / 7);
  368. c.lineTo(w - wn * 4 / 7, 0);
  369. c.stroke();
  370. c.begin();
  371. c.moveTo(0, h - hn * 5 / 7);
  372. c.lineTo(w - wn * 5 / 7, h - hn * 5 / 7);
  373. c.lineTo(w - wn * 5 / 7, 0);
  374. c.stroke();
  375. c.begin();
  376. c.moveTo(0, h - hn * 6 / 7);
  377. c.lineTo(w - wn * 6 / 7, h - hn * 6 / 7);
  378. c.lineTo(w - wn * 6 / 7, 0);
  379. c.stroke();
  380. };
  381. mxCellRenderer.registerShape(mxShapeElectricalEightLineBusElbow.prototype.cst.SHAPE_EIGHT_LINE_BUS_ELBOW, mxShapeElectricalEightLineBusElbow);
  382. mxShapeElectricalEightLineBusElbow.prototype.constraints = null;
  383. Graph.handleFactory[mxShapeElectricalEightLineBusElbow.prototype.cst.SHAPE_EIGHT_LINE_BUS_ELBOW] = function(state)
  384. {
  385. var handles = [Graph.createHandle(state, ['notch'], function(bounds)
  386. {
  387. var notch = Math.max(Math.min(bounds.height, parseFloat(mxUtils.getValue(this.state.style, 'notch', this.notch))), 0);
  388. return new mxPoint(bounds.x + bounds.width / 4, bounds.y + bounds.height - notch);
  389. }, function(bounds, pt)
  390. {
  391. this.state.style['notch'] = Math.round(0.2 * Math.max(0, bounds.width - pt.y + bounds.y)) / 0.2;
  392. })];
  393. return handles;
  394. }
  395. //**********************************************************************************************************************************************************
  396. //Logic Gate
  397. //**********************************************************************************************************************************************************
  398. /**
  399. * Extends mxShape.
  400. */
  401. function mxShapeElectricalLogicGate(bounds, fill, stroke, strokewidth)
  402. {
  403. mxShape.call(this);
  404. this.bounds = bounds;
  405. this.fill = fill;
  406. this.stroke = stroke;
  407. this.strokewidth = (strokewidth != null) ? strokewidth : 1;
  408. };
  409. /**
  410. * Extends mxShape.
  411. */
  412. mxUtils.extend(mxShapeElectricalLogicGate, mxShape);
  413. mxShapeElectricalLogicGate.prototype.cst = {
  414. SHAPE_LOGIC_GATE : 'mxgraph.electrical.logic_gates.logic_gate'
  415. };
  416. mxShapeElectricalLogicGate.prototype.customProperties = [
  417. {name: 'operation', dispName: 'Operation', type: 'enum', defVal:'and',
  418. enumList:[
  419. {val:'and', dispName:'And'},
  420. {val:'or', dispName:'Or'},
  421. {val:'xor', dispName:'Xor'}
  422. ]},
  423. {name: 'numInputs', dispName: 'Inputs', type: 'int', min:2, defVal:2},
  424. {name: 'negating', dispName: 'Negating', type: 'bool', defVal:0}
  425. ];
  426. /**
  427. * Function: paintVertexShape
  428. *
  429. * Paints the vertex shape.
  430. */
  431. mxShapeElectricalLogicGate.prototype.paintVertexShape = function(c, x, y, w, h)
  432. {
  433. c.translate(x, y);
  434. var numInputs = parseInt(mxUtils.getValue(this.style, 'numInputs', '2'));
  435. var spacing = h / numInputs;
  436. var currH = spacing * 0.5;
  437. c.begin();
  438. c.moveTo(w * 0.8, h * 0.5);
  439. c.lineTo(w, h * 0.5);
  440. var operation = mxUtils.getValue(this.style, 'operation', 'and');
  441. for (var i = 0; i < numInputs; i++)
  442. {
  443. c.moveTo(0, currH);
  444. if (operation == 'and')
  445. {
  446. c.lineTo(w * 0.2, currH);
  447. }
  448. else
  449. {
  450. c.lineTo(w * 0.23, currH);
  451. }
  452. currH = currH + spacing;
  453. }
  454. c.stroke();
  455. switch(operation) {
  456. case 'xor':
  457. c.begin();
  458. c.moveTo(w * 0.1, 0);
  459. c.arcTo(w * 0.6, h, 0, 0, 1, w * 0.1, h);
  460. c.stroke();
  461. //no break operation needed, XOR needs to draw an OR shape too
  462. case 'or':
  463. c.begin();
  464. c.moveTo(w * 0.4, 0);
  465. c.arcTo(w * 0.45, h * 0.83, 0, 0, 1, w * 0.8, h * 0.5);
  466. c.arcTo(w * 0.45, h * 0.83, 0, 0, 1, w * 0.4, h);
  467. c.lineTo(w * 0.15, h);
  468. c.arcTo(w * 0.6, h, 0, 0, 0, w * 0.15, 0);
  469. c.close();
  470. c.fillAndStroke();
  471. break;
  472. default:
  473. c.begin();
  474. c.moveTo(w * 0.2, 0);
  475. c.lineTo(w * 0.5, 0);
  476. c.arcTo(w * 0.3, h * 0.5, 0, 0, 1, w * 0.5, h);
  477. c.lineTo(w * 0.2, h);
  478. c.close();
  479. c.fillAndStroke();
  480. };
  481. var negating = mxUtils.getValue(this.style, 'negating', '0');
  482. if (negating == '1')
  483. {
  484. var negSize;
  485. if(this.style.negSize)
  486. {
  487. var tmpSize = parseFloat(mxUtils.getValue(this.style, 'negSize', '0.13'));
  488. negSize = Math.min(w * tmpSize * 0.5, h * tmpSize);
  489. }
  490. else
  491. {
  492. negSize = Math.min(w * 0.04, h * 0.07);
  493. }
  494. c.begin();
  495. c.ellipse(w * 0.8, h * 0.5 - negSize * 0.5, negSize, negSize);
  496. c.fillAndStroke();
  497. }
  498. };
  499. mxCellRenderer.registerShape(mxShapeElectricalLogicGate.prototype.cst.SHAPE_LOGIC_GATE, mxShapeElectricalLogicGate);
  500. mxShapeElectricalLogicGate.prototype.getConstraints = function(style)
  501. {
  502. var constr = [new mxConnectionConstraint(new mxPoint(1, 0.5), false)];
  503. var numInputs = parseInt(mxUtils.getValue(style, 'numInputs', '2'));
  504. var spacing = 1 / numInputs;
  505. var currH = spacing * 0.5;
  506. for (var i = 0; i < numInputs; i++)
  507. {
  508. constr.push(new mxConnectionConstraint(new mxPoint(0, currH), false));
  509. currH = currH + spacing;
  510. }
  511. return (constr);
  512. }
  513. //**********************************************************************************************************************************************************
  514. //Buffer
  515. //**********************************************************************************************************************************************************
  516. /**
  517. * Extends mxShape.
  518. */
  519. function mxShapeElectricalBuffer(bounds, fill, stroke, strokewidth)
  520. {
  521. mxShape.call(this);
  522. this.bounds = bounds;
  523. this.fill = fill;
  524. this.stroke = stroke;
  525. this.strokewidth = (strokewidth != null) ? strokewidth : 1;
  526. };
  527. /**
  528. * Extends mxShape.
  529. */
  530. mxUtils.extend(mxShapeElectricalBuffer, mxShape);
  531. mxShapeElectricalBuffer.prototype.cst = {
  532. SHAPE_BUFFER2 : 'mxgraph.electrical.logic_gates.buffer2'
  533. };
  534. mxShapeElectricalBuffer.prototype.customProperties = [
  535. {name: 'negating', dispName: 'Negating', type: 'bool', defVal:0}
  536. ];
  537. /**
  538. * Function: paintVertexShape
  539. *
  540. * Paints the vertex shape.
  541. */
  542. mxShapeElectricalBuffer.prototype.paintVertexShape = function(c, x, y, w, h)
  543. {
  544. c.translate(x, y);
  545. c.begin();
  546. c.moveTo(0, h * 0.5);
  547. c.lineTo(w * 0.2, h * 0.5);
  548. c.moveTo(w * 0.8, h * 0.5);
  549. c.lineTo(w, h * 0.5);
  550. c.stroke();
  551. c.begin();
  552. c.moveTo(w * 0.2, 0);
  553. c.lineTo(w * 0.8, h * 0.5);
  554. c.lineTo(w * 0.2, h);
  555. c.close();
  556. c.fillAndStroke();
  557. var negating = mxUtils.getValue(this.style, 'negating', '0');
  558. if (negating == '1')
  559. {
  560. var negSize = Math.min(w * 0.04, h * 0.07);
  561. c.begin();
  562. c.ellipse(w * 0.8, h * 0.5 - negSize * 0.5, negSize, negSize);
  563. c.fillAndStroke();
  564. }
  565. };
  566. mxCellRenderer.registerShape(mxShapeElectricalBuffer.prototype.cst.SHAPE_BUFFER2, mxShapeElectricalBuffer);
  567. mxShapeElectricalBuffer.prototype.constraints = [
  568. new mxConnectionConstraint(new mxPoint(0, 0.5), true),
  569. new mxConnectionConstraint(new mxPoint(1, 0.5), true)
  570. ];
  571. //**********************************************************************************************************************************************************
  572. //Dual In-Line IC
  573. //**********************************************************************************************************************************************************
  574. /**
  575. * Extends mxShape.
  576. */
  577. function mxShapeElectricalDualInLineIC(bounds, fill, stroke, strokewidth)
  578. {
  579. mxShape.call(this);
  580. this.bounds = bounds;
  581. this.fill = fill;
  582. this.stroke = stroke;
  583. this.strokewidth = (strokewidth != null) ? strokewidth : 1;
  584. };
  585. /**
  586. * Extends mxShape.
  587. */
  588. mxUtils.extend(mxShapeElectricalDualInLineIC, mxShape);
  589. mxShapeElectricalDualInLineIC.prototype.cst = {
  590. SHAPE_DUAL_INLINE_IC : 'mxgraph.electrical.logic_gates.dual_inline_ic'
  591. };
  592. mxShapeElectricalDualInLineIC.prototype.customProperties = [
  593. {name: 'pinStyle', dispName: 'Pin Style', type: 'enum', defVal:'line',
  594. enumList:[
  595. {val:'line', dispName:'Line'},
  596. {val:'square', dispName:'Square'}
  597. ]},
  598. {name: 'startPin', dispName: 'Starting Pin', type: 'enum', defVal:'n',
  599. enumList:[
  600. {val:'n', dispName:'N'},
  601. {val:'e', dispName:'E'},
  602. {val:'s', dispName:'S'},
  603. {val:'w', dispName:'W'}
  604. ]},
  605. {name: 'pinSpacing', dispName: 'Pin Spacing', type: 'float', min:1, defVal:20},
  606. {name: 'pinLabelType', dispName: 'Pin Label Type', type: 'enum', defVal:'gen',
  607. enumList:[
  608. {val:'gen', dispName:'Generated'},
  609. {val:'cust', dispName:'Custom'}
  610. ]},
  611. {name: 'labelCount', dispName: 'Number of Labels', type: 'int', defVal: 20, dependentProps: ['labelNames']},
  612. {name: 'labelNames', dispName: 'Label Names', type: 'staticArr', subType: 'string', sizeProperty: 'labelCount', subDefVal: 'a'}
  613. ];
  614. /**
  615. * Function: paintVertexShape
  616. *
  617. * Paints the vertex shape.
  618. */
  619. mxShapeElectricalDualInLineIC.prototype.paintVertexShape = function(c, x, y, w, h)
  620. {
  621. c.translate(x, y);
  622. var fontColor = mxUtils.getValue(this.style, 'fontColor', '#000000');
  623. c.setFontColor(fontColor);
  624. var startPin = mxUtils.getValue(this.style, 'startPin', 'n');
  625. var pinLabelType = mxUtils.getValue(this.style, 'pinLabelType', 'gen');
  626. var labelNames = decodeURIComponent(mxUtils.getValue(this.style, 'labelNames', '').toString()).split(',');
  627. c.begin();
  628. if (startPin == 'n' || startPin == 's')
  629. {
  630. c.rect(10, 0, w - 20, h);
  631. }
  632. else
  633. {
  634. c.rect(0, 10, w, h - 20);
  635. }
  636. c.fillAndStroke();
  637. var pinSpacing = parseFloat(mxUtils.getValue(this.style, 'pinSpacing', '20'));
  638. var pinStyle = mxUtils.getValue(this.style, 'pinStyle', 'line');
  639. var fontSize = parseFloat(mxUtils.getValue(this.style, 'fontSize', '12'));
  640. if (startPin == 'n' || startPin == 's')
  641. {
  642. var pinsOne = parseInt(h / pinSpacing);
  643. }
  644. else
  645. {
  646. var pinsOne = parseInt(w / pinSpacing);
  647. }
  648. if (pinStyle == 'line')
  649. {
  650. c.setFontSize(fontSize * 0.8);
  651. var pinCount = 1;
  652. var currH = pinSpacing * 0.5;
  653. c.begin();
  654. if (startPin == 'n' || startPin == 's')
  655. {
  656. while (pinCount * pinSpacing <= h)
  657. {
  658. c.moveTo(0, currH);
  659. c.lineTo(10, currH);
  660. c.moveTo(w - 10, currH);
  661. c.lineTo(w, currH);
  662. if (startPin == 'n')
  663. {
  664. var currPinNum = pinCount;
  665. }
  666. else
  667. {
  668. var currPinNum = pinsOne + pinCount;
  669. }
  670. if (pinLabelType == 'gen')
  671. {
  672. c.text(20, currH, 0, 0, currPinNum.toString(), mxConstants.ALIGN_LEFT, mxConstants.ALIGN_MIDDLE, 0, null, 0, 0, 0);
  673. }
  674. else if (currPinNum - 1 < labelNames.length)
  675. {
  676. c.text(20, currH, 0, 0, labelNames[currPinNum - 1].toString(), mxConstants.ALIGN_LEFT, mxConstants.ALIGN_MIDDLE, 0, null, 0, 0, 0);
  677. }
  678. if (startPin == 'n')
  679. {
  680. var pc2 = 2 * pinsOne - pinCount + 1;
  681. }
  682. else
  683. {
  684. var pc2 = pinsOne - pinCount + 1;
  685. }
  686. if (pinLabelType == 'gen')
  687. {
  688. c.text(w - 20, currH, 0, 0, pc2.toString(), mxConstants.ALIGN_RIGHT, mxConstants.ALIGN_MIDDLE, 0, null, 0, 0, 0);
  689. }
  690. else if (pc2 - 1 < labelNames.length)
  691. {
  692. c.text(w - 20, currH, 0, 0, labelNames[pc2 - 1].toString(), mxConstants.ALIGN_RIGHT, mxConstants.ALIGN_MIDDLE, 0, null, 0, 0, 0);
  693. }
  694. currH = currH + pinSpacing;
  695. pinCount++;
  696. }
  697. }
  698. else
  699. {
  700. while (pinCount * pinSpacing <= w)
  701. {
  702. c.moveTo(currH, 0);
  703. c.lineTo(currH, 10);
  704. c.moveTo(currH, h - 10);
  705. c.lineTo(currH, h);
  706. if (startPin == 'e')
  707. {
  708. var currPinNum = pinsOne - pinCount + 1;
  709. }
  710. else
  711. {
  712. var currPinNum = 2 * pinsOne - pinCount + 1;
  713. }
  714. if (pinLabelType == 'gen')
  715. {
  716. c.text(currH, 20, 0, 0, currPinNum.toString(), mxConstants.ALIGN_CENTER, mxConstants.ALIGN_MIDDLE, 0, null, 0, 0, 0);
  717. }
  718. else if (currPinNum - 1 < labelNames.length)
  719. {
  720. c.text(currH, 20, 0, 0, labelNames[currPinNum - 1].toString(), mxConstants.ALIGN_CENTER, mxConstants.ALIGN_MIDDLE, 0, null, 0, 0, 0);
  721. }
  722. if (startPin == 'e')
  723. {
  724. var pc2 = pinsOne + pinCount;
  725. }
  726. else
  727. {
  728. var pc2 = pinCount;
  729. }
  730. if (pinLabelType == 'gen')
  731. {
  732. c.text(currH, h - 20, 0, 0, pc2.toString(), mxConstants.ALIGN_CENTER, mxConstants.ALIGN_MIDDLE, 0, null, 0, 0, 0);
  733. }
  734. else if (pc2 - 1 < labelNames.length)
  735. {
  736. c.text(currH, h - 20, 0, 0, labelNames[pc2 - 1].toString(), mxConstants.ALIGN_CENTER, mxConstants.ALIGN_MIDDLE, 0, null, 0, 0, 0);
  737. }
  738. currH = currH + pinSpacing;
  739. pinCount++;
  740. }
  741. }
  742. c.stroke();
  743. }
  744. else
  745. {
  746. c.setFontSize(fontSize * 0.5);
  747. var pinCount = 1;
  748. var currH = pinSpacing * 0.5;
  749. if (startPin == 'n' || startPin == 's')
  750. {
  751. while (pinCount * pinSpacing <= h)
  752. {
  753. c.begin();
  754. c.rect(0, currH - pinSpacing * 0.25, 10, pinSpacing * 0.5);
  755. c.fillAndStroke();
  756. c.begin();
  757. c.rect(w - 10, currH - pinSpacing * 0.25, 10, pinSpacing * 0.5);
  758. c.fillAndStroke();
  759. if (startPin == 'n')
  760. {
  761. var currPinNum = pinCount;
  762. }
  763. else
  764. {
  765. var currPinNum = pinsOne + pinCount;
  766. }
  767. if (pinLabelType == 'gen')
  768. {
  769. c.text(5, currH + 1, 0, 0, currPinNum.toString(), mxConstants.ALIGN_CENTER, mxConstants.ALIGN_MIDDLE, 0, null, 0, 0, 0);
  770. }
  771. else if (currPinNum - 1 < labelNames.length)
  772. {
  773. c.text(5, currH + 1, 0, 0, labelNames[currPinNum - 1].toString(), mxConstants.ALIGN_CENTER, mxConstants.ALIGN_MIDDLE, 0, null, 0, 0, 0);
  774. }
  775. if (startPin == 'n')
  776. {
  777. var pc2 = 2 * pinsOne - pinCount + 1;
  778. }
  779. else
  780. {
  781. var pc2 = pinsOne - pinCount + 1;
  782. }
  783. if (pinLabelType == 'gen')
  784. {
  785. c.text(w - 5, currH + 1, 0, 0, pc2.toString(), mxConstants.ALIGN_CENTER, mxConstants.ALIGN_MIDDLE, 0, null, 0, 0, 0);
  786. }
  787. else if (pc2 - 1 < labelNames.length)
  788. {
  789. c.text(w - 5, currH + 1, 0, 0, labelNames[pc2 - 1].toString(), mxConstants.ALIGN_CENTER, mxConstants.ALIGN_MIDDLE, 0, null, 0, 0, 0);
  790. }
  791. currH = currH + pinSpacing;
  792. pinCount++;
  793. }
  794. }
  795. else
  796. {
  797. while (pinCount * pinSpacing <= w)
  798. {
  799. c.begin();
  800. c.rect(currH - pinSpacing * 0.25, 0, pinSpacing * 0.5, 10);
  801. c.fillAndStroke();
  802. c.begin();
  803. c.rect(currH - pinSpacing * 0.25, h - 10, pinSpacing * 0.5, 10);
  804. c.fillAndStroke();
  805. if (startPin == 'e')
  806. {
  807. var currPinNum = pinsOne - pinCount + 1;
  808. }
  809. else
  810. {
  811. var currPinNum = 2 * pinsOne - pinCount + 1;
  812. }
  813. if (pinLabelType == 'gen')
  814. {
  815. c.text(currH, 5, 0, 0, currPinNum.toString(), mxConstants.ALIGN_CENTER, mxConstants.ALIGN_MIDDLE, 0, null, 0, 0, 0);
  816. }
  817. else if (currPinNum - 1 < labelNames.length)
  818. {
  819. c.text(currH, 5, 0, 0, labelNames[currPinNum - 1].toString(), mxConstants.ALIGN_CENTER, mxConstants.ALIGN_MIDDLE, 0, null, 0, 0, 0);
  820. }
  821. if (startPin == 'e')
  822. {
  823. var pc2 = pinsOne + pinCount;
  824. }
  825. else
  826. {
  827. var pc2 = pinCount;
  828. }
  829. if (pinLabelType == 'gen')
  830. {
  831. c.text(currH, h - 5, 0, 0, pc2.toString(), mxConstants.ALIGN_CENTER, mxConstants.ALIGN_MIDDLE, 0, null, 0, 0, 0);
  832. }
  833. else if (pc2 - 1 < labelNames.length)
  834. {
  835. c.text(currH, h - 5, 0, 0, labelNames[pc2 - 1].toString(), mxConstants.ALIGN_CENTER, mxConstants.ALIGN_MIDDLE, 0, null, 0, 0, 0);
  836. }
  837. currH = currH + pinSpacing;
  838. pinCount++;
  839. }
  840. }
  841. }
  842. c.setShadow(false);
  843. c.begin();
  844. switch(startPin) {
  845. case 'e':
  846. if (h > 40)
  847. {
  848. c.moveTo(w, h * 0.5 - 10);
  849. c.arcTo(12, 12, 0, 0, 0, w, h * 0.5 + 10);
  850. }
  851. break;
  852. case 's':
  853. if (w > 40)
  854. {
  855. c.moveTo(w * 0.5 - 10, h);
  856. c.arcTo(12, 12, 0, 0, 1, w * 0.5 + 10, h);
  857. }
  858. break;
  859. case 'w':
  860. if (h > 40)
  861. {
  862. c.moveTo(0, h * 0.5 - 10);
  863. c.arcTo(12, 12, 0, 0, 1, 0, h * 0.5 + 10);
  864. }
  865. break;
  866. default:
  867. if (w > 40)
  868. {
  869. c.moveTo(w * 0.5 - 10, 0);
  870. c.arcTo(12, 12, 0, 0, 0, w * 0.5 + 10, 0);
  871. }
  872. }
  873. c.stroke();
  874. };
  875. mxCellRenderer.registerShape(mxShapeElectricalDualInLineIC.prototype.cst.SHAPE_DUAL_INLINE_IC, mxShapeElectricalDualInLineIC);
  876. mxShapeElectricalDualInLineIC.prototype.getConstraints = function(style, w, h)
  877. {
  878. var constr = [];
  879. var pinSpacing = parseFloat(mxUtils.getValue(this.style, 'pinSpacing', '20'));
  880. var startPin = mxUtils.getValue(this.style, 'startPin', 'n');
  881. var pinCount = 1;
  882. var currH = pinSpacing * 0.5;
  883. var pinsOne = parseInt(h / pinSpacing);
  884. if (startPin == 'n' || startPin == 's')
  885. {
  886. while (pinCount * pinSpacing <= h)
  887. {
  888. constr.push(new mxConnectionConstraint(new mxPoint(0, 0), false, null, 0, currH));
  889. constr.push(new mxConnectionConstraint(new mxPoint(1, 0), false, null, 0, currH));
  890. currH = currH + pinSpacing;
  891. pinCount++;
  892. }
  893. }
  894. else
  895. {
  896. while (pinCount * pinSpacing <= w)
  897. {
  898. constr.push(new mxConnectionConstraint(new mxPoint(0, 0), false, null, currH, 0));
  899. constr.push(new mxConnectionConstraint(new mxPoint(0, 1), false, null, currH, 0));
  900. currH = currH + pinSpacing;
  901. pinCount++;
  902. }
  903. }
  904. return (constr);
  905. }
  906. //**********************************************************************************************************************************************************
  907. //Quad Flat Package IC
  908. //**********************************************************************************************************************************************************
  909. /**
  910. * Extends mxShape.
  911. */
  912. function mxShapeElectricalQFPIC(bounds, fill, stroke, strokewidth)
  913. {
  914. mxShape.call(this);
  915. this.bounds = bounds;
  916. this.fill = fill;
  917. this.stroke = stroke;
  918. this.strokewidth = (strokewidth != null) ? strokewidth : 1;
  919. };
  920. /**
  921. * Extends mxShape.
  922. */
  923. mxUtils.extend(mxShapeElectricalQFPIC, mxShape);
  924. mxShapeElectricalQFPIC.prototype.cst = {
  925. SHAPE_QFP_IC : 'mxgraph.electrical.logic_gates.qfp_ic'
  926. };
  927. mxShapeElectricalQFPIC.prototype.customProperties = [
  928. {name: 'pinStyle', dispName: 'Pin Style', type: 'enum', defVal:'line',
  929. enumList:[
  930. {val:'line', dispName:'Line'},
  931. {val:'square', dispName:'Square'}
  932. ]},
  933. {name: 'startPin', dispName: 'Starting Pin', type: 'enum', defVal:'sw',
  934. enumList:[
  935. {val:'sw', dispName:'SW'},
  936. {val:'nw', dispName:'NW'},
  937. {val:'ne', dispName:'NE'},
  938. {val:'se', dispName:'SE'}
  939. ]},
  940. {name: 'pinSpacing', dispName: 'Pin Spacing', type: 'float', min:1, defVal:20},
  941. {name: 'pinLabelType', dispName: 'Pin Label Type', type: 'enum', defVal:'gen',
  942. enumList:[
  943. {val:'gen', dispName:'Generated'},
  944. {val:'cust', dispName:'Custom'}
  945. ]},
  946. {name: 'labelCount', dispName: 'Number of Labels', type: 'int', defVal: 40, dependentProps: ['labelNames']},
  947. {name: 'labelNames', dispName: 'Label Names', type: 'staticArr', subType: 'string', sizeProperty: 'labelCount', subDefVal: 'a'}
  948. ];
  949. /**
  950. * Function: paintVertexShape
  951. *
  952. * Paints the vertex shape.
  953. */
  954. mxShapeElectricalQFPIC.prototype.paintVertexShape = function(c, x, y, w, h)
  955. {
  956. c.translate(x, y);
  957. c.begin();
  958. c.moveTo(15, 10);
  959. c.lineTo(w - 15, 10);
  960. c.lineTo(w - 10, 15);
  961. c.lineTo(w - 10, h - 15);
  962. c.lineTo(w - 15, h - 10);
  963. c.lineTo(15, h - 10);
  964. c.lineTo(10, h - 15);
  965. c.lineTo(10, 15);
  966. c.close();
  967. c.fillAndStroke();
  968. var pinSpacing = parseFloat(mxUtils.getValue(this.style, 'pinSpacing', '20'));
  969. var pinStyle = mxUtils.getValue(this.style, 'pinStyle', 'line');
  970. var pinLabelType = mxUtils.getValue(this.style, 'pinLabelType', 'gen');
  971. var labelNames = decodeURIComponent(mxUtils.getValue(this.style, 'labelNames', '').toString()).split(',');
  972. var fontSize = parseFloat(mxUtils.getValue(this.style, 'fontSize', '12'));
  973. var fontColor = mxUtils.getValue(this.style, 'fontColor', '#000000');
  974. c.setFontColor(fontColor);
  975. var startPin = mxUtils.getValue(this.style, 'startPin', 'sw');
  976. if (pinStyle == 'line')
  977. {
  978. c.setFontSize(fontSize * 0.8);
  979. var pinCount = 1;
  980. var currH = pinSpacing * 0.5 + 20;
  981. c.begin();
  982. var pinsVOne = parseInt((h - pinSpacing - 40) / pinSpacing) + 1;
  983. var pinsHOne = parseInt((w - pinSpacing - 40) / pinSpacing) + 1;
  984. while (currH <= h - pinSpacing * 0.5 - 20)
  985. {
  986. c.moveTo(0, currH);
  987. c.lineTo(10, currH);
  988. c.moveTo(w - 10, currH);
  989. c.lineTo(w, currH);
  990. //west pins
  991. switch(startPin) {
  992. case 'nw':
  993. var currPinNum = pinCount;
  994. break;
  995. case 'ne':
  996. var currPinNum = pinsHOne + pinCount;
  997. break;
  998. case 'se':
  999. var currPinNum = pinsVOne + pinsHOne + pinCount;
  1000. break;
  1001. default:
  1002. var currPinNum = pinsVOne + 2 * pinsHOne + pinCount;
  1003. }
  1004. if (pinLabelType == 'gen')
  1005. {
  1006. c.text(20, currH, 0, 0, currPinNum.toString(), mxConstants.ALIGN_CENTER, mxConstants.ALIGN_MIDDLE, 0, null, 0, 0, 0);
  1007. }
  1008. else if (currPinNum - 1 < labelNames.length)
  1009. {
  1010. c.text(20, currH, 0, 0, labelNames[currPinNum - 1].toString(), mxConstants.ALIGN_CENTER, mxConstants.ALIGN_MIDDLE, 0, null, 0, 0, 0);
  1011. }
  1012. //east pins
  1013. switch(startPin) {
  1014. case 'nw':
  1015. var pc2 = pinsHOne + 2 * pinsVOne - pinCount + 1;
  1016. break;
  1017. case 'ne':
  1018. var pc2 = 2 * pinsHOne + 2 * pinsVOne - pinCount + 1;
  1019. break;
  1020. case 'se':
  1021. var pc2 = pinsVOne - pinCount + 1;
  1022. break;
  1023. default:
  1024. var pc2 = pinsHOne + pinsVOne - pinCount + 1;
  1025. }
  1026. if (pinLabelType == 'gen')
  1027. {
  1028. c.text(w - 20, currH, 0, 0, pc2.toString(), mxConstants.ALIGN_CENTER, mxConstants.ALIGN_MIDDLE, 0, null, 0, 0, 0);
  1029. }
  1030. else if (pc2 - 1 < labelNames.length)
  1031. {
  1032. c.text(w - 20, currH, 0, 0, labelNames[pc2 - 1].toString(), mxConstants.ALIGN_CENTER, mxConstants.ALIGN_MIDDLE, 0, null, 0, 0, 0);
  1033. }
  1034. currH = currH + pinSpacing;
  1035. pinCount++;
  1036. }
  1037. var pinCount = 1;
  1038. var currH = pinSpacing * 0.5 + 20;
  1039. while (currH <= w - pinSpacing * 0.5 - 20)
  1040. {
  1041. c.moveTo(currH, 0);
  1042. c.lineTo(currH, 10);
  1043. c.moveTo(currH, h - 10);
  1044. c.lineTo(currH, h);
  1045. //south pins
  1046. switch(startPin) {
  1047. case 'nw':
  1048. var currPinNum = pinsVOne + pinCount;
  1049. break;
  1050. case 'ne':
  1051. var currPinNum = pinsVOne + pinsHOne + pinCount;
  1052. break;
  1053. case 'se':
  1054. var currPinNum = 2 * pinsVOne + pinsHOne + pinCount;
  1055. break;
  1056. default:
  1057. var currPinNum = pinCount;
  1058. }
  1059. if (pinLabelType == 'gen')
  1060. {
  1061. c.text(currH, h - 20, 0, 0, currPinNum.toString(), mxConstants.ALIGN_CENTER, mxConstants.ALIGN_MIDDLE, 0, null, 0, 0, 0);
  1062. }
  1063. else if (currPinNum - 1 < labelNames.length)
  1064. {
  1065. c.text(currH, h - 20, 0, 0, labelNames[currPinNum - 1].toString(), mxConstants.ALIGN_CENTER, mxConstants.ALIGN_MIDDLE, 0, null, 0, 0, 0);
  1066. }
  1067. //north pins
  1068. switch(startPin) {
  1069. case 'nw':
  1070. var pc2 = 2 * pinsHOne + 2 * pinsVOne - pinCount + 1;
  1071. break;
  1072. case 'ne':
  1073. var pc2 = pinsHOne - pinCount + 1;
  1074. break;
  1075. case 'se':
  1076. var pc2 = pinsHOne + pinsVOne - pinCount + 1;
  1077. break;
  1078. default:
  1079. var pc2 = 2 * pinsHOne + pinsVOne - pinCount + 1;
  1080. }
  1081. if (pinLabelType == 'gen')
  1082. {
  1083. c.text(currH, 20, 0, 0, pc2.toString(), mxConstants.ALIGN_CENTER, mxConstants.ALIGN_MIDDLE, 0, null, 0, 0, 0);
  1084. }
  1085. else if (pc2 - 1 < labelNames.length)
  1086. {
  1087. c.text(currH, 20, 0, 0, labelNames[pc2 - 1].toString(), mxConstants.ALIGN_CENTER, mxConstants.ALIGN_MIDDLE, 0, null, 0, 0, 0);
  1088. }
  1089. currH = currH + pinSpacing;
  1090. pinCount++;
  1091. }
  1092. c.stroke();
  1093. }
  1094. else
  1095. {
  1096. c.setFontSize(fontSize * 0.5);
  1097. var pinCount = 1;
  1098. var currH = pinSpacing * 0.5 + 20;
  1099. var pinsVOne = parseInt((h - pinSpacing - 40) / pinSpacing) + 1;
  1100. var pinsHOne = parseInt((w - pinSpacing - 40) / pinSpacing) + 1;
  1101. while (currH <= h - pinSpacing * 0.5 - 20)
  1102. {
  1103. c.begin();
  1104. c.rect(0, currH - pinSpacing * 0.25, 10, pinSpacing * 0.5);
  1105. c.fillAndStroke();
  1106. c.begin();
  1107. c.rect(w - 10, currH - pinSpacing * 0.25, 10, pinSpacing * 0.5);
  1108. c.fillAndStroke();
  1109. //west pins
  1110. switch(startPin) {
  1111. case 'nw':
  1112. var currPinNum = pinCount;
  1113. break;
  1114. case 'ne':
  1115. var currPinNum = pinsHOne + pinCount;
  1116. break;
  1117. case 'se':
  1118. var currPinNum = pinsVOne + pinsHOne + pinCount;
  1119. break;
  1120. default:
  1121. var currPinNum = pinsVOne + 2 * pinsHOne + pinCount;
  1122. }
  1123. if (pinLabelType == 'gen')
  1124. {
  1125. c.text(5, currH + 1, 0, 0, currPinNum.toString(), mxConstants.ALIGN_CENTER, mxConstants.ALIGN_MIDDLE, 0, null, 0, 0, 0);
  1126. }
  1127. else if (currPinNum - 1 < labelNames.length)
  1128. {
  1129. c.text(5, currH + 1, 0, 0, labelNames[currPinNum - 1].toString(), mxConstants.ALIGN_CENTER, mxConstants.ALIGN_MIDDLE, 0, null, 0, 0, 0);
  1130. }
  1131. //east pins
  1132. switch(startPin) {
  1133. case 'nw':
  1134. var pc2 = pinsHOne + 2 * pinsVOne - pinCount + 1;
  1135. break;
  1136. case 'ne':
  1137. var pc2 = 2 * pinsHOne + 2 * pinsVOne - pinCount + 1;
  1138. break;
  1139. case 'se':
  1140. var pc2 = pinsVOne - pinCount + 1;
  1141. break;
  1142. default:
  1143. var pc2 = pinsHOne + pinsVOne - pinCount + 1;
  1144. }
  1145. if (pinLabelType == 'gen')
  1146. {
  1147. c.text(w - 5, currH + 1, 0, 0, pc2.toString(), mxConstants.ALIGN_CENTER, mxConstants.ALIGN_MIDDLE, 0, null, 0, 0, 0);
  1148. }
  1149. else if (pc2 - 1 < labelNames.length)
  1150. {
  1151. c.text(w - 5, currH + 1, 0, 0, labelNames[pc2 - 1].toString(), mxConstants.ALIGN_CENTER, mxConstants.ALIGN_MIDDLE, 0, null, 0, 0, 0);
  1152. }
  1153. currH = currH + pinSpacing;
  1154. pinCount++;
  1155. }
  1156. var pinCount = 1;
  1157. var currH = pinSpacing * 0.5 + 20;
  1158. while (currH <= w - pinSpacing * 0.5 - 20)
  1159. {
  1160. c.begin();
  1161. c.rect(currH - pinSpacing * 0.25, 0, pinSpacing * 0.5, 10);
  1162. c.fillAndStroke();
  1163. c.begin();
  1164. c.rect(currH - pinSpacing * 0.25, h - 10, pinSpacing * 0.5, 10);
  1165. c.fillAndStroke();
  1166. //south pins
  1167. switch(startPin) {
  1168. case 'nw':
  1169. var currPinNum = pinsVOne + pinCount;
  1170. break;
  1171. case 'ne':
  1172. var currPinNum = pinsVOne + pinsHOne + pinCount;
  1173. break;
  1174. case 'se':
  1175. var currPinNum = 2 * pinsVOne + pinsHOne + pinCount;
  1176. break;
  1177. default:
  1178. var currPinNum = pinCount;
  1179. }
  1180. if (pinLabelType == 'gen')
  1181. {
  1182. c.text(currH, h - 4, 0, 0, currPinNum.toString(), mxConstants.ALIGN_CENTER, mxConstants.ALIGN_MIDDLE, 0, null, 0, 0, 0);
  1183. }
  1184. else if (currPinNum - 1 < labelNames.length)
  1185. {
  1186. c.text(currH, h - 4, 0, 0, labelNames[currPinNum - 1].toString(), mxConstants.ALIGN_CENTER, mxConstants.ALIGN_MIDDLE, 0, null, 0, 0, 0);
  1187. }
  1188. //north pins
  1189. switch(startPin) {
  1190. case 'nw':
  1191. var pc2 = 2 * pinsHOne + 2 * pinsVOne - pinCount + 1;
  1192. break;
  1193. case 'ne':
  1194. var pc2 = pinsHOne - pinCount + 1;
  1195. break;
  1196. case 'se':
  1197. var pc2 = pinsHOne + pinsVOne - pinCount + 1;
  1198. break;
  1199. default:
  1200. var pc2 = 2 * pinsHOne + pinsVOne - pinCount + 1;
  1201. }
  1202. if (pinLabelType == 'gen')
  1203. {
  1204. c.text(currH, 6, 0, 0, pc2.toString(), mxConstants.ALIGN_CENTER, mxConstants.ALIGN_MIDDLE, 0, null, 0, 0, 0);
  1205. }
  1206. else if (pc2 - 1 < labelNames.length)
  1207. {
  1208. c.text(currH, 6, 0, 0, labelNames[pc2 - 1].toString(), mxConstants.ALIGN_CENTER, mxConstants.ALIGN_MIDDLE, 0, null, 0, 0, 0);
  1209. }
  1210. currH = currH + pinSpacing;
  1211. pinCount++;
  1212. }
  1213. }
  1214. c.setShadow(false);
  1215. if (w > 40)
  1216. {
  1217. c.setFillColor(mxUtils.getValue(this.style, 'strokeColor', '#000000'));
  1218. c.begin();
  1219. switch(startPin) {
  1220. case 'nw':
  1221. c.ellipse(15, 15, 10, 10);
  1222. break;
  1223. case 'ne':
  1224. c.ellipse(w - 25, 15, 10, 10);
  1225. break;
  1226. case 'se':
  1227. c.ellipse(w - 25, h - 25, 10, 10);
  1228. break;
  1229. default:
  1230. c.ellipse(15, h - 25, 10, 10);
  1231. }
  1232. c.fillAndStroke();
  1233. }
  1234. };
  1235. mxCellRenderer.registerShape(mxShapeElectricalQFPIC.prototype.cst.SHAPE_QFP_IC, mxShapeElectricalQFPIC);
  1236. mxShapeElectricalQFPIC.prototype.getConstraints = function(style, w, h)
  1237. {
  1238. var constr = [];
  1239. var pinSpacing = parseFloat(mxUtils.getValue(this.style, 'pinSpacing', '20'));
  1240. var currH = pinSpacing * 0.5 + 20;
  1241. while (currH <= h - pinSpacing * 0.5 - 20)
  1242. {
  1243. constr.push(new mxConnectionConstraint(new mxPoint(0, 0), false, null, 0, currH));
  1244. constr.push(new mxConnectionConstraint(new mxPoint(1, 0), false, null, 0, currH));
  1245. currH = currH + pinSpacing;
  1246. }
  1247. var currH = pinSpacing * 0.5 + 20;
  1248. while (currH <= w - pinSpacing * 0.5 - 20)
  1249. {
  1250. constr.push(new mxConnectionConstraint(new mxPoint(0, 0), false, null, currH, 0));
  1251. constr.push(new mxConnectionConstraint(new mxPoint(0, 1), false, null, currH, 0));
  1252. currH = currH + pinSpacing;
  1253. }
  1254. return (constr);
  1255. }
  1256. //**********************************************************************************************************************************************************
  1257. //Mux
  1258. //**********************************************************************************************************************************************************
  1259. /**
  1260. * Extends mxShape.
  1261. */
  1262. function mxShapeElectricalMux(bounds, fill, stroke, strokewidth)
  1263. {
  1264. mxShape.call(this);
  1265. this.bounds = bounds;
  1266. this.fill = fill;
  1267. this.stroke = stroke;
  1268. this.strokewidth = (strokewidth != null) ? strokewidth : 1;
  1269. };
  1270. /**
  1271. * Extends mxShape.
  1272. */
  1273. mxUtils.extend(mxShapeElectricalMux, mxShape);
  1274. mxShapeElectricalMux.prototype.cst = {
  1275. SHAPE_MUX : 'mxgraph.electrical.abstract.mux2'
  1276. };
  1277. mxShapeElectricalMux.prototype.customProperties = [
  1278. {name: 'operation', dispName: 'Operation', type: 'enum', defVal:'mux',
  1279. enumList:[
  1280. {val:'mux', dispName:'Mux'},
  1281. {val:'demux', dispName:'Demux'}
  1282. ]},
  1283. {name: 'selectorPins', dispName: 'Selector Pins', type: 'int', min:1, max:8, defVal:1},
  1284. ];
  1285. /**
  1286. * Function: paintVertexShape
  1287. *
  1288. * Paints the vertex shape.
  1289. */
  1290. mxShapeElectricalMux.prototype.paintVertexShape = function(c, x, y, w, h)
  1291. {
  1292. c.translate(x, y);
  1293. var selectorPins = parseInt(mxUtils.getValue(this.style, 'selectorPins', '1'));
  1294. var operation = mxUtils.getValue(this.style, 'operation', 'mux');
  1295. var fontSize = parseFloat(mxUtils.getValue(this.style, 'fontSize', '12'));
  1296. c.setFontSize(fontSize * 0.5);
  1297. var fontColor = mxUtils.getValue(this.style, 'fontColor', '#000000');
  1298. c.setFontColor(fontColor);
  1299. var dir = mxUtils.getValue(this.style, 'direction', 'east');
  1300. var txtRot = 0;
  1301. switch(dir)
  1302. {
  1303. case 'south' :
  1304. txtRot = 270;
  1305. break;
  1306. case 'west' :
  1307. txtRot = 180;
  1308. break;
  1309. case 'north' :
  1310. txtRot = 90;
  1311. break;
  1312. }
  1313. switch(operation)
  1314. {
  1315. case 'demux':
  1316. c.begin();
  1317. c.moveTo(w - 10, 0);
  1318. c.lineTo(10, h * 0.1);
  1319. c.lineTo(10, h * 0.9 - 10);
  1320. c.lineTo(w - 10, h - 10);
  1321. c.close();
  1322. c.fillAndStroke();
  1323. break;
  1324. default:
  1325. c.begin();
  1326. c.moveTo(10, 0);
  1327. c.lineTo(w - 10, h * 0.1);
  1328. c.lineTo(w - 10, h * 0.9 - 10);
  1329. c.lineTo(10, h - 10);
  1330. c.close();
  1331. c.fillAndStroke();
  1332. };
  1333. var numInputs = 1;
  1334. var numOutputs = 1;
  1335. if (operation == 'mux')
  1336. {
  1337. numInputs = Math.pow(2, selectorPins);
  1338. var spacing = (h - 16) / numInputs;
  1339. }
  1340. else
  1341. {
  1342. numOutputs = Math.pow(2, selectorPins);
  1343. var spacing = (h - 16) / numOutputs;
  1344. }
  1345. var currH = 3 + spacing * 0.5;
  1346. c.begin();
  1347. if (numInputs == 1)
  1348. {
  1349. c.moveTo(0, (h - 10) * 0.5);
  1350. c.lineTo(10, (h - 10) * 0.5);
  1351. }
  1352. else
  1353. {
  1354. for (var i = 0; i < numInputs; i++)
  1355. {
  1356. c.moveTo(0, currH);
  1357. c.lineTo(10, currH);
  1358. c.text(14, currH + 1, 0, 0, '' + i.toString(), mxConstants.ALIGN_CENTER, mxConstants.ALIGN_MIDDLE, 0, null, 0, 0, txtRot);
  1359. currH = currH + spacing;
  1360. }
  1361. }
  1362. if (numOutputs == 1)
  1363. {
  1364. c.moveTo(w - 10, (h - 10) * 0.5);
  1365. c.lineTo(w, (h - 10) * 0.5);
  1366. }
  1367. else
  1368. {
  1369. for (var i = 0; i < numOutputs; i++)
  1370. {
  1371. c.moveTo(w - 10, currH);
  1372. c.lineTo(w, currH);
  1373. c.text(w - 14, currH + 1, 0, 0, '' + i.toString(), mxConstants.ALIGN_CENTER, mxConstants.ALIGN_MIDDLE, 0, null, 0, 0, txtRot);
  1374. currH = currH + spacing;
  1375. }
  1376. }
  1377. var spacing = (w - 20) / selectorPins;
  1378. var currW = 10 + spacing * 0.5;
  1379. for (var i = 0; i < selectorPins; i++)
  1380. {
  1381. if (operation == 'mux')
  1382. {
  1383. c.moveTo(currW, h - 10 - (currW - 10) / (w - 20) * h * 0.1);
  1384. }
  1385. else
  1386. {
  1387. c.moveTo(currW, h - 10 - (w - currW - 10) / (w - 20) * h * 0.1);
  1388. }
  1389. c.lineTo(currW, h);
  1390. c.text(currW + 5, h -4, 0, 0, 'S' + (selectorPins - i - 1).toString(), mxConstants.ALIGN_CENTER, mxConstants.ALIGN_MIDDLE, 0, null, 0, 0, txtRot);
  1391. currW = currW + spacing;
  1392. }
  1393. c.stroke();
  1394. };
  1395. mxCellRenderer.registerShape(mxShapeElectricalMux.prototype.cst.SHAPE_MUX, mxShapeElectricalMux);
  1396. mxShapeElectricalMux.prototype.getConstraints = function(style, w, h)
  1397. {
  1398. var constr = [];
  1399. var pinRange = (h - 16) / h;
  1400. var selectorPins = parseInt(mxUtils.getValue(this.style, 'selectorPins', '1'));
  1401. var operation = mxUtils.getValue(this.style, 'operation', 'mux');
  1402. var numInputs = 1;
  1403. var numOutputs = 1;
  1404. if (operation == 'mux')
  1405. {
  1406. numInputs = Math.pow(2, selectorPins);
  1407. var spacing = pinRange / numInputs;
  1408. }
  1409. else
  1410. {
  1411. numOutputs = Math.pow(2, selectorPins);
  1412. var spacing = pinRange / numOutputs;
  1413. }
  1414. var currH = spacing * 0.5;
  1415. if (numInputs == 1)
  1416. {
  1417. constr.push(new mxConnectionConstraint(new mxPoint(0, 0.5 * (h - 10) / h), false, 0, 0));
  1418. }
  1419. else
  1420. {
  1421. for (var i = 0; i < numInputs; i++)
  1422. {
  1423. constr.push(new mxConnectionConstraint(new mxPoint(0, currH), false, null, 0, 3));
  1424. currH = currH + spacing;
  1425. }
  1426. }
  1427. if (numOutputs == 1)
  1428. {
  1429. constr.push(new mxConnectionConstraint(new mxPoint(1, 0.5), false, null, 0, -5));
  1430. }
  1431. else
  1432. {
  1433. for (var i = 0; i < numOutputs; i++)
  1434. {
  1435. constr.push(new mxConnectionConstraint(new mxPoint(1, currH), false, null, 0, 3));
  1436. currH = currH + spacing;
  1437. }
  1438. }
  1439. var spacing = (w - 20) / (w * selectorPins);
  1440. var currW = spacing * 0.5;
  1441. for (var i = 0; i < selectorPins; i++)
  1442. {
  1443. constr.push(new mxConnectionConstraint(new mxPoint(currW, 1), false, null, 10, 0));
  1444. currW = currW + spacing;
  1445. }
  1446. return (constr);
  1447. }
  1448. //**********************************************************************************************************************************************************
  1449. //Battery stack
  1450. //**********************************************************************************************************************************************************
  1451. /**
  1452. * Extends mxShape.
  1453. */
  1454. function mxShapeElectricalBatteryStack(bounds, fill, stroke, strokewidth)
  1455. {
  1456. mxShape.call(this);
  1457. this.bounds = bounds;
  1458. this.fill = fill;
  1459. this.stroke = stroke;
  1460. this.strokewidth = (strokewidth != null) ? strokewidth : 1;
  1461. };
  1462. /**
  1463. * Extends mxShape.
  1464. */
  1465. mxUtils.extend(mxShapeElectricalBatteryStack, mxShape);
  1466. mxShapeElectricalBatteryStack.prototype.cst = {
  1467. SHAPE_BATTERY_STACK : 'mxgraph.electrical.miscellaneous.batteryStack'
  1468. };
  1469. /**
  1470. * Function: paintVertexShape
  1471. *
  1472. * Paints the vertex shape.
  1473. */
  1474. mxShapeElectricalBatteryStack.prototype.paintVertexShape = function(c, x, y, w, h)
  1475. {
  1476. c.translate(x, y);
  1477. var bw = h * 0.3;
  1478. var strokeColor = mxUtils.getValue(this.style, mxConstants.STYLE_STROKECOLOR, '#000000');
  1479. var dashed = mxUtils.getValue(this.style, mxConstants.STYLE_DASHED, '0');
  1480. var bNum = Math.floor((w - 20) / bw);
  1481. var startX = (w - bNum * bw) * 0.5;
  1482. if (bNum > 0)
  1483. {
  1484. c.begin();
  1485. c.moveTo(0, h * 0.5);
  1486. c.lineTo(startX + bw * 0.2, h * 0.5);
  1487. c.moveTo(w - startX - bw * 0.2, h * 0.5);
  1488. c.lineTo(w, h * 0.5);
  1489. c.stroke();
  1490. var currX = startX;
  1491. c.setFillColor(strokeColor);
  1492. for (var i = 0; i < bNum; i++)
  1493. {
  1494. c.rect(currX + bw * 0.2, h * 0.25, bw * 0.2, h * 0.5);
  1495. c.fillAndStroke();
  1496. c.begin();
  1497. c.moveTo(currX + bw * 0.8, 0);
  1498. c.lineTo(currX + bw * 0.8, h);
  1499. c.stroke();
  1500. if (i > 0)
  1501. {
  1502. c.setDashed('1');
  1503. c.begin();
  1504. c.moveTo(currX - bw * 0.2, h * 0.5);
  1505. c.lineTo(currX + bw * 0.2, h * 0.5);
  1506. c.stroke();
  1507. c.setDashed(dashed);
  1508. }
  1509. currX = currX + bw;
  1510. }
  1511. }
  1512. };
  1513. mxCellRenderer.registerShape(mxShapeElectricalBatteryStack.prototype.cst.SHAPE_BATTERY_STACK, mxShapeElectricalBatteryStack);
  1514. mxShapeElectricalBatteryStack.prototype.constraints = [
  1515. new mxConnectionConstraint(new mxPoint(0, 0.5), true),
  1516. new mxConnectionConstraint(new mxPoint(1, 0.5), true)
  1517. ];
  1518. //**********************************************************************************************************************************************************
  1519. //DC Source 3 v2
  1520. //**********************************************************************************************************************************************************
  1521. /**
  1522. * Extends mxShape.
  1523. */
  1524. function mxShapeElectricalDCSource3_v2(bounds, fill, stroke, strokewidth)
  1525. {
  1526. mxShape.call(this);
  1527. this.bounds = bounds;
  1528. this.fill = fill;
  1529. this.stroke = stroke;
  1530. this.strokewidth = (strokewidth != null) ? strokewidth : 1;
  1531. };
  1532. /**
  1533. * Extends mxShape.
  1534. */
  1535. mxUtils.extend(mxShapeElectricalDCSource3_v2, mxShape);
  1536. mxShapeElectricalDCSource3_v2.prototype.cst = {
  1537. SHAPE_DC_SOURCE_3_V2 : 'mxgraph.electrical.signal_sources.dc_source_3_v2'
  1538. };
  1539. /**
  1540. * Function: paintVertexShape
  1541. *
  1542. * Paints the vertex shape.
  1543. */
  1544. mxShapeElectricalDCSource3_v2.prototype.paintVertexShape = function(c, x, y, w, h)
  1545. {
  1546. c.translate(x, y);
  1547. var ss = Math.max(3, Math.min(h, w) * 0.05); // half of symbol size
  1548. var i = 3; //indent
  1549. c.ellipse(0, 0, w, h);
  1550. c.fillAndStroke();
  1551. c.begin();
  1552. c.moveTo(w * 0.5 - ss, h * 0.05 + i);
  1553. c.lineTo(w * 0.5 + ss, h * 0.05 + i);
  1554. c.moveTo(w * 0.5, h * 0.05 - ss + i);
  1555. c.lineTo(w * 0.5, h * 0.05 + ss + i);
  1556. c.moveTo(w * 0.5 - ss, h * 0.95 - i);
  1557. c.lineTo(w * 0.5 + ss, h * 0.95 - i);
  1558. c.stroke();
  1559. };
  1560. mxCellRenderer.registerShape(mxShapeElectricalDCSource3_v2.prototype.cst.SHAPE_DC_SOURCE_3_V2, mxShapeElectricalDCSource3_v2);
  1561. mxShapeElectricalDCSource3_v2.prototype.constraints = [
  1562. new mxConnectionConstraint(new mxPoint(0.5, 0), true),
  1563. new mxConnectionConstraint(new mxPoint(0.5, 1), true)
  1564. ];
  1565. //**********************************************************************************************************************************************************
  1566. //Source
  1567. //**********************************************************************************************************************************************************
  1568. /**
  1569. * Extends mxShape.
  1570. */
  1571. function mxShapeElectricalSource(bounds, fill, stroke, strokewidth)
  1572. {
  1573. mxShape.call(this);
  1574. this.bounds = bounds;
  1575. this.fill = fill;
  1576. this.stroke = stroke;
  1577. this.strokewidth = (strokewidth != null) ? strokewidth : 1;
  1578. };
  1579. /**
  1580. * Extends mxShape.
  1581. */
  1582. mxUtils.extend(mxShapeElectricalSource, mxShape);
  1583. mxShapeElectricalSource.prototype.cst = {
  1584. SHAPE_SOURCE : 'mxgraph.electrical.signal_sources.source'
  1585. };
  1586. mxShapeElectricalSource.prototype.customProperties = [
  1587. {name: 'elSourceType', dispName: 'Source Type', type: 'enum', defVal: 'independent',
  1588. enumList: [{val: 'independent', dispName: 'Independent'},
  1589. {val: 'dependent', dispName: 'Dependent'}]
  1590. },
  1591. {name: 'elSignalType', dispName: 'Signal Type', type: 'enum', defVal: 'ac',
  1592. enumList: [{val: 'ac', dispName: 'AC'},
  1593. {val: 'none', dispName: 'None'},
  1594. {val: 'square', dispName: 'Square'},
  1595. {val: 'triangular', dispName: 'Triangular'},
  1596. {val: 'sawtooth', dispName: 'Sawtooth'},
  1597. {val: 'noise', dispName: 'Noise'},
  1598. {val: 'ideal', dispName: 'Ideal'},
  1599. {val: 'expSquib', dispName: 'Explosive Squib'},
  1600. {val: 'pulse', dispName: 'Pulse'},
  1601. {val: 'invPulse', dispName: 'Inverse Pulse'},
  1602. {val: 'chopSquare', dispName: 'Chopped Square'},
  1603. {val: 'stepOn', dispName: 'Step On'},
  1604. {val: 'stepOff', dispName: 'Step Off'},
  1605. {val: 'dc1', dispName: 'DC Horizontal'},
  1606. {val: 'dc2', dispName: 'DC Vertical'},
  1607. {val: 'dc3', dispName: 'DC Plus minus'}]
  1608. }
  1609. ];
  1610. /**
  1611. * Function: paintVertexShape
  1612. *
  1613. * Paints the vertex shape.
  1614. */
  1615. mxShapeElectricalSource.prototype.paintVertexShape = function(c, x, y, w, h)
  1616. {
  1617. c.translate(x, y);
  1618. var sourceType = mxUtils.getValue(this.style, 'elSourceType', 'independent');
  1619. var signalType = mxUtils.getValue(this.style, 'elSignalType', 'none');
  1620. switch (sourceType)
  1621. {
  1622. case "independent" :
  1623. c.ellipse(0, 0, w, h);
  1624. c.fillAndStroke();
  1625. break;
  1626. case "dependent" :
  1627. c.begin();
  1628. c.moveTo(0, h * 0.5);
  1629. c.lineTo(w * 0.5, 0);
  1630. c.lineTo(w, h * 0.5);
  1631. c.lineTo(w * 0.5, h);
  1632. c.lineTo(0, h * 0.5);
  1633. c.close();
  1634. c.fillAndStroke();
  1635. break;
  1636. }
  1637. switch (signalType)
  1638. {
  1639. case "ac" :
  1640. c.begin();
  1641. c.moveTo(w * 0.3, h * 0.5);
  1642. c.quadTo(w * 0.34, h * 0.35, w * 0.4, h * 0.35);
  1643. c.quadTo(w * 0.46, h * 0.35, w * 0.5, h * 0.5);
  1644. c.quadTo(w * 0.53, h * 0.65, w * 0.6, h * 0.65);
  1645. c.quadTo(w * 0.66, h * 0.65, w * 0.7, h * 0.5);
  1646. c.stroke();
  1647. break;
  1648. case "square" :
  1649. c.begin();
  1650. c.moveTo(w * 0.3, h * 0.5);
  1651. c.lineTo(w * 0.3, h * 0.35);
  1652. c.lineTo(w * 0.5, h * 0.35);
  1653. c.lineTo(w * 0.5, h * 0.65);
  1654. c.lineTo(w * 0.7, h * 0.65);
  1655. c.lineTo(w * 0.7, h * 0.5);
  1656. c.stroke();
  1657. break;
  1658. case "triangular" :
  1659. c.begin();
  1660. c.moveTo(w * 0.3, h * 0.65);
  1661. c.lineTo(w * 0.4, h * 0.35);
  1662. c.lineTo(w * 0.5, h * 0.65);
  1663. c.lineTo(w * 0.6, h * 0.35);
  1664. c.lineTo(w * 0.7, h * 0.65);
  1665. c.stroke();
  1666. break;
  1667. case "sawtooth" :
  1668. c.begin();
  1669. c.moveTo(w * 0.24, h * 0.65);
  1670. c.lineTo(w * 0.42, h * 0.35);
  1671. c.lineTo(w * 0.42, h * 0.65);
  1672. c.lineTo(w * 0.58, h * 0.35);
  1673. c.lineTo(w * 0.58, h * 0.65);
  1674. c.lineTo(w * 0.76, h * 0.35);
  1675. c.lineTo(w * 0.76, h * 0.65);
  1676. c.stroke();
  1677. break;
  1678. case "noise" :
  1679. c.begin();
  1680. c.moveTo(w * 0.5, h * 0.17);
  1681. c.lineTo(w * 0.5, h * 0.5);
  1682. c.moveTo(w * 0.18, h * 0.42);
  1683. c.lineTo(w * 0.5, h * 0.5);
  1684. c.moveTo(w * 0.32, h * 0.78);
  1685. c.lineTo(w * 0.5, h * 0.5);
  1686. c.moveTo(w * 0.82, h * 0.42);
  1687. c.lineTo(w * 0.5, h * 0.5);
  1688. c.moveTo(w * 0.68, h * 0.78);
  1689. c.lineTo(w * 0.5, h * 0.5);
  1690. c.stroke();
  1691. break;
  1692. case "ideal" :
  1693. c.begin();
  1694. c.moveTo(0, h * 0.5);
  1695. c.lineTo(w, h * 0.5);
  1696. c.stroke();
  1697. break;
  1698. case "expSquib" :
  1699. c.ellipse(0, h * 0.43, w * 0.14, h * 0.14);
  1700. c.stroke();
  1701. c.ellipse(w * 0.86, h * 0.43, w * 0.14, h * 0.14);
  1702. c.stroke();
  1703. c.begin();
  1704. c.moveTo(w * 0.83, h * 0.63);
  1705. c.lineTo(w * 0.73, h * 0.73);
  1706. c.lineTo(w * 0.27, h * 0.27);
  1707. c.lineTo(w * 0.17, h * 0.37);
  1708. c.stroke();
  1709. c.begin();
  1710. var strokeColor = mxUtils.getValue(this.style, mxConstants.STYLE_STROKECOLOR, '#000000');
  1711. c.setFillColor(strokeColor);
  1712. c.moveTo(w * 0.2, h * 0.25);
  1713. c.lineTo(w * 0.13, h * 0.4);
  1714. c.lineTo(w * 0.28, h * 0.33);
  1715. c.close();
  1716. c.fillAndStroke();
  1717. break;
  1718. case "pulse" :
  1719. c.begin();
  1720. c.moveTo(w * 0.3, h * 0.65);
  1721. c.lineTo(w * 0.4, h * 0.65);
  1722. c.lineTo(w * 0.4, h * 0.35);
  1723. c.lineTo(w * 0.6, h * 0.35);
  1724. c.lineTo(w * 0.6, h * 0.65);
  1725. c.lineTo(w * 0.7, h * 0.65);
  1726. c.stroke();
  1727. break;
  1728. case "invPulse" :
  1729. c.begin();
  1730. c.moveTo(w * 0.3, h * 0.35);
  1731. c.lineTo(w * 0.4, h * 0.35);
  1732. c.lineTo(w * 0.4, h * 0.65);
  1733. c.lineTo(w * 0.6, h * 0.65);
  1734. c.lineTo(w * 0.6, h * 0.35);
  1735. c.lineTo(w * 0.7, h * 0.35);
  1736. c.stroke();
  1737. break;
  1738. case "chopSquare" :
  1739. c.begin();
  1740. c.moveTo(w * 0.3, h * 0.5);
  1741. c.lineTo(w * 0.33, h * 0.35);
  1742. c.lineTo(w * 0.47, h * 0.35);
  1743. c.lineTo(w * 0.53, h * 0.65);
  1744. c.lineTo(w * 0.67, h * 0.65);
  1745. c.lineTo(w * 0.7, h * 0.5);
  1746. c.stroke();
  1747. break;
  1748. case "stepOn" :
  1749. c.begin();
  1750. c.moveTo(w * 0.3, h * 0.65);
  1751. c.lineTo(w * 0.5, h * 0.65);
  1752. c.lineTo(w * 0.5, h * 0.35);
  1753. c.lineTo(w * 0.7, h * 0.35);
  1754. c.stroke();
  1755. break;
  1756. case "stepOff" :
  1757. c.begin();
  1758. c.moveTo(w * 0.3, h * 0.35);
  1759. c.lineTo(w * 0.5, h * 0.35);
  1760. c.lineTo(w * 0.5, h * 0.65);
  1761. c.lineTo(w * 0.7, h * 0.65);
  1762. c.stroke();
  1763. break;
  1764. case "dc1" :
  1765. c.begin();
  1766. c.moveTo(w * 0.17, h * 0.5);
  1767. c.lineTo(w * 0.83, h * 0.5);
  1768. c.moveTo(w * 0.67, h * 0.42);
  1769. c.lineTo(w * 0.83, h * 0.5);
  1770. c.lineTo(w * 0.67, h * 0.58);
  1771. c.stroke();
  1772. break;
  1773. case "dc2" :
  1774. c.begin();
  1775. c.moveTo(w * 0.5, h * 0.17);
  1776. c.lineTo(w * 0.5, h * 0.83);
  1777. c.moveTo(w * 0.42, h * 0.67);
  1778. c.lineTo(w * 0.5, h * 0.83);
  1779. c.lineTo(w * 0.58, h * 0.67);
  1780. c.stroke();
  1781. break;
  1782. case "dc3" :
  1783. var ss = Math.max(3, Math.min(h, w) * 0.05); // half of symbol size
  1784. var i = 3; //indent
  1785. if (sourceType == 'dependent')
  1786. {
  1787. i += 3;
  1788. }
  1789. c.begin();
  1790. c.moveTo(w * 0.5 - ss, h * 0.05 + i);
  1791. c.lineTo(w * 0.5 + ss, h * 0.05 + i);
  1792. c.moveTo(w * 0.5, h * 0.05 - ss + i);
  1793. c.lineTo(w * 0.5, h * 0.05 + ss + i);
  1794. c.moveTo(w * 0.5 - ss, h * 0.95 - i);
  1795. c.lineTo(w * 0.5 + ss, h * 0.95 - i);
  1796. c.stroke();
  1797. break;
  1798. }
  1799. };
  1800. mxCellRenderer.registerShape(mxShapeElectricalSource.prototype.cst.SHAPE_SOURCE, mxShapeElectricalSource);
  1801. //**********************************************************************************************************************************************************
  1802. // Two way switch
  1803. //**********************************************************************************************************************************************************
  1804. /**
  1805. * Extends mxShape.
  1806. */
  1807. function mxShapeElectricalTwoWaySwitch(bounds, fill, stroke, strokewidth)
  1808. {
  1809. mxShape.call(this);
  1810. this.bounds = bounds;
  1811. this.fill = fill;
  1812. this.stroke = stroke;
  1813. this.strokewidth = (strokewidth != null) ? strokewidth : 1;
  1814. };
  1815. /**
  1816. * Extends mxShape.
  1817. */
  1818. mxUtils.extend(mxShapeElectricalTwoWaySwitch, mxShape);
  1819. mxShapeElectricalTwoWaySwitch.prototype.cst = {
  1820. SHAPE_TWO_WAY_SWITCH : 'mxgraph.electrical.electro-mechanical.twoWaySwitch'
  1821. };
  1822. mxShapeElectricalTwoWaySwitch.prototype.customProperties = [
  1823. {name: 'elSwitchState', dispName: 'Switch State', type: 'int', min:1, defVal: '1'}
  1824. ];
  1825. /**
  1826. * Function: paintVertexShape
  1827. *
  1828. * Paints the vertex shape.
  1829. */
  1830. mxShapeElectricalTwoWaySwitch.prototype.paintVertexShape = function(c, x, y, w, h)
  1831. {
  1832. c.translate(x, y);
  1833. var switchState = mxUtils.getValue(this.style, 'elSwitchState', '1');
  1834. c.begin();
  1835. c.moveTo(0, 0.5 * h);
  1836. c.lineTo(0.2 * w, 0.5 * h);
  1837. c.moveTo(0.8 * w, 0.88 * h);
  1838. c.lineTo(w, 0.88 * h);
  1839. c.moveTo(0.8 * w, 0.12 * h);
  1840. c.lineTo(w, 0.12 * h);
  1841. if (switchState == '2')
  1842. {
  1843. c.moveTo(0.28 * w, 0.48 * h);
  1844. c.lineTo(0.72 * w, 0.15 * h);
  1845. }
  1846. else
  1847. {
  1848. c.moveTo(0.28 * w, 0.52 * h);
  1849. c.lineTo(0.72 * w, 0.85 * h);
  1850. }
  1851. c.stroke();
  1852. c.ellipse(0.72 * w, 0.77 * h, 0.08 * w, 0.23 * h);
  1853. c.fillAndStroke();
  1854. c.ellipse(0.72 * w, 0, 0.08 * w, 0.23 * h);
  1855. c.fillAndStroke();
  1856. c.ellipse(0.2 * w, 0.385 * h, 0.08 * w, 0.23 * h);
  1857. c.fillAndStroke();
  1858. };
  1859. mxCellRenderer.registerShape(mxShapeElectricalTwoWaySwitch.prototype.cst.SHAPE_TWO_WAY_SWITCH, mxShapeElectricalTwoWaySwitch);
  1860. mxShapeElectricalTwoWaySwitch.prototype.constraints = [
  1861. new mxConnectionConstraint(new mxPoint(1, 0.12), true),
  1862. new mxConnectionConstraint(new mxPoint(0, 0.5), true),
  1863. new mxConnectionConstraint(new mxPoint(1, 0.88), true)
  1864. ];
  1865. //**********************************************************************************************************************************************************
  1866. // Pushbutton
  1867. //**********************************************************************************************************************************************************
  1868. /**
  1869. * Extends mxShape.
  1870. */
  1871. function mxShapeElectricalPushbutton(bounds, fill, stroke, strokewidth)
  1872. {
  1873. mxShape.call(this);
  1874. this.bounds = bounds;
  1875. this.fill = fill;
  1876. this.stroke = stroke;
  1877. this.strokewidth = (strokewidth != null) ? strokewidth : 1;
  1878. };
  1879. /**
  1880. * Extends mxShape.
  1881. */
  1882. mxUtils.extend(mxShapeElectricalPushbutton, mxShape);
  1883. mxShapeElectricalPushbutton.prototype.cst = {
  1884. SHAPE_PUSHBUTTON : 'mxgraph.electrical.electro-mechanical.pushbutton'
  1885. };
  1886. mxShapeElectricalPushbutton.prototype.customProperties = [
  1887. {name: 'elSwitchState', dispName: 'Switch State', type: 'enum', defVal: 'on',
  1888. enumList:[
  1889. {val:'on', dispName:'On'},
  1890. {val:'off', dispName:'Off'}
  1891. ]}
  1892. ];
  1893. /**
  1894. * Function: paintVertexShape
  1895. *
  1896. * Paints the vertex shape.
  1897. */
  1898. mxShapeElectricalPushbutton.prototype.paintVertexShape = function(c, x, y, w, h)
  1899. {
  1900. c.translate(x, y);
  1901. var switchState = mxUtils.getValue(this.style, 'elSwitchState', 'on');
  1902. c.begin();
  1903. c.moveTo(0, 0.8 * h);
  1904. c.lineTo(0.2 * w, 0.8 * h);
  1905. c.moveTo(0.8 * w, 0.8 * h);
  1906. c.lineTo(w, 0.8 * h);
  1907. if (switchState == 'off')
  1908. {
  1909. c.moveTo(0.5 * w, 0.5 * h);
  1910. c.lineTo(0.5 * w, 0);
  1911. c.moveTo(0.46 * w, 0);
  1912. c.lineTo(0.54 * w, 0);
  1913. c.moveTo(0.2 * w, 0.5 * h);
  1914. c.lineTo(0.8 * w, 0.5 * h);
  1915. }
  1916. else
  1917. {
  1918. c.moveTo(0.5 * w, h);
  1919. c.lineTo(0.5 * w, 0.5 * h);
  1920. c.moveTo(0.46 * w, 0.5 * h);
  1921. c.lineTo(0.54 * w, 0.5 * h);
  1922. c.moveTo(0.2 * w, h);
  1923. c.lineTo(0.8 * w, h);
  1924. }
  1925. c.stroke();
  1926. c.ellipse(0.72 * w, 0.65 * h, 0.08 * w, 0.3 * h);
  1927. c.fillAndStroke();
  1928. c.ellipse(0.2 * w, 0.65 * h, 0.08 * w, 0.3 * h);
  1929. c.fillAndStroke();
  1930. };
  1931. mxCellRenderer.registerShape(mxShapeElectricalPushbutton.prototype.cst.SHAPE_PUSHBUTTON, mxShapeElectricalPushbutton);
  1932. mxShapeElectricalPushbutton.prototype.constraints = [
  1933. new mxConnectionConstraint(new mxPoint(0, 0.8), true),
  1934. new mxConnectionConstraint(new mxPoint(1, 0.8), true)
  1935. ];
  1936. //**********************************************************************************************************************************************************
  1937. // Single switch
  1938. //**********************************************************************************************************************************************************
  1939. /**
  1940. * Extends mxShape.
  1941. */
  1942. function mxShapeElectricalSingleSwitch(bounds, fill, stroke, strokewidth)
  1943. {
  1944. mxShape.call(this);
  1945. this.bounds = bounds;
  1946. this.fill = fill;
  1947. this.stroke = stroke;
  1948. this.strokewidth = (strokewidth != null) ? strokewidth : 1;
  1949. };
  1950. /**
  1951. * Extends mxShape.
  1952. */
  1953. mxUtils.extend(mxShapeElectricalSingleSwitch, mxShape);
  1954. mxShapeElectricalSingleSwitch.prototype.cst = {
  1955. SHAPE_SINGLE_SWITCH : 'mxgraph.electrical.electro-mechanical.singleSwitch'
  1956. };
  1957. mxShapeElectricalSingleSwitch.prototype.customProperties = [
  1958. {name: 'elSwitchState', dispName: 'Switch State', type: 'enum', defVal: 'on',
  1959. enumList:[
  1960. {val:'on', dispName:'On'},
  1961. {val:'off', dispName:'Off'}
  1962. ]}
  1963. ];
  1964. /**
  1965. * Function: paintVertexShape
  1966. *
  1967. * Paints the vertex shape.
  1968. */
  1969. mxShapeElectricalSingleSwitch.prototype.paintVertexShape = function(c, x, y, w, h)
  1970. {
  1971. c.translate(x, y);
  1972. var switchState = mxUtils.getValue(this.style, 'elSwitchState', 'on');
  1973. c.begin();
  1974. c.moveTo(0, 0.8 * h);
  1975. c.lineTo(0.2 * w, 0.8 * h);
  1976. c.moveTo(0.8 * w, 0.8 * h);
  1977. c.lineTo(w, 0.8 * h);
  1978. if (switchState == 'off')
  1979. {
  1980. c.moveTo(0.28 * w, 0.75 * h);
  1981. c.lineTo(0.76 * w, 0);
  1982. }
  1983. else
  1984. {
  1985. c.moveTo(0.2 * w, 0.8 * h);
  1986. c.lineTo(0.8 * w, 0.8 * h);
  1987. }
  1988. c.stroke();
  1989. c.ellipse(0.72 * w, 0.65 * h, 0.08 * w, 0.3 * h);
  1990. c.fillAndStroke();
  1991. c.ellipse(0.2 * w, 0.65 * h, 0.08 * w, 0.3 * h);
  1992. c.fillAndStroke();
  1993. };
  1994. mxCellRenderer.registerShape(mxShapeElectricalSingleSwitch.prototype.cst.SHAPE_SINGLE_SWITCH, mxShapeElectricalSingleSwitch);
  1995. mxShapeElectricalSingleSwitch.prototype.constraints = [
  1996. new mxConnectionConstraint(new mxPoint(0, 0.8), true),
  1997. new mxConnectionConstraint(new mxPoint(1, 0.8), true)
  1998. ];
  1999. //**********************************************************************************************************************************************************
  2000. // Switch disconnector
  2001. //**********************************************************************************************************************************************************
  2002. /**
  2003. * Extends mxShape.
  2004. */
  2005. function mxShapeElectricalSwitchDisconnector(bounds, fill, stroke, strokewidth)
  2006. {
  2007. mxShape.call(this);
  2008. this.bounds = bounds;
  2009. this.fill = fill;
  2010. this.stroke = stroke;
  2011. this.strokewidth = (strokewidth != null) ? strokewidth : 1;
  2012. };
  2013. /**
  2014. * Extends mxShape.
  2015. */
  2016. mxUtils.extend(mxShapeElectricalSwitchDisconnector, mxShape);
  2017. mxShapeElectricalSwitchDisconnector.prototype.cst = {
  2018. SHAPE_SWITCH_DISCONNECTOR : 'mxgraph.electrical.electro-mechanical.switchDisconnector'
  2019. };
  2020. mxShapeElectricalSwitchDisconnector.prototype.customProperties = [
  2021. {name: 'elSwitchState', dispName: 'Switch State', type: 'enum', defVal: 'on',
  2022. enumList:[
  2023. {val:'on', dispName:'On'},
  2024. {val:'off', dispName:'Off'}
  2025. ]}
  2026. ];
  2027. /**
  2028. * Function: paintVertexShape
  2029. *
  2030. * Paints the vertex shape.
  2031. */
  2032. mxShapeElectricalSwitchDisconnector.prototype.paintVertexShape = function(c, x, y, w, h)
  2033. {
  2034. c.translate(x, y);
  2035. var switchState = mxUtils.getValue(this.style, 'elSwitchState', 'on');
  2036. c.begin();
  2037. c.moveTo(0.8 * w, 0.84 * h);
  2038. c.lineTo(w, 0.84 * h);
  2039. c.moveTo(0.8 * w, 0.68 * h);
  2040. c.lineTo(0.8 * w, h);
  2041. c.moveTo(0, 0.84 * h);
  2042. c.lineTo(0.24 * w, 0.84 * h);
  2043. if (switchState == 'off')
  2044. {
  2045. c.lineTo(0.76 * w, 0);
  2046. }
  2047. else
  2048. {
  2049. c.lineTo(0.8 * w, 0.84 * h);
  2050. }
  2051. c.stroke();
  2052. c.ellipse(0.72 * w, 0.68 * h, 0.08 * w, 0.32 * h);
  2053. c.fillAndStroke();
  2054. };
  2055. mxCellRenderer.registerShape(mxShapeElectricalSwitchDisconnector.prototype.cst.SHAPE_SWITCH_DISCONNECTOR, mxShapeElectricalSwitchDisconnector);
  2056. mxShapeElectricalSwitchDisconnector.prototype.constraints = [
  2057. new mxConnectionConstraint(new mxPoint(0, 0.84), true),
  2058. new mxConnectionConstraint(new mxPoint(1, 0.84), true)
  2059. ];
  2060. //**********************************************************************************************************************************************************
  2061. // Fuse 2
  2062. //**********************************************************************************************************************************************************
  2063. /**
  2064. * Extends mxShape.
  2065. */
  2066. function mxShapeElectricalFuse2(bounds, fill, stroke, strokewidth)
  2067. {
  2068. mxShape.call(this);
  2069. this.bounds = bounds;
  2070. this.fill = fill;
  2071. this.stroke = stroke;
  2072. this.strokewidth = (strokewidth != null) ? strokewidth : 1;
  2073. };
  2074. /**
  2075. * Extends mxShape.
  2076. */
  2077. mxUtils.extend(mxShapeElectricalFuse2, mxShape);
  2078. mxShapeElectricalFuse2.prototype.cst = {
  2079. SHAPE_FUSE2 : 'mxgraph.electrical.electro-mechanical.fuse2'
  2080. };
  2081. mxShapeElectricalFuse2.prototype.customProperties = [
  2082. {name: 'elSwitchState', dispName: 'Switch State', type: 'enum', defVal: 'on',
  2083. enumList:[
  2084. {val:'on', dispName:'On'},
  2085. {val:'off', dispName:'Off'}
  2086. ]}
  2087. ];
  2088. /**
  2089. * Function: paintVertexShape
  2090. *
  2091. * Paints the vertex shape.
  2092. */
  2093. mxShapeElectricalFuse2.prototype.paintVertexShape = function(c, x, y, w, h)
  2094. {
  2095. c.translate(x, y);
  2096. var switchState = mxUtils.getValue(this.style, 'elSwitchState', 'on');
  2097. c.begin();
  2098. c.moveTo(0.8 * w, 0.8 * h);
  2099. c.lineTo(w, 0.8 * h);
  2100. c.moveTo(0, 0.8 * h);
  2101. c.lineTo(0.25 * w, 0.8 * h);
  2102. if (switchState == 'off')
  2103. {
  2104. c.lineTo(0.76 * w, 0);
  2105. c.moveTo(0.348 * w, 0.47 * h);
  2106. c.lineTo(0.563 * w, 0.13 * h);
  2107. c.lineTo(0.603 * w, 0.46 * h);
  2108. c.lineTo(0.387 * w, 0.78 * h);
  2109. c.close();
  2110. }
  2111. else
  2112. {
  2113. c.lineTo(0.8 * w, 0.8 * h);
  2114. c.moveTo(0.38 * w, 0.6 * h);
  2115. c.lineTo(0.62 * w, 0.6 * h);
  2116. c.lineTo(0.62 * w, h);
  2117. c.lineTo(0.38 * w, h);
  2118. c.close();
  2119. }
  2120. c.stroke();
  2121. };
  2122. mxCellRenderer.registerShape(mxShapeElectricalFuse2.prototype.cst.SHAPE_FUSE2, mxShapeElectricalFuse2);
  2123. mxShapeElectricalFuse2.prototype.constraints = [
  2124. new mxConnectionConstraint(new mxPoint(0, 0.8), true),
  2125. new mxConnectionConstraint(new mxPoint(1, 0.8), true)
  2126. ];
  2127. //**********************************************************************************************************************************************************
  2128. // Liquid Level Actuated Switch
  2129. //**********************************************************************************************************************************************************
  2130. /**
  2131. * Extends mxShape.
  2132. */
  2133. function mxShapeElectricalLiquidLevelActuatedSwitch(bounds, fill, stroke, strokewidth)
  2134. {
  2135. mxShape.call(this);
  2136. this.bounds = bounds;
  2137. this.fill = fill;
  2138. this.stroke = stroke;
  2139. this.strokewidth = (strokewidth != null) ? strokewidth : 1;
  2140. };
  2141. /**
  2142. * Extends mxShape.
  2143. */
  2144. mxUtils.extend(mxShapeElectricalLiquidLevelActuatedSwitch, mxShape);
  2145. mxShapeElectricalLiquidLevelActuatedSwitch.prototype.cst = {
  2146. SHAPE_LIQUID_LEVEL_ACTUATED_SWITCH : 'mxgraph.electrical.electro-mechanical.liquidLevelActuatedSwitch'
  2147. };
  2148. mxShapeElectricalLiquidLevelActuatedSwitch.prototype.customProperties = [
  2149. {name: 'elSwitchState', dispName: 'Switch State', type: 'enum', defVal: 'on',
  2150. enumList:[
  2151. {val:'on', dispName:'On'},
  2152. {val:'off', dispName:'Off'}
  2153. ]}
  2154. ];
  2155. /**
  2156. * Function: paintVertexShape
  2157. *
  2158. * Paints the vertex shape.
  2159. */
  2160. mxShapeElectricalLiquidLevelActuatedSwitch.prototype.paintVertexShape = function(c, x, y, w, h)
  2161. {
  2162. c.translate(x, y);
  2163. var switchState = mxUtils.getValue(this.style, 'elSwitchState', 'on');
  2164. c.begin();
  2165. c.moveTo(0.8 * w, 0.27 * h);
  2166. c.lineTo(w, 0.27 * h);
  2167. c.moveTo(0, 0.27 * h);
  2168. c.lineTo(0.2 * w, 0.27 * h);
  2169. if (switchState == 'off')
  2170. {
  2171. c.moveTo(0.24 * w, 0);
  2172. c.lineTo(0.76 * w, 0);
  2173. c.moveTo(0.5 * w, 0);
  2174. c.lineTo(0.5 * w, 0.47 * h);
  2175. c.stroke();
  2176. c.ellipse(0.45 * w, 0.47 * h, 0.1 * w, 0.26 * h);
  2177. c.fillAndStroke();
  2178. }
  2179. else
  2180. {
  2181. c.moveTo(0.28 * w, 0.27 * h);
  2182. c.lineTo(0.72 * w, 0.27 * h);
  2183. c.moveTo(0.5 * w, 0.27 * h);
  2184. c.lineTo(0.5 * w, 0.74 * h);
  2185. c.stroke();
  2186. c.ellipse(0.45 * w, 0.74 * h, 0.1 * w, 0.26 * h);
  2187. c.fillAndStroke();
  2188. }
  2189. c.ellipse(0.2 * w, 0.17 * h, 0.08 * w, 0.2 * h);
  2190. c.fillAndStroke();
  2191. c.ellipse(0.72 * w, 0.17 * h, 0.08 * w, 0.2 * h);
  2192. c.fillAndStroke();
  2193. };
  2194. mxCellRenderer.registerShape(mxShapeElectricalLiquidLevelActuatedSwitch.prototype.cst.SHAPE_LIQUID_LEVEL_ACTUATED_SWITCH, mxShapeElectricalLiquidLevelActuatedSwitch);
  2195. mxShapeElectricalLiquidLevelActuatedSwitch.prototype.constraints = [
  2196. new mxConnectionConstraint(new mxPoint(0, 0.27), true),
  2197. new mxConnectionConstraint(new mxPoint(1, 0.27), true)
  2198. ];
  2199. //**********************************************************************************************************************************************************
  2200. // Liquid Level Actuated Switch 2
  2201. //**********************************************************************************************************************************************************
  2202. /**
  2203. * Extends mxShape.
  2204. */
  2205. function mxShapeElectricalLiquidLevelActuatedSwitch2(bounds, fill, stroke, strokewidth)
  2206. {
  2207. mxShape.call(this);
  2208. this.bounds = bounds;
  2209. this.fill = fill;
  2210. this.stroke = stroke;
  2211. this.strokewidth = (strokewidth != null) ? strokewidth : 1;
  2212. };
  2213. /**
  2214. * Extends mxShape.
  2215. */
  2216. mxUtils.extend(mxShapeElectricalLiquidLevelActuatedSwitch2, mxShape);
  2217. mxShapeElectricalLiquidLevelActuatedSwitch2.prototype.cst = {
  2218. SHAPE_LIQUID_LEVEL_ACTUATED_SWITCH_2 : 'mxgraph.electrical.electro-mechanical.liquidLevelActuatedSwitch2'
  2219. };
  2220. mxShapeElectricalLiquidLevelActuatedSwitch2.prototype.customProperties = [
  2221. {name: 'elSwitchState', dispName: 'Switch State', type: 'enum', defVal: 'on',
  2222. enumList:[
  2223. {val:'on', dispName:'On'},
  2224. {val:'off', dispName:'Off'}
  2225. ]}
  2226. ];
  2227. /**
  2228. * Function: paintVertexShape
  2229. *
  2230. * Paints the vertex shape.
  2231. */
  2232. mxShapeElectricalLiquidLevelActuatedSwitch2.prototype.paintVertexShape = function(c, x, y, w, h)
  2233. {
  2234. c.translate(x, y);
  2235. var switchState = mxUtils.getValue(this.style, 'elSwitchState', 'on');
  2236. c.begin();
  2237. c.moveTo(0.76 * w, h);
  2238. c.lineTo(w, h);
  2239. c.moveTo(0, h);
  2240. c.lineTo(0.24 * w, h);
  2241. if (switchState == 'off')
  2242. {
  2243. c.lineTo(0.76 * w, 0.5 * h);
  2244. c.moveTo(0.42 * w, 0);
  2245. c.lineTo(0.58 * w, 0);
  2246. c.lineTo(0.58 * w, 0.4 * h);
  2247. c.lineTo(0.42 * w, 0.4 * h);
  2248. c.close();
  2249. c.moveTo(0.46 * w, 0.22 * h);
  2250. c.arcTo(0.05 * w, 0.1 * h, 0, 0, 1, 0.54 * w, 0.22 * h);
  2251. c.arcTo(0.05 * w, 0.1 * h, 0, 0, 1, 0.46 * w, 0.22 * h);
  2252. c.close();
  2253. c.moveTo(0.5 * w, 0.1 * h);
  2254. c.lineTo(0.5 * w, 0.17 * h);
  2255. c.moveTo(0.5 * w, 0.4 * h);
  2256. c.lineTo(0.5 * w, 0.55 * h);
  2257. c.moveTo(0.5 * w, 0.63 * h);
  2258. c.lineTo(0.5 * w, 0.75 * h);
  2259. c.stroke();
  2260. }
  2261. else
  2262. {
  2263. c.lineTo(0.76 * w, h);
  2264. c.moveTo(0.42 * w, 0.25 * h);
  2265. c.lineTo(0.58 * w, 0.25 * h);
  2266. c.lineTo(0.58 * w, 0.65 * h);
  2267. c.lineTo(0.42 * w, 0.65 * h);
  2268. c.close();
  2269. c.moveTo(0.46 * w, 0.47 * h);
  2270. c.arcTo(0.05 * w, 0.1 * h, 0, 0, 1, 0.54 * w, 0.47 * h);
  2271. c.arcTo(0.05 * w, 0.1 * h, 0, 0, 1, 0.46 * w, 0.47 * h);
  2272. c.close();
  2273. c.moveTo(0.5 * w, 0.35 * h);
  2274. c.lineTo(0.5 * w, 0.42 * h);
  2275. c.moveTo(0.5 * w, 0.65 * h);
  2276. c.lineTo(0.5 * w, 0.8 * h);
  2277. c.moveTo(0.5 * w, 0.88 * h);
  2278. c.lineTo(0.5 * w, h);
  2279. c.stroke();
  2280. c.stroke();
  2281. }
  2282. };
  2283. mxCellRenderer.registerShape(mxShapeElectricalLiquidLevelActuatedSwitch2.prototype.cst.SHAPE_LIQUID_LEVEL_ACTUATED_SWITCH_2, mxShapeElectricalLiquidLevelActuatedSwitch2);
  2284. mxShapeElectricalLiquidLevelActuatedSwitch2.prototype.constraints = [
  2285. new mxConnectionConstraint(new mxPoint(0, 1), true),
  2286. new mxConnectionConstraint(new mxPoint(1, 1), true)
  2287. ];
  2288. //**********************************************************************************************************************************************************
  2289. // Gas Flow Actuated Switch
  2290. //**********************************************************************************************************************************************************
  2291. /**
  2292. * Extends mxShape.
  2293. */
  2294. function mxShapeElectricalGasFlowActuatedSwitch(bounds, fill, stroke, strokewidth)
  2295. {
  2296. mxShape.call(this);
  2297. this.bounds = bounds;
  2298. this.fill = fill;
  2299. this.stroke = stroke;
  2300. this.strokewidth = (strokewidth != null) ? strokewidth : 1;
  2301. };
  2302. /**
  2303. * Extends mxShape.
  2304. */
  2305. mxUtils.extend(mxShapeElectricalGasFlowActuatedSwitch, mxShape);
  2306. mxShapeElectricalGasFlowActuatedSwitch.prototype.cst = {
  2307. SHAPE_GAS_FLOW_ACTUATED_SWITCH : 'mxgraph.electrical.electro-mechanical.gasFlowActuatedSwitch'
  2308. };
  2309. mxShapeElectricalGasFlowActuatedSwitch.prototype.customProperties = [
  2310. {name: 'elSwitchState', dispName: 'Switch State', type: 'enum', defVal: 'on',
  2311. enumList:[
  2312. {val:'on', dispName:'On'},
  2313. {val:'off', dispName:'Off'}
  2314. ]}
  2315. ];
  2316. /**
  2317. * Function: paintVertexShape
  2318. *
  2319. * Paints the vertex shape.
  2320. */
  2321. mxShapeElectricalGasFlowActuatedSwitch.prototype.paintVertexShape = function(c, x, y, w, h)
  2322. {
  2323. c.translate(x, y);
  2324. var switchState = mxUtils.getValue(this.style, 'elSwitchState', 'on');
  2325. c.begin();
  2326. c.moveTo(0.76 * w, h);
  2327. c.lineTo(w, h);
  2328. c.moveTo(0, h);
  2329. c.lineTo(0.24 * w, h);
  2330. if (switchState == 'off')
  2331. {
  2332. c.lineTo(0.76 * w, 0.5 * h);
  2333. c.moveTo(0.42 * w, 0);
  2334. c.lineTo(0.58 * w, 0);
  2335. c.lineTo(0.58 * w, 0.4 * h);
  2336. c.lineTo(0.42 * w, 0.4 * h);
  2337. c.close();
  2338. c.moveTo(0.54 * w, 0.34 * h);
  2339. c.lineTo(0.54 * w, 0.09 * h);
  2340. c.lineTo(0.46 * w, 0.09 * h);
  2341. c.lineTo(0.46 * w, 0.26 * h);
  2342. c.lineTo(0.54 * w, 0.26 * h);
  2343. c.moveTo(0.5 * w, 0.4 * h);
  2344. c.lineTo(0.5 * w, 0.55 * h);
  2345. c.moveTo(0.5 * w, 0.63 * h);
  2346. c.lineTo(0.5 * w, 0.75 * h);
  2347. c.stroke();
  2348. c.ellipse(0.475 * w, 0.165 * h, 0.025 * w, 0.06 * h);
  2349. c.stroke();
  2350. }
  2351. else
  2352. {
  2353. c.lineTo(0.76 * w, h);
  2354. c.moveTo(0.42 * w, 0.25 * h);
  2355. c.lineTo(0.58 * w, 0.25 * h);
  2356. c.lineTo(0.58 * w, 0.65 * h);
  2357. c.lineTo(0.42 * w, 0.65 * h);
  2358. c.close();
  2359. c.moveTo(0.54 * w, 0.59 * h);
  2360. c.lineTo(0.54 * w, 0.34 * h);
  2361. c.lineTo(0.46 * w, 0.34 * h);
  2362. c.lineTo(0.46 * w, 0.51 * h);
  2363. c.lineTo(0.54 * w, 0.51 * h);
  2364. c.moveTo(0.5 * w, 0.65 * h);
  2365. c.lineTo(0.5 * w, 0.80 * h);
  2366. c.moveTo(0.5 * w, 0.88 * h);
  2367. c.lineTo(0.5 * w, h);
  2368. c.stroke();
  2369. c.ellipse(0.475 * w, 0.415 * h, 0.025 * w, 0.06 * h);
  2370. c.stroke();
  2371. }
  2372. };
  2373. mxCellRenderer.registerShape(mxShapeElectricalGasFlowActuatedSwitch.prototype.cst.SHAPE_GAS_FLOW_ACTUATED_SWITCH, mxShapeElectricalGasFlowActuatedSwitch);
  2374. mxShapeElectricalGasFlowActuatedSwitch.prototype.constraints = [
  2375. new mxConnectionConstraint(new mxPoint(0, 1), true),
  2376. new mxConnectionConstraint(new mxPoint(1, 1), true)
  2377. ];
  2378. //**********************************************************************************************************************************************************
  2379. // Flow Actuated Switch
  2380. //**********************************************************************************************************************************************************
  2381. /**
  2382. * Extends mxShape.
  2383. */
  2384. function mxShapeElectricalFlowActuatedSwitch(bounds, fill, stroke, strokewidth)
  2385. {
  2386. mxShape.call(this);
  2387. this.bounds = bounds;
  2388. this.fill = fill;
  2389. this.stroke = stroke;
  2390. this.strokewidth = (strokewidth != null) ? strokewidth : 1;
  2391. };
  2392. /**
  2393. * Extends mxShape.
  2394. */
  2395. mxUtils.extend(mxShapeElectricalFlowActuatedSwitch, mxShape);
  2396. mxShapeElectricalFlowActuatedSwitch.prototype.cst = {
  2397. SHAPE_FLOW_ACTUATED_SWITCH : 'mxgraph.electrical.electro-mechanical.flowActuatedSwitch'
  2398. };
  2399. mxShapeElectricalFlowActuatedSwitch.prototype.customProperties = [
  2400. {name: 'elSwitchState', dispName: 'Switch State', type: 'enum', defVal: 'on',
  2401. enumList:[
  2402. {val:'on', dispName:'On'},
  2403. {val:'off', dispName:'Off'}
  2404. ]}
  2405. ];
  2406. /**
  2407. * Function: paintVertexShape
  2408. *
  2409. * Paints the vertex shape.
  2410. */
  2411. mxShapeElectricalFlowActuatedSwitch.prototype.paintVertexShape = function(c, x, y, w, h)
  2412. {
  2413. c.translate(x, y);
  2414. var switchState = mxUtils.getValue(this.style, 'elSwitchState', 'on');
  2415. c.begin();
  2416. c.moveTo(0.8 * w, 0.1 * h);
  2417. c.lineTo(w, 0.1 * h);
  2418. c.moveTo(0, 0.1 * h);
  2419. c.lineTo(0.2 * w, 0.1 * h);
  2420. if (switchState == 'off')
  2421. {
  2422. c.moveTo(0.28 * w, 0.13 * h);
  2423. c.lineTo(0.76 * w, 0.61 * h);
  2424. c.moveTo(0.5 * w, 0.35 * h);
  2425. c.lineTo(0.5 * w, h);
  2426. c.lineTo(0.6 * w, h);
  2427. c.lineTo(0.5 * w, 0.68 * h);
  2428. }
  2429. else
  2430. {
  2431. c.moveTo(0.28 * w, 0.1 * h);
  2432. c.lineTo(0.72 * w, 0.1 * h);
  2433. c.moveTo(0.5 * w, 0.1 * h);
  2434. c.lineTo(0.5 * w, 0.85 * h);
  2435. c.lineTo(0.6 * w, 0.85 * h);
  2436. c.lineTo(0.5 * w, 0.53 * h);
  2437. }
  2438. c.stroke();
  2439. c.ellipse(0.2 * w, 0, 0.08 * w, 0.2 * h);
  2440. c.stroke();
  2441. c.ellipse(0.72 * w, 0, 0.08 * w, 0.2 * h);
  2442. c.stroke();
  2443. };
  2444. mxCellRenderer.registerShape(mxShapeElectricalFlowActuatedSwitch.prototype.cst.SHAPE_FLOW_ACTUATED_SWITCH, mxShapeElectricalFlowActuatedSwitch);
  2445. mxShapeElectricalFlowActuatedSwitch.prototype.constraints = [
  2446. new mxConnectionConstraint(new mxPoint(0, 0.27), true),
  2447. new mxConnectionConstraint(new mxPoint(1, 0.27), true)
  2448. ];
  2449. //**********************************************************************************************************************************************************
  2450. // Pressure Actuated Switch
  2451. //**********************************************************************************************************************************************************
  2452. /**
  2453. * Extends mxShape.
  2454. */
  2455. function mxShapeElectricalPressureActuatedSwitch(bounds, fill, stroke, strokewidth)
  2456. {
  2457. mxShape.call(this);
  2458. this.bounds = bounds;
  2459. this.fill = fill;
  2460. this.stroke = stroke;
  2461. this.strokewidth = (strokewidth != null) ? strokewidth : 1;
  2462. };
  2463. /**
  2464. * Extends mxShape.
  2465. */
  2466. mxUtils.extend(mxShapeElectricalPressureActuatedSwitch, mxShape);
  2467. mxShapeElectricalPressureActuatedSwitch.prototype.cst = {
  2468. SHAPE_PRESSURE_ACTUATED_SWITCH : 'mxgraph.electrical.electro-mechanical.pressureActuatedSwitch'
  2469. };
  2470. mxShapeElectricalPressureActuatedSwitch.prototype.customProperties = [
  2471. {name: 'elSwitchState', dispName: 'Switch State', type: 'enum', defVal: 'on',
  2472. enumList:[
  2473. {val:'on', dispName:'On'},
  2474. {val:'off', dispName:'Off'}
  2475. ]}
  2476. ];
  2477. /**
  2478. * Function: paintVertexShape
  2479. *
  2480. * Paints the vertex shape.
  2481. */
  2482. mxShapeElectricalPressureActuatedSwitch.prototype.paintVertexShape = function(c, x, y, w, h)
  2483. {
  2484. c.translate(x, y);
  2485. var switchState = mxUtils.getValue(this.style, 'elSwitchState', 'on');
  2486. c.begin();
  2487. c.moveTo(0.8 * w, 0.1 * h);
  2488. c.lineTo(w, 0.1 * h);
  2489. c.moveTo(0, 0.1 * h);
  2490. c.lineTo(0.2 * w, 0.1 * h);
  2491. if (switchState == 'off')
  2492. {
  2493. c.moveTo(0.28 * w, 0.13 * h);
  2494. c.lineTo(0.76 * w, 0.61 * h);
  2495. c.moveTo(0.5 * w, 0.35 * h);
  2496. c.lineTo(0.5 * w, 0.74 * h);
  2497. c.moveTo(0.39 * w, h);
  2498. c.arcTo(0.11 * w, 0.26 * h, 0, 0, 1, 0.5 * w, 0.74 * h);
  2499. c.arcTo(0.11 * w, 0.26 * h, 0, 0, 1, 0.61 * w, h);
  2500. c.close();
  2501. }
  2502. else
  2503. {
  2504. c.moveTo(0.28 * w, 0.1 * h);
  2505. c.lineTo(0.72 * w, 0.1 * h);
  2506. c.moveTo(0.5 * w, 0.1 * h);
  2507. c.lineTo(0.5 * w, 0.49 * h);
  2508. c.moveTo(0.39 * w, 0.75 * h);
  2509. c.arcTo(0.11 * w, 0.26 * h, 0, 0, 1, 0.5 * w, 0.49 * h);
  2510. c.arcTo(0.11 * w, 0.26 * h, 0, 0, 1, 0.61 * w, 0.75 * h);
  2511. c.close();
  2512. }
  2513. c.stroke();
  2514. c.ellipse(0.2 * w, 0, 0.08 * w, 0.2 * h);
  2515. c.stroke();
  2516. c.ellipse(0.72 * w, 0, 0.08 * w, 0.2 * h);
  2517. c.stroke();
  2518. };
  2519. mxCellRenderer.registerShape(mxShapeElectricalPressureActuatedSwitch.prototype.cst.SHAPE_PRESSURE_ACTUATED_SWITCH, mxShapeElectricalPressureActuatedSwitch);
  2520. mxShapeElectricalPressureActuatedSwitch.prototype.constraints = [
  2521. new mxConnectionConstraint(new mxPoint(0, 0.1), true),
  2522. new mxConnectionConstraint(new mxPoint(1, 0.1), true)
  2523. ];
  2524. //**********************************************************************************************************************************************************
  2525. // Temperature Actuated Switch
  2526. //**********************************************************************************************************************************************************
  2527. /**
  2528. * Extends mxShape.
  2529. */
  2530. function mxShapeElectricalTemperatureActuatedSwitch(bounds, fill, stroke, strokewidth)
  2531. {
  2532. mxShape.call(this);
  2533. this.bounds = bounds;
  2534. this.fill = fill;
  2535. this.stroke = stroke;
  2536. this.strokewidth = (strokewidth != null) ? strokewidth : 1;
  2537. };
  2538. /**
  2539. * Extends mxShape.
  2540. */
  2541. mxUtils.extend(mxShapeElectricalTemperatureActuatedSwitch, mxShape);
  2542. mxShapeElectricalTemperatureActuatedSwitch.prototype.cst = {
  2543. SHAPE_TEMPERATURE_ACTUATED_SWITCH : 'mxgraph.electrical.electro-mechanical.temperatureActuatedSwitch'
  2544. };
  2545. mxShapeElectricalTemperatureActuatedSwitch.prototype.customProperties = [
  2546. {name: 'elSwitchState', dispName: 'Switch State', type: 'enum', defVal: 'on',
  2547. enumList:[
  2548. {val:'on', dispName:'On'},
  2549. {val:'off', dispName:'Off'}
  2550. ]}
  2551. ];
  2552. /**
  2553. * Function: paintVertexShape
  2554. *
  2555. * Paints the vertex shape.
  2556. */
  2557. mxShapeElectricalTemperatureActuatedSwitch.prototype.paintVertexShape = function(c, x, y, w, h)
  2558. {
  2559. c.translate(x, y);
  2560. var switchState = mxUtils.getValue(this.style, 'elSwitchState', 'on');
  2561. c.begin();
  2562. c.moveTo(0.8 * w, 0.1 * h);
  2563. c.lineTo(w, 0.1 * h);
  2564. c.moveTo(0, 0.1 * h);
  2565. c.lineTo(0.2 * w, 0.1 * h);
  2566. if (switchState == 'off')
  2567. {
  2568. c.moveTo(0.28 * w, 0.13 * h);
  2569. c.lineTo(0.76 * w, 0.61 * h);
  2570. c.moveTo(0.5 * w, 0.35 * h);
  2571. c.lineTo(0.5 * w, 0.64 * h);
  2572. c.lineTo(0.57 * w, 0.64 * h);
  2573. c.lineTo(0.57 * w, 0.81 * h);
  2574. c.lineTo(0.5 * w, 0.81 * h);
  2575. c.lineTo(0.5 * w, h);
  2576. }
  2577. else
  2578. {
  2579. c.moveTo(0.28 * w, 0.1 * h);
  2580. c.lineTo(0.72 * w, 0.1 * h);
  2581. c.moveTo(0.5 * w, 0.1 * h);
  2582. c.lineTo(0.5 * w, 0.39 * h);
  2583. c.lineTo(0.57 * w, 0.39 * h);
  2584. c.lineTo(0.57 * w, 0.56 * h);
  2585. c.lineTo(0.5 * w, 0.56 * h);
  2586. c.lineTo(0.5 * w, 0.75 * h);
  2587. }
  2588. c.stroke();
  2589. c.ellipse(0.2 * w, 0, 0.08 * w, 0.2 * h);
  2590. c.stroke();
  2591. c.ellipse(0.72 * w, 0, 0.08 * w, 0.2 * h);
  2592. c.stroke();
  2593. };
  2594. mxCellRenderer.registerShape(mxShapeElectricalTemperatureActuatedSwitch.prototype.cst.SHAPE_TEMPERATURE_ACTUATED_SWITCH, mxShapeElectricalTemperatureActuatedSwitch);
  2595. mxShapeElectricalTemperatureActuatedSwitch.prototype.constraints = [
  2596. new mxConnectionConstraint(new mxPoint(0, 0.1), true),
  2597. new mxConnectionConstraint(new mxPoint(1, 0.1), true)
  2598. ];
  2599. //**********************************************************************************************************************************************************
  2600. // Safety Interlock Switch
  2601. //**********************************************************************************************************************************************************
  2602. /**
  2603. * Extends mxShape.
  2604. */
  2605. function mxShapeElectricalSafetyInterlockSwitch(bounds, fill, stroke, strokewidth)
  2606. {
  2607. mxShape.call(this);
  2608. this.bounds = bounds;
  2609. this.fill = fill;
  2610. this.stroke = stroke;
  2611. this.strokewidth = (strokewidth != null) ? strokewidth : 1;
  2612. };
  2613. /**
  2614. * Extends mxShape.
  2615. */
  2616. mxUtils.extend(mxShapeElectricalSafetyInterlockSwitch, mxShape);
  2617. mxShapeElectricalSafetyInterlockSwitch.prototype.cst = {
  2618. SHAPE_SAFETY_INTERLOCK_SWITCH : 'mxgraph.electrical.electro-mechanical.safetyInterlockSwitch'
  2619. };
  2620. mxShapeElectricalSafetyInterlockSwitch.prototype.customProperties = [
  2621. {name: 'elSwitchState', dispName: 'Switch State', type: 'enum', defVal: 'on',
  2622. enumList:[
  2623. {val:'on', dispName:'On'},
  2624. {val:'off', dispName:'Off'}
  2625. ]}
  2626. ];
  2627. /**
  2628. * Function: paintVertexShape
  2629. *
  2630. * Paints the vertex shape.
  2631. */
  2632. mxShapeElectricalSafetyInterlockSwitch.prototype.paintVertexShape = function(c, x, y, w, h)
  2633. {
  2634. c.translate(x, y);
  2635. var switchState = mxUtils.getValue(this.style, 'elSwitchState', 'on');
  2636. c.begin();
  2637. c.moveTo(0.8 * w, 0.34 * h);
  2638. c.lineTo(w, 0.34 * h);
  2639. c.moveTo(0, 0.34 * h);
  2640. c.lineTo(0.2 * w, 0.34 * h);
  2641. if (switchState == 'off')
  2642. {
  2643. c.moveTo(0.25 * w, 0);
  2644. c.lineTo(0.75 * w, 0);
  2645. c.lineTo(0.5 * w, 0.81 * h);
  2646. c.close();
  2647. }
  2648. else
  2649. {
  2650. c.moveTo(0.25 * w, 0.19 * h);
  2651. c.lineTo(0.75 * w, 0.19 * h);
  2652. c.lineTo(0.5 * w, h);
  2653. c.close();
  2654. }
  2655. c.stroke();
  2656. c.ellipse(0.2 * w, 0.27 * h, 0.08 * w, 0.14 * h);
  2657. c.stroke();
  2658. c.ellipse(0.72 * w, 0.27 * h, 0.08 * w, 0.14 * h);
  2659. c.stroke();
  2660. };
  2661. mxCellRenderer.registerShape(mxShapeElectricalSafetyInterlockSwitch.prototype.cst.SHAPE_SAFETY_INTERLOCK_SWITCH, mxShapeElectricalSafetyInterlockSwitch);
  2662. mxShapeElectricalSafetyInterlockSwitch.prototype.constraints = [
  2663. new mxConnectionConstraint(new mxPoint(0, 0.35), true),
  2664. new mxConnectionConstraint(new mxPoint(1, 0.35), true)
  2665. ];
  2666. //**********************************************************************************************************************************************************
  2667. // Temperature Switch
  2668. //**********************************************************************************************************************************************************
  2669. /**
  2670. * Extends mxShape.
  2671. */
  2672. function mxShapeElectricalTemperatureSwitch(bounds, fill, stroke, strokewidth)
  2673. {
  2674. mxShape.call(this);
  2675. this.bounds = bounds;
  2676. this.fill = fill;
  2677. this.stroke = stroke;
  2678. this.strokewidth = (strokewidth != null) ? strokewidth : 1;
  2679. };
  2680. /**
  2681. * Extends mxShape.
  2682. */
  2683. mxUtils.extend(mxShapeElectricalTemperatureSwitch, mxShape);
  2684. mxShapeElectricalTemperatureSwitch.prototype.cst = {
  2685. SHAPE_TEMPERATURE_SWITCH : 'mxgraph.electrical.electro-mechanical.temperatureSwitch'
  2686. };
  2687. mxShapeElectricalTemperatureSwitch.prototype.customProperties = [
  2688. {name: 'elSwitchState', dispName: 'Switch State', type: 'enum', defVal: 'on',
  2689. enumList:[
  2690. {val:'on', dispName:'On'},
  2691. {val:'off', dispName:'Off'}
  2692. ]}
  2693. ];
  2694. /**
  2695. * Function: paintVertexShape
  2696. *
  2697. * Paints the vertex shape.
  2698. */
  2699. mxShapeElectricalTemperatureSwitch.prototype.paintVertexShape = function(c, x, y, w, h)
  2700. {
  2701. c.translate(x, y);
  2702. var switchState = mxUtils.getValue(this.style, 'elSwitchState', 'on');
  2703. c.begin();
  2704. c.moveTo(0.76 * w, h);
  2705. c.lineTo(w, h);
  2706. c.moveTo(0, h);
  2707. c.lineTo(0.24 * w, h);
  2708. if (switchState == 'off')
  2709. {
  2710. c.lineTo(0.76 * w, 0.1 * h);
  2711. }
  2712. else
  2713. {
  2714. c.lineTo(0.76 * w, h);
  2715. }
  2716. c.stroke();
  2717. c.ellipse(0.43 * w, 0, 0.1 * w, 0.22 * h);
  2718. c.fillAndStroke();
  2719. c.begin();
  2720. c.moveTo(0.48 * w, 0);
  2721. c.lineTo(0.48 * w, 0.22 * h);
  2722. c.stroke();
  2723. };
  2724. mxCellRenderer.registerShape(mxShapeElectricalTemperatureSwitch.prototype.cst.SHAPE_TEMPERATURE_SWITCH, mxShapeElectricalTemperatureSwitch);
  2725. mxShapeElectricalTemperatureSwitch.prototype.constraints = [
  2726. new mxConnectionConstraint(new mxPoint(0, 1), true),
  2727. new mxConnectionConstraint(new mxPoint(1, 1), true)
  2728. ];
  2729. //**********************************************************************************************************************************************************
  2730. // Thermostat2
  2731. //**********************************************************************************************************************************************************
  2732. /**
  2733. * Extends mxShape.
  2734. */
  2735. function mxShapeElectricalThermostat2(bounds, fill, stroke, strokewidth)
  2736. {
  2737. mxShape.call(this);
  2738. this.bounds = bounds;
  2739. this.fill = fill;
  2740. this.stroke = stroke;
  2741. this.strokewidth = (strokewidth != null) ? strokewidth : 1;
  2742. };
  2743. /**
  2744. * Extends mxShape.
  2745. */
  2746. mxUtils.extend(mxShapeElectricalThermostat2, mxShape);
  2747. mxShapeElectricalThermostat2.prototype.cst = {
  2748. SHAPE_THERMOSTAT2 : 'mxgraph.electrical.electro-mechanical.thermostat2'
  2749. };
  2750. mxShapeElectricalThermostat2.prototype.customProperties = [
  2751. {name: 'elSwitchState', dispName: 'Switch State', type: 'enum', defVal: 'on',
  2752. enumList:[
  2753. {val:'on', dispName:'On'},
  2754. {val:'off', dispName:'Off'}
  2755. ]}
  2756. ];
  2757. /**
  2758. * Function: paintVertexShape
  2759. *
  2760. * Paints the vertex shape.
  2761. */
  2762. mxShapeElectricalThermostat2.prototype.paintVertexShape = function(c, x, y, w, h)
  2763. {
  2764. c.translate(x, y);
  2765. var switchState = mxUtils.getValue(this.style, 'elSwitchState', 'on');
  2766. c.begin();
  2767. c.moveTo(0.8 * w, 0.86 * h);
  2768. c.lineTo(w, 0.86 * h);
  2769. c.moveTo(0, 0.86 * h);
  2770. c.lineTo(0.2 * w, 0.86 * h);
  2771. if (switchState == 'off')
  2772. {
  2773. c.moveTo(0.28 * w, 0.82 * h);
  2774. c.lineTo(0.76 * w, 0.2 * h);
  2775. }
  2776. else
  2777. {
  2778. c.moveTo(0.28 * w, 0.86 * h);
  2779. c.lineTo(0.72 * w, 0.85 * h);
  2780. }
  2781. c.stroke();
  2782. c.ellipse(0.2 * w, 0.72 * h, 0.08 * w, 0.28 * h);
  2783. c.fillAndStroke();
  2784. c.ellipse(0.72 * w, 0.72 * h, 0.08 * w, 0.28 * h);
  2785. c.fillAndStroke();
  2786. c.text(0.5 * w, 0.2 * h, 0, 0, 'tº', mxConstants.ALIGN_CENTER, mxConstants.ALIGN_MIDDLE, 0, null, 0, 0, 0);
  2787. };
  2788. mxCellRenderer.registerShape(mxShapeElectricalThermostat2.prototype.cst.SHAPE_THERMOSTAT2, mxShapeElectricalThermostat2);
  2789. mxShapeElectricalThermostat2.prototype.constraints = [
  2790. new mxConnectionConstraint(new mxPoint(0, 1), true),
  2791. new mxConnectionConstraint(new mxPoint(1, 1), true)
  2792. ];
  2793. //**********************************************************************************************************************************************************
  2794. // Limit Switch 2
  2795. //**********************************************************************************************************************************************************
  2796. /**
  2797. * Extends mxShape.
  2798. */
  2799. function mxShapeElectricalLimitSwitch2(bounds, fill, stroke, strokewidth)
  2800. {
  2801. mxShape.call(this);
  2802. this.bounds = bounds;
  2803. this.fill = fill;
  2804. this.stroke = stroke;
  2805. this.strokewidth = (strokewidth != null) ? strokewidth : 1;
  2806. };
  2807. /**
  2808. * Extends mxShape.
  2809. */
  2810. mxUtils.extend(mxShapeElectricalLimitSwitch2, mxShape);
  2811. mxShapeElectricalLimitSwitch2.prototype.cst = {
  2812. SHAPE_LIMIT_SWITCH2 : 'mxgraph.electrical.electro-mechanical.limitSwitch2'
  2813. };
  2814. mxShapeElectricalLimitSwitch2.prototype.customProperties = [
  2815. {name: 'elSwitchState', dispName: 'Switch State', type: 'enum', defVal: 'on',
  2816. enumList:[
  2817. {val:'on', dispName:'On'},
  2818. {val:'off', dispName:'Off'}
  2819. ]}
  2820. ];
  2821. /**
  2822. * Function: paintVertexShape
  2823. *
  2824. * Paints the vertex shape.
  2825. */
  2826. mxShapeElectricalLimitSwitch2.prototype.paintVertexShape = function(c, x, y, w, h)
  2827. {
  2828. c.translate(x, y);
  2829. var switchState = mxUtils.getValue(this.style, 'elSwitchState', 'on');
  2830. c.begin();
  2831. c.moveTo(0.8 * w, 0.84 * h);
  2832. c.lineTo(w, 0.84 * h);
  2833. c.moveTo(0, 0.84 * h);
  2834. c.lineTo(0.2 * w, 0.84 * h);
  2835. if (switchState == 'off')
  2836. {
  2837. c.moveTo(0.28 * w, 0.8 * h);
  2838. c.lineTo(0.76 * w, 0);
  2839. c.moveTo(0.46 * w, 0.5 * h);
  2840. c.lineTo(0.545 * w, 0.07 * h);
  2841. c.lineTo(0.57 * w, 0.3 * h);
  2842. }
  2843. else
  2844. {
  2845. c.moveTo(0.28 * w, 0.84 * h);
  2846. c.lineTo(0.72 * w, 0.84 * h);
  2847. c.moveTo(0.47 * w, 0.84 * h);
  2848. c.lineTo(0.58 * w, 0.57 * h);
  2849. c.lineTo(0.58 * w, 0.84 * h);
  2850. }
  2851. c.stroke();
  2852. c.ellipse(0.2 * w, 0.68 * h, 0.08 * w, 0.32 * h);
  2853. c.fillAndStroke();
  2854. c.ellipse(0.72 * w, 0.68 * h, 0.08 * w, 0.32 * h);
  2855. c.fillAndStroke();
  2856. };
  2857. mxCellRenderer.registerShape(mxShapeElectricalLimitSwitch2.prototype.cst.SHAPE_LIMIT_SWITCH2, mxShapeElectricalLimitSwitch2);
  2858. mxShapeElectricalLimitSwitch2.prototype.constraints = [
  2859. new mxConnectionConstraint(new mxPoint(0, 1), true),
  2860. new mxConnectionConstraint(new mxPoint(1, 1), true)
  2861. ];
  2862. //**********************************************************************************************************************************************************
  2863. // Circuit Breaker 2
  2864. //**********************************************************************************************************************************************************
  2865. /**
  2866. * Extends mxShape.
  2867. */
  2868. function mxShapeElectricalCircuitBreaker2(bounds, fill, stroke, strokewidth)
  2869. {
  2870. mxShape.call(this);
  2871. this.bounds = bounds;
  2872. this.fill = fill;
  2873. this.stroke = stroke;
  2874. this.strokewidth = (strokewidth != null) ? strokewidth : 1;
  2875. };
  2876. /**
  2877. * Extends mxShape.
  2878. */
  2879. mxUtils.extend(mxShapeElectricalCircuitBreaker2, mxShape);
  2880. mxShapeElectricalCircuitBreaker2.prototype.cst = {
  2881. SHAPE_CIRCUIT_BREAKER2 : 'mxgraph.electrical.electro-mechanical.circuitBreaker2'
  2882. };
  2883. mxShapeElectricalCircuitBreaker2.prototype.customProperties = [
  2884. {name: 'elSwitchState', dispName: 'Switch State', type: 'enum', defVal: 'on',
  2885. enumList:[
  2886. {val:'on', dispName:'On'},
  2887. {val:'off', dispName:'Off'}
  2888. ]}
  2889. ];
  2890. /**
  2891. * Function: paintVertexShape
  2892. *
  2893. * Paints the vertex shape.
  2894. */
  2895. mxShapeElectricalCircuitBreaker2.prototype.paintVertexShape = function(c, x, y, w, h)
  2896. {
  2897. c.translate(x, y);
  2898. var switchState = mxUtils.getValue(this.style, 'elSwitchState', 'on');
  2899. c.begin();
  2900. c.moveTo(0.8 * w, 0.8 * h);
  2901. c.lineTo(w, 0.8 * h);
  2902. c.moveTo(0.75 * w, 0.6 * h);
  2903. c.lineTo(0.85 * w, h);
  2904. c.moveTo(0.85 * w, 0.6 * h);
  2905. c.lineTo(0.75 * w, h);
  2906. c.moveTo(0, 0.8 * h);
  2907. c.lineTo(0.24 * w, 0.8 * h);
  2908. if (switchState == 'off')
  2909. {
  2910. c.lineTo(0.76 * w, 0);
  2911. }
  2912. else
  2913. {
  2914. c.lineTo(0.8 * w, 0.8 * h);
  2915. }
  2916. c.stroke();
  2917. };
  2918. mxCellRenderer.registerShape(mxShapeElectricalCircuitBreaker2.prototype.cst.SHAPE_CIRCUIT_BREAKER2, mxShapeElectricalCircuitBreaker2);
  2919. mxShapeElectricalCircuitBreaker2.prototype.constraints = [
  2920. new mxConnectionConstraint(new mxPoint(0, 0.8), true),
  2921. new mxConnectionConstraint(new mxPoint(1, 0.8), true)
  2922. ];
  2923. //**********************************************************************************************************************************************************
  2924. // Selector Switch - 3 Position 2
  2925. //**********************************************************************************************************************************************************
  2926. /**
  2927. * Extends mxShape.
  2928. */
  2929. function mxShapeElectricalSelectorSwitch3Position2(bounds, fill, stroke, strokewidth)
  2930. {
  2931. mxShape.call(this);
  2932. this.bounds = bounds;
  2933. this.fill = fill;
  2934. this.stroke = stroke;
  2935. this.strokewidth = (strokewidth != null) ? strokewidth : 1;
  2936. };
  2937. /**
  2938. * Extends mxShape.
  2939. */
  2940. mxUtils.extend(mxShapeElectricalSelectorSwitch3Position2, mxShape);
  2941. mxShapeElectricalSelectorSwitch3Position2.prototype.cst = {
  2942. SHAPE_SELECTOR_SWITCH_3_POSITION : 'mxgraph.electrical.electro-mechanical.selectorSwitch3Position2'
  2943. };
  2944. mxShapeElectricalSelectorSwitch3Position2.prototype.customProperties = [
  2945. {name: 'elSwitchState', dispName: 'Switch State', type: 'int', min:1, max:3, defVal: '1',}
  2946. ];
  2947. /**
  2948. * Function: paintVertexShape
  2949. *
  2950. * Paints the vertex shape.
  2951. */
  2952. mxShapeElectricalSelectorSwitch3Position2.prototype.paintVertexShape = function(c, x, y, w, h)
  2953. {
  2954. c.translate(x, y);
  2955. var switchState = mxUtils.getValue(this.style, 'elSwitchState', '1');
  2956. var strokeColor = mxUtils.getValue(this.style, 'strokeColor', '#000000');
  2957. c.begin();
  2958. c.moveTo(0, 0.5 * h);
  2959. c.lineTo(0.2 * w, 0.5 * h);
  2960. c.moveTo(0.68 * w, 0.06 * h);
  2961. c.lineTo(w, 0.06 * h);
  2962. c.moveTo(0.75 * w, 0.5 * h);
  2963. c.lineTo(w, 0.5 * h);
  2964. c.moveTo(0.68 * w, 0.94 * h);
  2965. c.lineTo(w, 0.94 * h);
  2966. c.stroke();
  2967. c.ellipse(0.2 * w, 0.435 * h, 0.08 * w, 0.13 * h);
  2968. c.fillAndStroke();
  2969. c.ellipse(0.6 * w, 0, 0.08 * w, 0.13 * h);
  2970. c.fillAndStroke();
  2971. c.ellipse(0.67 * w, 0.435 * h, 0.08 * w, 0.13 * h);
  2972. c.fillAndStroke();
  2973. c.ellipse(0.6 * w, 0.87 * h, 0.08 * w, 0.13 * h);
  2974. c.fillAndStroke();
  2975. c.setFillColor(strokeColor);
  2976. if (switchState == '1')
  2977. {
  2978. c.begin();
  2979. c.moveTo(0.27 * w, 0.47 * h);
  2980. c.lineTo(0.59 * w, 0.12 * h);
  2981. c.stroke();
  2982. c.begin();
  2983. c.moveTo(0.52 * w, 0.12 * h);
  2984. c.lineTo(0.61 * w, 0.095 * h);
  2985. c.lineTo(0.565 * w, 0.22 * h);
  2986. c.close();
  2987. c.fill();
  2988. }
  2989. else if (switchState == '2')
  2990. {
  2991. c.begin();
  2992. c.moveTo(0.28 * w, 0.5 * h);
  2993. c.lineTo(0.64 * w, 0.5 * h);
  2994. c.stroke();
  2995. c.begin();
  2996. c.moveTo(0.59 * w, 0.44 * h);
  2997. c.lineTo(0.67 * w, 0.5 * h);
  2998. c.lineTo(0.59 * w, 0.56 * h);
  2999. c.close();
  3000. c.fill();
  3001. }
  3002. else
  3003. {
  3004. c.begin();
  3005. c.moveTo(0.27 * w, 0.53 * h);
  3006. c.lineTo(0.59 * w, 0.88 * h);
  3007. c.stroke();
  3008. c.begin();
  3009. c.moveTo(0.52 * w, 0.88 * h);
  3010. c.lineTo(0.61 * w, 0.905 * h);
  3011. c.lineTo(0.565 * w, 0.78 * h);
  3012. c.close();
  3013. c.fill();
  3014. }
  3015. };
  3016. mxCellRenderer.registerShape(mxShapeElectricalSelectorSwitch3Position2.prototype.cst.SHAPE_SELECTOR_SWITCH_3_POSITION, mxShapeElectricalSelectorSwitch3Position2);
  3017. mxShapeElectricalSelectorSwitch3Position2.prototype.constraints = [
  3018. new mxConnectionConstraint(new mxPoint(0, 0.8), true),
  3019. new mxConnectionConstraint(new mxPoint(1, 0.8), true)
  3020. ];
  3021. //**********************************************************************************************************************************************************
  3022. // Selector Switch - 4 Position 2
  3023. //**********************************************************************************************************************************************************
  3024. /**
  3025. * Extends mxShape.
  3026. */
  3027. function mxShapeElectricalSelectorSwitch4Position2(bounds, fill, stroke, strokewidth)
  3028. {
  3029. mxShape.call(this);
  3030. this.bounds = bounds;
  3031. this.fill = fill;
  3032. this.stroke = stroke;
  3033. this.strokewidth = (strokewidth != null) ? strokewidth : 1;
  3034. };
  3035. /**
  3036. * Extends mxShape.
  3037. */
  3038. mxUtils.extend(mxShapeElectricalSelectorSwitch4Position2, mxShape);
  3039. mxShapeElectricalSelectorSwitch4Position2.prototype.cst = {
  3040. SHAPE_SELECTOR_SWITCH_4_POSITION : 'mxgraph.electrical.electro-mechanical.selectorSwitch4Position2'
  3041. };
  3042. mxShapeElectricalSelectorSwitch4Position2.prototype.customProperties = [
  3043. {name: 'elSwitchState', dispName: 'Switch State', type: 'int', min:1, max:4, defVal: '1',}
  3044. ];
  3045. /**
  3046. * Function: paintVertexShape
  3047. *
  3048. * Paints the vertex shape.
  3049. */
  3050. mxShapeElectricalSelectorSwitch4Position2.prototype.paintVertexShape = function(c, x, y, w, h)
  3051. {
  3052. c.translate(x, y);
  3053. var switchState = mxUtils.getValue(this.style, 'elSwitchState', '1');
  3054. var strokeColor = mxUtils.getValue(this.style, 'strokeColor', '#000000');
  3055. c.begin();
  3056. c.moveTo(0, 0.5 * h);
  3057. c.lineTo(0.2 * w, 0.5 * h);
  3058. c.moveTo(0.68 * w, 0.045 * h);
  3059. c.lineTo(w, 0.045 * h);
  3060. c.moveTo(0.8 * w, 0.35 * h);
  3061. c.lineTo(w, 0.35 * h);
  3062. c.moveTo(0.8 * w, 0.65 * h);
  3063. c.lineTo(w, 0.65 * h);
  3064. c.moveTo(0.68 * w, 0.955 * h);
  3065. c.lineTo(w, 0.955 * h);
  3066. c.stroke();
  3067. c.ellipse(0.2 * w, 0.455 * h, 0.08 * w, 0.09 * h);
  3068. c.fillAndStroke();
  3069. c.ellipse(0.6 * w, 0, 0.08 * w, 0.09 * h);
  3070. c.fillAndStroke();
  3071. c.ellipse(0.72 * w, 0.305 * h, 0.08 * w, 0.09 * h);
  3072. c.fillAndStroke();
  3073. c.ellipse(0.72 * w, 0.605 * h, 0.08 * w, 0.09 * h);
  3074. c.fillAndStroke();
  3075. c.ellipse(0.6 * w, 0.91 * h, 0.08 * w, 0.09 * h);
  3076. c.fillAndStroke();
  3077. c.setFillColor(strokeColor);
  3078. if (switchState == '1')
  3079. {
  3080. c.begin();
  3081. c.moveTo(0.27 * w, 0.47 * h);
  3082. c.lineTo(0.58 * w, 0.11 * h);
  3083. c.stroke();
  3084. c.begin();
  3085. c.moveTo(0.515 * w, 0.115 * h);
  3086. c.lineTo(0.61 * w, 0.08 * h);
  3087. c.lineTo(0.58 * w, 0.18 * h);
  3088. c.close();
  3089. c.fill();
  3090. }
  3091. else if (switchState == '2')
  3092. {
  3093. c.begin();
  3094. c.moveTo(0.28 * w, 0.485 * h);
  3095. c.lineTo(0.69 * w, 0.37 * h);
  3096. c.stroke();
  3097. c.begin();
  3098. c.moveTo(0.62 * w, 0.34 * h);
  3099. c.lineTo(0.72 * w, 0.36 * h);
  3100. c.lineTo(0.64 * w, 0.43 * h);
  3101. c.close();
  3102. c.fill();
  3103. }
  3104. else if (switchState == '3')
  3105. {
  3106. c.begin();
  3107. c.moveTo(0.28 * w, 0.515 * h);
  3108. c.lineTo(0.69 * w, 0.63 * h);
  3109. c.stroke();
  3110. c.begin();
  3111. c.moveTo(0.62 * w, 0.66 * h);
  3112. c.lineTo(0.72 * w, 0.64 * h);
  3113. c.lineTo(0.64 * w, 0.57 * h);
  3114. c.close();
  3115. c.fill();
  3116. }
  3117. else
  3118. {
  3119. c.begin();
  3120. c.moveTo(0.27 * w, 0.53 * h);
  3121. c.lineTo(0.58 * w, 0.89 * h);
  3122. c.stroke();
  3123. c.begin();
  3124. c.moveTo(0.515 * w, 0.885 * h);
  3125. c.lineTo(0.61 * w, 0.92 * h);
  3126. c.lineTo(0.58 * w, 0.82 * h);
  3127. c.close();
  3128. c.fill();
  3129. }
  3130. };
  3131. mxCellRenderer.registerShape(mxShapeElectricalSelectorSwitch4Position2.prototype.cst.SHAPE_SELECTOR_SWITCH_4_POSITION, mxShapeElectricalSelectorSwitch4Position2);
  3132. mxShapeElectricalSelectorSwitch4Position2.prototype.constraints = [
  3133. new mxConnectionConstraint(new mxPoint(0, 0.8), true),
  3134. new mxConnectionConstraint(new mxPoint(1, 0.8), true)
  3135. ];
  3136. //**********************************************************************************************************************************************************
  3137. // Selector Switch - 6 Position 2
  3138. //**********************************************************************************************************************************************************
  3139. /**
  3140. * Extends mxShape.
  3141. */
  3142. function mxShapeElectricalSelectorSwitch6Position2(bounds, fill, stroke, strokewidth)
  3143. {
  3144. mxShape.call(this);
  3145. this.bounds = bounds;
  3146. this.fill = fill;
  3147. this.stroke = stroke;
  3148. this.strokewidth = (strokewidth != null) ? strokewidth : 1;
  3149. };
  3150. /**
  3151. * Extends mxShape.
  3152. */
  3153. mxUtils.extend(mxShapeElectricalSelectorSwitch6Position2, mxShape);
  3154. mxShapeElectricalSelectorSwitch6Position2.prototype.cst = {
  3155. SHAPE_SELECTOR_SWITCH_6_POSITION : 'mxgraph.electrical.electro-mechanical.selectorSwitch6Position2'
  3156. };
  3157. mxShapeElectricalSelectorSwitch6Position2.prototype.customProperties = [
  3158. {name: 'elSwitchState', dispName: 'Switch State', type: 'int', min:1, max:6, defVal: '1',}
  3159. ];
  3160. /**
  3161. * Function: paintVertexShape
  3162. *
  3163. * Paints the vertex shape.
  3164. */
  3165. mxShapeElectricalSelectorSwitch6Position2.prototype.paintVertexShape = function(c, x, y, w, h)
  3166. {
  3167. c.translate(x, y);
  3168. var switchState = mxUtils.getValue(this.style, 'elSwitchState', '1');
  3169. var strokeColor = mxUtils.getValue(this.style, 'strokeColor', '#000000');
  3170. c.begin();
  3171. c.moveTo(0, 0.5 * h);
  3172. c.lineTo(0.2 * w, 0.5 * h);
  3173. c.moveTo(0.39 * w, 0.03 * h);
  3174. c.lineTo(w, 0.03 * h);
  3175. c.moveTo(0.68 * w, 0.22 * h);
  3176. c.lineTo(w, 0.22 * h);
  3177. c.moveTo(0.8 * w, 0.405 * h);
  3178. c.lineTo(w, 0.405 * h);
  3179. c.moveTo(0.8 * w, 0.595 * h);
  3180. c.lineTo(w, 0.595 * h);
  3181. c.moveTo(0.68 * w, 0.78 * h);
  3182. c.lineTo(w, 0.78 * h);
  3183. c.moveTo(0.39 * w, 0.97 * h);
  3184. c.lineTo(w, 0.97 * h);
  3185. c.stroke();
  3186. c.ellipse(0.2 * w, 0.47 * h, 0.08 * w, 0.06 * h);
  3187. c.fillAndStroke();
  3188. c.ellipse(0.31 * w, 0, 0.08 * w, 0.06 * h);
  3189. c.fillAndStroke();
  3190. c.ellipse(0.6 * w, 0.19 * h, 0.08 * w, 0.06 * h);
  3191. c.fillAndStroke();
  3192. c.ellipse(0.72 * w, 0.375 * h, 0.08 * w, 0.06 * h);
  3193. c.fillAndStroke();
  3194. c.ellipse(0.72 * w, 0.565 * h, 0.08 * w, 0.06 * h);
  3195. c.fillAndStroke();
  3196. c.ellipse(0.6 * w, 0.75 * h, 0.08 * w, 0.06 * h);
  3197. c.fillAndStroke();
  3198. c.ellipse(0.31 * w, 0.94 * h, 0.08 * w, 0.06 * h);
  3199. c.fillAndStroke();
  3200. c.setFillColor(strokeColor);
  3201. if (switchState == '1')
  3202. {
  3203. c.begin();
  3204. c.moveTo(0.25 * w, 0.47 * h);
  3205. c.lineTo(0.34 * w, 0.08 * h);
  3206. c.stroke();
  3207. c.begin();
  3208. c.moveTo(0.29 * w, 0.115 * h);
  3209. c.lineTo(0.34 * w, 0.06 * h);
  3210. c.lineTo(0.37 * w, 0.12 * h);
  3211. c.close();
  3212. c.fill();
  3213. }
  3214. else if (switchState == '2')
  3215. {
  3216. c.begin();
  3217. c.moveTo(0.27 * w, 0.48 * h);
  3218. c.lineTo(0.595 * w, 0.25 * h);
  3219. c.stroke();
  3220. c.begin();
  3221. c.moveTo(0.52 * w, 0.265 * h);
  3222. c.lineTo(0.61 * w, 0.24 * h);
  3223. c.lineTo(0.58 * w, 0.302 * h);
  3224. c.close();
  3225. c.fill();
  3226. }
  3227. else if (switchState == '3')
  3228. {
  3229. c.begin();
  3230. c.moveTo(0.28 * w, 0.495 * h);
  3231. c.lineTo(0.69 * w, 0.42 * h);
  3232. c.stroke();
  3233. c.begin();
  3234. c.moveTo(0.63 * w, 0.405 * h);
  3235. c.lineTo(0.72 * w, 0.415 * h);
  3236. c.lineTo(0.65 * w, 0.455 * h);
  3237. c.close();
  3238. c.fill();
  3239. }
  3240. else if (switchState == '4')
  3241. {
  3242. c.begin();
  3243. c.moveTo(0.28 * w, 0.505 * h);
  3244. c.lineTo(0.69 * w, 0.58 * h);
  3245. c.stroke();
  3246. c.begin();
  3247. c.moveTo(0.63 * w, 0.595 * h);
  3248. c.lineTo(0.72 * w, 0.585 * h);
  3249. c.lineTo(0.65 * w, 0.545 * h);
  3250. c.close();
  3251. c.fill();
  3252. }
  3253. else if (switchState == '5')
  3254. {
  3255. c.begin();
  3256. c.moveTo(0.27 * w, 0.52 * h);
  3257. c.lineTo(0.595 * w, 0.75 * h);
  3258. c.stroke();
  3259. c.begin();
  3260. c.moveTo(0.52 * w, 0.735 * h);
  3261. c.lineTo(0.61 * w, 0.76 * h);
  3262. c.lineTo(0.58 * w, 0.698 * h);
  3263. c.close();
  3264. c.fill();
  3265. }
  3266. else
  3267. {
  3268. c.begin();
  3269. c.moveTo(0.25 * w, 0.53 * h);
  3270. c.lineTo(0.34 * w, 0.92 * h);
  3271. c.stroke();
  3272. c.begin();
  3273. c.moveTo(0.29 * w, 0.885 * h);
  3274. c.lineTo(0.34 * w, 0.94 * h);
  3275. c.lineTo(0.37 * w, 0.88 * h);
  3276. c.close();
  3277. c.fill();
  3278. }
  3279. };
  3280. mxCellRenderer.registerShape(mxShapeElectricalSelectorSwitch6Position2.prototype.cst.SHAPE_SELECTOR_SWITCH_6_POSITION, mxShapeElectricalSelectorSwitch6Position2);
  3281. mxShapeElectricalSelectorSwitch6Position2.prototype.constraints = [
  3282. new mxConnectionConstraint(new mxPoint(0, 0.5), true),
  3283. new mxConnectionConstraint(new mxPoint(1, 0.03), true),
  3284. new mxConnectionConstraint(new mxPoint(1, 0.22), true),
  3285. new mxConnectionConstraint(new mxPoint(1, 0.405), true),
  3286. new mxConnectionConstraint(new mxPoint(1, 0.595), true),
  3287. new mxConnectionConstraint(new mxPoint(1, 0.78), true),
  3288. new mxConnectionConstraint(new mxPoint(1, 0.97), true)
  3289. ];
  3290. //**********************************************************************************************************************************************************
  3291. // Shorting Selector Switch 2
  3292. //**********************************************************************************************************************************************************
  3293. /**
  3294. * Extends mxShape.
  3295. */
  3296. function mxShapeElectricalShortingSelectorSwitch2(bounds, fill, stroke, strokewidth)
  3297. {
  3298. mxShape.call(this);
  3299. this.bounds = bounds;
  3300. this.fill = fill;
  3301. this.stroke = stroke;
  3302. this.strokewidth = (strokewidth != null) ? strokewidth : 1;
  3303. };
  3304. /**
  3305. * Extends mxShape.
  3306. */
  3307. mxUtils.extend(mxShapeElectricalShortingSelectorSwitch2, mxShape);
  3308. mxShapeElectricalShortingSelectorSwitch2.prototype.cst = {
  3309. SHAPE_SHORTING_SELECTOR_SWITCH_2 : 'mxgraph.electrical.electro-mechanical.shortingSelectorSwitch2'
  3310. };
  3311. mxShapeElectricalShortingSelectorSwitch2.prototype.customProperties = [
  3312. {name: 'elSwitchState', dispName: 'Switch State', type: 'int', min:1, max:4, defVal: '1',}
  3313. ];
  3314. /**
  3315. * Function: paintVertexShape
  3316. *
  3317. * Paints the vertex shape.
  3318. */
  3319. mxShapeElectricalShortingSelectorSwitch2.prototype.paintVertexShape = function(c, x, y, w, h)
  3320. {
  3321. c.translate(x, y);
  3322. var switchState = mxUtils.getValue(this.style, 'elSwitchState', '1');
  3323. var strokeColor = mxUtils.getValue(this.style, 'strokeColor', '#000000');
  3324. c.begin();
  3325. c.moveTo(0, 0.5 * h);
  3326. c.lineTo(0.25 * w, 0.5 * h);
  3327. c.stroke();
  3328. c.ellipse(0.25 * w, 0.455 * h, 0.1 * w, 0.09 * h);
  3329. c.fillAndStroke();
  3330. c.ellipse(0.75 * w, 0, 0.1 * w, 0.09 * h);
  3331. c.fillAndStroke();
  3332. c.ellipse(0.9 * w, 0.305 * h, 0.1 * w, 0.09 * h);
  3333. c.fillAndStroke();
  3334. c.ellipse(0.9 * w, 0.605 * h, 0.1 * w, 0.09 * h);
  3335. c.fillAndStroke();
  3336. c.ellipse(0.75 * w, 0.91 * h, 0.1 * w, 0.09 * h);
  3337. c.fillAndStroke();
  3338. if (switchState == '1')
  3339. {
  3340. c.begin();
  3341. c.moveTo(0.33 * w, 0.47 * h);
  3342. c.lineTo(0.72 * w, 0.12 * h);
  3343. c.stroke();
  3344. c.begin();
  3345. c.moveTo(0.617 * w, 0.044 * h);
  3346. c.arcTo(0.21 * w, 0.17 * h, 0, 0, 1, 0.818 * w, 0.182 * h);
  3347. c.lineTo(0.766 * w, 0.198 * h);
  3348. c.arcTo(0.15 * w, 0.13 * h, 0, 0, 0, 0.617 * w, 0.092 * h);
  3349. c.close();
  3350. c.fillAndStroke();
  3351. }
  3352. else if (switchState == '2')
  3353. {
  3354. c.begin();
  3355. c.moveTo(0.34 * w, 0.49 * h);
  3356. c.lineTo(0.83 * w, 0.375 * h);
  3357. c.stroke();
  3358. c.begin();
  3359. c.moveTo(0.791 * w, 0.263 * h);
  3360. c.arcTo(0.24 * w, 0.2 * h, 0, 0, 1, 0.889 * w, 0.474 * h);
  3361. c.lineTo(0.837 * w, 0.465 * h);
  3362. c.arcTo(0.16 * w, 0.14 * h, 0, 0, 0, 0.767 * w, 0.303 * h);
  3363. c.close();
  3364. c.fillAndStroke();
  3365. }
  3366. else if (switchState == '3')
  3367. {
  3368. c.begin();
  3369. c.moveTo(0.34 * w, 0.51 * h);
  3370. c.lineTo(0.83 * w, 0.625 * h);
  3371. c.stroke();
  3372. c.begin();
  3373. c.moveTo(0.791 * w, 0.737 * h);
  3374. c.arcTo(0.24 * w, 0.2 * h, 0, 0, 0, 0.889 * w, 0.526 * h);
  3375. c.lineTo(0.837 * w, 0.535 * h);
  3376. c.arcTo(0.16 * w, 0.14 * h, 0, 0, 1, 0.767 * w, 0.697 * h);
  3377. c.close();
  3378. c.fillAndStroke();
  3379. }
  3380. else
  3381. {
  3382. c.begin();
  3383. c.moveTo(0.33 * w, 0.53 * h);
  3384. c.lineTo(0.72 * w, 0.88 * h);
  3385. c.stroke();
  3386. c.begin();
  3387. c.moveTo(0.617 * w, 0.956 * h);
  3388. c.arcTo(0.21 * w, 0.17 * h, 0, 0, 0, 0.818 * w, 0.818 * h);
  3389. c.lineTo(0.766 * w, 0.802 * h);
  3390. c.arcTo(0.15 * w, 0.13 * h, 0, 0, 1, 0.617 * w, 0.908 * h);
  3391. c.close();
  3392. c.fillAndStroke();
  3393. }
  3394. };
  3395. mxCellRenderer.registerShape(mxShapeElectricalShortingSelectorSwitch2.prototype.cst.SHAPE_SHORTING_SELECTOR_SWITCH_2, mxShapeElectricalShortingSelectorSwitch2);
  3396. mxShapeElectricalShortingSelectorSwitch2.prototype.constraints = [
  3397. new mxConnectionConstraint(new mxPoint(0, 0.5), true)
  3398. ];
  3399. //**********************************************************************************************************************************************************
  3400. // Proximity Limit Switch 2
  3401. //**********************************************************************************************************************************************************
  3402. /**
  3403. * Extends mxShape.
  3404. */
  3405. function mxShapeElectricalProximityLimitSwitch2(bounds, fill, stroke, strokewidth)
  3406. {
  3407. mxShape.call(this);
  3408. this.bounds = bounds;
  3409. this.fill = fill;
  3410. this.stroke = stroke;
  3411. this.strokewidth = (strokewidth != null) ? strokewidth : 1;
  3412. };
  3413. /**
  3414. * Extends mxShape.
  3415. */
  3416. mxUtils.extend(mxShapeElectricalProximityLimitSwitch2, mxShape);
  3417. mxShapeElectricalProximityLimitSwitch2.prototype.cst = {
  3418. SHAPE_PROXIMITY_LIMIT_SWITCH_2 : 'mxgraph.electrical.electro-mechanical.proximityLimitSwitch2'
  3419. };
  3420. mxShapeElectricalProximityLimitSwitch2.prototype.customProperties = [
  3421. {name: 'elSwitchState', dispName: 'Switch State', type: 'enum', defVal: 'on',
  3422. enumList:[
  3423. {val:'on', dispName:'On'},
  3424. {val:'off', dispName:'Off'}
  3425. ]}
  3426. ];
  3427. /**
  3428. * Function: paintVertexShape
  3429. *
  3430. * Paints the vertex shape.
  3431. */
  3432. mxShapeElectricalProximityLimitSwitch2.prototype.paintVertexShape = function(c, x, y, w, h)
  3433. {
  3434. c.translate(x, y);
  3435. var switchState = mxUtils.getValue(this.style, 'elSwitchState', 'on');
  3436. c.begin();
  3437. c.moveTo(0, 0.5 * h);
  3438. c.lineTo(0.2 * w, 0.5 * h);
  3439. c.moveTo(0.8 * w, 0.5 * h);
  3440. c.lineTo(w, 0.5 * h);
  3441. c.moveTo(0.13 * w, 0.5 * h);
  3442. c.lineTo(0.5 * w, 0);
  3443. c.lineTo(0.87 * w, 0.5 * h);
  3444. c.lineTo(0.5 * w, h);
  3445. c.close();
  3446. c.stroke();
  3447. if (switchState == 'off')
  3448. {
  3449. c.begin();
  3450. c.moveTo(0.755 * w, 0.355 * h);
  3451. c.lineTo(0.22 * w, 0.5 * h);
  3452. c.lineTo(0.625 * w, 0.61 * h);
  3453. c.lineTo(0.72 * w, 0.36 * h);
  3454. c.stroke();
  3455. }
  3456. else
  3457. {
  3458. c.begin();
  3459. c.moveTo(0.76 * w, 0.43 * h);
  3460. c.lineTo(0.235 * w, 0.5 * h);
  3461. c.lineTo(0.615 * w, 0.66 * h);
  3462. c.lineTo(0.72 * w, 0.44 * h);
  3463. c.stroke();
  3464. }
  3465. c.ellipse(0.2 * w, 0.445 * h, 0.08 * w, 0.11 * h);
  3466. c.fillAndStroke();
  3467. c.ellipse(0.72 * w, 0.445 * h, 0.08 * w, 0.11 * h);
  3468. c.fillAndStroke();
  3469. };
  3470. mxCellRenderer.registerShape(mxShapeElectricalProximityLimitSwitch2.prototype.cst.SHAPE_PROXIMITY_LIMIT_SWITCH_2, mxShapeElectricalProximityLimitSwitch2);
  3471. mxShapeElectricalProximityLimitSwitch2.prototype.constraints = [
  3472. new mxConnectionConstraint(new mxPoint(0, 0.5), true),
  3473. new mxConnectionConstraint(new mxPoint(1, 0.5), true)
  3474. ];
  3475. //**********************************************************************************************************************************************************
  3476. // Inertia Switch 2
  3477. //**********************************************************************************************************************************************************
  3478. /**
  3479. * Extends mxShape.
  3480. */
  3481. function mxShapeElectricalInertiaSwitch2(bounds, fill, stroke, strokewidth)
  3482. {
  3483. mxShape.call(this);
  3484. this.bounds = bounds;
  3485. this.fill = fill;
  3486. this.stroke = stroke;
  3487. this.strokewidth = (strokewidth != null) ? strokewidth : 1;
  3488. };
  3489. /**
  3490. * Extends mxShape.
  3491. */
  3492. mxUtils.extend(mxShapeElectricalInertiaSwitch2, mxShape);
  3493. mxShapeElectricalInertiaSwitch2.prototype.cst = {
  3494. SHAPE_INERTIA_SWITCH_2 : 'mxgraph.electrical.electro-mechanical.inertiaSwitch2'
  3495. };
  3496. mxShapeElectricalInertiaSwitch2.prototype.customProperties = [
  3497. {name: 'elSwitchState', dispName: 'Switch State', type: 'enum', defVal: 'on',
  3498. enumList:[
  3499. {val:'on', dispName:'On'},
  3500. {val:'off', dispName:'Off'}
  3501. ]}
  3502. ];
  3503. /**
  3504. * Function: paintVertexShape
  3505. *
  3506. * Paints the vertex shape.
  3507. */
  3508. mxShapeElectricalInertiaSwitch2.prototype.paintVertexShape = function(c, x, y, w, h)
  3509. {
  3510. c.translate(x, y);
  3511. var switchState = mxUtils.getValue(this.style, 'elSwitchState', 'on');
  3512. c.begin();
  3513. c.moveTo(0, 0.85 * h);
  3514. c.lineTo(0.2 * w, 0.85 * h);
  3515. c.moveTo(0.8 * w, 0.85 * h);
  3516. c.lineTo(w, 0.85 * h);
  3517. c.stroke();
  3518. if (switchState == 'off')
  3519. {
  3520. c.begin();
  3521. c.moveTo(0.28 * w, 0.79 * h);
  3522. c.lineTo(0.76 * w, 0);
  3523. c.moveTo(0.493 * w, 0.45 * h);
  3524. c.lineTo(0.493 * w, 0.26 * h);
  3525. c.lineTo(0.43 * w, 0.26 * h);
  3526. c.stroke();
  3527. c.ellipse(0.35 * w, 0.1 * h, 0.08 * w, 0.3 * h);
  3528. c.fillAndStroke();
  3529. }
  3530. else
  3531. {
  3532. c.begin();
  3533. c.moveTo(0.28 * w, 0.85 * h);
  3534. c.lineTo(0.76 * w, 0.85 * h);
  3535. c.moveTo(0.51 * w, 0.85 * h);
  3536. c.lineTo(0.51 * w, 0.26 * h);
  3537. c.lineTo(0.43 * w, 0.26 * h);
  3538. c.stroke();
  3539. c.ellipse(0.35 * w, 0.1 * h, 0.08 * w, 0.3 * h);
  3540. c.fillAndStroke();
  3541. }
  3542. c.ellipse(0.2 * w, 0.7 * h, 0.08 * w, 0.3 * h);
  3543. c.fillAndStroke();
  3544. c.ellipse(0.72 * w, 0.7 * h, 0.08 * w, 0.3 * h);
  3545. c.fillAndStroke();
  3546. };
  3547. mxCellRenderer.registerShape(mxShapeElectricalInertiaSwitch2.prototype.cst.SHAPE_INERTIA_SWITCH_2, mxShapeElectricalInertiaSwitch2);
  3548. mxShapeElectricalInertiaSwitch2.prototype.constraints = [
  3549. new mxConnectionConstraint(new mxPoint(0, 0.85), true),
  3550. new mxConnectionConstraint(new mxPoint(1, 0.85), true)
  3551. ];
  3552. //**********************************************************************************************************************************************************
  3553. // Pushbutton Break 2
  3554. //**********************************************************************************************************************************************************
  3555. /**
  3556. * Extends mxShape.
  3557. */
  3558. function mxShapeElectricalPushbuttonBreak2(bounds, fill, stroke, strokewidth)
  3559. {
  3560. mxShape.call(this);
  3561. this.bounds = bounds;
  3562. this.fill = fill;
  3563. this.stroke = stroke;
  3564. this.strokewidth = (strokewidth != null) ? strokewidth : 1;
  3565. };
  3566. /**
  3567. * Extends mxShape.
  3568. */
  3569. mxUtils.extend(mxShapeElectricalPushbuttonBreak2, mxShape);
  3570. mxShapeElectricalPushbuttonBreak2.prototype.cst = {
  3571. SHAPE_PUSHBUTTON_BREAK_2 : 'mxgraph.electrical.electro-mechanical.pushbuttonBreak2'
  3572. };
  3573. mxShapeElectricalPushbuttonBreak2.prototype.customProperties = [
  3574. {name: 'elSwitchState', dispName: 'Switch State', type: 'enum', defVal: 'on',
  3575. enumList:[
  3576. {val:'on', dispName:'On'},
  3577. {val:'off', dispName:'Off'}
  3578. ]}
  3579. ];
  3580. /**
  3581. * Function: paintVertexShape
  3582. *
  3583. * Paints the vertex shape.
  3584. */
  3585. mxShapeElectricalPushbuttonBreak2.prototype.paintVertexShape = function(c, x, y, w, h)
  3586. {
  3587. c.translate(x, y);
  3588. var switchState = mxUtils.getValue(this.style, 'elSwitchState', 'on');
  3589. c.begin();
  3590. c.moveTo(0, 0.8 * h);
  3591. c.lineTo(0.2 * w, 0.8 * h);
  3592. c.moveTo(0.8 * w, 0.8 * h);
  3593. c.lineTo(w, 0.8 * h);
  3594. c.stroke();
  3595. if (switchState == 'off')
  3596. {
  3597. c.begin();
  3598. c.moveTo(0.24 * w, h);
  3599. c.lineTo(0.76 * w, h);
  3600. c.moveTo(0.5 * w, h);
  3601. c.lineTo(0.5 * w, 0.1 * h);
  3602. c.stroke();
  3603. }
  3604. else
  3605. {
  3606. c.begin();
  3607. c.moveTo(0.24 * w, 0.9 * h);
  3608. c.lineTo(0.76 * w, 0.9 * h);
  3609. c.moveTo(0.5 * w, 0.9 * h);
  3610. c.lineTo(0.5 * w, 0);
  3611. c.stroke();
  3612. }
  3613. c.ellipse(0.2 * w, 0.725 * h, 0.08 * w, 0.15 * h);
  3614. c.fillAndStroke();
  3615. c.ellipse(0.72 * w, 0.725 * h, 0.08 * w, 0.15 * h);
  3616. c.fillAndStroke();
  3617. };
  3618. mxCellRenderer.registerShape(mxShapeElectricalPushbuttonBreak2.prototype.cst.SHAPE_PUSHBUTTON_BREAK_2, mxShapeElectricalPushbuttonBreak2);
  3619. mxShapeElectricalPushbuttonBreak2.prototype.constraints = [
  3620. new mxConnectionConstraint(new mxPoint(0, 0.8), true),
  3621. new mxConnectionConstraint(new mxPoint(1, 0.8), true)
  3622. ];
  3623. //**********************************************************************************************************************************************************
  3624. // Manual Switch 2
  3625. //**********************************************************************************************************************************************************
  3626. /**
  3627. * Extends mxShape.
  3628. */
  3629. function mxShapeElectricalManualSwitch2(bounds, fill, stroke, strokewidth)
  3630. {
  3631. mxShape.call(this);
  3632. this.bounds = bounds;
  3633. this.fill = fill;
  3634. this.stroke = stroke;
  3635. this.strokewidth = (strokewidth != null) ? strokewidth : 1;
  3636. };
  3637. /**
  3638. * Extends mxShape.
  3639. */
  3640. mxUtils.extend(mxShapeElectricalManualSwitch2, mxShape);
  3641. mxShapeElectricalManualSwitch2.prototype.cst = {
  3642. SHAPE_MANUAL_SWITCH_2 : 'mxgraph.electrical.electro-mechanical.manualSwitch2'
  3643. };
  3644. mxShapeElectricalManualSwitch2.prototype.customProperties = [
  3645. {name: 'elSwitchState', dispName: 'Switch State', type: 'enum', defVal: 'on',
  3646. enumList:[
  3647. {val:'on', dispName:'On'},
  3648. {val:'off', dispName:'Off'}
  3649. ]}
  3650. ];
  3651. /**
  3652. * Function: paintVertexShape
  3653. *
  3654. * Paints the vertex shape.
  3655. */
  3656. mxShapeElectricalManualSwitch2.prototype.paintVertexShape = function(c, x, y, w, h)
  3657. {
  3658. c.translate(x, y);
  3659. var switchState = mxUtils.getValue(this.style, 'elSwitchState', 'on');
  3660. c.begin();
  3661. c.moveTo(0.8 * w, h);
  3662. c.lineTo(w, h);
  3663. c.moveTo(0, h);
  3664. c.lineTo(0.25 * w, h);
  3665. if (switchState == 'off')
  3666. {
  3667. c.lineTo(0.76 * w, 0.1 * h);
  3668. c.moveTo(0.49 * w, 0);
  3669. c.lineTo(0.49 * w, 0.2 * h);
  3670. c.moveTo(0.49 * w, 0.3 * h);
  3671. c.lineTo(0.49 * w, 0.55 * h);
  3672. c.moveTo(0.41 * w, 0);
  3673. c.lineTo(0.57 * w, 0);
  3674. }
  3675. else
  3676. {
  3677. c.lineTo(0.8 * w, h);
  3678. c.moveTo(0.49 * w, 0.45 * h);
  3679. c.lineTo(0.49 * w, 0.65 * h);
  3680. c.moveTo(0.49 * w, 0.75 * h);
  3681. c.lineTo(0.49 * w, h);
  3682. c.moveTo(0.41 * w, 0.45 * h);
  3683. c.lineTo(0.57 * w, 0.45 * h);
  3684. }
  3685. c.stroke();
  3686. };
  3687. mxCellRenderer.registerShape(mxShapeElectricalManualSwitch2.prototype.cst.SHAPE_MANUAL_SWITCH_2, mxShapeElectricalManualSwitch2);
  3688. mxShapeElectricalManualSwitch2.prototype.constraints = [
  3689. new mxConnectionConstraint(new mxPoint(0, 0.8), true),
  3690. new mxConnectionConstraint(new mxPoint(1, 0.8), true)
  3691. ];
  3692. //**********************************************************************************************************************************************************
  3693. // Two Way Contact 2
  3694. //**********************************************************************************************************************************************************
  3695. /**
  3696. * Extends mxShape.
  3697. */
  3698. function mxShapeElectricalTwoWayContact2(bounds, fill, stroke, strokewidth)
  3699. {
  3700. mxShape.call(this);
  3701. this.bounds = bounds;
  3702. this.fill = fill;
  3703. this.stroke = stroke;
  3704. this.strokewidth = (strokewidth != null) ? strokewidth : 1;
  3705. };
  3706. /**
  3707. * Extends mxShape.
  3708. */
  3709. mxUtils.extend(mxShapeElectricalTwoWayContact2, mxShape);
  3710. mxShapeElectricalTwoWayContact2.prototype.cst = {
  3711. SHAPE_TWO_WAY_CONTACT_2 : 'mxgraph.electrical.electro-mechanical.twoWayContact2'
  3712. };
  3713. mxShapeElectricalTwoWayContact2.prototype.customProperties = [
  3714. {name: 'elSwitchState', dispName: 'Switch State', type: 'enum', defVal: 'neutral',
  3715. enumList:[
  3716. {val:'1', dispName:'1'},
  3717. {val:'neutral', dispName:'Neutral'},
  3718. {val:'2', dispName:'2'}
  3719. ]}
  3720. ];
  3721. /**
  3722. * Function: paintVertexShape
  3723. *
  3724. * Paints the vertex shape.
  3725. */
  3726. mxShapeElectricalTwoWayContact2.prototype.paintVertexShape = function(c, x, y, w, h)
  3727. {
  3728. c.translate(x, y);
  3729. var switchState = mxUtils.getValue(this.style, 'elSwitchState', 'neutral');
  3730. c.begin();
  3731. c.moveTo(0, 0.5 * h);
  3732. c.lineTo(0.21 * w, 0.5 * h);
  3733. c.moveTo(0.67 * w, 0);
  3734. c.lineTo(w, 0);
  3735. c.moveTo(0.67 * w, h);
  3736. c.lineTo(w, h);
  3737. if (switchState == '1')
  3738. {
  3739. c.moveTo(0.28 * w, 0.46 * h);
  3740. c.lineTo(0.67 * w, 0);
  3741. }
  3742. else if (switchState == '2')
  3743. {
  3744. c.moveTo(0.28 * w, 0.54 * h);
  3745. c.lineTo(0.67 * w, h);
  3746. }
  3747. else
  3748. {
  3749. c.moveTo(0.28 * w, 0.5 * h);
  3750. c.lineTo(0.67 * w, 0.5 * h);
  3751. }
  3752. c.stroke();
  3753. c.ellipse(0.2 * w, 0.4 * h, 0.08 * w, 0.2 * h);
  3754. c.fillAndStroke();
  3755. };
  3756. mxCellRenderer.registerShape(mxShapeElectricalTwoWayContact2.prototype.cst.SHAPE_TWO_WAY_CONTACT_2, mxShapeElectricalTwoWayContact2);
  3757. mxShapeElectricalTwoWayContact2.prototype.constraints = [
  3758. new mxConnectionConstraint(new mxPoint(0, 0.5), true),
  3759. new mxConnectionConstraint(new mxPoint(1, 0), true),
  3760. new mxConnectionConstraint(new mxPoint(1, 1), true)
  3761. ];
  3762. //**********************************************************************************************************************************************************
  3763. // Passing Make-Contact 2
  3764. //**********************************************************************************************************************************************************
  3765. /**
  3766. * Extends mxShape.
  3767. */
  3768. function mxShapeElectricalPassingMakeContact2(bounds, fill, stroke, strokewidth)
  3769. {
  3770. mxShape.call(this);
  3771. this.bounds = bounds;
  3772. this.fill = fill;
  3773. this.stroke = stroke;
  3774. this.strokewidth = (strokewidth != null) ? strokewidth : 1;
  3775. };
  3776. /**
  3777. * Extends mxShape.
  3778. */
  3779. mxUtils.extend(mxShapeElectricalPassingMakeContact2, mxShape);
  3780. mxShapeElectricalPassingMakeContact2.prototype.cst = {
  3781. SHAPE_PASSING_MAKE_CONTACT_2 : 'mxgraph.electrical.electro-mechanical.passingMakeContact2'
  3782. };
  3783. mxShapeElectricalPassingMakeContact2.prototype.customProperties = [
  3784. {name: 'elSwitchState', dispName: 'Switch State', type: 'enum', defVal: 'on',
  3785. enumList:[
  3786. {val:'on', dispName:'On'},
  3787. {val:'off', dispName:'Off'}
  3788. ]}
  3789. ];
  3790. /**
  3791. * Function: paintVertexShape
  3792. *
  3793. * Paints the vertex shape.
  3794. */
  3795. mxShapeElectricalPassingMakeContact2.prototype.paintVertexShape = function(c, x, y, w, h)
  3796. {
  3797. c.translate(x, y);
  3798. var switchState = mxUtils.getValue(this.style, 'elSwitchState', 'neutral');
  3799. c.begin();
  3800. c.moveTo(w, 0.7 * h);
  3801. c.lineTo(0.77 * w, 0.7 * h);
  3802. c.lineTo(0.93 * w, h);
  3803. c.moveTo(0, 0.7 * h);
  3804. c.lineTo(0.25 * w, 0.7 * h);
  3805. if (switchState == 'off')
  3806. {
  3807. c.lineTo(0.76 * w, 0);
  3808. }
  3809. else
  3810. {
  3811. c.lineTo(0.76 * w, 0.7 * h);
  3812. }
  3813. c.stroke();
  3814. };
  3815. mxCellRenderer.registerShape(mxShapeElectricalPassingMakeContact2.prototype.cst.SHAPE_PASSING_MAKE_CONTACT_2, mxShapeElectricalPassingMakeContact2);
  3816. mxShapeElectricalPassingMakeContact2.prototype.constraints = [
  3817. new mxConnectionConstraint(new mxPoint(0, 0.7), true),
  3818. new mxConnectionConstraint(new mxPoint(1, 0.7), true)
  3819. ];
  3820. //**********************************************************************************************************************************************************
  3821. // DPST 2
  3822. //**********************************************************************************************************************************************************
  3823. /**
  3824. * Extends mxShape.
  3825. */
  3826. function mxShapeElectricalDPST2(bounds, fill, stroke, strokewidth)
  3827. {
  3828. mxShape.call(this);
  3829. this.bounds = bounds;
  3830. this.fill = fill;
  3831. this.stroke = stroke;
  3832. this.strokewidth = (strokewidth != null) ? strokewidth : 1;
  3833. };
  3834. /**
  3835. * Extends mxShape.
  3836. */
  3837. mxUtils.extend(mxShapeElectricalDPST2, mxShape);
  3838. mxShapeElectricalDPST2.prototype.cst = {
  3839. SHAPE_DPST_2 : 'mxgraph.electrical.electro-mechanical.dpst2'
  3840. };
  3841. mxShapeElectricalDPST2.prototype.customProperties = [
  3842. {name: 'elSwitchState', dispName: 'Switch State', type: 'enum', defVal: 'on',
  3843. enumList:[
  3844. {val:'on', dispName:'On'},
  3845. {val:'off', dispName:'Off'}
  3846. ]}
  3847. ];
  3848. /**
  3849. * Function: paintVertexShape
  3850. *
  3851. * Paints the vertex shape.
  3852. */
  3853. mxShapeElectricalDPST2.prototype.paintVertexShape = function(c, x, y, w, h)
  3854. {
  3855. c.translate(x, y);
  3856. var switchState = mxUtils.getValue(this.style, 'elSwitchState', 'neutral');
  3857. c.begin();
  3858. c.moveTo(0, 0.4 * h);
  3859. c.lineTo(0.2 * w, 0.4 * h);
  3860. c.moveTo(0.8 * w, 0.4 * h);
  3861. c.lineTo(w, 0.4 * h);
  3862. c.moveTo(0, 0.92 * h);
  3863. c.lineTo(0.2 * w, 0.92 * h);
  3864. c.moveTo(0.8 * w, 0.92 * h);
  3865. c.lineTo(w, 0.92 * h);
  3866. if (switchState == 'off')
  3867. {
  3868. c.moveTo(0.28 * w, 0.38 * h);
  3869. c.lineTo(0.76 * w, 0);
  3870. c.moveTo(0.28 * w, 0.9 * h);
  3871. c.lineTo(0.76 * w, 0.52 * h);
  3872. c.moveTo(0.5 * w, 0.2 * h);
  3873. c.lineTo(0.5 * w, 0.33 * h);
  3874. c.moveTo(0.5 * w, 0.38 * h);
  3875. c.lineTo(0.5 * w, 0.51 * h);
  3876. c.moveTo(0.5 * w, 0.56 * h);
  3877. c.lineTo(0.5 * w, 0.69 * h);
  3878. }
  3879. else
  3880. {
  3881. c.moveTo(0.28 * w, 0.4 * h);
  3882. c.lineTo(0.72 * w, 0.4 * h);
  3883. c.moveTo(0.28 * w, 0.92 * h);
  3884. c.lineTo(0.72 * w, 0.92 * h);
  3885. c.moveTo(0.5 * w, 0.4 * h);
  3886. c.lineTo(0.5 * w, 0.53 * h);
  3887. c.moveTo(0.5 * w, 0.58 * h);
  3888. c.lineTo(0.5 * w, 0.71 * h);
  3889. c.moveTo(0.5 * w, 0.76 * h);
  3890. c.lineTo(0.5 * w, 0.89 * h);
  3891. }
  3892. c.stroke();
  3893. c.ellipse(0.2 * w, 0.325 * h, 0.08 * w, 0.15 * h);
  3894. c.fillAndStroke();
  3895. c.ellipse(0.2 * w, 0.845 * h, 0.08 * w, 0.15 * h);
  3896. c.fillAndStroke();
  3897. c.ellipse(0.72 * w, 0.325 * h, 0.08 * w, 0.15 * h);
  3898. c.fillAndStroke();
  3899. c.ellipse(0.72 * w, 0.845 * h, 0.08 * w, 0.15 * h);
  3900. c.fillAndStroke();
  3901. };
  3902. mxCellRenderer.registerShape(mxShapeElectricalDPST2.prototype.cst.SHAPE_DPST_2, mxShapeElectricalDPST2);
  3903. mxShapeElectricalDPST2.prototype.constraints = [
  3904. new mxConnectionConstraint(new mxPoint(0, 0.4), true),
  3905. new mxConnectionConstraint(new mxPoint(0, 0.92), true),
  3906. new mxConnectionConstraint(new mxPoint(1, 0.4), true),
  3907. new mxConnectionConstraint(new mxPoint(1, 0.92), true)
  3908. ];
  3909. //**********************************************************************************************************************************************************
  3910. // Spring Return Switch 3
  3911. //**********************************************************************************************************************************************************
  3912. /**
  3913. * Extends mxShape.
  3914. */
  3915. function mxShapeElectricalSpringReturn3(bounds, fill, stroke, strokewidth)
  3916. {
  3917. mxShape.call(this);
  3918. this.bounds = bounds;
  3919. this.fill = fill;
  3920. this.stroke = stroke;
  3921. this.strokewidth = (strokewidth != null) ? strokewidth : 1;
  3922. };
  3923. /**
  3924. * Extends mxShape.
  3925. */
  3926. mxUtils.extend(mxShapeElectricalSpringReturn3, mxShape);
  3927. mxShapeElectricalSpringReturn3.prototype.cst = {
  3928. SHAPE_SPRING_RETURN_3 : 'mxgraph.electrical.electro-mechanical.springReturn3'
  3929. };
  3930. mxShapeElectricalSpringReturn3.prototype.customProperties = [
  3931. {name: 'elSwitchState', dispName: 'Switch State', type: 'enum', defVal: 'on',
  3932. enumList:[
  3933. {val:'on', dispName:'On'},
  3934. {val:'off', dispName:'Off'}
  3935. ]}
  3936. ];
  3937. /**
  3938. * Function: paintVertexShape
  3939. *
  3940. * Paints the vertex shape.
  3941. */
  3942. mxShapeElectricalSpringReturn3.prototype.paintVertexShape = function(c, x, y, w, h)
  3943. {
  3944. c.translate(x, y);
  3945. var switchState = mxUtils.getValue(this.style, 'elSwitchState', 'neutral');
  3946. c.begin();
  3947. c.moveTo(0, 0.62 * h);
  3948. c.lineTo(0.21 * w, 0.62 * h);
  3949. c.stroke();
  3950. if (switchState == 'off')
  3951. {
  3952. c.begin();
  3953. c.moveTo(0.28 * w, 0.57 * h);
  3954. c.lineTo(0.76 * w, 0);
  3955. c.moveTo(w, 0.62 * h);
  3956. c.lineTo(0.625 * w, 0.62 * h);
  3957. c.lineTo(0.695 * w, 0.31 * h);
  3958. c.lineTo(0.765 * w, 0.62 * h);
  3959. c.fillAndStroke();
  3960. }
  3961. else
  3962. {
  3963. c.begin();
  3964. c.moveTo(0.28 * w, 0.64 * h);
  3965. c.lineTo(0.76 * w, h);
  3966. c.moveTo(w, 0.62 * h);
  3967. c.lineTo(0.625 * w, 0.62 * h);
  3968. c.lineTo(0.695 * w, 0.93 * h);
  3969. c.lineTo(0.765 * w, 0.62 * h);
  3970. c.fillAndStroke();
  3971. }
  3972. c.ellipse(0.205 * w, 0.5 * h, 0.08 * w, 0.24 * h);
  3973. c.fillAndStroke();
  3974. };
  3975. mxCellRenderer.registerShape(mxShapeElectricalSpringReturn3.prototype.cst.SHAPE_SPRING_RETURN_3, mxShapeElectricalSpringReturn3);
  3976. mxShapeElectricalSpringReturn3.prototype.constraints = [
  3977. new mxConnectionConstraint(new mxPoint(0, 0.62), true),
  3978. new mxConnectionConstraint(new mxPoint(1, 0.62), true)
  3979. ];
  3980. //**********************************************************************************************************************************************************
  3981. // Limit Switch
  3982. //**********************************************************************************************************************************************************
  3983. /**
  3984. * Extends mxShape.
  3985. */
  3986. function mxShapeElectricalLimitSwitch(bounds, fill, stroke, strokewidth)
  3987. {
  3988. mxShape.call(this);
  3989. this.bounds = bounds;
  3990. this.fill = fill;
  3991. this.stroke = stroke;
  3992. this.strokewidth = (strokewidth != null) ? strokewidth : 1;
  3993. };
  3994. /**
  3995. * Extends mxShape.
  3996. */
  3997. mxUtils.extend(mxShapeElectricalLimitSwitch, mxShape);
  3998. mxShapeElectricalLimitSwitch.prototype.cst = {
  3999. SHAPE_LIMIT_SWITCH : 'mxgraph.electrical.electro-mechanical.limitSwitch'
  4000. };
  4001. mxShapeElectricalLimitSwitch.prototype.customProperties = [
  4002. {name: 'elSwitchState', dispName: 'Switch State', type: 'enum', defVal: 'on',
  4003. enumList:[
  4004. {val:'on', dispName:'On'},
  4005. {val:'off', dispName:'Off'}
  4006. ]}
  4007. ];
  4008. /**
  4009. * Function: paintVertexShape
  4010. *
  4011. * Paints the vertex shape.
  4012. */
  4013. mxShapeElectricalLimitSwitch.prototype.paintVertexShape = function(c, x, y, w, h)
  4014. {
  4015. c.translate(x, y);
  4016. var switchState = mxUtils.getValue(this.style, 'elSwitchState', 'neutral');
  4017. c.begin();
  4018. c.moveTo(0, 0.16 * h);
  4019. c.lineTo(0.2 * w, 0.16 * h);
  4020. c.moveTo(0.8 * w, 0.16 * h);
  4021. c.lineTo(w, 0.16 * h);
  4022. c.stroke();
  4023. if (switchState == 'off')
  4024. {
  4025. c.begin();
  4026. c.moveTo(0.725 * w, 0.75 * h);
  4027. c.lineTo(0.24 * w, 0.16 * h);
  4028. c.lineTo(0.515 * w, h);
  4029. c.lineTo(0.69 * w, 0.72 * h);
  4030. c.fillAndStroke();
  4031. }
  4032. else
  4033. {
  4034. c.begin();
  4035. c.moveTo(0.76 * w, 0);
  4036. c.lineTo(0.24 * w, 0.16 * h);
  4037. c.lineTo(0.615 * w, 0.52 * h);
  4038. c.lineTo(0.72 * w, 0.02 * h);
  4039. c.fillAndStroke();
  4040. }
  4041. c.ellipse(0.2 * w, 0.04 * h, 0.08 * w, 0.24 * h);
  4042. c.fillAndStroke();
  4043. c.ellipse(0.72 * w, 0.04 * h, 0.08 * w, 0.24 * h);
  4044. c.fillAndStroke();
  4045. };
  4046. mxCellRenderer.registerShape(mxShapeElectricalLimitSwitch.prototype.cst.SHAPE_LIMIT_SWITCH, mxShapeElectricalLimitSwitch);
  4047. mxShapeElectricalLimitSwitch.prototype.constraints = [
  4048. new mxConnectionConstraint(new mxPoint(0, 0.16), true),
  4049. new mxConnectionConstraint(new mxPoint(1, 0.16), true)
  4050. ];
  4051. //**********************************************************************************************************************************************************
  4052. // DPDT 3
  4053. //**********************************************************************************************************************************************************
  4054. /**
  4055. * Extends mxShape.
  4056. */
  4057. function mxShapeElectricalDPDT3(bounds, fill, stroke, strokewidth)
  4058. {
  4059. mxShape.call(this);
  4060. this.bounds = bounds;
  4061. this.fill = fill;
  4062. this.stroke = stroke;
  4063. this.strokewidth = (strokewidth != null) ? strokewidth : 1;
  4064. };
  4065. /**
  4066. * Extends mxShape.
  4067. */
  4068. mxUtils.extend(mxShapeElectricalDPDT3, mxShape);
  4069. mxShapeElectricalDPDT3.prototype.cst = {
  4070. SHAPE_DPDT_3 : 'mxgraph.electrical.electro-mechanical.dpdt3'
  4071. };
  4072. mxShapeElectricalDPDT3.prototype.customProperties = [
  4073. {name: 'elSwitchState', dispName: 'Switch State', type: 'enum', defVal: '1',
  4074. enumList:[
  4075. {val:'1', dispName:'1'},
  4076. {val:'2', dispName:'2'}
  4077. ]}
  4078. ];
  4079. /**
  4080. * Function: paintVertexShape
  4081. *
  4082. * Paints the vertex shape.
  4083. */
  4084. mxShapeElectricalDPDT3.prototype.paintVertexShape = function(c, x, y, w, h)
  4085. {
  4086. c.translate(x, y);
  4087. var switchState = mxUtils.getValue(this.style, 'elSwitchState', 'neutral');
  4088. c.begin();
  4089. c.moveTo(0, 0.23 * h);
  4090. c.lineTo(0.27 * w, 0.23 * h);
  4091. c.moveTo(0, 0.79 * h);
  4092. c.lineTo(0.27 * w, 0.79 * h);
  4093. c.moveTo(0.74 * w, 0.05 * h);
  4094. c.lineTo(w, 0.05 * h);
  4095. c.moveTo(0.74 * w, 0.39 * h);
  4096. c.lineTo(w, 0.39 * h);
  4097. c.moveTo(0.74 * w, 0.61 * h);
  4098. c.lineTo(w, 0.61 * h);
  4099. c.moveTo(0.74 * w, 0.95 * h);
  4100. c.lineTo(w, 0.95 * h);
  4101. if (switchState == '1')
  4102. {
  4103. c.moveTo(0.37 * w, 0.215 * h);
  4104. c.lineTo(0.69 * w, 0.105 * h);
  4105. c.moveTo(0.37 * w, 0.775 * h);
  4106. c.lineTo(0.69 * w, 0.665 * h);
  4107. c.moveTo(0.515 * w, 0.17 * h);
  4108. c.lineTo(0.515 * w, 0.245 * h);
  4109. c.moveTo(0.515 * w, 0.28 * h);
  4110. c.lineTo(0.515 * w, 0.355 * h);
  4111. c.moveTo(0.515 * w, 0.39 * h);
  4112. c.lineTo(0.515 * w, 0.465 * h);
  4113. c.moveTo(0.515 * w, 0.5 * h);
  4114. c.lineTo(0.515 * w, 0.575 * h);
  4115. c.moveTo(0.515 * w, 0.61 * h);
  4116. c.lineTo(0.515 * w, 0.685 * h);
  4117. }
  4118. else
  4119. {
  4120. c.moveTo(0.37 * w, 0.245 * h);
  4121. c.lineTo(0.69 * w, 0.335 * h);
  4122. c.moveTo(0.37 * w, 0.805 * h);
  4123. c.lineTo(0.69 * w, 0.895 * h);
  4124. c.moveTo(0.515 * w, 0.29 * h);
  4125. c.lineTo(0.515 * w, 0.365 * h);
  4126. c.moveTo(0.515 * w, 0.4 * h);
  4127. c.lineTo(0.515 * w, 0.475 * h);
  4128. c.moveTo(0.515 * w, 0.51 * h);
  4129. c.lineTo(0.515 * w, 0.585 * h);
  4130. c.moveTo(0.515 * w, 0.62 * h);
  4131. c.lineTo(0.515 * w, 0.695 * h);
  4132. c.moveTo(0.515 * w, 0.73 * h);
  4133. c.lineTo(0.515 * w, 0.805 * h);
  4134. }
  4135. c.stroke();
  4136. c.ellipse(0.265 * w, 0.18 * h, 0.105 * w, 0.095 * h);
  4137. c.fillAndStroke();
  4138. c.ellipse(0.265 * w, 0.745 * h, 0.105 * w, 0.095 * h);
  4139. c.fillAndStroke();
  4140. c.ellipse(0.635 * w, 0, 0.105 * w, 0.095 * h);
  4141. c.fillAndStroke();
  4142. c.ellipse(0.635 * w, 0.345 * h, 0.105 * w, 0.095 * h);
  4143. c.fillAndStroke();
  4144. c.ellipse(0.635 * w, 0.56 * h, 0.105 * w, 0.095 * h);
  4145. c.fillAndStroke();
  4146. c.ellipse(0.635 * w, 0.905 * h, 0.105 * w, 0.095 * h);
  4147. c.fillAndStroke();
  4148. };
  4149. mxCellRenderer.registerShape(mxShapeElectricalDPDT3.prototype.cst.SHAPE_DPDT_3, mxShapeElectricalDPDT3);
  4150. mxShapeElectricalDPDT3.prototype.constraints = [
  4151. new mxConnectionConstraint(new mxPoint(0, 0.23), true),
  4152. new mxConnectionConstraint(new mxPoint(0, 0.79), true),
  4153. new mxConnectionConstraint(new mxPoint(1, 0.05), true),
  4154. new mxConnectionConstraint(new mxPoint(1, 0.39), true),
  4155. new mxConnectionConstraint(new mxPoint(1, 0.61), true),
  4156. new mxConnectionConstraint(new mxPoint(1, 0.95), true)
  4157. ];
  4158. //**********************************************************************************************************************************************************
  4159. // Two Position Switch 2
  4160. //**********************************************************************************************************************************************************
  4161. /**
  4162. * Extends mxShape.
  4163. */
  4164. function mxShapeElectricalTwoPositionSwitch2(bounds, fill, stroke, strokewidth)
  4165. {
  4166. mxShape.call(this);
  4167. this.bounds = bounds;
  4168. this.fill = fill;
  4169. this.stroke = stroke;
  4170. this.strokewidth = (strokewidth != null) ? strokewidth : 1;
  4171. };
  4172. /**
  4173. * Extends mxShape.
  4174. */
  4175. mxUtils.extend(mxShapeElectricalTwoPositionSwitch2, mxShape);
  4176. mxShapeElectricalTwoPositionSwitch2.prototype.cst = {
  4177. SHAPE_TWO_POSITION_SWITCH_2 : 'mxgraph.electrical.electro-mechanical.twoPositionSwitch2'
  4178. };
  4179. mxShapeElectricalTwoPositionSwitch2.prototype.customProperties = [
  4180. {name: 'elSwitchState', dispName: 'Switch State', type: 'enum', defVal: '1',
  4181. enumList:[
  4182. {val:'1', dispName:'1'},
  4183. {val:'2', dispName:'2'}
  4184. ]}
  4185. ];
  4186. /**
  4187. * Function: paintVertexShape
  4188. *
  4189. * Paints the vertex shape.
  4190. */
  4191. mxShapeElectricalTwoPositionSwitch2.prototype.paintVertexShape = function(c, x, y, w, h)
  4192. {
  4193. c.translate(x, y);
  4194. var switchState = mxUtils.getValue(this.style, 'elSwitchState', '1');
  4195. c.begin();
  4196. c.moveTo(0, 0.5 * h);
  4197. c.lineTo(0.2 * w, 0.5 * h);
  4198. c.moveTo(0.8 * w, 0.5 * h);
  4199. c.lineTo(w, 0.5 * h);
  4200. c.moveTo(0.5 * w, 0);
  4201. c.lineTo(0.5 * w, 0.18 * h);
  4202. c.moveTo(0.5 * w, 0.82 * h);
  4203. c.lineTo(0.5 * w, h);
  4204. c.moveTo(0.63 * w, 0.145 * h);
  4205. c.arcTo(0.2 * w, 0.22 * h, 0, 0, 1, 0.835 * w, 0.36 * h);
  4206. if (switchState == '1')
  4207. {
  4208. c.moveTo(0.24 * w, 0.5 * h);
  4209. c.arcTo(0.27 * w, 0.27 * h, 0, 0, 1, 0.5 * w, 0.78 * h);
  4210. c.moveTo(0.76 * w, 0.5 * h);
  4211. c.arcTo(0.27 * w, 0.27 * h, 0, 0, 1, 0.5 * w, 0.22 * h);
  4212. c.moveTo(0.39 * w, 0.56 * h);
  4213. c.lineTo(0.55 * w, 0.39 * h);
  4214. c.moveTo(0.39 * w, 0.56 * h);
  4215. c.lineTo(0.55 * w, 0.39 * h);
  4216. c.moveTo(0.61 * w, 0.44 * h);
  4217. c.lineTo(0.45 * w, 0.61 * h);
  4218. c.moveTo(0.61 * w, 0.44 * h);
  4219. c.lineTo(0.45 * w, 0.61 * h);
  4220. }
  4221. else
  4222. {
  4223. c.moveTo(0.76 * w, 0.5 * h);
  4224. c.arcTo(0.27 * w, 0.27 * h, 0, 0, 0, 0.5 * w, 0.78 * h);
  4225. c.moveTo(0.24 * w, 0.5 * h);
  4226. c.arcTo(0.27 * w, 0.27 * h, 0, 0, 0, 0.5 * w, 0.22 * h);
  4227. c.moveTo(0.61 * w, 0.56 * h);
  4228. c.lineTo(0.45 * w, 0.39 * h);
  4229. c.moveTo(0.61 * w, 0.56 * h);
  4230. c.lineTo(0.45 * w, 0.39 * h);
  4231. c.moveTo(0.39 * w, 0.44 * h);
  4232. c.lineTo(0.55 * w, 0.61 * h);
  4233. c.moveTo(0.39 * w, 0.44 * h);
  4234. c.lineTo(0.55 * w, 0.61 * h);
  4235. }
  4236. c.stroke();
  4237. c.ellipse(0.2 * w, 0.4575 * h, 0.08 * w, 0.085 * h);
  4238. c.fillAndStroke();
  4239. c.ellipse(0.72 * w, 0.4575 * h, 0.08 * w, 0.085 * h);
  4240. c.fillAndStroke();
  4241. c.ellipse(0.46 * w, 0.18 * h, 0.08 * w, 0.085 * h);
  4242. c.fillAndStroke();
  4243. c.ellipse(0.46 * w, 0.735 * h, 0.08 * w, 0.085 * h);
  4244. c.fillAndStroke();
  4245. var strokeColor = mxUtils.getValue(this.style, mxConstants.STYLE_STROKECOLOR, '#000000');
  4246. c.setFillColor(strokeColor);
  4247. c.begin();
  4248. c.moveTo(0.633 * w, 0.1 * h);
  4249. c.lineTo(0.633 * w, 0.185 * h);
  4250. c.lineTo(0.56 * w, 0.1425 * h);
  4251. c.close();
  4252. c.moveTo(0.795 * w, 0.355 * h);
  4253. c.lineTo(0.875 * w, 0.355 * h);
  4254. c.lineTo(0.835 * w, 0.435 * h);
  4255. c.close();
  4256. c.fillAndStroke();
  4257. };
  4258. mxCellRenderer.registerShape(mxShapeElectricalTwoPositionSwitch2.prototype.cst.SHAPE_TWO_POSITION_SWITCH_2, mxShapeElectricalTwoPositionSwitch2);
  4259. mxShapeElectricalTwoPositionSwitch2.prototype.constraints = [
  4260. new mxConnectionConstraint(new mxPoint(0, 0.5), true),
  4261. new mxConnectionConstraint(new mxPoint(1, 0.5), true),
  4262. new mxConnectionConstraint(new mxPoint(0.5, 0), true),
  4263. new mxConnectionConstraint(new mxPoint(0.5, 1), true)
  4264. ];
  4265. //**********************************************************************************************************************************************************
  4266. // Three Position Switch 2
  4267. //**********************************************************************************************************************************************************
  4268. /**
  4269. * Extends mxShape.
  4270. */
  4271. function mxShapeElectricalThreePositionSwitch2(bounds, fill, stroke, strokewidth)
  4272. {
  4273. mxShape.call(this);
  4274. this.bounds = bounds;
  4275. this.fill = fill;
  4276. this.stroke = stroke;
  4277. this.strokewidth = (strokewidth != null) ? strokewidth : 1;
  4278. };
  4279. /**
  4280. * Extends mxShape.
  4281. */
  4282. mxUtils.extend(mxShapeElectricalThreePositionSwitch2, mxShape);
  4283. mxShapeElectricalThreePositionSwitch2.prototype.cst = {
  4284. SHAPE_THREE_POSITION_SWITCH_2 : 'mxgraph.electrical.electro-mechanical.threePositionSwitch2'
  4285. };
  4286. mxShapeElectricalThreePositionSwitch2.prototype.customProperties = [
  4287. {name: 'elSwitchState', dispName: 'Switch State', type: 'enum', defVal: '1',
  4288. enumList:[
  4289. {val:'1', dispName:'1'},
  4290. {val:'2', dispName:'2'},
  4291. {val:'3', dispName:'3'}
  4292. ]}
  4293. ];
  4294. /**
  4295. * Function: paintVertexShape
  4296. *
  4297. * Paints the vertex shape.
  4298. */
  4299. mxShapeElectricalThreePositionSwitch2.prototype.paintVertexShape = function(c, x, y, w, h)
  4300. {
  4301. c.translate(x, y);
  4302. var switchState = mxUtils.getValue(this.style, 'elSwitchState', '1');
  4303. c.begin();
  4304. c.moveTo(0.5 * w, 0);
  4305. c.lineTo(0.5 * w, 0.2 * h);
  4306. c.moveTo(0, h);
  4307. c.lineTo(0.215 * w, 0.825 * h);
  4308. c.moveTo(w, h);
  4309. c.lineTo(0.785 * w, 0.825 * h);
  4310. c.moveTo(0.12 * w, 0.62 * h);
  4311. c.arcTo(0.38 * w, 0.38 * h, 0, 0, 1, 0.31 * w, 0.26 * h);
  4312. if (switchState == '1')
  4313. {
  4314. c.moveTo(0.5 * w, 0.26 * h);
  4315. c.arcTo(0.65 * w, 0.65 * h, 0, 0, 1, 0.25 * w, 0.79 * h);
  4316. }
  4317. else if (switchState == '2')
  4318. {
  4319. c.moveTo(0.5 * w, 0.26 * h);
  4320. c.arcTo(0.65 * w, 0.65 * h, 0, 0, 0, 0.75 * w, 0.79 * h);
  4321. }
  4322. else
  4323. {
  4324. c.moveTo(0.25 * w, 0.79 * h);
  4325. c.arcTo(0.5 * w, 0.5 * h, 0, 0, 1, 0.75 * w, 0.79 * h);
  4326. }
  4327. c.stroke();
  4328. c.ellipse(0.2 * w, 0.74 * h, 0.1 * w, 0.1 * h);
  4329. c.fillAndStroke();
  4330. c.ellipse(0.45 * w, 0.21 * h, 0.1 * w, 0.1 * h);
  4331. c.fillAndStroke();
  4332. c.ellipse(0.7 * w, 0.74 * h, 0.1 * w, 0.1 * h);
  4333. c.fillAndStroke();
  4334. var strokeColor = mxUtils.getValue(this.style, mxConstants.STYLE_STROKECOLOR, '#000000');
  4335. c.setFillColor(strokeColor);
  4336. c.begin();
  4337. c.moveTo(0.285 * w, 0.215 * h);
  4338. c.lineTo(0.39 * w, 0.2 * h);
  4339. c.lineTo(0.345 * w, 0.295 * h);
  4340. c.close();
  4341. c.moveTo(0.07 * w, 0.63 * h);
  4342. c.lineTo(0.18 * w, 0.61 * h);
  4343. c.lineTo(0.14 * w, 0.71 * h);
  4344. c.close();
  4345. c.fillAndStroke();
  4346. };
  4347. mxCellRenderer.registerShape(mxShapeElectricalThreePositionSwitch2.prototype.cst.SHAPE_THREE_POSITION_SWITCH_2, mxShapeElectricalThreePositionSwitch2);
  4348. mxShapeElectricalThreePositionSwitch2.prototype.constraints = [
  4349. new mxConnectionConstraint(new mxPoint(0.5, 0), true),
  4350. new mxConnectionConstraint(new mxPoint(0, 1), true),
  4351. new mxConnectionConstraint(new mxPoint(1, 1), true)
  4352. ];
  4353. //**********************************************************************************************************************************************************
  4354. // Four Position Switch 2
  4355. //**********************************************************************************************************************************************************
  4356. /**
  4357. * Extends mxShape.
  4358. */
  4359. function mxShapeElectricalFourPositionSwitch2(bounds, fill, stroke, strokewidth)
  4360. {
  4361. mxShape.call(this);
  4362. this.bounds = bounds;
  4363. this.fill = fill;
  4364. this.stroke = stroke;
  4365. this.strokewidth = (strokewidth != null) ? strokewidth : 1;
  4366. };
  4367. /**
  4368. * Extends mxShape.
  4369. */
  4370. mxUtils.extend(mxShapeElectricalFourPositionSwitch2, mxShape);
  4371. mxShapeElectricalFourPositionSwitch2.prototype.cst = {
  4372. SHAPE_FOUR_POSITION_SWITCH_2 : 'mxgraph.electrical.electro-mechanical.fourPositionSwitch2'
  4373. };
  4374. mxShapeElectricalFourPositionSwitch2.prototype.customProperties = [
  4375. {name: 'elSwitchState', dispName: 'Switch State', type: 'enum', defVal: '1',
  4376. enumList:[
  4377. {val:'1', dispName:'1'},
  4378. {val:'2', dispName:'2'},
  4379. {val:'3', dispName:'3'},
  4380. {val:'4', dispName:'4'}
  4381. ]}
  4382. ];
  4383. /**
  4384. * Function: paintVertexShape
  4385. *
  4386. * Paints the vertex shape.
  4387. */
  4388. mxShapeElectricalFourPositionSwitch2.prototype.paintVertexShape = function(c, x, y, w, h)
  4389. {
  4390. c.translate(x, y);
  4391. var switchState = mxUtils.getValue(this.style, 'elSwitchState', '1');
  4392. c.begin();
  4393. c.moveTo(0, 0.5 * h);
  4394. c.lineTo(0.2 * w, 0.5 * h);
  4395. c.moveTo(0.8 * w, 0.5 * h);
  4396. c.lineTo(w, 0.5 * h);
  4397. c.moveTo(0.5 * w, 0);
  4398. c.lineTo(0.5 * w, 0.18 * h);
  4399. c.moveTo(0.5 * w, 0.82 * h);
  4400. c.lineTo(0.5 * w, h);
  4401. c.moveTo(0.37 * w, 0.145 * h);
  4402. c.arcTo(0.2 * w, 0.22 * h, 0, 0, 0, 0.165 * w, 0.36 * h);
  4403. if (switchState == '1')
  4404. {
  4405. c.moveTo(0.32 * w, 0.7 * h);
  4406. c.arcTo(0.25 * w, 0.25 * h, 0, 0, 1, 0.68 * w, 0.7 * h);
  4407. c.moveTo(0.32 * w, 0.3 * h);
  4408. c.arcTo(0.25 * w, 0.25 * h, 0, 0, 0, 0.68 * w, 0.3 * h);
  4409. c.moveTo(0.46 * w, 0.37 * h);
  4410. c.lineTo(0.46 * w, 0.63 * h);
  4411. c.moveTo(0.54 * w, 0.37 * h);
  4412. c.lineTo(0.54 * w, 0.63 * h);
  4413. c.moveTo(0.28 * w, 0.5 * h);
  4414. c.lineTo(0.72 * w, 0.5 * h);
  4415. }
  4416. else if (switchState == '2')
  4417. {
  4418. c.moveTo(0.24 * w, 0.5 * h);
  4419. c.arcTo(0.27 * w, 0.27 * h, 0, 0, 1, 0.5 * w, 0.78 * h);
  4420. c.moveTo(0.76 * w, 0.5 * h);
  4421. c.arcTo(0.27 * w, 0.27 * h, 0, 0, 1, 0.5 * w, 0.22 * h);
  4422. c.moveTo(0.39 * w, 0.56 * h);
  4423. c.lineTo(0.55 * w, 0.39 * h);
  4424. c.moveTo(0.39 * w, 0.56 * h);
  4425. c.lineTo(0.55 * w, 0.39 * h);
  4426. c.moveTo(0.61 * w, 0.44 * h);
  4427. c.lineTo(0.45 * w, 0.61 * h);
  4428. c.moveTo(0.61 * w, 0.44 * h);
  4429. c.lineTo(0.45 * w, 0.61 * h);
  4430. c.moveTo(0.32 * w, 0.32 * h);
  4431. c.lineTo(0.68 * w, 0.68 * h);
  4432. }
  4433. else if (switchState == '3')
  4434. {
  4435. c.moveTo(0.7 * w, 0.32 * h);
  4436. c.arcTo(0.25 * w, 0.25 * h, 0, 0, 0, 0.7 * w, 0.68 * h);
  4437. c.moveTo(0.3 * w, 0.32 * h);
  4438. c.arcTo(0.25 * w, 0.25 * h, 0, 0, 1, 0.3 * w, 0.68 * h);
  4439. c.moveTo(0.37 * w, 0.46 * h);
  4440. c.lineTo(0.63 * w, 0.46 * h);
  4441. c.moveTo(0.37 * w, 0.54 * h);
  4442. c.lineTo(0.63 * w, 0.54 * h);
  4443. c.moveTo(0.5 * w, 0.26 * h);
  4444. c.lineTo(0.5 * w, 0.74 * h);
  4445. }
  4446. else
  4447. {
  4448. c.moveTo(0.76 * w, 0.5 * h);
  4449. c.arcTo(0.27 * w, 0.27 * h, 0, 0, 0, 0.5 * w, 0.78 * h);
  4450. c.moveTo(0.24 * w, 0.5 * h);
  4451. c.arcTo(0.27 * w, 0.27 * h, 0, 0, 0, 0.5 * w, 0.22 * h);
  4452. c.moveTo(0.61 * w, 0.56 * h);
  4453. c.lineTo(0.45 * w, 0.39 * h);
  4454. c.moveTo(0.61 * w, 0.56 * h);
  4455. c.lineTo(0.45 * w, 0.39 * h);
  4456. c.moveTo(0.39 * w, 0.44 * h);
  4457. c.lineTo(0.55 * w, 0.61 * h);
  4458. c.moveTo(0.39 * w, 0.44 * h);
  4459. c.lineTo(0.55 * w, 0.61 * h);
  4460. c.moveTo(0.68 * w, 0.32 * h);
  4461. c.lineTo(0.32 * w, 0.68 * h);
  4462. }
  4463. c.stroke();
  4464. c.ellipse(0.2 * w, 0.4575 * h, 0.08 * w, 0.085 * h);
  4465. c.fillAndStroke();
  4466. c.ellipse(0.72 * w, 0.4575 * h, 0.08 * w, 0.085 * h);
  4467. c.fillAndStroke();
  4468. c.ellipse(0.46 * w, 0.18 * h, 0.08 * w, 0.085 * h);
  4469. c.fillAndStroke();
  4470. c.ellipse(0.46 * w, 0.735 * h, 0.08 * w, 0.085 * h);
  4471. c.fillAndStroke();
  4472. var strokeColor = mxUtils.getValue(this.style, mxConstants.STYLE_STROKECOLOR, '#000000');
  4473. c.setFillColor(strokeColor);
  4474. c.begin();
  4475. c.moveTo(0.367 * w, 0.1 * h);
  4476. c.lineTo(0.367 * w, 0.185 * h);
  4477. c.lineTo(0.44 * w, 0.1425 * h);
  4478. c.close();
  4479. c.moveTo(0.205 * w, 0.355 * h);
  4480. c.lineTo(0.125 * w, 0.355 * h);
  4481. c.lineTo(0.165 * w, 0.435 * h);
  4482. c.close();
  4483. c.fillAndStroke();
  4484. };
  4485. mxCellRenderer.registerShape(mxShapeElectricalFourPositionSwitch2.prototype.cst.SHAPE_FOUR_POSITION_SWITCH_2, mxShapeElectricalFourPositionSwitch2);
  4486. mxShapeElectricalFourPositionSwitch2.prototype.constraints = [
  4487. new mxConnectionConstraint(new mxPoint(0, 0.5), true),
  4488. new mxConnectionConstraint(new mxPoint(1, 0.5), true),
  4489. new mxConnectionConstraint(new mxPoint(0.5, 0), true),
  4490. new mxConnectionConstraint(new mxPoint(0.5, 1), true)
  4491. ];
  4492. //**********************************************************************************************************************************************************
  4493. // Pushubutton Make Switch 2
  4494. //**********************************************************************************************************************************************************
  4495. /**
  4496. * Extends mxShape.
  4497. */
  4498. function mxShapeElectricalPushbuttonMakeSwitch2(bounds, fill, stroke, strokewidth)
  4499. {
  4500. mxShape.call(this);
  4501. this.bounds = bounds;
  4502. this.fill = fill;
  4503. this.stroke = stroke;
  4504. this.strokewidth = (strokewidth != null) ? strokewidth : 1;
  4505. };
  4506. /**
  4507. * Extends mxShape.
  4508. */
  4509. mxUtils.extend(mxShapeElectricalPushbuttonMakeSwitch2, mxShape);
  4510. mxShapeElectricalPushbuttonMakeSwitch2.prototype.cst = {
  4511. SHAPE_PUSHBUTTON_MAKE_SWITCH_2 : 'mxgraph.electrical.electro-mechanical.pushbuttonMakeSwitch2'
  4512. };
  4513. mxShapeElectricalPushbuttonMakeSwitch2.prototype.customProperties = [
  4514. {name: 'elSwitchState', dispName: 'Switch State', type: 'enum', defVal: '1',
  4515. enumList:[
  4516. {val:'1', dispName:'1'},
  4517. {val:'2', dispName:'2'}
  4518. ]}
  4519. ];
  4520. /**
  4521. * Function: paintVertexShape
  4522. *
  4523. * Paints the vertex shape.
  4524. */
  4525. mxShapeElectricalPushbuttonMakeSwitch2.prototype.paintVertexShape = function(c, x, y, w, h)
  4526. {
  4527. c.translate(x, y);
  4528. var switchState = mxUtils.getValue(this.style, 'elSwitchState', '1');
  4529. c.begin();
  4530. c.moveTo(0, 0.94 * h);
  4531. c.lineTo(0.2 * w, 0.94 * h);
  4532. c.moveTo(0.8 * w, 0.94 * h);
  4533. c.lineTo(w, 0.94 * h);
  4534. if (switchState == '1')
  4535. {
  4536. c.moveTo(0.5 * w, 0);
  4537. c.lineTo(0.5 * w, 0.8 * h);
  4538. c.moveTo(0.24 * w, 0.8 * h);
  4539. c.lineTo(0.76 * w, 0.8 * h);
  4540. }
  4541. else
  4542. {
  4543. c.moveTo(0.5 * w, 0.07 * h);
  4544. c.lineTo(0.5 * w, 0.87 * h);
  4545. c.moveTo(0.24 * w, 0.87 * h);
  4546. c.lineTo(0.76 * w, 0.87 * h);
  4547. }
  4548. c.stroke();
  4549. c.ellipse(0.2 * w, 0.88 * h, 0.08 * w, 0.12 * h);
  4550. c.fillAndStroke();
  4551. c.ellipse(0.72 * w, 0.88 * h, 0.08 * w, 0.12 * h);
  4552. c.fillAndStroke();
  4553. };
  4554. mxCellRenderer.registerShape(mxShapeElectricalPushbuttonMakeSwitch2.prototype.cst.SHAPE_PUSHBUTTON_MAKE_SWITCH_2, mxShapeElectricalPushbuttonMakeSwitch2);
  4555. mxShapeElectricalPushbuttonMakeSwitch2.prototype.constraints = [
  4556. new mxConnectionConstraint(new mxPoint(0, 0.94), true),
  4557. new mxConnectionConstraint(new mxPoint(1, 0.94), true)
  4558. ];
  4559. //**********************************************************************************************************************************************************
  4560. // Pushubutton Two-Circuit Switch 2
  4561. //**********************************************************************************************************************************************************
  4562. /**
  4563. * Extends mxShape.
  4564. */
  4565. function mxShapeElectricalPushbuttonTwoCircuitSwitch2(bounds, fill, stroke, strokewidth)
  4566. {
  4567. mxShape.call(this);
  4568. this.bounds = bounds;
  4569. this.fill = fill;
  4570. this.stroke = stroke;
  4571. this.strokewidth = (strokewidth != null) ? strokewidth : 1;
  4572. };
  4573. /**
  4574. * Extends mxShape.
  4575. */
  4576. mxUtils.extend(mxShapeElectricalPushbuttonTwoCircuitSwitch2, mxShape);
  4577. mxShapeElectricalPushbuttonTwoCircuitSwitch2.prototype.cst = {
  4578. SHAPE_PUSHBUTTON_TWO_CIRCUIT_SWITCH_2 : 'mxgraph.electrical.electro-mechanical.pushbuttonTwoCircuitSwitch2'
  4579. };
  4580. mxShapeElectricalPushbuttonTwoCircuitSwitch2.prototype.customProperties = [
  4581. {name: 'elSwitchState', dispName: 'Switch State', type: 'enum', defVal: '1',
  4582. enumList:[
  4583. {val:'1', dispName:'1'},
  4584. {val:'2', dispName:'2'}
  4585. ]}
  4586. ];
  4587. /**
  4588. * Function: paintVertexShape
  4589. *
  4590. * Paints the vertex shape.
  4591. */
  4592. mxShapeElectricalPushbuttonTwoCircuitSwitch2.prototype.paintVertexShape = function(c, x, y, w, h)
  4593. {
  4594. c.translate(x, y);
  4595. var switchState = mxUtils.getValue(this.style, 'elSwitchState', '1');
  4596. c.begin();
  4597. c.moveTo(0, 0.68 * h);
  4598. c.lineTo(0.2 * w, 0.68 * h);
  4599. c.moveTo(0.8 * w, 0.68 * h);
  4600. c.lineTo(w, 0.68 * h);
  4601. c.moveTo(0, 0.96 * h);
  4602. c.lineTo(0.2 * w, 0.96 * h);
  4603. c.moveTo(0.8 * w, 0.96 * h);
  4604. c.lineTo(w, 0.96 * h);
  4605. if (switchState == '1')
  4606. {
  4607. c.moveTo(0.5 * w, 0);
  4608. c.lineTo(0.5 * w, 0.73 * h);
  4609. c.moveTo(0.24 * w, 0.73 * h);
  4610. c.lineTo(0.76 * w, 0.73 * h);
  4611. }
  4612. else
  4613. {
  4614. c.moveTo(0.5 * w, 0.18 * h);
  4615. c.lineTo(0.5 * w, 0.91 * h);
  4616. c.moveTo(0.24 * w, 0.91 * h);
  4617. c.lineTo(0.76 * w, 0.91 * h);
  4618. }
  4619. c.stroke();
  4620. c.ellipse(0.2 * w, 0.92 * h, 0.08 * w, 0.08 * h);
  4621. c.fillAndStroke();
  4622. c.ellipse(0.72 * w, 0.92 * h, 0.08 * w, 0.08 * h);
  4623. c.fillAndStroke();
  4624. c.ellipse(0.2 * w, 0.64 * h, 0.08 * w, 0.08 * h);
  4625. c.fillAndStroke();
  4626. c.ellipse(0.72 * w, 0.64 * h, 0.08 * w, 0.08 * h);
  4627. c.fillAndStroke();
  4628. };
  4629. mxCellRenderer.registerShape(mxShapeElectricalPushbuttonTwoCircuitSwitch2.prototype.cst.SHAPE_PUSHBUTTON_TWO_CIRCUIT_SWITCH_2, mxShapeElectricalPushbuttonTwoCircuitSwitch2);
  4630. mxShapeElectricalPushbuttonTwoCircuitSwitch2.prototype.constraints = [
  4631. new mxConnectionConstraint(new mxPoint(0, 0.68), true),
  4632. new mxConnectionConstraint(new mxPoint(1, 0.68), true),
  4633. new mxConnectionConstraint(new mxPoint(0, 0.96), true),
  4634. new mxConnectionConstraint(new mxPoint(1, 0.96), true)
  4635. ];
  4636. //**********************************************************************************************************************************************************
  4637. // Time Delay Switch
  4638. //**********************************************************************************************************************************************************
  4639. /**
  4640. * Extends mxShape.
  4641. */
  4642. function mxShapeElectricalTimeDelaySwitch(bounds, fill, stroke, strokewidth)
  4643. {
  4644. mxShape.call(this);
  4645. this.bounds = bounds;
  4646. this.fill = fill;
  4647. this.stroke = stroke;
  4648. this.strokewidth = (strokewidth != null) ? strokewidth : 1;
  4649. };
  4650. /**
  4651. * Extends mxShape.
  4652. */
  4653. mxUtils.extend(mxShapeElectricalTimeDelaySwitch, mxShape);
  4654. mxShapeElectricalTimeDelaySwitch.prototype.cst = {
  4655. SHAPE_TIME_DELAY_SWITCH : 'mxgraph.electrical.electro-mechanical.timeDelaySwitch'
  4656. };
  4657. mxShapeElectricalTimeDelaySwitch.prototype.customProperties = [
  4658. {name: 'elSwitchState', dispName: 'Switch State', type: 'enum', defVal: 'on',
  4659. enumList:[
  4660. {val:'on', dispName:'On'},
  4661. {val:'off', dispName:'Off'}
  4662. ]}
  4663. ];
  4664. /**
  4665. * Function: paintVertexShape
  4666. *
  4667. * Paints the vertex shape.
  4668. */
  4669. mxShapeElectricalTimeDelaySwitch.prototype.paintVertexShape = function(c, x, y, w, h)
  4670. {
  4671. c.translate(x, y);
  4672. var switchState = mxUtils.getValue(this.style, 'elSwitchState', 'off');
  4673. c.begin();
  4674. c.moveTo(0, 0.13 * h);
  4675. c.lineTo(0.2 * w, 0.13 * h);
  4676. c.moveTo(0.8 * w, 0.13 * h);
  4677. c.lineTo(w, 0.13 * h);
  4678. if (switchState == 'off')
  4679. {
  4680. c.moveTo(0.5 * w, 0.37 * h);
  4681. c.lineTo(0.5 * w, 0.83 * h);
  4682. c.moveTo(0.28 * w, 0.16 * h);
  4683. c.lineTo(0.76 * w, 0.62 * h);
  4684. c.moveTo(0.44 * w, h);
  4685. c.lineTo(0.5 * w, 0.83 * h);
  4686. c.lineTo(0.56 * w, h);
  4687. }
  4688. else
  4689. {
  4690. c.moveTo(0.5 * w, 0.04 * h);
  4691. c.lineTo(0.5 * w, 0.5 * h);
  4692. c.moveTo(0.28 * w, 0.09 * h);
  4693. c.lineTo(0.76 * w, 0);
  4694. c.moveTo(0.44 * w, 0.67 * h);
  4695. c.lineTo(0.5 * w, 0.5 * h);
  4696. c.lineTo(0.56 * w, 0.67 * h);
  4697. }
  4698. c.stroke();
  4699. c.ellipse(0.2 * w, 0.03 * h, 0.08 * w, 0.19 * h);
  4700. c.fillAndStroke();
  4701. c.ellipse(0.72 * w, 0.03 * h, 0.08 * w, 0.19 * h);
  4702. c.fillAndStroke();
  4703. };
  4704. mxCellRenderer.registerShape(mxShapeElectricalTimeDelaySwitch.prototype.cst.SHAPE_TIME_DELAY_SWITCH, mxShapeElectricalTimeDelaySwitch);
  4705. mxShapeElectricalTimeDelaySwitch.prototype.constraints = [
  4706. new mxConnectionConstraint(new mxPoint(0, 0.13), true),
  4707. new mxConnectionConstraint(new mxPoint(1, 0.13), true)
  4708. ];
  4709. //**********************************************************************************************************************************************************
  4710. // Time Delay Switch 2
  4711. //**********************************************************************************************************************************************************
  4712. /**
  4713. * Extends mxShape.
  4714. */
  4715. function mxShapeElectricalTimeDelaySwitch2(bounds, fill, stroke, strokewidth)
  4716. {
  4717. mxShape.call(this);
  4718. this.bounds = bounds;
  4719. this.fill = fill;
  4720. this.stroke = stroke;
  4721. this.strokewidth = (strokewidth != null) ? strokewidth : 1;
  4722. };
  4723. /**
  4724. * Extends mxShape.
  4725. */
  4726. mxUtils.extend(mxShapeElectricalTimeDelaySwitch2, mxShape);
  4727. mxShapeElectricalTimeDelaySwitch2.prototype.cst = {
  4728. SHAPE_TIME_DELAY_SWITCH2 : 'mxgraph.electrical.electro-mechanical.timeDelaySwitch2'
  4729. };
  4730. mxShapeElectricalTimeDelaySwitch2.prototype.customProperties = [
  4731. {name: 'elSwitchState', dispName: 'Switch State', type: 'enum', defVal: 'on',
  4732. enumList:[
  4733. {val:'on', dispName:'On'},
  4734. {val:'off', dispName:'Off'}
  4735. ]}
  4736. ];
  4737. /**
  4738. * Function: paintVertexShape
  4739. *
  4740. * Paints the vertex shape.
  4741. */
  4742. mxShapeElectricalTimeDelaySwitch2.prototype.paintVertexShape = function(c, x, y, w, h)
  4743. {
  4744. c.translate(x, y);
  4745. var switchState = mxUtils.getValue(this.style, 'elSwitchState', 'off');
  4746. c.begin();
  4747. c.moveTo(0, 0.45 * h);
  4748. c.lineTo(0.23 * w, 0.45 * h);
  4749. if (switchState == 'off')
  4750. {
  4751. c.lineTo(0.75 * w, 0);
  4752. c.moveTo(w, 0.45 * h);
  4753. c.lineTo(0.8 * w, 0.45 * h);
  4754. c.moveTo(0.465 * w, 0.25 * h);
  4755. c.lineTo(0.465 * w, 0.76 * h);
  4756. c.moveTo(0.535 * w, 0.19 * h);
  4757. c.lineTo(0.535 * w, 0.76 * h);
  4758. c.moveTo(0.4 * w, 0.89 * h);
  4759. c.arcTo(0.11 * w, 0.25 * h, 0, 0, 1, 0.6 * w, 0.89 * h);
  4760. }
  4761. else
  4762. {
  4763. c.lineTo(0.73 * w, 0.25 * h);
  4764. c.moveTo(w, 0.45 * h);
  4765. c.lineTo(0.67 * w, 0.45 * h);
  4766. c.lineTo(0.67 * w, 0.16 * h);
  4767. c.moveTo(0.465 * w, 0.36 * h);
  4768. c.lineTo(0.465 * w, 0.87 * h);
  4769. c.moveTo(0.535 * w, 0.33 * h);
  4770. c.lineTo(0.535 * w, 0.87 * h);
  4771. c.moveTo(0.4 * w, h);
  4772. c.arcTo(0.11 * w, 0.25 * h, 0, 0, 1, 0.6 * w, h);
  4773. }
  4774. c.stroke();
  4775. };
  4776. mxCellRenderer.registerShape(mxShapeElectricalTimeDelaySwitch2.prototype.cst.SHAPE_TIME_DELAY_SWITCH2, mxShapeElectricalTimeDelaySwitch2);
  4777. mxShapeElectricalTimeDelaySwitch2.prototype.constraints = [
  4778. new mxConnectionConstraint(new mxPoint(0, 0.45), true),
  4779. new mxConnectionConstraint(new mxPoint(1, 0.45), true)
  4780. ];
  4781. //**********************************************************************************************************************************************************
  4782. // Isolator Switch 2
  4783. //**********************************************************************************************************************************************************
  4784. /**
  4785. * Extends mxShape.
  4786. */
  4787. function mxShapeElectricalIsolatorSwitch2(bounds, fill, stroke, strokewidth)
  4788. {
  4789. mxShape.call(this);
  4790. this.bounds = bounds;
  4791. this.fill = fill;
  4792. this.stroke = stroke;
  4793. this.strokewidth = (strokewidth != null) ? strokewidth : 1;
  4794. };
  4795. /**
  4796. * Extends mxShape.
  4797. */
  4798. mxUtils.extend(mxShapeElectricalIsolatorSwitch2, mxShape);
  4799. mxShapeElectricalIsolatorSwitch2.prototype.cst = {
  4800. SHAPE_ISOLATOR_SWITCH2 : 'mxgraph.electrical.electro-mechanical.isolatorSwitch2'
  4801. };
  4802. mxShapeElectricalIsolatorSwitch2.prototype.customProperties = [
  4803. {name: 'elSwitchState', dispName: 'Switch State', type: 'enum', defVal: 'on',
  4804. enumList:[
  4805. {val:'on', dispName:'On'},
  4806. {val:'off', dispName:'Off'}
  4807. ]}
  4808. ];
  4809. /**
  4810. * Function: paintVertexShape
  4811. *
  4812. * Paints the vertex shape.
  4813. */
  4814. mxShapeElectricalIsolatorSwitch2.prototype.paintVertexShape = function(c, x, y, w, h)
  4815. {
  4816. c.translate(x, y);
  4817. var switchState = mxUtils.getValue(this.style, 'elSwitchState', 'off');
  4818. c.begin();
  4819. c.moveTo(w, 0.8 * h);
  4820. c.lineTo(0.8 * w, 0.8 * h);
  4821. c.moveTo(0.8 * w, 0.6 * h);
  4822. c.lineTo(0.8 * w, h);
  4823. c.moveTo(0, 0.8 * h);
  4824. c.lineTo(0.23 * w, 0.8 * h);
  4825. if (switchState == 'off')
  4826. {
  4827. c.lineTo(0.75 * w, 0);
  4828. }
  4829. else
  4830. {
  4831. c.lineTo(0.8 * w, 0.8 * h);
  4832. }
  4833. c.stroke();
  4834. };
  4835. mxCellRenderer.registerShape(mxShapeElectricalIsolatorSwitch2.prototype.cst.SHAPE_ISOLATOR_SWITCH2, mxShapeElectricalIsolatorSwitch2);
  4836. mxShapeElectricalIsolatorSwitch2.prototype.constraints = [
  4837. new mxConnectionConstraint(new mxPoint(0, 0.8), true),
  4838. new mxConnectionConstraint(new mxPoint(1, 0.8), true)
  4839. ];
  4840. //**********************************************************************************************************************************************************
  4841. // Isolator Switch 2
  4842. //**********************************************************************************************************************************************************
  4843. /**
  4844. * Extends mxShape.
  4845. */
  4846. function mxShapeElectricalChangeoverContactSwitch2(bounds, fill, stroke, strokewidth)
  4847. {
  4848. mxShape.call(this);
  4849. this.bounds = bounds;
  4850. this.fill = fill;
  4851. this.stroke = stroke;
  4852. this.strokewidth = (strokewidth != null) ? strokewidth : 1;
  4853. };
  4854. /**
  4855. * Extends mxShape.
  4856. */
  4857. mxUtils.extend(mxShapeElectricalChangeoverContactSwitch2, mxShape);
  4858. mxShapeElectricalChangeoverContactSwitch2.prototype.cst = {
  4859. SHAPE_CHANGEOVER_CONTACT_SWITCH2 : 'mxgraph.electrical.electro-mechanical.changeoverContactSwitch2'
  4860. };
  4861. mxShapeElectricalChangeoverContactSwitch2.prototype.customProperties = [
  4862. {name: 'elSwitchState', dispName: 'Switch State', type: 'enum', defVal: '1',
  4863. enumList:[
  4864. {val:'1', dispName:'1'},
  4865. {val:'2', dispName:'2'}
  4866. ]}
  4867. ];
  4868. /**
  4869. * Function: paintVertexShape
  4870. *
  4871. * Paints the vertex shape.
  4872. */
  4873. mxShapeElectricalChangeoverContactSwitch2.prototype.paintVertexShape = function(c, x, y, w, h)
  4874. {
  4875. c.translate(x, y);
  4876. var switchState = mxUtils.getValue(this.style, 'elSwitchState', '1');
  4877. c.begin();
  4878. c.moveTo(0, h);
  4879. c.lineTo(0.25 * w, h);
  4880. if (switchState == '1')
  4881. {
  4882. c.lineTo(0.76 * w, 0.2 * h);
  4883. c.moveTo(w, 0);
  4884. c.lineTo(0.67 * w, 0);
  4885. c.lineTo(0.67 * w, 0.5 * h);
  4886. c.moveTo(w, h);
  4887. c.lineTo(0.8 * w, h);
  4888. }
  4889. else
  4890. {
  4891. c.lineTo(0.77 * w, 0.6 * h);
  4892. c.moveTo(w, h);
  4893. c.lineTo(0.67 * w, h);
  4894. c.lineTo(0.67 * w, 0.5 * h);
  4895. c.moveTo(w, 0);
  4896. c.lineTo(0.8 * w, 0);
  4897. }
  4898. c.stroke();
  4899. };
  4900. mxCellRenderer.registerShape(mxShapeElectricalChangeoverContactSwitch2.prototype.cst.SHAPE_CHANGEOVER_CONTACT_SWITCH2, mxShapeElectricalChangeoverContactSwitch2);
  4901. mxShapeElectricalChangeoverContactSwitch2.prototype.constraints = [
  4902. new mxConnectionConstraint(new mxPoint(0, 0.8), true),
  4903. new mxConnectionConstraint(new mxPoint(0, 0.8), true),
  4904. new mxConnectionConstraint(new mxPoint(1, 0.8), true)
  4905. ];
  4906. //**********************************************************************************************************************************************************
  4907. // Reed Switch 2
  4908. //**********************************************************************************************************************************************************
  4909. /**
  4910. * Extends mxShape.
  4911. */
  4912. function mxShapeElectricalReedSwitch2(bounds, fill, stroke, strokewidth)
  4913. {
  4914. mxShape.call(this);
  4915. this.bounds = bounds;
  4916. this.fill = fill;
  4917. this.stroke = stroke;
  4918. this.strokewidth = (strokewidth != null) ? strokewidth : 1;
  4919. };
  4920. /**
  4921. * Extends mxShape.
  4922. */
  4923. mxUtils.extend(mxShapeElectricalReedSwitch2, mxShape);
  4924. mxShapeElectricalReedSwitch2.prototype.cst = {
  4925. SHAPE_REED_SWITCH2 : 'mxgraph.electrical.electro-mechanical.reedSwitch2'
  4926. };
  4927. mxShapeElectricalReedSwitch2.prototype.customProperties = [
  4928. {name: 'elSwitchState', dispName: 'Switch State', type: 'enum', defVal: 'on',
  4929. enumList:[
  4930. {val:'on', dispName:'On'},
  4931. {val:'off', dispName:'Off'}
  4932. ]}
  4933. ];
  4934. /**
  4935. * Function: paintVertexShape
  4936. *
  4937. * Paints the vertex shape.
  4938. */
  4939. mxShapeElectricalReedSwitch2.prototype.paintVertexShape = function(c, x, y, w, h)
  4940. {
  4941. c.translate(x, y);
  4942. var switchState = mxUtils.getValue(this.style, 'elSwitchState', 'off');
  4943. c.begin();
  4944. c.moveTo(0.69 * w, 0);
  4945. c.arcTo(0.13 * w, 0.5 * h, 0, 0, 1, 0.82 * w, 0.5 * h);
  4946. c.arcTo(0.13 * w, 0.5 * h, 0, 0, 1, 0.69 * w, h);
  4947. c.lineTo(0.31 * w, h);
  4948. c.arcTo(0.13 * w, 0.5 * h, 0, 0, 1, 0.18 * w, 0.5 * h);
  4949. c.arcTo(0.13 * w, 0.5 * h, 0, 0, 1, 0.31 * w, 0);
  4950. c.close();
  4951. c.fillAndStroke();
  4952. c.begin();
  4953. c.moveTo(w, 0.5 * h);
  4954. c.lineTo(0.65 * w, 0.5 * h);
  4955. c.moveTo(0, 0.5 * h);
  4956. c.lineTo(0.35 * w, 0.5 * h);
  4957. if (switchState == 'on')
  4958. {
  4959. c.lineTo(0.65 * w, 0.5 * h);
  4960. }
  4961. else
  4962. {
  4963. c.lineTo(0.65 * w, 0.25 * h);
  4964. }
  4965. c.stroke();
  4966. };
  4967. mxCellRenderer.registerShape(mxShapeElectricalReedSwitch2.prototype.cst.SHAPE_REED_SWITCH2, mxShapeElectricalReedSwitch2);
  4968. mxShapeElectricalReedSwitch2.prototype.constraints = [
  4969. new mxConnectionConstraint(new mxPoint(0, 0.5), true),
  4970. new mxConnectionConstraint(new mxPoint(1, 0.5), true)
  4971. ];