1/**
2 * $Id: mxCabinets.js,v 1.0 2014/04/15 07:05:39 mate Exp $
3 * Copyright (c) 2006-2014, JGraph Ltd
4 */
5
6//**********************************************************************************************************************************************************
7//Cabinet
8//**********************************************************************************************************************************************************
9/**
10* Extends mxShape.
11*/
12function mxCabinetsCabinet(bounds, fill, stroke, strokewidth)
13{
14	mxShape.call(this);
15	this.bounds = bounds;
16	this.fill = fill;
17	this.stroke = stroke;
18	this.strokewidth = (strokewidth != null) ? strokewidth : 1;
19};
20
21/**
22* Extends mxShape.
23*/
24mxUtils.extend(mxCabinetsCabinet, mxShape);
25
26mxCabinetsCabinet.prototype.cst = {
27		HAS_STAND : 'hasStand',
28		CABINET : 'mxgraph.cabinets.cabinet'
29};
30
31mxCabinetsCabinet.prototype.customProperties = [
32	{name: 'hasStand', dispName:'Has Stand', type:'bool', defVal:true}
33];
34
35/**
36* Function: paintVertexShape
37*
38* Paints the vertex shape.
39*/
40mxCabinetsCabinet.prototype.paintVertexShape = function(c, x, y, w, h)
41{
42	c.translate(x, y);
43	this.background(c, 0, 0, w, h);
44	c.setShadow(false);
45	this.foreground(c, 0, 0, w, h);
46};
47
48mxCabinetsCabinet.prototype.background = function(c, x, y, w, h)
49{
50	c.rect(0, 0, w, h);
51	c.fillAndStroke();
52};
53
54mxCabinetsCabinet.prototype.foreground = function(c, x, y, w, h)
55{
56	var wallTh = 15;
57	c.rect(0, 0, w, wallTh);
58	c.stroke();
59
60	c.begin();
61	c.moveTo(wallTh, wallTh);
62	c.lineTo(wallTh, h);
63	c.moveTo(w - wallTh, wallTh);
64	c.lineTo(w - wallTh, h);
65	c.stroke();
66
67	var hasStand = mxUtils.getValue(this.style, mxCabinetsCabinet.prototype.cst.HAS_STAND, '1');
68
69	if (hasStand === 1)
70	{
71		c.rect(0, h - 40, w, 40);
72		c.fillAndStroke();
73	}
74	else
75	{
76		c.rect(0, h - wallTh, w, wallTh);
77		c.fillAndStroke();
78	};
79};
80
81mxCellRenderer.registerShape(mxCabinetsCabinet.prototype.cst.CABINET, mxCabinetsCabinet);
82
83//**********************************************************************************************************************************************************
84//Cover Plate
85//**********************************************************************************************************************************************************
86/**
87* Extends mxShape.
88*/
89function mxCabinetsCoverPlate(bounds, fill, stroke, strokewidth)
90{
91	mxShape.call(this);
92	this.bounds = bounds;
93	this.fill = fill;
94	this.stroke = stroke;
95	this.strokewidth = (strokewidth != null) ? strokewidth : 1;
96};
97
98/**
99* Extends mxShape.
100*/
101mxUtils.extend(mxCabinetsCoverPlate, mxShape);
102
103mxCabinetsCoverPlate.prototype.cst = {
104		COVER_PLATE : 'mxgraph.cabinets.coverPlate'
105};
106
107
108
109/**
110* Function: paintVertexShape
111*
112* Paints the vertex shape.
113*/
114mxCabinetsCoverPlate.prototype.paintVertexShape = function(c, x, y, w, h)
115{
116	c.translate(x, y);
117	this.background(c, 0, 0, w, h);
118	c.setShadow(false);
119	this.foreground(c, 0, 0, w, h);
120};
121
122mxCabinetsCoverPlate.prototype.background = function(c, x, y, w, h)
123{
124	c.begin();
125	c.moveTo(0, 0);
126	c.lineTo(w, 0);
127	c.lineTo(w, h);
128	c.lineTo(0, h);
129	c.close();
130	c.moveTo(10, h * 0.5 - 12.5);
131	c.lineTo(10, h * 0.5 + 12.5);
132	c.lineTo(w - 10, h * 0.5 + 12.5);
133	c.lineTo(w - 10, h * 0.5 - 12.5);
134	c.close();
135	c.fillAndStroke();
136};
137
138mxCabinetsCoverPlate.prototype.foreground = function(c, x, y, w, h)
139{
140};
141
142mxCellRenderer.registerShape(mxCabinetsCoverPlate.prototype.cst.COVER_PLATE, mxCabinetsCoverPlate);
143
144//**********************************************************************************************************************************************************
145//Dimension
146//**********************************************************************************************************************************************************
147/**
148* Extends mxShape.
149*/
150function mxCabinetsDimension(bounds, fill, stroke, strokewidth)
151{
152	mxShape.call(this);
153	this.bounds = bounds;
154	this.fill = fill;
155	this.stroke = stroke;
156	this.strokewidth = (strokewidth != null) ? strokewidth : 1;
157};
158
159/**
160* Extends mxShape.
161*/
162mxUtils.extend(mxCabinetsDimension, mxShape);
163
164mxCabinetsDimension.prototype.cst = {
165		DIMENSION : 'mxgraph.cabinets.dimension'
166};
167
168
169
170/**
171* Function: paintVertexShape
172*
173* Paints the vertex shape.
174*/
175mxCabinetsDimension.prototype.paintVertexShape = function(c, x, y, w, h)
176{
177	c.translate(x, y);
178	this.background(c, x, y, w, h);
179};
180
181mxCabinetsDimension.prototype.background = function(c, x, y, w, h)
182{
183	c.begin();
184	c.moveTo(0, 20);
185	c.lineTo(w, 20);
186	c.moveTo(10, 15);
187	c.lineTo(0, 20);
188	c.lineTo(10, 25);
189	c.moveTo(w - 10, 15);
190	c.lineTo(w, 20);
191	c.lineTo(w - 10, 25);
192	c.moveTo(0, 15);
193	c.lineTo(0, h);
194	c.moveTo(w, 15);
195	c.lineTo(w, h);
196	c.stroke();
197};
198
199mxCellRenderer.registerShape(mxCabinetsDimension.prototype.cst.DIMENSION, mxCabinetsDimension);
200
201//**********************************************************************************************************************************************************
202//Dimension Bottom
203//**********************************************************************************************************************************************************
204/**
205* Extends mxShape.
206*/
207function mxCabinetsDimensionBottom(bounds, fill, stroke, strokewidth)
208{
209	mxShape.call(this);
210	this.bounds = bounds;
211	this.fill = fill;
212	this.stroke = stroke;
213	this.strokewidth = (strokewidth != null) ? strokewidth : 1;
214};
215
216/**
217* Extends mxShape.
218*/
219mxUtils.extend(mxCabinetsDimensionBottom, mxShape);
220
221mxCabinetsDimensionBottom.prototype.cst = {
222		DIMENSION : 'mxgraph.cabinets.dimensionBottom'
223};
224
225
226
227/**
228* Function: paintVertexShape
229*
230* Paints the vertex shape.
231*/
232mxCabinetsDimensionBottom.prototype.paintVertexShape = function(c, x, y, w, h)
233{
234	c.translate(x, y);
235	this.background(c, x, y, w, h);
236};
237
238mxCabinetsDimensionBottom.prototype.background = function(c, x, y, w, h)
239{
240	c.begin();
241	c.moveTo(0, h - 20);
242	c.lineTo(w, h - 20);
243	c.moveTo(10, h - 15);
244	c.lineTo(0, h - 20);
245	c.lineTo(10, h - 25);
246	c.moveTo(w - 10, h - 15);
247	c.lineTo(w, h - 20);
248	c.lineTo(w - 10, h - 25);
249	c.moveTo(0, h - 15);
250	c.lineTo(0, 0);
251	c.moveTo(w, h - 15);
252	c.lineTo(w, 0);
253	c.stroke();
254};
255
256mxCellRenderer.registerShape(mxCabinetsDimensionBottom.prototype.cst.DIMENSION, mxCabinetsDimensionBottom);
257
258