mxFloorplan.js 47 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620162116221623162416251626162716281629163016311632163316341635163616371638163916401641164216431644164516461647164816491650165116521653165416551656165716581659166016611662166316641665166616671668166916701671167216731674167516761677167816791680168116821683168416851686168716881689169016911692169316941695169616971698169917001701170217031704170517061707170817091710171117121713171417151716171717181719172017211722172317241725172617271728172917301731173217331734173517361737173817391740174117421743174417451746174717481749175017511752175317541755175617571758175917601761176217631764176517661767176817691770177117721773177417751776177717781779
  1. /**
  2. * Copyright (c) 2006-2014, JGraph Holdings Ltd
  3. */
  4. //**********************************************************************************************************************************************************
  5. //Wall
  6. //**********************************************************************************************************************************************************
  7. /**
  8. * Extends mxShape.
  9. */
  10. function mxFloorplanWall(bounds, fill, stroke, strokewidth)
  11. {
  12. mxShape.call(this);
  13. this.bounds = bounds;
  14. this.fill = fill;
  15. this.stroke = stroke;
  16. this.strokewidth = (strokewidth != null) ? strokewidth : 1;
  17. };
  18. /**
  19. * Extends mxShape.
  20. */
  21. mxUtils.extend(mxFloorplanWall, mxShape);
  22. mxFloorplanWall.prototype.cst = {
  23. WALL : 'mxgraph.floorplan.wall',
  24. WALL_THICKNESS : "wallThickness"
  25. };
  26. mxFloorplanWall.prototype.customProperties = [
  27. {name:'wallThickness', dispName:'Thickness', type:'float', min:0, defVal:10}
  28. ];
  29. /**
  30. * Function: paintVertexShape
  31. *
  32. * Paints the vertex shape.
  33. */
  34. mxFloorplanWall.prototype.paintVertexShape = function(c, x, y, w, h)
  35. {
  36. c.translate(x, y);
  37. this.background(c, x, y, w, h);
  38. };
  39. mxFloorplanWall.prototype.background = function(c, x, y, w, h)
  40. {
  41. var wallTh = parseFloat(mxUtils.getValue(this.style, mxFloorplanWall.prototype.cst.WALL_THICKNESS, '10'));
  42. c.rect(0, h * 0.5 - wallTh * 0.5, w, wallTh);
  43. c.fillAndStroke();
  44. };
  45. mxCellRenderer.registerShape(mxFloorplanWall.prototype.cst.WALL, mxFloorplanWall);
  46. //**********************************************************************************************************************************************************
  47. //Wall Corner
  48. //**********************************************************************************************************************************************************
  49. /**
  50. * Extends mxShape.
  51. */
  52. function mxFloorplanWallCorner(bounds, fill, stroke, strokewidth)
  53. {
  54. mxShape.call(this);
  55. this.bounds = bounds;
  56. this.fill = fill;
  57. this.stroke = stroke;
  58. this.strokewidth = (strokewidth != null) ? strokewidth : 1;
  59. };
  60. /**
  61. * Extends mxShape.
  62. */
  63. mxUtils.extend(mxFloorplanWallCorner, mxShape);
  64. mxFloorplanWallCorner.prototype.cst = {
  65. WALL_CORNER : 'mxgraph.floorplan.wallCorner',
  66. WALL_THICKNESS : "wallThickness"
  67. };
  68. mxFloorplanWallCorner.prototype.customProperties = [
  69. {name:'wallThickness', dispName:'Thickness', type:'float', min:0, defVal:10}
  70. ];
  71. /**
  72. * Function: paintVertexShape
  73. *
  74. * Paints the vertex shape.
  75. */
  76. mxFloorplanWallCorner.prototype.paintVertexShape = function(c, x, y, w, h)
  77. {
  78. c.translate(x, y);
  79. this.background(c, x, y, w, h);
  80. };
  81. mxFloorplanWallCorner.prototype.background = function(c, x, y, w, h)
  82. {
  83. var wallTh = parseFloat(mxUtils.getValue(this.style, mxFloorplanWallCorner.prototype.cst.WALL_THICKNESS, '10'));
  84. c.begin();
  85. c.moveTo(0, h);
  86. c.lineTo(0, 0);
  87. c.lineTo(w, 0);
  88. c.lineTo(w, wallTh);
  89. c.lineTo(wallTh, wallTh);
  90. c.lineTo(wallTh, h);
  91. c.close();
  92. c.fillAndStroke();
  93. };
  94. mxCellRenderer.registerShape(mxFloorplanWallCorner.prototype.cst.WALL_CORNER, mxFloorplanWallCorner);
  95. //**********************************************************************************************************************************************************
  96. //Wall U
  97. //**********************************************************************************************************************************************************
  98. /**
  99. * Extends mxShape.
  100. */
  101. function mxFloorplanWallU(bounds, fill, stroke, strokewidth)
  102. {
  103. mxShape.call(this);
  104. this.bounds = bounds;
  105. this.fill = fill;
  106. this.stroke = stroke;
  107. this.strokewidth = (strokewidth != null) ? strokewidth : 1;
  108. };
  109. /**
  110. * Extends mxShape.
  111. */
  112. mxUtils.extend(mxFloorplanWallU, mxShape);
  113. mxFloorplanWallU.prototype.cst = {
  114. WALL_U : 'mxgraph.floorplan.wallU',
  115. WALL_THICKNESS : "wallThickness"
  116. };
  117. mxFloorplanWallU.prototype.customProperties = [
  118. {name:'wallThickness', dispName:'Thickness', type:'float', min:0, defVal:10}
  119. ];
  120. /**
  121. * Function: paintVertexShape
  122. *
  123. * Paints the vertex shape.
  124. */
  125. mxFloorplanWallU.prototype.paintVertexShape = function(c, x, y, w, h)
  126. {
  127. c.translate(x, y);
  128. this.background(c, x, y, w, h);
  129. };
  130. mxFloorplanWallU.prototype.background = function(c, x, y, w, h)
  131. {
  132. var wallTh = parseFloat(mxUtils.getValue(this.style, mxFloorplanWallU.prototype.cst.WALL_THICKNESS, '10'));
  133. c.begin();
  134. c.moveTo(0, h);
  135. c.lineTo(0, 0);
  136. c.lineTo(w, 0);
  137. c.lineTo(w, h);
  138. c.lineTo(w - wallTh, h);
  139. c.lineTo(w - wallTh, wallTh);
  140. c.lineTo(wallTh, wallTh);
  141. c.lineTo(wallTh, h);
  142. c.close();
  143. c.fillAndStroke();
  144. };
  145. mxCellRenderer.registerShape(mxFloorplanWallU.prototype.cst.WALL_U, mxFloorplanWallU);
  146. //**********************************************************************************************************************************************************
  147. //Room
  148. //**********************************************************************************************************************************************************
  149. /**
  150. * Extends mxShape.
  151. */
  152. function mxFloorplanRoom(bounds, fill, stroke, strokewidth)
  153. {
  154. mxShape.call(this);
  155. this.bounds = bounds;
  156. this.fill = fill;
  157. this.stroke = stroke;
  158. this.strokewidth = (strokewidth != null) ? strokewidth : 1;
  159. };
  160. /**
  161. * Extends mxShape.
  162. */
  163. mxUtils.extend(mxFloorplanRoom, mxShape);
  164. mxFloorplanRoom.prototype.cst = {
  165. ROOM : 'mxgraph.floorplan.room',
  166. WALL_THICKNESS : "wallThickness"
  167. };
  168. mxFloorplanRoom.prototype.customProperties = [
  169. {name:'wallThickness', dispName:'Thickness', type:'float', min:0, defVal:10}
  170. ];
  171. /**
  172. * Function: paintVertexShape
  173. *
  174. * Paints the vertex shape.
  175. */
  176. mxFloorplanRoom.prototype.paintVertexShape = function(c, x, y, w, h)
  177. {
  178. c.translate(x, y);
  179. this.background(c, x, y, w, h);
  180. };
  181. mxFloorplanRoom.prototype.background = function(c, x, y, w, h)
  182. {
  183. var wallTh = parseFloat(mxUtils.getValue(this.style, mxFloorplanRoom.prototype.cst.WALL_THICKNESS, '10'));
  184. c.begin();
  185. c.moveTo(0, h);
  186. c.lineTo(0, 0);
  187. c.lineTo(w, 0);
  188. c.lineTo(w, h);
  189. c.close();
  190. c.moveTo(wallTh, wallTh);
  191. c.lineTo(wallTh, h - wallTh);
  192. c.lineTo(w - wallTh, h - wallTh);
  193. c.lineTo(w - wallTh, wallTh);
  194. c.close();
  195. c.fillAndStroke();
  196. };
  197. mxCellRenderer.registerShape(mxFloorplanRoom.prototype.cst.ROOM, mxFloorplanRoom);
  198. //**********************************************************************************************************************************************************
  199. //Window
  200. //**********************************************************************************************************************************************************
  201. /**
  202. * Extends mxShape.
  203. */
  204. function mxFloorplanWindow(bounds, fill, stroke, strokewidth)
  205. {
  206. mxShape.call(this);
  207. this.bounds = bounds;
  208. this.fill = fill;
  209. this.stroke = stroke;
  210. this.strokewidth = (strokewidth != null) ? strokewidth : 1;
  211. };
  212. /**
  213. * Extends mxShape.
  214. */
  215. mxUtils.extend(mxFloorplanWindow, mxShape);
  216. mxFloorplanWindow.prototype.cst = {
  217. WINDOW : 'mxgraph.floorplan.window',
  218. WALL_THICKNESS : "wallThickness"
  219. };
  220. mxFloorplanWindow.prototype.customProperties = [
  221. {name:'wallThickness', dispName:'Thickness', type:'float', min:0, defVal:10}
  222. ];
  223. /**
  224. * Function: paintVertexShape
  225. *
  226. * Paints the vertex shape.
  227. */
  228. mxFloorplanWindow.prototype.paintVertexShape = function(c, x, y, w, h)
  229. {
  230. c.translate(x, y);
  231. this.background(c, x, y, w, h);
  232. };
  233. mxFloorplanWindow.prototype.background = function(c, x, y, w, h)
  234. {
  235. var wallTh = parseFloat(mxUtils.getValue(this.style, mxFloorplanWindow.prototype.cst.WALL_THICKNESS, '10'));
  236. c.rect(0, h * 0.5 - wallTh * 0.5, w, wallTh);
  237. c.fillAndStroke();
  238. c.begin();
  239. c.moveTo(0, h * 0.5);
  240. c.lineTo(w, h * 0.5);
  241. c.stroke();
  242. };
  243. mxCellRenderer.registerShape(mxFloorplanWindow.prototype.cst.WINDOW, mxFloorplanWindow);
  244. //**********************************************************************************************************************************************************
  245. //Dimension
  246. //**********************************************************************************************************************************************************
  247. /**
  248. * Extends mxShape.
  249. */
  250. function mxFloorplanDimension(bounds, fill, stroke, strokewidth)
  251. {
  252. mxShape.call(this);
  253. this.bounds = bounds;
  254. this.fill = fill;
  255. this.stroke = stroke;
  256. this.strokewidth = (strokewidth != null) ? strokewidth : 1;
  257. };
  258. /**
  259. * Extends mxShape.
  260. */
  261. mxUtils.extend(mxFloorplanDimension, mxShape);
  262. mxFloorplanDimension.prototype.cst = {
  263. DIMENSION : 'mxgraph.floorplan.dimension'
  264. };
  265. mxFloorplanDimension.prototype.customProperties = [
  266. {name:'wallThickness', dispName:'Thickness', type:'float', min:0, defVal:10}
  267. ];
  268. /**
  269. * Function: paintVertexShape
  270. *
  271. * Paints the vertex shape.
  272. */
  273. mxFloorplanDimension.prototype.paintVertexShape = function(c, x, y, w, h)
  274. {
  275. c.translate(x, y);
  276. this.background(c, x, y, w, h);
  277. };
  278. mxFloorplanDimension.prototype.background = function(c, x, y, w, h)
  279. {
  280. c.begin();
  281. c.moveTo(0, 20);
  282. c.lineTo(w, 20);
  283. c.moveTo(10, 15);
  284. c.lineTo(0, 20);
  285. c.lineTo(10, 25);
  286. c.moveTo(w - 10, 15);
  287. c.lineTo(w, 20);
  288. c.lineTo(w - 10, 25);
  289. c.moveTo(0, 15);
  290. c.lineTo(0, h);
  291. c.moveTo(w, 15);
  292. c.lineTo(w, h);
  293. c.stroke();
  294. };
  295. mxCellRenderer.registerShape(mxFloorplanDimension.prototype.cst.DIMENSION, mxFloorplanDimension);
  296. //**********************************************************************************************************************************************************
  297. //Dimension Bottom
  298. //**********************************************************************************************************************************************************
  299. /**
  300. * Extends mxShape.
  301. */
  302. function mxFloorplanDimensionBottom(bounds, fill, stroke, strokewidth)
  303. {
  304. mxShape.call(this);
  305. this.bounds = bounds;
  306. this.fill = fill;
  307. this.stroke = stroke;
  308. this.strokewidth = (strokewidth != null) ? strokewidth : 1;
  309. };
  310. /**
  311. * Extends mxShape.
  312. */
  313. mxUtils.extend(mxFloorplanDimensionBottom, mxShape);
  314. mxFloorplanDimensionBottom.prototype.cst = {
  315. DIMENSION : 'mxgraph.floorplan.dimensionBottom'
  316. };
  317. /**
  318. * Function: paintVertexShape
  319. *
  320. * Paints the vertex shape.
  321. */
  322. mxFloorplanDimensionBottom.prototype.paintVertexShape = function(c, x, y, w, h)
  323. {
  324. c.translate(x, y);
  325. this.background(c, x, y, w, h);
  326. };
  327. mxFloorplanDimensionBottom.prototype.background = function(c, x, y, w, h)
  328. {
  329. c.begin();
  330. c.moveTo(0, h - 20);
  331. c.lineTo(w, h - 20);
  332. c.moveTo(10, h - 15);
  333. c.lineTo(0, h - 20);
  334. c.lineTo(10, h - 25);
  335. c.moveTo(w - 10, h - 15);
  336. c.lineTo(w, h - 20);
  337. c.lineTo(w - 10, h - 25);
  338. c.moveTo(0, h - 15);
  339. c.lineTo(0, 0);
  340. c.moveTo(w, h - 15);
  341. c.lineTo(w, 0);
  342. c.stroke();
  343. };
  344. mxCellRenderer.registerShape(mxFloorplanDimensionBottom.prototype.cst.DIMENSION, mxFloorplanDimensionBottom);
  345. //**********************************************************************************************************************************************************
  346. //Stairs
  347. //**********************************************************************************************************************************************************
  348. /**
  349. * Extends mxShape.
  350. */
  351. function mxFloorplanStairs(bounds, fill, stroke, strokewidth)
  352. {
  353. mxShape.call(this);
  354. this.bounds = bounds;
  355. this.fill = fill;
  356. this.stroke = stroke;
  357. this.strokewidth = (strokewidth != null) ? strokewidth : 1;
  358. };
  359. /**
  360. * Extends mxShape.
  361. */
  362. mxUtils.extend(mxFloorplanStairs, mxShape);
  363. mxFloorplanStairs.prototype.cst = {
  364. STAIRS : 'mxgraph.floorplan.stairs'
  365. };
  366. /**
  367. * Function: paintVertexShape
  368. *
  369. * Paints the vertex shape.
  370. */
  371. mxFloorplanStairs.prototype.paintVertexShape = function(c, x, y, w, h)
  372. {
  373. c.translate(x, y);
  374. var minW = Math.max(w, 50);
  375. this.background(c, x, y, minW, h);
  376. };
  377. mxFloorplanStairs.prototype.background = function(c, x, y, w, h)
  378. {
  379. c.rect(0, 0, w, h);
  380. c.fillAndStroke();
  381. var step = 25;
  382. c.setShadow(false);
  383. c.begin();
  384. for (var i = 25; i < w; i = i + step)
  385. {
  386. c.moveTo(i, 0);
  387. c.lineTo(i, h);
  388. }
  389. c.stroke();
  390. c.begin();
  391. c.moveTo(0, h * 0.5);
  392. c.lineTo(w, h * 0.5);
  393. c.moveTo(w - step, 0);
  394. c.lineTo(w, h * 0.5);
  395. c.lineTo(w - step, h);
  396. c.stroke();
  397. };
  398. mxCellRenderer.registerShape(mxFloorplanStairs.prototype.cst.STAIRS, mxFloorplanStairs);
  399. ////**********************************************************************************************************************************************************
  400. ////Stairs Double
  401. ////**********************************************************************************************************************************************************
  402. ///**
  403. //* Extends mxShape.
  404. //*/
  405. //function mxFloorplanStairsRest(bounds, fill, stroke, strokewidth)
  406. //{
  407. // mxShape.call(this);
  408. // this.bounds = bounds;
  409. // this.fill = fill;
  410. // this.stroke = stroke;
  411. // this.strokewidth = (strokewidth != null) ? strokewidth : 1;
  412. //};
  413. //
  414. ///**
  415. //* Extends mxShape.
  416. //*/
  417. //mxUtils.extend(mxFloorplanStairsRest, mxShape);
  418. //
  419. //mxFloorplanStairsRest.prototype.cst = {
  420. // STAIRS : 'mxgraph.floorplan.stairsRest'
  421. //};
  422. //
  423. //
  424. //
  425. ///**
  426. //* Function: paintVertexShape
  427. //*
  428. //* Paints the vertex shape.
  429. //*/
  430. //mxFloorplanStairsRest.prototype.paintVertexShape = function(c, x, y, w, h)
  431. //{
  432. // c.translate(x, y);
  433. // var minW = Math.max(w, 50, h);
  434. // var minH = Math.min(w, h);
  435. // this.background(c, x, y, minW, h);
  436. //};
  437. //
  438. //mxFloorplanStairsRest.prototype.background = function(c, x, y, w, h)
  439. //{
  440. // c.rect(0, 0, w, h);
  441. // c.fillAndStroke();
  442. //
  443. // var step = 25;
  444. // c.setShadow(false);
  445. //
  446. // c.begin();
  447. //
  448. // for (var i = 25; i < w - h * 0.5; i = i + step)
  449. // {
  450. // c.moveTo(i, 0);
  451. // c.lineTo(i, h);
  452. // }
  453. //
  454. // c.stroke();
  455. //
  456. // c.begin();
  457. // c.moveTo(0, h * 0.5);
  458. // c.lineTo(w, h * 0.5);
  459. //
  460. // c.moveTo(w, 0);
  461. // c.lineTo(w - h * 0.5, h * 0.5);
  462. // c.lineTo(w, h);
  463. //
  464. // c.moveTo(w - h * 0.5, 0);
  465. // c.lineTo(w - h * 0.5, h);
  466. //
  467. // c.moveTo(0, h * 0.5);
  468. // c.lineTo(w, h * 0.5);
  469. // c.stroke();
  470. //};
  471. //
  472. //mxCellRenderer.registerShape(mxFloorplanStairsRest.prototype.cst.STAIRS, mxFloorplanStairsRest);
  473. //**********************************************************************************************************************************************************
  474. //Stairs
  475. //**********************************************************************************************************************************************************
  476. /**
  477. * Extends mxShape.
  478. */
  479. function mxFloorplanStairsRest(bounds, fill, stroke, strokewidth)
  480. {
  481. mxShape.call(this);
  482. this.bounds = bounds;
  483. this.fill = fill;
  484. this.stroke = stroke;
  485. this.strokewidth = (strokewidth != null) ? strokewidth : 1;
  486. };
  487. /**
  488. * Extends mxShape.
  489. */
  490. mxUtils.extend(mxFloorplanStairsRest, mxShape);
  491. mxFloorplanStairsRest.prototype.cst = {
  492. STAIRS : 'mxgraph.floorplan.stairsRest'
  493. };
  494. /**
  495. * Function: paintVertexShape
  496. *
  497. * Paints the vertex shape.
  498. */
  499. mxFloorplanStairsRest.prototype.paintVertexShape = function(c, x, y, w, h)
  500. {
  501. c.translate(x, y);
  502. var minW = Math.max(w, 50, h);
  503. var minH = Math.min(w, h);
  504. this.background(c, x, y, minW, h);
  505. };
  506. mxFloorplanStairsRest.prototype.background = function(c, x, y, w, h)
  507. {
  508. c.rect(0, 0, w, h);
  509. c.fillAndStroke();
  510. var step = 25;
  511. c.setShadow(false);
  512. c.begin();
  513. for (var i = 25; i < w - h * 0.5; i = i + step)
  514. {
  515. c.moveTo(i, 0);
  516. c.lineTo(i, h);
  517. }
  518. c.stroke();
  519. c.begin();
  520. c.moveTo(0, h * 0.5);
  521. c.lineTo(w, h * 0.5);
  522. c.moveTo(w, 0);
  523. c.lineTo(w - h * 0.5, h * 0.5);
  524. c.lineTo(w, h);
  525. c.moveTo(w - h * 0.5, 0);
  526. c.lineTo(w - h * 0.5, h);
  527. c.moveTo(0, h * 0.5);
  528. c.lineTo(w, h * 0.5);
  529. c.stroke();
  530. };
  531. mxCellRenderer.registerShape(mxFloorplanStairsRest.prototype.cst.STAIRS, mxFloorplanStairsRest);
  532. //**********************************************************************************************************************************************************
  533. //Door, Left
  534. //**********************************************************************************************************************************************************
  535. /**
  536. * Extends mxShape.
  537. */
  538. function mxFloorplanDoorLeft(bounds, fill, stroke, strokewidth)
  539. {
  540. mxShape.call(this);
  541. this.bounds = bounds;
  542. this.fill = fill;
  543. this.stroke = stroke;
  544. this.strokewidth = (strokewidth != null) ? strokewidth : 1;
  545. };
  546. /**
  547. * Extends mxShape.
  548. */
  549. mxUtils.extend(mxFloorplanDoorLeft, mxShape);
  550. mxFloorplanDoorLeft.prototype.cst = {
  551. DOOR_LEFT : 'mxgraph.floorplan.doorLeft'
  552. };
  553. /**
  554. * Function: paintVertexShape
  555. *
  556. * Paints the vertex shape.
  557. */
  558. mxFloorplanDoorLeft.prototype.paintVertexShape = function(c, x, y, w, h)
  559. {
  560. c.translate(x, y);
  561. this.background(c, x, y, w, h);
  562. };
  563. mxFloorplanDoorLeft.prototype.background = function(c, x, y, w, h)
  564. {
  565. c.rect(0, 0, w, 5);
  566. c.fillAndStroke();
  567. c.begin();
  568. c.moveTo(w, 5);
  569. c.arcTo(w, w, 0, 0, 1, 0, 5 + w);
  570. c.lineTo(0, 5);
  571. c.stroke();
  572. };
  573. mxCellRenderer.registerShape(mxFloorplanDoorLeft.prototype.cst.DOOR_LEFT, mxFloorplanDoorLeft);
  574. //**********************************************************************************************************************************************************
  575. //Door, Right
  576. //**********************************************************************************************************************************************************
  577. /**
  578. * Extends mxShape.
  579. */
  580. function mxFloorplanDoorRight(bounds, fill, stroke, strokewidth)
  581. {
  582. mxShape.call(this);
  583. this.bounds = bounds;
  584. this.fill = fill;
  585. this.stroke = stroke;
  586. this.strokewidth = (strokewidth != null) ? strokewidth : 1;
  587. };
  588. /**
  589. * Extends mxShape.
  590. */
  591. mxUtils.extend(mxFloorplanDoorRight, mxShape);
  592. mxFloorplanDoorRight.prototype.cst = {
  593. DOOR_RIGHT : 'mxgraph.floorplan.doorRight'
  594. };
  595. /**
  596. * Function: paintVertexShape
  597. *
  598. * Paints the vertex shape.
  599. */
  600. mxFloorplanDoorRight.prototype.paintVertexShape = function(c, x, y, w, h)
  601. {
  602. c.translate(x, y);
  603. this.background(c, x, y, w, h);
  604. };
  605. mxFloorplanDoorRight.prototype.background = function(c, x, y, w, h)
  606. {
  607. c.rect(0, 0, w, 5);
  608. c.fillAndStroke();
  609. c.begin();
  610. c.moveTo(0, 5);
  611. c.arcTo(w, w, 0, 0, 0, w, 5 + w);
  612. c.lineTo(w, 5);
  613. c.stroke();
  614. };
  615. mxCellRenderer.registerShape(mxFloorplanDoorRight.prototype.cst.DOOR_RIGHT, mxFloorplanDoorRight);
  616. //**********************************************************************************************************************************************************
  617. //Door, Double
  618. //**********************************************************************************************************************************************************
  619. /**
  620. * Extends mxShape.
  621. */
  622. function mxFloorplanDoorDouble(bounds, fill, stroke, strokewidth)
  623. {
  624. mxShape.call(this);
  625. this.bounds = bounds;
  626. this.fill = fill;
  627. this.stroke = stroke;
  628. this.strokewidth = (strokewidth != null) ? strokewidth : 1;
  629. };
  630. /**
  631. * Extends mxShape.
  632. */
  633. mxUtils.extend(mxFloorplanDoorDouble, mxShape);
  634. mxFloorplanDoorDouble.prototype.cst = {
  635. DOOR_DOUBLE : 'mxgraph.floorplan.doorDouble'
  636. };
  637. /**
  638. * Function: paintVertexShape
  639. *
  640. * Paints the vertex shape.
  641. */
  642. mxFloorplanDoorDouble.prototype.paintVertexShape = function(c, x, y, w, h)
  643. {
  644. c.translate(x, y);
  645. this.background(c, x, y, w, h);
  646. };
  647. mxFloorplanDoorDouble.prototype.background = function(c, x, y, w, h)
  648. {
  649. var halfW = w * 0.5;
  650. c.rect(0, 0, w, 5);
  651. c.fillAndStroke();
  652. c.begin();
  653. c.moveTo(halfW, 0);
  654. c.lineTo(halfW, 5);
  655. c.moveTo(halfW, 5);
  656. c.arcTo(halfW, halfW, 0, 0, 1, 0, 5 + halfW);
  657. c.lineTo(0, 5);
  658. c.moveTo(halfW, 5);
  659. c.arcTo(halfW, halfW, 0, 0, 0, w, 5 + halfW);
  660. c.lineTo(w, 5);
  661. c.stroke();
  662. };
  663. mxCellRenderer.registerShape(mxFloorplanDoorDouble.prototype.cst.DOOR_DOUBLE, mxFloorplanDoorDouble);
  664. //**********************************************************************************************************************************************************
  665. //Door, Uneven
  666. //**********************************************************************************************************************************************************
  667. /**
  668. * Extends mxShape.
  669. */
  670. function mxFloorplanDoorUneven(bounds, fill, stroke, strokewidth)
  671. {
  672. mxShape.call(this);
  673. this.bounds = bounds;
  674. this.fill = fill;
  675. this.stroke = stroke;
  676. this.strokewidth = (strokewidth != null) ? strokewidth : 1;
  677. this.dx = 0.3;
  678. };
  679. /**
  680. * Extends mxShape.
  681. */
  682. mxUtils.extend(mxFloorplanDoorUneven, mxShape);
  683. mxFloorplanDoorUneven.prototype.customProperties = [
  684. {name: 'dx', dispName: 'Door size', type: 'float', min:0, max:1, defVal:0.3}
  685. ];
  686. mxFloorplanDoorUneven.prototype.cst = {
  687. DOOR_UNEVEN : 'mxgraph.floorplan.doorUneven'
  688. };
  689. /**
  690. * Function: paintVertexShape
  691. *
  692. * Paints the vertex shape.
  693. */
  694. mxFloorplanDoorUneven.prototype.paintVertexShape = function(c, x, y, w, h)
  695. {
  696. c.translate(x, y);
  697. this.background(c, x, y, w, h);
  698. };
  699. mxFloorplanDoorUneven.prototype.background = function(c, x, y, w, h)
  700. {
  701. var dx = w * Math.max(0, Math.min(w, parseFloat(mxUtils.getValue(this.style, 'dx', this.dx))));
  702. c.rect(0, 0, w, 5);
  703. c.fillAndStroke();
  704. c.begin();
  705. c.moveTo(dx, 0);
  706. c.lineTo(dx, 5);
  707. c.arcTo(dx, dx, 0, 0, 1, 0, 5 + dx);
  708. c.lineTo(0, 5);
  709. c.moveTo(dx, 5);
  710. c.arcTo(w - dx, w - dx, 0, 0, 0, w, 5 + w - dx);
  711. c.lineTo(w, 5);
  712. c.stroke();
  713. };
  714. mxCellRenderer.registerShape(mxFloorplanDoorUneven.prototype.cst.DOOR_UNEVEN, mxFloorplanDoorUneven);
  715. Graph.handleFactory[mxFloorplanDoorUneven.prototype.cst.DOOR_UNEVEN] = function(state)
  716. {
  717. var handles = [Graph.createHandle(state, ['dx'], function(bounds)
  718. {
  719. var dx = Math.max(0, Math.min(1, parseFloat(mxUtils.getValue(this.state.style, 'dx', this.dx))));
  720. return new mxPoint(bounds.x + dx * bounds.width, bounds.y + 5);
  721. }, function(bounds, pt)
  722. {
  723. this.state.style['dx'] = Math.round(100 * Math.max(0, Math.min(1, (pt.x - bounds.x) / bounds.width))) / 100;
  724. })];
  725. return handles;
  726. }
  727. //**********************************************************************************************************************************************************
  728. //Door, Opposing
  729. //**********************************************************************************************************************************************************
  730. /**
  731. * Extends mxShape.
  732. */
  733. function mxFloorplanDoorOpposing(bounds, fill, stroke, strokewidth)
  734. {
  735. mxShape.call(this);
  736. this.bounds = bounds;
  737. this.fill = fill;
  738. this.stroke = stroke;
  739. this.strokewidth = (strokewidth != null) ? strokewidth : 1;
  740. this.dx = 0.3;
  741. };
  742. /**
  743. * Extends mxShape.
  744. */
  745. mxUtils.extend(mxFloorplanDoorOpposing, mxShape);
  746. mxFloorplanDoorOpposing.prototype.customProperties = [
  747. {name: 'dx', dispName: 'Door size', type: 'float', min:0, max:1, defVal:0.3}
  748. ];
  749. mxFloorplanDoorOpposing.prototype.cst = {
  750. DOOR_OPPOSING : 'mxgraph.floorplan.doorOpposing'
  751. };
  752. /**
  753. * Function: paintVertexShape
  754. *
  755. * Paints the vertex shape.
  756. */
  757. mxFloorplanDoorOpposing.prototype.paintVertexShape = function(c, x, y, w, h)
  758. {
  759. c.translate(x, y);
  760. this.background(c, x, y, w, h);
  761. };
  762. mxFloorplanDoorOpposing.prototype.background = function(c, x, y, w, h)
  763. {
  764. var dx = w * Math.max(0, Math.min(w, parseFloat(mxUtils.getValue(this.style, 'dx', this.dx))));
  765. c.rect(0, dx, w, 5);
  766. c.fillAndStroke();
  767. c.begin();
  768. c.moveTo(dx, dx);
  769. c.lineTo(dx, dx + 5);
  770. c.arcTo(dx, dx, 0, 0, 0, 0, 0);
  771. c.lineTo(0, dx);
  772. c.moveTo(dx, dx + 5);
  773. c.arcTo(w - dx, w - dx, 0, 0, 0, w, 5 + w);
  774. c.lineTo(w, dx + 5);
  775. c.stroke();
  776. };
  777. mxCellRenderer.registerShape(mxFloorplanDoorOpposing.prototype.cst.DOOR_OPPOSING, mxFloorplanDoorOpposing);
  778. Graph.handleFactory[mxFloorplanDoorOpposing.prototype.cst.DOOR_OPPOSING] = function(state)
  779. {
  780. var handles = [Graph.createHandle(state, ['dx'], function(bounds)
  781. {
  782. var dx = Math.max(0, Math.min(1, parseFloat(mxUtils.getValue(this.state.style, 'dx', this.dx))));
  783. return new mxPoint(bounds.x + dx * bounds.width, bounds.y + 5);
  784. }, function(bounds, pt)
  785. {
  786. this.state.style['dx'] = Math.round(100 * Math.max(0, Math.min(1, (pt.x - bounds.x) / bounds.width))) / 100;
  787. })];
  788. return handles;
  789. }
  790. //**********************************************************************************************************************************************************
  791. //Door, Revolving
  792. //**********************************************************************************************************************************************************
  793. /**
  794. * Extends mxShape.
  795. */
  796. function mxFloorplanDoorRevolving(bounds, fill, stroke, strokewidth)
  797. {
  798. mxShape.call(this);
  799. this.bounds = bounds;
  800. this.fill = fill;
  801. this.stroke = stroke;
  802. this.strokewidth = (strokewidth != null) ? strokewidth : 1;
  803. };
  804. /**
  805. * Extends mxShape.
  806. */
  807. mxUtils.extend(mxFloorplanDoorRevolving, mxShape);
  808. mxFloorplanDoorRevolving.prototype.cst = {
  809. DOOR_REVOLVING : 'mxgraph.floorplan.doorRevolving'
  810. };
  811. /**
  812. * Function: paintVertexShape
  813. *
  814. * Paints the vertex shape.
  815. */
  816. mxFloorplanDoorRevolving.prototype.paintVertexShape = function(c, x, y, w, h)
  817. {
  818. c.translate(x, y);
  819. this.background(c, x, y, w, h);
  820. };
  821. mxFloorplanDoorRevolving.prototype.background = function(c, x, y, w, h)
  822. {
  823. var d = Math.min(w, h);
  824. c.rect((w - d) * 0.5 , h * 0.5 - 2.5, d, 5);
  825. c.fillAndStroke();
  826. c.rect(w * 0.5 - 2.5, (h - d) * 0.5, 5, d);
  827. c.fillAndStroke();
  828. c.begin();
  829. c.ellipse((w - d) * 0.5, (h - d) * 0.5, d, d);
  830. c.stroke();
  831. };
  832. mxCellRenderer.registerShape(mxFloorplanDoorRevolving.prototype.cst.DOOR_REVOLVING, mxFloorplanDoorRevolving);
  833. //**********************************************************************************************************************************************************
  834. //Door, Pocket
  835. //**********************************************************************************************************************************************************
  836. /**
  837. * Extends mxShape.
  838. */
  839. function mxFloorplanDoorPocket(bounds, fill, stroke, strokewidth)
  840. {
  841. mxShape.call(this);
  842. this.bounds = bounds;
  843. this.fill = fill;
  844. this.stroke = stroke;
  845. this.strokewidth = (strokewidth != null) ? strokewidth : 1;
  846. this.dx = 0.5;
  847. };
  848. /**
  849. * Extends mxShape.
  850. */
  851. mxUtils.extend(mxFloorplanDoorPocket, mxShape);
  852. mxFloorplanDoorPocket.prototype.customProperties = [
  853. {name: 'dx', dispName: 'Door size', type: 'float', min:0, max:1, defVal:0.3}
  854. ];
  855. mxFloorplanDoorPocket.prototype.cst = {
  856. DOOR_POCKET : 'mxgraph.floorplan.doorPocket'
  857. };
  858. /**
  859. * Function: paintVertexShape
  860. *
  861. * Paints the vertex shape.
  862. */
  863. mxFloorplanDoorPocket.prototype.paintVertexShape = function(c, x, y, w, h)
  864. {
  865. var dx = w * Math.max(0, Math.min(w, parseFloat(mxUtils.getValue(this.style, 'dx', this.dx))));
  866. c.translate(x, y);
  867. c.rect(dx, h * 0.5 - 5, 5, 10);
  868. c.fillAndStroke();
  869. c.rect(w - 5, h * 0.5 - 5, 5, 10);
  870. c.fillAndStroke();
  871. c.rect(0, h * 0.5 - 2.5, w - dx, 5);
  872. c.fillAndStroke();
  873. };
  874. mxCellRenderer.registerShape(mxFloorplanDoorPocket.prototype.cst.DOOR_POCKET, mxFloorplanDoorPocket);
  875. Graph.handleFactory[mxFloorplanDoorPocket.prototype.cst.DOOR_POCKET] = function(state)
  876. {
  877. var handles = [Graph.createHandle(state, ['dx'], function(bounds)
  878. {
  879. var dx = Math.max(0, Math.min(0.5, parseFloat(mxUtils.getValue(this.state.style, 'dx', this.dx))));
  880. return new mxPoint(bounds.x + dx * bounds.width, bounds.y + 5);
  881. }, function(bounds, pt)
  882. {
  883. this.state.style['dx'] = Math.round(100 * Math.max(0, Math.min(0.5, (pt.x - bounds.x) / bounds.width))) / 100;
  884. })];
  885. return handles;
  886. }
  887. //**********************************************************************************************************************************************************
  888. //Door, Double Pocket
  889. //**********************************************************************************************************************************************************
  890. /**
  891. * Extends mxShape.
  892. */
  893. function mxFloorplanDoorDoublePocket(bounds, fill, stroke, strokewidth)
  894. {
  895. mxShape.call(this);
  896. this.bounds = bounds;
  897. this.fill = fill;
  898. this.stroke = stroke;
  899. this.strokewidth = (strokewidth != null) ? strokewidth : 1;
  900. this.dx = 0.5;
  901. };
  902. /**
  903. * Extends mxShape.
  904. */
  905. mxUtils.extend(mxFloorplanDoorDoublePocket, mxShape);
  906. mxFloorplanDoorDoublePocket.prototype.customProperties = [
  907. {name: 'dx', dispName: 'Door size', type: 'float', min:0, max:1, defVal:0.3}
  908. ];
  909. mxFloorplanDoorDoublePocket.prototype.cst = {
  910. DOOR_DOUBLE_POCKET : 'mxgraph.floorplan.doorDoublePocket'
  911. };
  912. /**
  913. * Function: paintVertexShape
  914. *
  915. * Paints the vertex shape.
  916. */
  917. mxFloorplanDoorDoublePocket.prototype.paintVertexShape = function(c, x, y, w, h)
  918. {
  919. var dx = w * Math.max(0, Math.min(w, parseFloat(mxUtils.getValue(this.style, 'dx', this.dx))));
  920. c.translate(x, y);
  921. c.rect(dx, h * 0.5 - 5, 5, 10);
  922. c.fillAndStroke();
  923. c.rect(w - dx - 5, h * 0.5 - 5, 5, 10);
  924. c.fillAndStroke();
  925. c.rect(0, h * 0.5 - 2.5, w * 0.5 - dx, 5);
  926. c.fillAndStroke();
  927. c.rect(w * 0.5 + dx, h * 0.5 - 2.5, w * 0.5 - dx, 5);
  928. c.fillAndStroke();
  929. };
  930. mxCellRenderer.registerShape(mxFloorplanDoorDoublePocket.prototype.cst.DOOR_DOUBLE_POCKET, mxFloorplanDoorDoublePocket);
  931. Graph.handleFactory[mxFloorplanDoorDoublePocket.prototype.cst.DOOR_DOUBLE_POCKET] = function(state)
  932. {
  933. var handles = [Graph.createHandle(state, ['dx'], function(bounds)
  934. {
  935. var dx = Math.max(0, Math.min(0.25, parseFloat(mxUtils.getValue(this.state.style, 'dx', this.dx))));
  936. return new mxPoint(bounds.x + dx * bounds.width, bounds.y + 5);
  937. }, function(bounds, pt)
  938. {
  939. this.state.style['dx'] = Math.round(100 * Math.max(0, Math.min(0.25, (pt.x - bounds.x) / bounds.width))) / 100;
  940. })];
  941. return handles;
  942. }
  943. //**********************************************************************************************************************************************************
  944. //Door, By-Pass
  945. //**********************************************************************************************************************************************************
  946. /**
  947. * Extends mxShape.
  948. */
  949. function mxFloorplanDoorBypass(bounds, fill, stroke, strokewidth)
  950. {
  951. mxShape.call(this);
  952. this.bounds = bounds;
  953. this.fill = fill;
  954. this.stroke = stroke;
  955. this.strokewidth = (strokewidth != null) ? strokewidth : 1;
  956. this.dx = 0.5;
  957. };
  958. /**
  959. * Extends mxShape.
  960. */
  961. mxUtils.extend(mxFloorplanDoorBypass, mxShape);
  962. mxFloorplanDoorBypass.prototype.customProperties = [
  963. {name: 'dx', dispName: 'Door size', type: 'float', min:0, max:1, defVal:0.3}
  964. ];
  965. mxFloorplanDoorBypass.prototype.cst = {
  966. DOOR_BYPASS : 'mxgraph.floorplan.doorBypass'
  967. };
  968. /**
  969. * Function: paintVertexShape
  970. *
  971. * Paints the vertex shape.
  972. */
  973. mxFloorplanDoorBypass.prototype.paintVertexShape = function(c, x, y, w, h)
  974. {
  975. var dx = w * Math.max(0, Math.min(w, parseFloat(mxUtils.getValue(this.style, 'dx', this.dx))));
  976. c.translate(x, y);
  977. c.rect(0, h * 0.5 - 5, 5, 10);
  978. c.fillAndStroke();
  979. c.rect(w - 5, h * 0.5 - 5, 5, 10);
  980. c.fillAndStroke();
  981. c.rect(0, h * 0.5, w * 0.5, 5);
  982. c.fillAndStroke();
  983. c.rect(dx, h * 0.5 - 5, w * 0.5, 5);
  984. c.fillAndStroke();
  985. };
  986. mxCellRenderer.registerShape(mxFloorplanDoorBypass.prototype.cst.DOOR_BYPASS, mxFloorplanDoorBypass);
  987. Graph.handleFactory[mxFloorplanDoorBypass.prototype.cst.DOOR_BYPASS] = function(state)
  988. {
  989. var handles = [Graph.createHandle(state, ['dx'], function(bounds)
  990. {
  991. var dx = Math.max(0, Math.min(0.5, parseFloat(mxUtils.getValue(this.state.style, 'dx', this.dx))));
  992. return new mxPoint(bounds.x + dx * bounds.width, bounds.y + 5);
  993. }, function(bounds, pt)
  994. {
  995. this.state.style['dx'] = Math.round(100 * Math.max(0, Math.min(0.5, (pt.x - bounds.x) / bounds.width))) / 100;
  996. })];
  997. return handles;
  998. }
  999. //**********************************************************************************************************************************************************
  1000. //Door, Bi-fold
  1001. //**********************************************************************************************************************************************************
  1002. /**
  1003. * Extends mxShape.
  1004. */
  1005. function mxFloorplanDoorBifold(bounds, fill, stroke, strokewidth)
  1006. {
  1007. mxShape.call(this);
  1008. this.bounds = bounds;
  1009. this.fill = fill;
  1010. this.stroke = stroke;
  1011. this.strokewidth = (strokewidth != null) ? strokewidth : 1;
  1012. this.dx = 0.5;
  1013. };
  1014. /**
  1015. * Extends mxShape.
  1016. */
  1017. mxUtils.extend(mxFloorplanDoorBifold, mxShape);
  1018. mxFloorplanDoorBifold.prototype.customProperties = [
  1019. {name: 'dx', dispName: 'Door size', type: 'float', min:0, max:1, defVal:0.3}
  1020. ];
  1021. mxFloorplanDoorBifold.prototype.cst = {
  1022. DOOR_BIFOLD : 'mxgraph.floorplan.doorBifold'
  1023. };
  1024. /**
  1025. * Function: paintVertexShape
  1026. *
  1027. * Paints the vertex shape.
  1028. */
  1029. mxFloorplanDoorBifold.prototype.paintVertexShape = function(c, x, y, w, h)
  1030. {
  1031. var dx = w * Math.max(0, Math.min(w, parseFloat(mxUtils.getValue(this.style, 'dx', this.dx))));
  1032. var strokeWidth = parseFloat(mxUtils.getValue(this.style, 'strokeWidth', this.dx));
  1033. c.translate(x, y);
  1034. c.rect(0, h - 10, 5, 10);
  1035. c.fillAndStroke();
  1036. c.rect(w - 5, h - 10, 5, 10);
  1037. c.fillAndStroke();
  1038. c.setStrokeWidth(strokeWidth * 3);
  1039. c.begin();
  1040. c.moveTo(5, h - 10);
  1041. c.lineTo(Math.max((dx - 10) * 0.5 + 5, 5), 0);
  1042. c.lineTo(Math.max(dx, 5), h - 10);
  1043. c.moveTo(w - 5, h - 10);
  1044. c.lineTo(w - Math.max((dx - 10) * 0.5 + 5, 5), 0);
  1045. c.lineTo(w - Math.max(dx, 5), h - 10);
  1046. c.stroke();
  1047. };
  1048. mxCellRenderer.registerShape(mxFloorplanDoorBifold.prototype.cst.DOOR_BIFOLD, mxFloorplanDoorBifold);
  1049. Graph.handleFactory[mxFloorplanDoorBifold.prototype.cst.DOOR_BIFOLD] = function(state)
  1050. {
  1051. var handles = [Graph.createHandle(state, ['dx'], function(bounds)
  1052. {
  1053. var dx = Math.max(0, Math.min(0.5, parseFloat(mxUtils.getValue(this.state.style, 'dx', this.dx))));
  1054. return new mxPoint(bounds.x + dx * bounds.width, bounds.y + 5);
  1055. }, function(bounds, pt)
  1056. {
  1057. this.state.style['dx'] = Math.round(100 * Math.max(0, Math.min(0.5, (pt.x - bounds.x) / bounds.width))) / 100;
  1058. })];
  1059. return handles;
  1060. }
  1061. //**********************************************************************************************************************************************************
  1062. //Door, Sliding Glass
  1063. //**********************************************************************************************************************************************************
  1064. /**
  1065. * Extends mxShape.
  1066. */
  1067. function mxFloorplanDoorSlidingGlass(bounds, fill, stroke, strokewidth)
  1068. {
  1069. mxShape.call(this);
  1070. this.bounds = bounds;
  1071. this.fill = fill;
  1072. this.stroke = stroke;
  1073. this.strokewidth = (strokewidth != null) ? strokewidth : 1;
  1074. this.dx = 0.5;
  1075. };
  1076. /**
  1077. * Extends mxShape.
  1078. */
  1079. mxUtils.extend(mxFloorplanDoorSlidingGlass, mxShape);
  1080. mxFloorplanDoorSlidingGlass.prototype.customProperties = [
  1081. {name: 'dx', dispName: 'Door size', type: 'float', min:0, max:1, defVal:0.3}
  1082. ];
  1083. mxFloorplanDoorSlidingGlass.prototype.cst = {
  1084. DOOR_SLIDING_GLASS : 'mxgraph.floorplan.doorSlidingGlass'
  1085. };
  1086. /**
  1087. * Function: paintVertexShape
  1088. *
  1089. * Paints the vertex shape.
  1090. */
  1091. mxFloorplanDoorSlidingGlass.prototype.paintVertexShape = function(c, x, y, w, h)
  1092. {
  1093. var dx = w * Math.max(0, Math.min(w, parseFloat(mxUtils.getValue(this.style, 'dx', this.dx))));
  1094. c.translate(x, y);
  1095. c.rect(0, h * 0.5 - 5, 5, 10);
  1096. c.fillAndStroke();
  1097. c.rect(w - 5, h * 0.5 - 5, 5, 10);
  1098. c.fillAndStroke();
  1099. c.rect(0, h * 0.5, w * 0.5, 2);
  1100. c.fillAndStroke();
  1101. c.rect(dx, h * 0.5 - 2, w * 0.5, 2);
  1102. c.fillAndStroke();
  1103. };
  1104. mxCellRenderer.registerShape(mxFloorplanDoorSlidingGlass.prototype.cst.DOOR_SLIDING_GLASS, mxFloorplanDoorSlidingGlass);
  1105. Graph.handleFactory[mxFloorplanDoorSlidingGlass.prototype.cst.DOOR_SLIDING_GLASS] = function(state)
  1106. {
  1107. var handles = [Graph.createHandle(state, ['dx'], function(bounds)
  1108. {
  1109. var dx = Math.max(0, Math.min(0.5, parseFloat(mxUtils.getValue(this.state.style, 'dx', this.dx))));
  1110. return new mxPoint(bounds.x + dx * bounds.width, bounds.y + 5);
  1111. }, function(bounds, pt)
  1112. {
  1113. this.state.style['dx'] = Math.round(100 * Math.max(0, Math.min(0.5, (pt.x - bounds.x) / bounds.width))) / 100;
  1114. })];
  1115. return handles;
  1116. }
  1117. //**********************************************************************************************************************************************************
  1118. //Door, Overhead
  1119. //**********************************************************************************************************************************************************
  1120. /**
  1121. * Extends mxShape.
  1122. */
  1123. function mxFloorplanOverhead(bounds, fill, stroke, strokewidth)
  1124. {
  1125. mxShape.call(this);
  1126. this.bounds = bounds;
  1127. this.fill = fill;
  1128. this.stroke = stroke;
  1129. this.strokewidth = (strokewidth != null) ? strokewidth : 1;
  1130. this.dx = 0.5;
  1131. };
  1132. /**
  1133. * Extends mxShape.
  1134. */
  1135. mxUtils.extend(mxFloorplanOverhead, mxShape);
  1136. mxFloorplanOverhead.prototype.cst = {
  1137. DOOR_OVERHEAD : 'mxgraph.floorplan.doorOverhead'
  1138. };
  1139. /**
  1140. * Function: paintVertexShape
  1141. *
  1142. * Paints the vertex shape.
  1143. */
  1144. mxFloorplanOverhead.prototype.paintVertexShape = function(c, x, y, w, h)
  1145. {
  1146. c.translate(x, y);
  1147. c.rect(0, h - 10, 5, 10);
  1148. c.fillAndStroke();
  1149. c.rect(w - 5, h - 10, 5, 10);
  1150. c.fillAndStroke();
  1151. c.rect(5, 0, w - 10, h - 5);
  1152. c.fillAndStroke();
  1153. };
  1154. mxCellRenderer.registerShape(mxFloorplanOverhead.prototype.cst.DOOR_OVERHEAD, mxFloorplanOverhead);
  1155. //**********************************************************************************************************************************************************
  1156. //Opening
  1157. //**********************************************************************************************************************************************************
  1158. /**
  1159. * Extends mxShape.
  1160. */
  1161. function mxFloorplanOpening(bounds, fill, stroke, strokewidth)
  1162. {
  1163. mxShape.call(this);
  1164. this.bounds = bounds;
  1165. this.fill = fill;
  1166. this.stroke = stroke;
  1167. this.strokewidth = (strokewidth != null) ? strokewidth : 1;
  1168. this.dx = 0.5;
  1169. };
  1170. /**
  1171. * Extends mxShape.
  1172. */
  1173. mxUtils.extend(mxFloorplanOpening, mxShape);
  1174. mxFloorplanOpening.prototype.cst = {
  1175. OPENING : 'mxgraph.floorplan.opening'
  1176. };
  1177. /**
  1178. * Function: paintVertexShape
  1179. *
  1180. * Paints the vertex shape.
  1181. */
  1182. mxFloorplanOpening.prototype.paintVertexShape = function(c, x, y, w, h)
  1183. {
  1184. c.translate(x, y);
  1185. c.rect(0, 0, 5, h);
  1186. c.fillAndStroke();
  1187. c.rect(w - 5, 0, 5, h);
  1188. c.fillAndStroke();
  1189. };
  1190. mxCellRenderer.registerShape(mxFloorplanOpening.prototype.cst.OPENING, mxFloorplanOpening);
  1191. //**********************************************************************************************************************************************************
  1192. //Window, Glider
  1193. //**********************************************************************************************************************************************************
  1194. /**
  1195. * Extends mxShape.
  1196. */
  1197. function mxFloorplanWindowGlider(bounds, fill, stroke, strokewidth)
  1198. {
  1199. mxShape.call(this);
  1200. this.bounds = bounds;
  1201. this.fill = fill;
  1202. this.stroke = stroke;
  1203. this.strokewidth = (strokewidth != null) ? strokewidth : 1;
  1204. this.dx = 0.5;
  1205. };
  1206. /**
  1207. * Extends mxShape.
  1208. */
  1209. mxUtils.extend(mxFloorplanWindowGlider, mxShape);
  1210. mxFloorplanWindowGlider.prototype.customProperties = [
  1211. {name: 'dx', dispName: 'Window size', type: 'float', min:0, max:1, defVal:0.3}
  1212. ];
  1213. mxFloorplanWindowGlider.prototype.cst = {
  1214. WINDOW_GLIDER : 'mxgraph.floorplan.windowGlider'
  1215. };
  1216. /**
  1217. * Function: paintVertexShape
  1218. *
  1219. * Paints the vertex shape.
  1220. */
  1221. mxFloorplanWindowGlider.prototype.paintVertexShape = function(c, x, y, w, h)
  1222. {
  1223. var dx = w * Math.max(0, Math.min(w, parseFloat(mxUtils.getValue(this.style, 'dx', this.dx))));
  1224. c.translate(x, y);
  1225. c.rect(0, h * 0.5 - 5, w, 10);
  1226. c.fillAndStroke();
  1227. c.rect(0, h * 0.5, w * 0.5, 1);
  1228. c.fillAndStroke();
  1229. c.rect(dx, h * 0.5 - 1, w * 0.5, 1);
  1230. c.fillAndStroke();
  1231. };
  1232. mxCellRenderer.registerShape(mxFloorplanWindowGlider.prototype.cst.WINDOW_GLIDER, mxFloorplanWindowGlider);
  1233. Graph.handleFactory[mxFloorplanWindowGlider.prototype.cst.WINDOW_GLIDER] = function(state)
  1234. {
  1235. var handles = [Graph.createHandle(state, ['dx'], function(bounds)
  1236. {
  1237. var dx = Math.max(0, Math.min(0.5, parseFloat(mxUtils.getValue(this.state.style, 'dx', this.dx))));
  1238. return new mxPoint(bounds.x + dx * bounds.width, bounds.y + 5);
  1239. }, function(bounds, pt)
  1240. {
  1241. this.state.style['dx'] = Math.round(100 * Math.max(0, Math.min(0.5, (pt.x - bounds.x) / bounds.width))) / 100;
  1242. })];
  1243. return handles;
  1244. }
  1245. //**********************************************************************************************************************************************************
  1246. //Window, Garden
  1247. //**********************************************************************************************************************************************************
  1248. /**
  1249. * Extends mxShape.
  1250. */
  1251. function mxFloorplanWindowGarden(bounds, fill, stroke, strokewidth)
  1252. {
  1253. mxShape.call(this);
  1254. this.bounds = bounds;
  1255. this.fill = fill;
  1256. this.stroke = stroke;
  1257. this.strokewidth = (strokewidth != null) ? strokewidth : 1;
  1258. this.windowPanes = 3;
  1259. };
  1260. /**
  1261. * Extends mxShape.
  1262. */
  1263. mxUtils.extend(mxFloorplanWindowGarden, mxShape);
  1264. mxFloorplanWindowGarden.prototype.customProperties = [
  1265. {name: 'windowPanes', dispName: 'Panes', type: 'int', min:0, max:20, defVal:3}
  1266. ];
  1267. mxFloorplanWindowGarden.prototype.cst = {
  1268. WINDOW_GARDEN : 'mxgraph.floorplan.windowGarden'
  1269. };
  1270. /**
  1271. * Function: paintVertexShape
  1272. *
  1273. * Paints the vertex shape.
  1274. */
  1275. mxFloorplanWindowGarden.prototype.paintVertexShape = function(c, x, y, w, h)
  1276. {
  1277. var windowPanes = Math.min(mxUtils.getValue(this.style, 'windowPanes', this.windowPanes), 20);
  1278. var d = 2;
  1279. var paneW = (w - 14 - (windowPanes - 1) * d) / windowPanes;
  1280. c.translate(x, y);
  1281. c.rect(0, h - 10, 5, 10);
  1282. c.fillAndStroke();
  1283. c.rect(w - 5, h - 10, 5, 10);
  1284. c.fillAndStroke();
  1285. c.begin();
  1286. c.moveTo(5, h);
  1287. c.lineTo(5, 0);
  1288. c.lineTo(w - 5, 0);
  1289. c.lineTo(w - 5, h);
  1290. c.lineTo(w - 5 - d, h);
  1291. c.lineTo(w - 5 - d, d);
  1292. for (var i = 1; i < windowPanes; i++)
  1293. {
  1294. c.lineTo(w - 5 - d - i * paneW - (i - 1) * d, d);
  1295. c.lineTo(w - 5 - d - i * paneW - (i - 1) * d, h);
  1296. c.lineTo(w - 5 - 2 * d - (i - 1) * d - i * paneW, h);
  1297. c.lineTo(w - 5 - 2 * d - (i - 1) * d - i * paneW, d);
  1298. }
  1299. c.lineTo(5 + d, d);
  1300. c.lineTo(5 + d, h);
  1301. c.close();
  1302. c.fillAndStroke();
  1303. };
  1304. mxCellRenderer.registerShape(mxFloorplanWindowGarden.prototype.cst.WINDOW_GARDEN, mxFloorplanWindowGarden);
  1305. //**********************************************************************************************************************************************************
  1306. //Window, Bow
  1307. //**********************************************************************************************************************************************************
  1308. /**
  1309. * Extends mxShape.
  1310. */
  1311. function mxFloorplanWindowBow(bounds, fill, stroke, strokewidth)
  1312. {
  1313. mxShape.call(this);
  1314. this.bounds = bounds;
  1315. this.fill = fill;
  1316. this.stroke = stroke;
  1317. this.strokewidth = (strokewidth != null) ? strokewidth : 1;
  1318. this.windowPanes = 3;
  1319. };
  1320. /**
  1321. * Extends mxShape.
  1322. */
  1323. mxUtils.extend(mxFloorplanWindowBow, mxShape);
  1324. mxFloorplanWindowBow.prototype.cst = {
  1325. WINDOW_BOW : 'mxgraph.floorplan.windowBow'
  1326. };
  1327. /**
  1328. * Function: paintVertexShape
  1329. *
  1330. * Paints the vertex shape.
  1331. */
  1332. mxFloorplanWindowBow.prototype.paintVertexShape = function(c, x, y, w, h)
  1333. {
  1334. c.translate(x, y);
  1335. var d = Math.min(w * 0.5, h);
  1336. c.begin();
  1337. c.moveTo(0, (h - d) * 0.5);
  1338. c.lineTo(d, (h + d) * 0.5);
  1339. c.lineTo(w - d, (h + d) * 0.5);
  1340. c.lineTo(w, (h - d) * 0.5);
  1341. c.stroke();
  1342. };
  1343. mxCellRenderer.registerShape(mxFloorplanWindowBow.prototype.cst.WINDOW_BOW, mxFloorplanWindowBow);
  1344. //**********************************************************************************************************************************************************
  1345. //Window, Bay
  1346. //**********************************************************************************************************************************************************
  1347. /**
  1348. * Extends mxShape.
  1349. */
  1350. function mxFloorplanWindowBay(bounds, fill, stroke, strokewidth)
  1351. {
  1352. mxShape.call(this);
  1353. this.bounds = bounds;
  1354. this.fill = fill;
  1355. this.stroke = stroke;
  1356. this.strokewidth = (strokewidth != null) ? strokewidth : 1;
  1357. this.windowPanes = 3;
  1358. };
  1359. /**
  1360. * Extends mxShape.
  1361. */
  1362. mxUtils.extend(mxFloorplanWindowBay, mxShape);
  1363. mxFloorplanWindowBay.prototype.cst = {
  1364. WINDOW_BAY : 'mxgraph.floorplan.windowBay'
  1365. };
  1366. /**
  1367. * Function: paintVertexShape
  1368. *
  1369. * Paints the vertex shape.
  1370. */
  1371. mxFloorplanWindowBay.prototype.paintVertexShape = function(c, x, y, w, h)
  1372. {
  1373. c.translate(x, y);
  1374. var d = Math.min(w * 0.5, h);
  1375. c.begin();
  1376. c.moveTo(0, 0);
  1377. c.lineTo(w * 0.15, h * 0.6);
  1378. c.lineTo(w * 0.35, h);
  1379. c.lineTo(w * 0.65, h);
  1380. c.lineTo(w * 0.85, h * 0.6);
  1381. c.lineTo(w, 0);
  1382. c.stroke();
  1383. };
  1384. mxCellRenderer.registerShape(mxFloorplanWindowBay.prototype.cst.WINDOW_BAY, mxFloorplanWindowBay);
  1385. //**********************************************************************************************************************************************************
  1386. //Door, Accordion
  1387. //**********************************************************************************************************************************************************
  1388. /**
  1389. * Extends mxShape.
  1390. */
  1391. function mxFloorplanDoorAccordion(bounds, fill, stroke, strokewidth)
  1392. {
  1393. mxShape.call(this);
  1394. this.bounds = bounds;
  1395. this.fill = fill;
  1396. this.stroke = stroke;
  1397. this.strokewidth = (strokewidth != null) ? strokewidth : 1;
  1398. this.dx = 0.5;
  1399. };
  1400. /**
  1401. * Extends mxShape.
  1402. */
  1403. mxUtils.extend(mxFloorplanDoorAccordion, mxShape);
  1404. mxFloorplanDoorAccordion.prototype.customProperties = [
  1405. {name: 'dx', dispName: 'Door size', type: 'float', min:0, max:1, defVal:0.3}
  1406. ];
  1407. mxFloorplanDoorAccordion.prototype.cst = {
  1408. DOOR_ACCORDION : 'mxgraph.floorplan.doorAccordion'
  1409. };
  1410. /**
  1411. * Function: paintVertexShape
  1412. *
  1413. * Paints the vertex shape.
  1414. */
  1415. mxFloorplanDoorAccordion.prototype.paintVertexShape = function(c, x, y, w, h)
  1416. {
  1417. var dx = w * Math.max(0, Math.min(w, parseFloat(mxUtils.getValue(this.style, 'dx', this.dx))));
  1418. var dx = Math.max(5, dx);
  1419. var dx = Math.min(w - 5, dx);
  1420. var strokeWidth = parseFloat(mxUtils.getValue(this.style, 'strokeWidth', this.dx));
  1421. c.translate(x, y);
  1422. c.rect(0, h * 0.5 - 5, 5, 10);
  1423. c.fillAndStroke();
  1424. c.rect(w - 5, h * 0.5 - 5, 5, 10);
  1425. c.fillAndStroke();
  1426. c.setStrokeWidth(strokeWidth * 3);
  1427. var l = dx - 5;
  1428. c.begin();
  1429. c.moveTo(5, h * 0.5);
  1430. c.lineTo(5 + l * 0.1, 0);
  1431. c.lineTo(5 + l * 0.3, h);
  1432. c.lineTo(5 + l * 0.5, 0);
  1433. c.lineTo(5 + l * 0.7, h);
  1434. c.lineTo(5 + l * 0.9, 0);
  1435. c.lineTo(5 + l, h * 0.5);
  1436. c.stroke();
  1437. };
  1438. mxCellRenderer.registerShape(mxFloorplanDoorAccordion.prototype.cst.DOOR_ACCORDION, mxFloorplanDoorAccordion);
  1439. Graph.handleFactory[mxFloorplanDoorAccordion.prototype.cst.DOOR_ACCORDION] = function(state)
  1440. {
  1441. var handles = [Graph.createHandle(state, ['dx'], function(bounds)
  1442. {
  1443. var dx = Math.max(0, Math.min(1, parseFloat(mxUtils.getValue(this.state.style, 'dx', this.dx))));
  1444. return new mxPoint(bounds.x + dx * bounds.width, bounds.y + 5);
  1445. }, function(bounds, pt)
  1446. {
  1447. this.state.style['dx'] = Math.round(100 * Math.max(0, Math.min(1, (pt.x - bounds.x) / bounds.width))) / 100;
  1448. })];
  1449. return handles;
  1450. }
  1451. //**********************************************************************************************************************************************************
  1452. //Door, Double-action
  1453. //**********************************************************************************************************************************************************
  1454. /**
  1455. * Extends mxShape.
  1456. */
  1457. function mxFloorplanDoorDoubleAction(bounds, fill, stroke, strokewidth)
  1458. {
  1459. mxShape.call(this);
  1460. this.bounds = bounds;
  1461. this.fill = fill;
  1462. this.stroke = stroke;
  1463. this.strokewidth = (strokewidth != null) ? strokewidth : 1;
  1464. };
  1465. /**
  1466. * Extends mxShape.
  1467. */
  1468. mxUtils.extend(mxFloorplanDoorDoubleAction, mxShape);
  1469. mxFloorplanDoorDoubleAction.prototype.cst = {
  1470. DOOR_DOUBLE_ACTION : 'mxgraph.floorplan.doorDoubleAction'
  1471. };
  1472. /**
  1473. * Function: paintVertexShape
  1474. *
  1475. * Paints the vertex shape.
  1476. */
  1477. mxFloorplanDoorDoubleAction.prototype.paintVertexShape = function(c, x, y, w, h)
  1478. {
  1479. c.translate(x, y);
  1480. this.background(c, x, y, w, h);
  1481. };
  1482. mxFloorplanDoorDoubleAction.prototype.background = function(c, x, y, w, h)
  1483. {
  1484. c.rect(0, h * 0.5 - 2.5, w, 5);
  1485. c.fillAndStroke();
  1486. c.begin();
  1487. c.moveTo(w, h * 0.5 + 2.5);
  1488. c.arcTo(w, w, 0, 0, 1, 0, h * 0.5 + 2.5 + w);
  1489. c.lineTo(0, h * 0.5 + 2.5);
  1490. c.stroke();
  1491. c.setDashed(true);
  1492. c.begin();
  1493. c.moveTo(w, h * 0.5 - 2.5);
  1494. c.arcTo(w, w, 0, 0, 0, 0, h * 0.5 - 2.5 - w);
  1495. c.lineTo(0, h * 0.5 - 2.5);
  1496. c.stroke();
  1497. };
  1498. mxCellRenderer.registerShape(mxFloorplanDoorDoubleAction.prototype.cst.DOOR_DOUBLE_ACTION, mxFloorplanDoorDoubleAction);