mxFloorplan.js 47 KB

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