mxElectrical.js 154 KB

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