1/**
2 * $Id: mxArchiMate.js,v 1.0 2014/03/17 07:05:39 mate Exp $
3 * Copyright (c) 2006-2014, JGraph Ltd
4 */
5
6//**********************************************************************************************************************************************************
7//Location
8//**********************************************************************************************************************************************************
9/**
10* Extends mxShape.
11*/
12function mxArchiMateLocation(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(mxArchiMateLocation, mxShape);
25
26mxArchiMateLocation.prototype.cst = {
27		LOCATION : 'mxgraph.archimate.location'
28};
29
30/**
31* Function: paintVertexShape
32*
33* Paints the vertex shape.
34*/
35mxArchiMateLocation.prototype.paintVertexShape = function(c, x, y, w, h)
36{
37	c.translate(x, y);
38	this.background(c, 0, 0, w, h);
39	c.setShadow(false);
40	c.translate(w - 20, 5);
41	this.foreground(c, w - 20, 5, 15, 15);
42};
43
44mxArchiMateLocation.prototype.background = function(c, x, y, w, h)
45{
46	c.rect(0, 0, w, h);
47	c.fillAndStroke();
48};
49
50mxArchiMateLocation.prototype.foreground = function(c, x, y, w, h)
51{
52	c.setDashed(false);
53
54	c.translate(3 ,0);
55	w = w - 6;
56	c.begin();
57	c.moveTo(w * 0.5, h);
58	c.arcTo(w * 0.1775, h * 0.3, 0, 0, 0, w * 0.345, h * 0.7);
59	c.arcTo(w * 0.538, h * 0.364, 0, 0, 1, w * 0.5, 0);
60	c.arcTo(w * 0.538, h * 0.364, 0, 0, 1, w * 0.655, h * 0.7);
61	c.arcTo(w * 0.1775, h * 0.3, 0, 0, 0, w * 0.5, h);
62	c.stroke();
63};
64
65mxCellRenderer.registerShape(mxArchiMateLocation.prototype.cst.LOCATION, mxArchiMateLocation);
66
67mxArchiMateLocation.prototype.getConstraints = function(style, w, h)
68{
69	var constr = [];
70
71	constr.push(new mxConnectionConstraint(new mxPoint(0, 0), false));
72	constr.push(new mxConnectionConstraint(new mxPoint(0.25, 0), false));
73	constr.push(new mxConnectionConstraint(new mxPoint(0.5, 0), false));
74	constr.push(new mxConnectionConstraint(new mxPoint(0.75, 0), false));
75	constr.push(new mxConnectionConstraint(new mxPoint(1, 0), false));
76	constr.push(new mxConnectionConstraint(new mxPoint(1, 0.25), false));
77	constr.push(new mxConnectionConstraint(new mxPoint(1, 0.5), false));
78	constr.push(new mxConnectionConstraint(new mxPoint(1, 0.75), false));
79	constr.push(new mxConnectionConstraint(new mxPoint(1, 1), false));
80	constr.push(new mxConnectionConstraint(new mxPoint(0.75, 1), false));
81	constr.push(new mxConnectionConstraint(new mxPoint(0.5, 1), false));
82	constr.push(new mxConnectionConstraint(new mxPoint(0.25, 1), false));
83	constr.push(new mxConnectionConstraint(new mxPoint(0, 1), false));
84	constr.push(new mxConnectionConstraint(new mxPoint(0, 0.75), false));
85	constr.push(new mxConnectionConstraint(new mxPoint(0, 0.5), false));
86	constr.push(new mxConnectionConstraint(new mxPoint(0, 0.25), false));
87
88	return (constr);
89};
90
91//**********************************************************************************************************************************************************
92//Business
93//**********************************************************************************************************************************************************
94/**
95* Extends mxShape.
96*/
97function mxArchiMateBusiness(bounds, fill, stroke, strokewidth)
98{
99	mxShape.call(this);
100	this.bounds = bounds;
101	this.fill = fill;
102	this.stroke = stroke;
103	this.strokewidth = (strokewidth != null) ? strokewidth : 1;
104};
105
106/**
107* Extends mxShape.
108*/
109mxUtils.extend(mxArchiMateBusiness, mxShape);
110
111mxArchiMateBusiness.prototype.cst = {
112		BUSINESS : 'mxgraph.archimate.business',
113		TYPE : 'busType',
114		PROCESS : 'process',
115		FUNCTION : 'function',
116		INTERACTION : 'interaction',
117		EVENT : 'event',
118		SERVICE : 'service'
119};
120
121mxArchiMateBusiness.prototype.customProperties = [
122	{name: 'busType', dispName: 'Business Type', type: 'enum',
123		enumList: [{val: 'process', dispName: 'Process'},
124				   {val: 'function', dispName: 'Function'},
125				   {val: 'interaction', dispName: 'Interaction'},
126				   {val: 'event', dispName: 'Event'},
127				   {val: 'service', dispName: 'Service'}]
128	}
129];
130
131/**
132* Function: paintVertexShape
133*
134* Paints the vertex shape.
135*/
136mxArchiMateBusiness.prototype.paintVertexShape = function(c, x, y, w, h)
137{
138	c.translate(x, y);
139	this.background(c, 0, 0, w, h);
140	c.setShadow(false);
141	c.translate(w - 20, 5);
142	this.foreground(c, w - 20, 5, 15, 15);
143};
144
145mxArchiMateBusiness.prototype.background = function(c, x, y, w, h)
146{
147	c.roundrect(0, 0, w, h, 10, 10);
148	c.fillAndStroke();
149};
150
151mxArchiMateBusiness.prototype.foreground = function(c, x, y, w, h)
152{
153	var type = mxUtils.getValue(this.style, mxArchiMateBusiness.prototype.cst.TYPE, mxArchiMateBusiness.prototype.cst.PROCESS);
154
155	c.setDashed(false);
156
157	if (type === mxArchiMateBusiness.prototype.cst.PROCESS)
158	{
159		c.translate(0, 2);
160		h = h - 4;
161
162		c.begin();
163		c.moveTo(0, h * 0.15);
164		c.lineTo(w * 0.65, h * 0.15);
165		c.lineTo(w * 0.65, 0);
166		c.lineTo(w, h * 0.5);
167		c.lineTo(w * 0.65, h);
168		c.lineTo(w * 0.65, h * 0.85);
169		c.lineTo(0, h * 0.85);
170		c.close();
171		c.stroke();
172	}
173	else if (type === mxArchiMateBusiness.prototype.cst.FUNCTION)
174	{
175		c.translate(2, 0);
176		w = w - 4;
177
178		c.begin();
179		c.moveTo(0, h * 0.15);
180		c.lineTo(w * 0.5, 0);
181		c.lineTo(w, h * 0.15);
182		c.lineTo(w, h);
183		c.lineTo(w * 0.5, h * 0.85);
184		c.lineTo(0, h);
185		c.close();
186		c.stroke();
187	}
188	else if (type === mxArchiMateBusiness.prototype.cst.INTERACTION)
189	{
190		c.begin();
191		c.moveTo(w * 0.55, 0);
192		c.arcTo(w * 0.45, h * 0.5, 0, 0, 1, w * 0.55, h);
193		c.close();
194		c.moveTo(w * 0.45, 0);
195		c.arcTo(w * 0.45, h * 0.5, 0, 0, 0, w * 0.45, h);
196		c.close();
197		c.stroke();
198	}
199	else if (type === mxArchiMateBusiness.prototype.cst.EVENT)
200	{
201		c.translate(0, 3);
202		h = h - 6;
203
204		c.begin();
205		c.moveTo(w - h * 0.5, 0);
206		c.arcTo(h * 0.5, h * 0.5, 0, 0, 1, w - h * 0.5, h);
207		c.lineTo(0, h);
208		c.arcTo(h * 0.5, h * 0.5, 0, 0, 0, 0, 0);
209		c.close();
210		c.stroke();
211	}
212	else if (type === mxArchiMateBusiness.prototype.cst.SERVICE)
213	{
214		c.translate(0, 3);
215		h = h - 6;
216
217		c.begin();
218		c.moveTo(w - h * 0.5, 0);
219		c.arcTo(h * 0.5, h * 0.5, 0, 0, 1, w - h * 0.5, h);
220		c.lineTo(0, h);
221		c.arcTo(h * 0.5, h * 0.5, 0, 0, 1, 0, 0);
222		c.close();
223		c.stroke();
224	}
225};
226
227mxCellRenderer.registerShape(mxArchiMateBusiness.prototype.cst.BUSINESS, mxArchiMateBusiness);
228
229mxArchiMateBusiness.prototype.getConstraints = function(style, w, h)
230{
231	var constr = [];
232
233	constr.push(new mxConnectionConstraint(new mxPoint(0, 0), false, null, 2.9, 2.9));
234	constr.push(new mxConnectionConstraint(new mxPoint(0.25, 0), false));
235	constr.push(new mxConnectionConstraint(new mxPoint(0.5, 0), false));
236	constr.push(new mxConnectionConstraint(new mxPoint(0.75, 0), false));
237	constr.push(new mxConnectionConstraint(new mxPoint(1, 0), false, null, -2.9, 2.9));
238	constr.push(new mxConnectionConstraint(new mxPoint(1, 0.25), false));
239	constr.push(new mxConnectionConstraint(new mxPoint(1, 0.5), false));
240	constr.push(new mxConnectionConstraint(new mxPoint(1, 0.75), false));
241	constr.push(new mxConnectionConstraint(new mxPoint(1, 1), false, null, -2.9, -2.9));
242	constr.push(new mxConnectionConstraint(new mxPoint(0.75, 1), false));
243	constr.push(new mxConnectionConstraint(new mxPoint(0.5, 1), false));
244	constr.push(new mxConnectionConstraint(new mxPoint(0.25, 1), false));
245	constr.push(new mxConnectionConstraint(new mxPoint(0, 1), false, null, 2.9, -2.9));
246	constr.push(new mxConnectionConstraint(new mxPoint(0, 0.75), false));
247	constr.push(new mxConnectionConstraint(new mxPoint(0, 0.5), false));
248	constr.push(new mxConnectionConstraint(new mxPoint(0, 0.25), false));
249
250	return (constr);
251};
252
253//**********************************************************************************************************************************************************
254//Business Object
255//**********************************************************************************************************************************************************
256/**
257* Extends mxShape.
258*/
259function mxArchiMateBusinessObject(bounds, fill, stroke, strokewidth)
260{
261	mxShape.call(this);
262	this.bounds = bounds;
263	this.fill = fill;
264	this.stroke = stroke;
265	this.strokewidth = (strokewidth != null) ? strokewidth : 1;
266};
267
268/**
269* Extends mxShape.
270*/
271mxUtils.extend(mxArchiMateBusinessObject, mxShape);
272
273mxArchiMateBusinessObject.prototype.cst = {
274		BUSINESS_OBJECT : 'mxgraph.archimate.businessObject'
275};
276
277/**
278* Function: paintVertexShape
279*
280* Paints the vertex shape.
281*/
282mxArchiMateBusinessObject.prototype.paintVertexShape = function(c, x, y, w, h)
283{
284	c.translate(x, y);
285	this.background(c, 0, 0, w, h);
286	c.setShadow(false);
287	this.foreground(c, 0, 0, w, h);
288};
289
290mxArchiMateBusinessObject.prototype.background = function(c, x, y, w, h)
291{
292	c.rect(0, 0, w, h);
293	c.fillAndStroke();
294};
295
296mxArchiMateBusinessObject.prototype.foreground = function(c, x, y, w, h)
297{
298	if (h >= 15)
299	{
300		c.begin();
301		c.moveTo(0, 15);
302		c.lineTo(w, 15);
303		c.stroke();
304	}
305};
306
307mxCellRenderer.registerShape(mxArchiMateBusinessObject.prototype.cst.BUSINESS_OBJECT, mxArchiMateBusinessObject);
308
309mxArchiMateBusinessObject.prototype.getConstraints = function(style, w, h)
310{
311	var constr = [];
312
313	constr.push(new mxConnectionConstraint(new mxPoint(0, 0), false, null, 2.9, 2.9));
314	constr.push(new mxConnectionConstraint(new mxPoint(0.25, 0), false));
315	constr.push(new mxConnectionConstraint(new mxPoint(0.5, 0), false));
316	constr.push(new mxConnectionConstraint(new mxPoint(0.75, 0), false));
317	constr.push(new mxConnectionConstraint(new mxPoint(1, 0), false, null, -2.9, 2.9));
318	constr.push(new mxConnectionConstraint(new mxPoint(1, 0.25), false));
319	constr.push(new mxConnectionConstraint(new mxPoint(1, 0.5), false));
320	constr.push(new mxConnectionConstraint(new mxPoint(1, 0.75), false));
321	constr.push(new mxConnectionConstraint(new mxPoint(1, 1), false, null, -2.9, -2.9));
322	constr.push(new mxConnectionConstraint(new mxPoint(0.75, 1), false));
323	constr.push(new mxConnectionConstraint(new mxPoint(0.5, 1), false));
324	constr.push(new mxConnectionConstraint(new mxPoint(0.25, 1), false));
325	constr.push(new mxConnectionConstraint(new mxPoint(0, 1), false, null, 2.9, -2.9));
326	constr.push(new mxConnectionConstraint(new mxPoint(0, 0.75), false));
327	constr.push(new mxConnectionConstraint(new mxPoint(0, 0.5), false));
328	constr.push(new mxConnectionConstraint(new mxPoint(0, 0.25), false));
329
330	return (constr);
331};
332
333//**********************************************************************************************************************************************************
334//Representation
335//**********************************************************************************************************************************************************
336/**
337* Extends mxShape.
338*/
339function mxArchiMateRepresentation(bounds, fill, stroke, strokewidth)
340{
341	mxShape.call(this);
342	this.bounds = bounds;
343	this.fill = fill;
344	this.stroke = stroke;
345	this.strokewidth = (strokewidth != null) ? strokewidth : 1;
346};
347
348/**
349* Extends mxShape.
350*/
351mxUtils.extend(mxArchiMateRepresentation, mxShape);
352
353mxArchiMateRepresentation.prototype.cst = {
354		REPRESENTATION : 'mxgraph.archimate.representation'
355};
356
357/**
358* Function: paintVertexShape
359*
360* Paints the vertex shape.
361*/
362mxArchiMateRepresentation.prototype.paintVertexShape = function(c, x, y, w, h)
363{
364	c.translate(x, y);
365	this.background(c, 0, 0, w, h);
366};
367
368mxArchiMateRepresentation.prototype.background = function(c, x, y, w, h)
369{
370	c.begin();
371	c.moveTo(0, 0);
372	c.lineTo(w, 0);
373	c.lineTo(w, h * 0.85);
374	c.arcTo(w * 0.35, h * 0.35, 0, 0, 0, w * 0.5, h * 0.85);
375	c.arcTo(w * 0.35, h * 0.35, 0, 0, 1, 0, h * 0.85);
376	c.close();
377	c.fillAndStroke();
378};
379
380mxCellRenderer.registerShape(mxArchiMateRepresentation.prototype.cst.REPRESENTATION, mxArchiMateRepresentation);
381
382mxArchiMateRepresentation.prototype.getConstraints = function(style, w, h)
383{
384	var constr = [];
385
386	constr.push(new mxConnectionConstraint(new mxPoint(0, 0), false));
387	constr.push(new mxConnectionConstraint(new mxPoint(0.25, 0), false));
388	constr.push(new mxConnectionConstraint(new mxPoint(0.5, 0), false));
389	constr.push(new mxConnectionConstraint(new mxPoint(0.75, 0), false));
390	constr.push(new mxConnectionConstraint(new mxPoint(1, 0), false));
391	constr.push(new mxConnectionConstraint(new mxPoint(1, 0.25), false));
392	constr.push(new mxConnectionConstraint(new mxPoint(1, 0.5), false));
393	constr.push(new mxConnectionConstraint(new mxPoint(1, 0.75), false));
394	constr.push(new mxConnectionConstraint(new mxPoint(1, 0.85), false, null));
395	constr.push(new mxConnectionConstraint(new mxPoint(0.75, 0.745), false));
396	constr.push(new mxConnectionConstraint(new mxPoint(0.5, 0.85), false));
397	constr.push(new mxConnectionConstraint(new mxPoint(0.25, 0.955), false));
398	constr.push(new mxConnectionConstraint(new mxPoint(0, 0.85), false));
399	constr.push(new mxConnectionConstraint(new mxPoint(0, 0.75), false));
400	constr.push(new mxConnectionConstraint(new mxPoint(0, 0.5), false));
401	constr.push(new mxConnectionConstraint(new mxPoint(0, 0.25), false));
402
403	return (constr);
404};
405
406//**********************************************************************************************************************************************************
407//Product
408//**********************************************************************************************************************************************************
409/**
410* Extends mxShape.
411*/
412function mxArchiMateProduct(bounds, fill, stroke, strokewidth)
413{
414	mxShape.call(this);
415	this.bounds = bounds;
416	this.fill = fill;
417	this.stroke = stroke;
418	this.strokewidth = (strokewidth != null) ? strokewidth : 1;
419};
420
421/**
422* Extends mxShape.
423*/
424mxUtils.extend(mxArchiMateProduct, mxShape);
425
426mxArchiMateProduct.prototype.cst = {
427		PRODUCT : 'mxgraph.archimate.product'
428};
429
430/**
431* Function: paintVertexShape
432*
433* Paints the vertex shape.
434*/
435mxArchiMateProduct.prototype.paintVertexShape = function(c, x, y, w, h)
436{
437	c.translate(x, y);
438	this.background(c, 0, 0, w, h);
439	c.setShadow(false);
440	this.foreground(c, 0, 0, w, h);
441};
442
443mxArchiMateProduct.prototype.background = function(c, x, y, w, h)
444{
445	c.rect(0, 0, w, h);
446	c.fillAndStroke();
447};
448
449mxArchiMateProduct.prototype.foreground = function(c, x, y, w, h)
450{
451	if (h >= 15)
452	{
453		c.begin();
454		c.moveTo(0, 15);
455		c.lineTo(w * 0.6, 15);
456		c.lineTo(w * 0.6, 0);
457		c.stroke();
458	}
459};
460
461mxCellRenderer.registerShape(mxArchiMateProduct.prototype.cst.PRODUCT, mxArchiMateProduct);
462
463//**********************************************************************************************************************************************************
464//Application
465//**********************************************************************************************************************************************************
466/**
467* Extends mxShape.
468*/
469function mxArchiMateApplication(bounds, fill, stroke, strokewidth)
470{
471	mxShape.call(this);
472	this.bounds = bounds;
473	this.fill = fill;
474	this.stroke = stroke;
475	this.strokewidth = (strokewidth != null) ? strokewidth : 1;
476};
477
478/**
479* Extends mxShape.
480*/
481mxUtils.extend(mxArchiMateApplication, mxShape);
482
483mxArchiMateApplication.prototype.cst = {
484		APPLICATION : 'mxgraph.archimate.application',
485		TYPE : 'appType',
486		COMPONENT : 'comp',
487		INTERFACE : 'interface',
488		INTERFACE2 : 'interface2',
489		FUNCTION : 'function',
490		INTERACTION : 'interaction',
491		SERVICE : 'service',
492		NODE : 'node',
493		NETWORK : 'network',
494		COMM_PATH : 'commPath',
495		SYS_SW : 'sysSw',
496		ARTIFACT : 'artifact',
497		ACTOR : 'actor',
498		ROLE : 'role',
499		COLLABORATION : 'collab'
500};
501
502mxArchiMateApplication.prototype.customProperties = [
503	{name: 'appType', dispName: 'App Type', type: 'enum',
504		enumList: [{val: 'comp', dispName: 'Component'},
505				   {val: 'interface', dispName: 'Interface'},
506				   {val: 'interface2', dispName: 'Interface2'},
507				   {val: 'function', dispName: 'Function'},
508				   {val: 'interaction', dispName: 'Interaction'},
509				   {val: 'service', dispName: 'Service'},
510				   {val: 'node', dispName: 'Node'},
511				   {val: 'network', dispName: 'Network'},
512				   {val: 'commPath', dispName: 'Comm Path'},
513				   {val: 'artifact', dispName: 'Artifact'},
514				   {val: 'sysSw', dispName: 'System Sw'},
515				   {val: 'path', dispName: 'Path'},
516				   {val: 'actor', dispName: 'Actor'},
517				   {val: 'role', dispName: 'Role'},
518				   {val: 'collab', dispName: 'Collaboration'}]
519	}
520];
521
522/**
523* Function: paintVertexShape
524*
525* Paints the vertex shape.
526*/
527mxArchiMateApplication.prototype.paintVertexShape = function(c, x, y, w, h)
528{
529	c.translate(x, y);
530	this.background(c, 0, 0, w, h);
531	c.setShadow(false);
532	c.translate(w - 20, 5);
533	this.foreground(c, w - 20, 5, 15, 15);
534};
535
536mxArchiMateApplication.prototype.background = function(c, x, y, w, h)
537{
538	c.rect(0, 0, w, h);
539	c.fillAndStroke();
540};
541
542mxArchiMateApplication.prototype.foreground = function(c, x, y, w, h)
543{
544	var type = mxUtils.getValue(this.style, mxArchiMateApplication.prototype.cst.TYPE, mxArchiMateApplication.prototype.cst.COMPONENT);
545
546	c.setDashed(false);
547
548	if (type === mxArchiMateApplication.prototype.cst.COMPONENT)
549	{
550		c.translate(1, 0);
551		w = w - 2;
552
553		c.rect(w * 0.25, 0, w * 0.75, h);
554		c.stroke();
555
556		c.rect(0, h * 0.25, w * 0.5, h * 0.15);
557		c.fillAndStroke();
558
559		c.rect(0, h * 0.6, w * 0.5, h * 0.15);
560		c.fillAndStroke();
561	}
562	else if (type === mxArchiMateApplication.prototype.cst.COLLABORATION)
563	{
564		c.translate(0, 3);
565		h = h - 6;
566
567		c.ellipse(0, 0, w * 0.6, h);
568		c.stroke();
569		c.ellipse(w * 0.4, 0, w * 0.6, h);
570		c.fillAndStroke();
571	}
572	else if (type === mxArchiMateApplication.prototype.cst.INTERFACE)
573	{
574		c.translate(0, 4);
575		h = h - 8;
576
577		c.ellipse(w * 0.5, 0, w * 0.5, h);
578		c.stroke();
579
580		c.begin();
581		c.moveTo(0, h * 0.5);
582		c.lineTo(w * 0.5, h * 0.5);
583		c.stroke();
584	}
585	else if (type === mxArchiMateApplication.prototype.cst.INTERFACE2)
586	{
587		c.translate(0, 1);
588		h = h - 2;
589
590		c.begin();
591		c.moveTo(0, h * 0.5);
592		c.lineTo(w * 0.6, h * 0.5);
593		c.moveTo(w, 0);
594		c.arcTo(w * 0.4, h * 0.5, 0, 0, 0, w, h);
595		c.stroke();
596	}
597	else if (type === mxArchiMateApplication.prototype.cst.FUNCTION)
598	{
599		c.begin();
600		c.moveTo(w * 0.5, 0);
601		c.lineTo(w, h * 0.2);
602		c.lineTo(w, h);
603		c.lineTo(w * 0.5, h * 0.8);
604		c.lineTo(0, h);
605		c.lineTo(0, h * 0.2);
606		c.close();
607		c.stroke();
608	}
609	else if (type === mxArchiMateApplication.prototype.cst.INTERACTION)
610	{
611		c.begin();
612		c.moveTo(w * 0.55, 0);
613		c.arcTo(w * 0.45, h * 0.5, 0, 0, 1, w * 0.55, h);
614		c.close();
615		c.moveTo(w * 0.45, 0);
616		c.arcTo(w * 0.45, h * 0.5, 0, 0, 0, w * 0.45, h);
617		c.close();
618		c.stroke();
619	}
620	else if (type === mxArchiMateApplication.prototype.cst.SERVICE)
621	{
622		c.translate(0, 3);
623		h = h - 6;
624
625		c.begin();
626		c.moveTo(w - h * 0.5, 0);
627		c.arcTo(h * 0.5, h * 0.5, 0, 0, 1, w - h * 0.5, h);
628		c.lineTo(0, h);
629		c.arcTo(h * 0.5, h * 0.5, 0, 0, 1, 0, 0);
630		c.close();
631		c.stroke();
632	}
633	else if (type === mxArchiMateApplication.prototype.cst.NODE)
634	{
635		c.begin();
636		c.moveTo(0, h * 0.25);
637		c.lineTo(w * 0.25, 0);
638		c.lineTo(w, 0);
639		c.lineTo(w, h * 0.75);
640		c.lineTo(w * 0.75, h);
641		c.lineTo(0, h);
642		c.close();
643		c.moveTo(0, h * 0.25);
644		c.lineTo(w * 0.75, h * 0.25);
645		c.lineTo(w * 0.75, h);
646		c.moveTo(w, 0);
647		c.lineTo(w * 0.75, h * 0.25);
648		c.stroke();
649	}
650	else if (type === mxArchiMateApplication.prototype.cst.NETWORK)
651	{
652		c.translate(0, 2);
653		h = h - 4;
654
655		c.begin();
656		c.moveTo(w * 0.4, h * 0.2);
657		c.lineTo(w * 0.85, h * 0.2);
658		c.lineTo(w * 0.6, h * 0.8);
659		c.lineTo(w * 0.15, h * 0.8);
660		c.close();
661		c.stroke();
662
663		var strokeColor = mxUtils.getValue(this.style, mxConstants.STYLE_STROKECOLOR, '#000000');
664		c.setFillColor(strokeColor);
665
666		c.ellipse(w * 0.25, 0, w * 0.3, h * 0.4);
667		c.fill();
668
669		c.ellipse(w * 0.7, 0, w * 0.3, h * 0.4);
670		c.fill();
671
672		c.ellipse(0, h * 0.6, w * 0.3, h * 0.4);
673		c.fill();
674
675		c.ellipse(w * 0.45, h * 0.6, w * 0.3, h * 0.4);
676		c.fill();
677	}
678	else if (type === mxArchiMateApplication.prototype.cst.COMM_PATH)
679	{
680		c.translate(0, 5);
681		h = h - 10;
682
683		c.begin();
684		c.moveTo(w * 0.1, 0);
685		c.lineTo(0, h * 0.5);
686		c.lineTo(w * 0.1, h);
687		c.moveTo(w * 0.9, 0);
688		c.lineTo(w, h * 0.5);
689		c.lineTo(w * 0.9, h);
690		c.stroke();
691
692		c.setDashed(true);
693		c.begin();
694		c.moveTo(0, h * 0.5);
695		c.lineTo(w, h * 0.5);
696		c.stroke();
697	}
698	else if (type === mxArchiMateApplication.prototype.cst.SYS_SW)
699	{
700		c.ellipse(w * 0.3, 0, w * 0.7, h * 0.7);
701		c.stroke();
702
703		c.ellipse(0, h * 0.02, w * 0.98, h * 0.98);
704		c.fillAndStroke();
705	}
706	else if (type === mxArchiMateApplication.prototype.cst.ARTIFACT)
707	{
708		c.translate(2, 0);
709		w = w - 4;
710
711		c.begin();
712		c.moveTo(0, 0);
713		c.lineTo(w * 0.7, 0);
714		c.lineTo(w, h * 0.22);
715		c.lineTo(w, h);
716		c.lineTo(0, h);
717		c.close();
718		c.moveTo(w * 0.7, 0);
719		c.lineTo(w * 0.7, h * 0.22);
720		c.lineTo(w, h * 0.22);
721		c.stroke();
722	}
723	else if (type === mxArchiMateApplication.prototype.cst.ACTOR)
724	{
725		c.translate(3, 0);
726		w = w - 6;
727		c.ellipse(w * 0.2, 0, w * 0.6, h * 0.3);
728		c.stroke();
729
730		c.begin();
731		c.moveTo(w * 0.5, h * 0.3);
732		c.lineTo(w * 0.5, h * 0.75);
733		c.moveTo(0, h * 0.45);
734		c.lineTo(w, h * 0.45);
735		c.moveTo(0, h);
736		c.lineTo(w * 0.5, h * 0.75);
737		c.lineTo(w, h);
738		c.stroke();
739	}
740	if (type === mxArchiMateApplication.prototype.cst.ROLE)
741	{
742		c.translate(0, 4);
743		h = h - 8;
744
745		c.begin();
746		c.moveTo(w * 0.8, 0);
747		c.lineTo(w * 0.2, 0);
748		c.arcTo(w * 0.2, h * 0.5, 0, 0, 0, w * 0.2, h);
749		c.lineTo(w * 0.8, h);
750		c.stroke();
751
752		c.ellipse(w * 0.6, 0, w * 0.4, h);
753		c.stroke();
754	}
755};
756
757mxCellRenderer.registerShape(mxArchiMateApplication.prototype.cst.APPLICATION, mxArchiMateApplication);
758
759mxArchiMateApplication.prototype.getConstraints = function(style, w, h)
760{
761	var constr = [];
762
763	constr.push(new mxConnectionConstraint(new mxPoint(0, 0), false));
764	constr.push(new mxConnectionConstraint(new mxPoint(0.25, 0), false));
765	constr.push(new mxConnectionConstraint(new mxPoint(0.5, 0), false));
766	constr.push(new mxConnectionConstraint(new mxPoint(0.75, 0), false));
767	constr.push(new mxConnectionConstraint(new mxPoint(1, 0), false));
768	constr.push(new mxConnectionConstraint(new mxPoint(1, 0.25), false));
769	constr.push(new mxConnectionConstraint(new mxPoint(1, 0.5), false));
770	constr.push(new mxConnectionConstraint(new mxPoint(1, 0.75), false));
771	constr.push(new mxConnectionConstraint(new mxPoint(1, 1), false));
772	constr.push(new mxConnectionConstraint(new mxPoint(0.75, 1), false));
773	constr.push(new mxConnectionConstraint(new mxPoint(0.5, 1), false));
774	constr.push(new mxConnectionConstraint(new mxPoint(0.25, 1), false));
775	constr.push(new mxConnectionConstraint(new mxPoint(0, 1), false));
776	constr.push(new mxConnectionConstraint(new mxPoint(0, 0.75), false));
777	constr.push(new mxConnectionConstraint(new mxPoint(0, 0.5), false));
778	constr.push(new mxConnectionConstraint(new mxPoint(0, 0.25), false));
779
780	return (constr);
781};
782
783//**********************************************************************************************************************************************************
784//Tech
785//**********************************************************************************************************************************************************
786/**
787* Extends mxShape.
788*/
789function mxArchiMateTech(bounds, fill, stroke, strokewidth)
790{
791	mxShape.call(this);
792	this.bounds = bounds;
793	this.fill = fill;
794	this.stroke = stroke;
795	this.strokewidth = (strokewidth != null) ? strokewidth : 1;
796};
797
798/**
799* Extends mxShape.
800*/
801mxUtils.extend(mxArchiMateTech, mxShape);
802
803mxArchiMateTech.prototype.cst = {
804		TECH : 'mxgraph.archimate.tech',
805		TYPE : 'techType',
806		DEVICE : 'device',
807		PLATEAU : 'plateau'
808};
809
810mxArchiMateTech.prototype.customProperties = [
811	{name: 'techType', dispName: 'Tech Type', type: 'enum',
812		enumList: [{val: 'device', dispName: 'Device'},
813				   {val: 'plateau', dispName: 'Plateau'}]
814	}
815];
816
817/**
818* Function: paintVertexShape
819*
820* Paints the vertex shape.
821*/
822mxArchiMateTech.prototype.paintVertexShape = function(c, x, y, w, h)
823{
824	c.translate(x, y);
825	this.background(c, 0, 0, w, h);
826	c.setShadow(false);
827	c.translate(w - 30, 15);
828	this.foreground(c, w - 30, 15, 15, 15);
829};
830
831mxArchiMateTech.prototype.background = function(c, x, y, w, h)
832{
833	c.begin();
834	c.moveTo(0, 10);
835	c.lineTo(10, 0);
836	c.lineTo(w, 0);
837	c.lineTo(w, h - 10);
838	c.lineTo(w - 10, h);
839	c.lineTo(0, h);
840	c.close();
841	c.moveTo(0, 10);
842	c.lineTo(w - 10, 10);
843	c.lineTo(w - 10, h);
844	c.moveTo(w, 0);
845	c.lineTo(w - 10, 10);
846	c.fillAndStroke();
847};
848
849mxArchiMateTech.prototype.foreground = function(c, x, y, w, h)
850{
851	var type = mxUtils.getValue(this.style, mxArchiMateTech.prototype.cst.TYPE, mxArchiMateTech.prototype.cst.DEVICE);
852
853	c.setDashed(false);
854
855	if (type === mxArchiMateTech.prototype.cst.DEVICE)
856	{
857		c.roundrect(0, 0, w, h * 0.88, w * 0.05, h * 0.05);
858		c.stroke();
859		c.begin();
860		c.moveTo(w * 0.1, h * 0.88);
861		c.lineTo(0, h);
862		c.lineTo(w, h);
863		c.lineTo(w * 0.9, h * 0.88);
864		c.stroke();
865	}
866	else if (type === mxArchiMateTech.prototype.cst.PLATEAU)
867	{
868		var strokeColor = mxUtils.getValue(this.style, mxConstants.STYLE_STROKECOLOR, '#000000');
869		c.setFillColor(strokeColor);
870
871		c.rect(w * 0.4, 0, w * 0.6, h * 0.2);
872		c.fill();
873
874		c.rect(w * 0.2, h * 0.4, w * 0.6, h * 0.2);
875		c.fill();
876
877		c.rect(0, h * 0.8, w * 0.6, h * 0.2);
878		c.fill();
879	}
880};
881
882mxCellRenderer.registerShape(mxArchiMateTech.prototype.cst.TECH, mxArchiMateTech);
883
884mxArchiMateTech.prototype.getConstraints = function(style, w, h)
885{
886	var constr = [];
887
888	constr.push(new mxConnectionConstraint(new mxPoint(0, 0), false, null, 0, 10));
889	constr.push(new mxConnectionConstraint(new mxPoint(0, 0), false, null, 10, 0));
890	constr.push(new mxConnectionConstraint(new mxPoint(0.25, 0), false));
891	constr.push(new mxConnectionConstraint(new mxPoint(0.5, 0), false));
892	constr.push(new mxConnectionConstraint(new mxPoint(0.75, 0), false));
893	constr.push(new mxConnectionConstraint(new mxPoint(1, 0), false));
894	constr.push(new mxConnectionConstraint(new mxPoint(1, 0.25), false));
895	constr.push(new mxConnectionConstraint(new mxPoint(1, 0.5), false));
896	constr.push(new mxConnectionConstraint(new mxPoint(1, 0.75), false));
897	constr.push(new mxConnectionConstraint(new mxPoint(1, 1), false, null, 0, -10));
898	constr.push(new mxConnectionConstraint(new mxPoint(1, 1), false, null, -10, 0));
899	constr.push(new mxConnectionConstraint(new mxPoint(0.75, 1), false));
900	constr.push(new mxConnectionConstraint(new mxPoint(0.5, 1), false));
901	constr.push(new mxConnectionConstraint(new mxPoint(0.25, 1), false));
902	constr.push(new mxConnectionConstraint(new mxPoint(0, 1), false));
903	constr.push(new mxConnectionConstraint(new mxPoint(0, 0.75), false));
904	constr.push(new mxConnectionConstraint(new mxPoint(0, 0.5), false));
905	constr.push(new mxConnectionConstraint(new mxPoint(0, 0.25), false));
906
907	return (constr);
908};
909
910//**********************************************************************************************************************************************************
911//Motivational
912//**********************************************************************************************************************************************************
913/**
914* Extends mxShape.
915*/
916function mxArchiMateMotivational(bounds, fill, stroke, strokewidth)
917{
918	mxShape.call(this);
919	this.bounds = bounds;
920	this.fill = fill;
921	this.stroke = stroke;
922	this.strokewidth = (strokewidth != null) ? strokewidth : 1;
923};
924
925/**
926* Extends mxShape.
927*/
928mxUtils.extend(mxArchiMateMotivational, mxShape);
929
930mxArchiMateMotivational.prototype.cst = {
931		MOTIV : 'mxgraph.archimate.motiv',
932		TYPE : 'motivType',
933		STAKE : 'stake',
934		DRIVER : 'driver',
935		ASSESSMENT : 'assess',
936		GOAL : 'goal',
937		REQUIREMENT : 'req',
938		CONSTRAINT : 'const',
939		PRINCIPLE : 'princ'
940};
941
942mxArchiMateMotivational.prototype.customProperties = [
943	{name: 'motivType', dispName: 'Motivational Type', type: 'enum',
944		enumList: [{val: 'stake', dispName: 'Stake'},
945				   {val: 'driver', dispName: 'Driver'},
946				   {val: 'assess', dispName: 'Assessment'},
947				   {val: 'goal', dispName: 'Goal'},
948				   {val: 'req', dispName: 'Requirement'},
949				   {val: 'const', dispName: 'Constraint'},
950				   {val: 'princ', dispName: 'Principle'}]
951	}
952];
953
954/**
955* Function: paintVertexShape
956*
957* Paints the vertex shape.
958*/
959mxArchiMateMotivational.prototype.paintVertexShape = function(c, x, y, w, h)
960{
961	c.translate(x, y);
962	this.background(c, 0, 0, w, h);
963	c.setShadow(false);
964	c.translate(w - 20, 5);
965	this.foreground(c, w - 20, 5, 15, 15);
966};
967
968mxArchiMateMotivational.prototype.background = function(c, x, y, w, h)
969{
970	c.begin();
971	c.moveTo(10, 0);
972	c.lineTo(w - 10, 0);
973	c.lineTo(w, 10);
974	c.lineTo(w, h - 10);
975	c.lineTo(w - 10, h);
976	c.lineTo(10, h);
977	c.lineTo(0, h - 10);
978	c.lineTo(0, 10);
979	c.close();
980	c.fillAndStroke();
981};
982
983mxArchiMateMotivational.prototype.foreground = function(c, x, y, w, h)
984{
985	var type = mxUtils.getValue(this.style, mxArchiMateMotivational.prototype.cst.TYPE, mxArchiMateMotivational.prototype.cst.STAKE);
986
987	c.setDashed(false);
988
989	if (type === mxArchiMateMotivational.prototype.cst.STAKE)
990	{
991		c.translate(0, 4);
992		h = h - 8;
993
994		c.begin();
995		c.moveTo(w * 0.8, 0);
996		c.lineTo(w * 0.2, 0);
997		c.arcTo(w * 0.2, h * 0.5, 0, 0, 0, w * 0.2, h);
998		c.lineTo(w * 0.8, h);
999		c.stroke();
1000
1001		c.ellipse(w * 0.6, 0, w * 0.4, h);
1002		c.stroke();
1003	}
1004	else if (type === mxArchiMateMotivational.prototype.cst.DRIVER)
1005	{
1006		c.ellipse(w * 0.1, h * 0.1, w * 0.8, h * 0.8);
1007		c.stroke();
1008
1009		c.begin();
1010		c.moveTo(0, h * 0.5);
1011		c.lineTo(w, h * 0.5);
1012		c.moveTo(w * 0.5, 0);
1013		c.lineTo(w * 0.5, h);
1014		c.moveTo(w * 0.145, h * 0.145);
1015		c.lineTo(w * 0.855, h * 0.855);
1016		c.moveTo(w * 0.145, h * 0.855);
1017		c.lineTo(w * 0.855, h * 0.145);
1018		c.stroke();
1019
1020		var strokeColor = mxUtils.getValue(this.style, mxConstants.STYLE_STROKECOLOR, '#000000');
1021		c.setFillColor(strokeColor);
1022
1023		c.ellipse(w * 0.35, h * 0.35, w * 0.3, h * 0.3);
1024		c.fillAndStroke();
1025	}
1026	else if (type === mxArchiMateMotivational.prototype.cst.ASSESSMENT)
1027	{
1028		c.ellipse(w * 0.2, 0, w * 0.8, h * 0.8);
1029		c.stroke();
1030
1031		c.begin();
1032		c.moveTo(0, h);
1033		c.lineTo(w * 0.32, h * 0.68);
1034		c.stroke();
1035	}
1036	else if (type === mxArchiMateMotivational.prototype.cst.GOAL)
1037	{
1038		c.ellipse(0, 0, w, h);
1039		c.stroke();
1040		c.ellipse(w * 0.15, h * 0.15, w * 0.7, h * 0.7);
1041		c.stroke();
1042		var strokeColor = mxUtils.getValue(this.style, mxConstants.STYLE_STROKECOLOR, '#000000');
1043		c.setFillColor(strokeColor);
1044		c.ellipse(w * 0.3, h * 0.3, w * 0.4, h * 0.4);
1045		c.fillAndStroke();
1046	}
1047	else if (type === mxArchiMateMotivational.prototype.cst.REQUIREMENT)
1048	{
1049		c.translate(0, 4);
1050		h = h - 8;
1051
1052		c.begin();
1053		c.moveTo(w * 0.25, 0);
1054		c.lineTo(w, 0);
1055		c.lineTo(w * 0.75, h);
1056		c.lineTo(0, h);
1057		c.close();
1058		c.stroke();
1059	}
1060	else if (type === mxArchiMateMotivational.prototype.cst.CONSTRAINT)
1061	{
1062		c.translate(0, 4);
1063		h = h - 8;
1064
1065		c.begin();
1066		c.moveTo(w * 0.25, 0);
1067		c.lineTo(w, 0);
1068		c.lineTo(w * 0.75, h);
1069		c.lineTo(0, h);
1070		c.close();
1071		c.moveTo(w * 0.45, 0);
1072		c.lineTo(w * 0.2, h);
1073		c.stroke();
1074	}
1075	else if (type === mxArchiMateMotivational.prototype.cst.PRINCIPLE)
1076	{
1077		c.begin();
1078		c.moveTo(w * 0.05, h * 0.05);
1079		c.arcTo(w * 2.3, h * 2.3, 0, 0, 1, w * 0.95, h * 0.05);
1080		c.arcTo(w * 2.3, h * 2.3, 0, 0, 1, w * 0.95, h * 0.95);
1081		c.arcTo(w * 2.3, h * 2.3, 0, 0, 1, w * 0.05, h * 0.95);
1082		c.arcTo(w * 2.3, h * 2.3, 0, 0, 1, w * 0.05, h * 0.05);
1083		c.close();
1084		c.stroke();
1085
1086		var strokeColor = mxUtils.getValue(this.style, mxConstants.STYLE_STROKECOLOR, '#000000');
1087		c.setFillColor(strokeColor);
1088
1089		c.begin();
1090		c.moveTo(w * 0.45, h * 0.7);
1091		c.lineTo(w * 0.42, h * 0.15);
1092		c.lineTo(w * 0.58, h * 0.15);
1093		c.lineTo(w * 0.55, h * 0.7);
1094		c.close();
1095		c.fill();
1096
1097		c.rect(w * 0.45, h * 0.75, w * 0.1, h * 0.1);
1098		c.fill();
1099	}
1100};
1101
1102mxCellRenderer.registerShape(mxArchiMateMotivational.prototype.cst.MOTIV, mxArchiMateMotivational);
1103
1104mxArchiMateMotivational.prototype.getConstraints = function(style, w, h)
1105{
1106	var constr = [];
1107
1108	constr.push(new mxConnectionConstraint(new mxPoint(0, 0), false, null, 5, 5));
1109	constr.push(new mxConnectionConstraint(new mxPoint(0.25, 0), false));
1110	constr.push(new mxConnectionConstraint(new mxPoint(0.5, 0), false));
1111	constr.push(new mxConnectionConstraint(new mxPoint(0.75, 0), false));
1112	constr.push(new mxConnectionConstraint(new mxPoint(1, 0), false, null, -5, 5));
1113	constr.push(new mxConnectionConstraint(new mxPoint(1, 0.25), false));
1114	constr.push(new mxConnectionConstraint(new mxPoint(1, 0.5), false));
1115	constr.push(new mxConnectionConstraint(new mxPoint(1, 0.75), false));
1116	constr.push(new mxConnectionConstraint(new mxPoint(1, 1), false, null, -5, -5));
1117	constr.push(new mxConnectionConstraint(new mxPoint(0.75, 1), false));
1118	constr.push(new mxConnectionConstraint(new mxPoint(0.5, 1), false));
1119	constr.push(new mxConnectionConstraint(new mxPoint(0.25, 1), false));
1120	constr.push(new mxConnectionConstraint(new mxPoint(0, 1), false, null, 5, -5));
1121	constr.push(new mxConnectionConstraint(new mxPoint(0, 0.75), false));
1122	constr.push(new mxConnectionConstraint(new mxPoint(0, 0.5), false));
1123	constr.push(new mxConnectionConstraint(new mxPoint(0, 0.25), false));
1124
1125	return (constr);
1126};
1127
1128//**********************************************************************************************************************************************************
1129//Gap
1130//**********************************************************************************************************************************************************
1131/**
1132* Extends mxShape.
1133*/
1134function mxArchiMateGap(bounds, fill, stroke, strokewidth)
1135{
1136	mxShape.call(this);
1137	this.bounds = bounds;
1138	this.fill = fill;
1139	this.stroke = stroke;
1140	this.strokewidth = (strokewidth != null) ? strokewidth : 1;
1141};
1142
1143/**
1144* Extends mxShape.
1145*/
1146mxUtils.extend(mxArchiMateGap, mxShape);
1147
1148mxArchiMateGap.prototype.cst = {
1149		GAP : 'mxgraph.archimate.gap'
1150};
1151
1152/**
1153* Function: paintVertexShape
1154*
1155* Paints the vertex shape.
1156*/
1157mxArchiMateGap.prototype.paintVertexShape = function(c, x, y, w, h)
1158{
1159	c.translate(x, y);
1160	this.background(c, 0, 0, w, h);
1161	c.setShadow(false);
1162	c.translate(w - 20, 5);
1163	this.foreground(c, w - 20, 5, 15, 15);
1164};
1165
1166mxArchiMateGap.prototype.background = function(c, x, y, w, h)
1167{
1168	c.begin();
1169	c.moveTo(0, 0);
1170	c.lineTo(w, 0);
1171	c.lineTo(w, h * 0.85);
1172	c.arcTo(w * 0.35, h * 0.35, 0, 0, 0, w * 0.5, h * 0.85);
1173	c.arcTo(w * 0.35, h * 0.35, 0, 0, 1, 0, h * 0.85);
1174	c.close();
1175	c.fillAndStroke();
1176};
1177
1178mxArchiMateGap.prototype.foreground = function(c, x, y, w, h)
1179{
1180	c.setDashed(false);
1181
1182	c.translate(0, 2);
1183	h = h - 4;
1184
1185	c.ellipse(w * 0.15, 0, w * 0.7, h);
1186	c.stroke();
1187
1188	c.begin();
1189	c.moveTo(0, h * 0.35);
1190	c.lineTo(w, h * 0.35);
1191	c.moveTo(0, h * 0.65);
1192	c.lineTo(w, h * 0.65);
1193	c.stroke();
1194};
1195
1196mxCellRenderer.registerShape(mxArchiMateGap.prototype.cst.GAP, mxArchiMateGap);
1197
1198mxArchiMateGap.prototype.getConstraints = function(style, w, h)
1199{
1200	var constr = [];
1201
1202	constr.push(new mxConnectionConstraint(new mxPoint(0, 0), false));
1203	constr.push(new mxConnectionConstraint(new mxPoint(0.25, 0), false));
1204	constr.push(new mxConnectionConstraint(new mxPoint(0.5, 0), false));
1205	constr.push(new mxConnectionConstraint(new mxPoint(0.75, 0), false));
1206	constr.push(new mxConnectionConstraint(new mxPoint(1, 0), false));
1207	constr.push(new mxConnectionConstraint(new mxPoint(1, 0.25), false));
1208	constr.push(new mxConnectionConstraint(new mxPoint(1, 0.5), false));
1209	constr.push(new mxConnectionConstraint(new mxPoint(1, 0.75), false));
1210	constr.push(new mxConnectionConstraint(new mxPoint(1, 0.85), false, null));
1211	constr.push(new mxConnectionConstraint(new mxPoint(0.75, 0.745), false));
1212	constr.push(new mxConnectionConstraint(new mxPoint(0.5, 0.85), false));
1213	constr.push(new mxConnectionConstraint(new mxPoint(0.25, 0.955), false));
1214	constr.push(new mxConnectionConstraint(new mxPoint(0, 0.85), false));
1215	constr.push(new mxConnectionConstraint(new mxPoint(0, 0.75), false));
1216	constr.push(new mxConnectionConstraint(new mxPoint(0, 0.5), false));
1217	constr.push(new mxConnectionConstraint(new mxPoint(0, 0.25), false));
1218
1219	return (constr);
1220};
1221