1/**
2 * $Id: mxDFD.js,v 1.5 2018/26/11 12:32:06 mate Exp $
3 * Copyright (c) 2006-2018, JGraph Ltd
4 */
5//**********************************************************************************************************************************************************
6// Start
7//**********************************************************************************************************************************************************
8/**
9* Extends mxShape.
10*/
11function mxShapeDFDStart(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/**
21* Extends mxShape.
22*/
23mxUtils.extend(mxShapeDFDStart, mxShape);
24
25mxShapeDFDStart.prototype.cst = {START : 'mxgraph.dfd.start'};
26
27/**
28* Function: paintVertexShape
29*
30* Paints the vertex shape.
31*/
32mxShapeDFDStart.prototype.paintVertexShape = function(c, x, y, w, h)
33{
34	c.translate(x, y);
35	var r = Math.min(h * 0.5, w * 0.5);
36
37	c.begin();
38	c.moveTo(w - r, h * 0.5 - r);
39	c.arcTo(r, r, 0, 0, 1, w, h * 0.5);
40	c.arcTo(r, r, 0, 0, 1, w - r, h * 0.5 + r);
41	c.lineTo(r, h * 0.5 + r);
42	c.arcTo(r, r, 0, 0, 1, 0, h * 0.5);
43	c.arcTo(r, r, 0, 0, 1, r, h * 0.5 - r);
44	c.close();
45	c.fillAndStroke();
46};
47
48mxCellRenderer.registerShape(mxShapeDFDStart.prototype.cst.START, mxShapeDFDStart);
49
50mxShapeDFDStart.prototype.getConstraints = function(style, w, h)
51{
52	var constr = [];
53	var r = Math.min(h * 0.5, w * 0.5);
54
55	constr.push(new mxConnectionConstraint(new mxPoint(0, 0.5), false));
56	constr.push(new mxConnectionConstraint(new mxPoint(0.5, 0.5), false, null, 0, -r));
57	constr.push(new mxConnectionConstraint(new mxPoint(1, 0.5), false));
58	constr.push(new mxConnectionConstraint(new mxPoint(0.5, 0.5), false, null, 0, r));
59	constr.push(new mxConnectionConstraint(new mxPoint(0, 0), false, null, r * 0.293, h * 0.5 - r * 0.707));
60	constr.push(new mxConnectionConstraint(new mxPoint(0, 0), false, null, w - r * 0.293, h * 0.5 - r * 0.707));
61	constr.push(new mxConnectionConstraint(new mxPoint(0, 0), false, null, w - r * 0.293, h * 0.5 + r * 0.707));
62	constr.push(new mxConnectionConstraint(new mxPoint(0, 0), false, null, r * 0.293, h * 0.5 + r * 0.707));
63
64	if (w >= 4 * h)
65	{
66		constr.push(new mxConnectionConstraint(new mxPoint(0.25, 0), false));
67		constr.push(new mxConnectionConstraint(new mxPoint(0.75, 0), false));
68		constr.push(new mxConnectionConstraint(new mxPoint(0.75, 1), false));
69		constr.push(new mxConnectionConstraint(new mxPoint(0.25, 1), false));
70	}
71
72	return (constr);
73}
74
75//**********************************************************************************************************************************************************
76//Archive
77//**********************************************************************************************************************************************************
78/**
79* Extends mxShape.
80*/
81function mxShapeDFDArchive(bounds, fill, stroke, strokewidth)
82{
83	mxShape.call(this);
84	this.bounds = bounds;
85	this.fill = fill;
86	this.stroke = stroke;
87	this.strokewidth = (strokewidth != null) ? strokewidth : 1;
88};
89
90/**
91* Extends mxShape.
92*/
93mxUtils.extend(mxShapeDFDArchive, mxShape);
94
95mxShapeDFDArchive.prototype.cst = {ARCHIVE : 'mxgraph.dfd.archive'};
96
97/**
98* Function: paintVertexShape
99*
100* Paints the vertex shape.
101*/
102mxShapeDFDArchive.prototype.paintVertexShape = function(c, x, y, w, h)
103{
104	c.translate(x, y);
105
106	c.begin();
107	c.moveTo(0,0);
108	c.lineTo(w, 0);
109	c.lineTo(w * 0.5, h);
110	c.close();
111	c.fillAndStroke();
112
113	c.setShadow(false);
114
115	c.begin();
116	c.moveTo(w * 0.1, h * 0.2);
117	c.lineTo(w * 0.9, h * 0.2);
118	c.stroke();
119};
120
121mxCellRenderer.registerShape(mxShapeDFDArchive.prototype.cst.ARCHIVE, mxShapeDFDArchive);
122
123mxShapeDFDArchive.prototype.getConstraints = function(style, w, h)
124{
125	var constr = [];
126
127	constr.push(new mxConnectionConstraint(new mxPoint(0, 0), false));
128	constr.push(new mxConnectionConstraint(new mxPoint(0.25, 0), false));
129	constr.push(new mxConnectionConstraint(new mxPoint(0.5, 0), false));
130	constr.push(new mxConnectionConstraint(new mxPoint(0.75, 0), false));
131	constr.push(new mxConnectionConstraint(new mxPoint(1, 0), false));
132	constr.push(new mxConnectionConstraint(new mxPoint(0.875, 0.25), false));
133	constr.push(new mxConnectionConstraint(new mxPoint(0.75, 0.5), false));
134	constr.push(new mxConnectionConstraint(new mxPoint(0.625, 0.75), false));
135	constr.push(new mxConnectionConstraint(new mxPoint(0.5, 1), false));
136	constr.push(new mxConnectionConstraint(new mxPoint(0.375, 0.75), false));
137	constr.push(new mxConnectionConstraint(new mxPoint(0.25, 0.5), false));
138	constr.push(new mxConnectionConstraint(new mxPoint(0.125, 0.25), false));
139
140	return (constr);
141}
142
143//**********************************************************************************************************************************************************
144//Check2
145//**********************************************************************************************************************************************************
146/**
147* Extends mxShape.
148*/
149function mxShapeDFDCheck2(bounds, fill, stroke, strokewidth)
150{
151	mxShape.call(this);
152	this.bounds = bounds;
153	this.fill = fill;
154	this.stroke = stroke;
155	this.strokewidth = (strokewidth != null) ? strokewidth : 1;
156};
157
158/**
159* Extends mxShape.
160*/
161mxUtils.extend(mxShapeDFDCheck2, mxShape);
162
163mxShapeDFDCheck2.prototype.cst = {CHECK2 : 'mxgraph.dfd.check2'};
164
165/**
166* Function: paintVertexShape
167*
168* Paints the vertex shape.
169*/
170mxShapeDFDCheck2.prototype.paintVertexShape = function(c, x, y, w, h)
171{
172	c.translate(x, y);
173	var size = Math.min(h * 0.5, w * 0.5);
174
175	c.begin();
176	c.moveTo(0, h * 0.5);
177	c.lineTo(size, 0);
178	c.lineTo(w - size, 0);
179	c.lineTo(w, h * 0.5);
180	c.lineTo(w - size, h);
181	c.lineTo(size, h);
182	c.lineTo(0, h * 0.5);
183	c.close();
184	c.fillAndStroke();
185
186	c.setShadow(false);
187
188	c.begin();
189	c.moveTo(w - size, 0);
190	c.lineTo(w - 2 * size, h * 0.5);
191	c.lineTo(w - size, h);
192	c.stroke();
193};
194
195mxCellRenderer.registerShape(mxShapeDFDCheck2.prototype.cst.CHECK2, mxShapeDFDCheck2);
196
197mxShapeDFDCheck2.prototype.getConstraints = function(style, w, h)
198{
199	var constr = [];
200	var size = Math.min(h * 0.5, w * 0.5);
201
202	constr.push(new mxConnectionConstraint(new mxPoint(0.5, 0), false));
203	constr.push(new mxConnectionConstraint(new mxPoint(1, 0.5), false));
204	constr.push(new mxConnectionConstraint(new mxPoint(0.5, 1), false));
205	constr.push(new mxConnectionConstraint(new mxPoint(0, 0.5), false));
206	constr.push(new mxConnectionConstraint(new mxPoint(0, 0), false, null, size * 0.5, h * 0.25));
207	constr.push(new mxConnectionConstraint(new mxPoint(0, 0), false, null, w - size * 0.5, h * 0.25));
208	constr.push(new mxConnectionConstraint(new mxPoint(0, 0), false, null, size * 0.5, h * 0.75));
209	constr.push(new mxConnectionConstraint(new mxPoint(0, 0), false, null, w - size * 0.5, h * 0.75));
210
211	if (w > h)
212	{
213		constr.push(new mxConnectionConstraint(new mxPoint(0, 0), false, null, size, 0));
214		constr.push(new mxConnectionConstraint(new mxPoint(0, 0), false, null, w - size, 0));
215		constr.push(new mxConnectionConstraint(new mxPoint(0, 0), false, null, size, h));
216		constr.push(new mxConnectionConstraint(new mxPoint(0, 0), false, null, w - size, h));
217	}
218
219	if(size * 4 <= w)
220	{
221		constr.push(new mxConnectionConstraint(new mxPoint(0.25, 0), false));
222		constr.push(new mxConnectionConstraint(new mxPoint(0.75, 0), false));
223		constr.push(new mxConnectionConstraint(new mxPoint(0.25, 1), false));
224		constr.push(new mxConnectionConstraint(new mxPoint(0.75, 1), false));
225	}
226
227	return (constr);
228}
229
230//**********************************************************************************************************************************************************
231//Data Store with ID
232//**********************************************************************************************************************************************************
233/**
234* Extends mxShape.
235*/
236function mxShapeDFDDataStoreID(bounds, fill, stroke, strokewidth)
237{
238	mxShape.call(this);
239	this.bounds = bounds;
240	this.fill = fill;
241	this.stroke = stroke;
242	this.strokewidth = (strokewidth != null) ? strokewidth : 1;
243};
244
245/**
246* Extends mxShape.
247*/
248mxUtils.extend(mxShapeDFDDataStoreID, mxShape);
249
250mxShapeDFDDataStoreID.prototype.cst = {DATA_STORE_ID : 'mxgraph.dfd.dataStoreID'};
251
252/**
253* Function: paintVertexShape
254*
255* Paints the vertex shape.
256*/
257mxShapeDFDDataStoreID.prototype.paintVertexShape = function(c, x, y, w, h)
258{
259	c.translate(x, y);
260	var size = Math.min(h * 0.5, w * 0.5);
261
262	c.begin();
263	c.moveTo(w, h);
264	c.lineTo(0, h);
265	c.lineTo(0, 0);
266	c.lineTo(w, 0);
267	c.fillAndStroke();
268
269	c.setShadow(false);
270
271	var s = Math.min(30, w);
272
273	c.begin();
274	c.moveTo(s, 0);
275	c.lineTo(s, h);
276	c.stroke();
277};
278
279mxCellRenderer.registerShape(mxShapeDFDDataStoreID.prototype.cst.DATA_STORE_ID, mxShapeDFDDataStoreID);
280
281mxShapeDFDDataStoreID.prototype.constraints = null;
282
283//**********************************************************************************************************************************************************
284//External Entity
285//**********************************************************************************************************************************************************
286/**
287* Extends mxShape.
288*/
289function mxShapeDFDExternalEntity(bounds, fill, stroke, strokewidth)
290{
291	mxShape.call(this);
292	this.bounds = bounds;
293	this.fill = fill;
294	this.stroke = stroke;
295	this.strokewidth = (strokewidth != null) ? strokewidth : 1;
296};
297
298/**
299* Extends mxShape.
300*/
301mxUtils.extend(mxShapeDFDExternalEntity, mxShape);
302
303mxShapeDFDExternalEntity.prototype.cst = {EXTERNAL_ENTITY : 'mxgraph.dfd.externalEntity'};
304
305/**
306* Function: paintVertexShape
307*
308* Paints the vertex shape.
309*/
310mxShapeDFDExternalEntity.prototype.paintVertexShape = function(c, x, y, w, h)
311{
312	c.translate(x, y);
313	var size = 10;
314
315	c.begin();
316	c.moveTo(0, 0);
317	c.lineTo(w - size, 0);
318	c.lineTo(w, size);
319	c.lineTo(w, h);
320	c.lineTo(size, h);
321	c.lineTo(0, h - size);
322	c.close();
323	c.fillAndStroke();
324
325	c.setShadow(false);
326
327
328	c.setFillColor('#000000');
329	c.setAlpha(0.5);
330
331	c.begin();
332	c.moveTo(0, 0);
333	c.lineTo(w - size, 0);
334	c.lineTo(w, size);
335	c.lineTo(size, size);
336	c.lineTo(size, h);
337	c.lineTo(0, h - size);
338	c.close();
339	c.fill();
340
341	var opacity = parseFloat(mxUtils.getValue(this.style, 'opacity', '100'));
342
343	c.setAlpha(opacity / 100);
344
345	c.begin();
346	c.moveTo(0, 0);
347	c.lineTo(w - size, 0);
348	c.lineTo(w, size);
349	c.lineTo(w, h);
350	c.lineTo(size, h);
351	c.lineTo(0, h - size);
352	c.close();
353	c.moveTo(size, h);
354	c.lineTo(size, size);
355	c.lineTo(w, size);
356	c.moveTo(0, 0);
357	c.lineTo(size, size);
358	c.stroke();
359};
360
361mxCellRenderer.registerShape(mxShapeDFDExternalEntity.prototype.cst.EXTERNAL_ENTITY, mxShapeDFDExternalEntity);
362
363mxShapeDFDExternalEntity.prototype.getConstraints = function(style, w, h)
364{
365	var constr = [];
366	var size = 10;
367
368	constr.push(new mxConnectionConstraint(new mxPoint(0, 0), false));
369	constr.push(new mxConnectionConstraint(new mxPoint(0, 0), false, null, (w - size) * 0.25, 0));
370	constr.push(new mxConnectionConstraint(new mxPoint(0, 0), false, null, (w - size) * 0.5, 0));
371	constr.push(new mxConnectionConstraint(new mxPoint(0, 0), false, null, (w - size) * 0.75, 0));
372	constr.push(new mxConnectionConstraint(new mxPoint(0, 0), false, null, w - size, 0));
373	constr.push(new mxConnectionConstraint(new mxPoint(0, 0), false, null, size, h));
374	constr.push(new mxConnectionConstraint(new mxPoint(0, 0), false, null, (w - size) * 0.25 + size, h));
375	constr.push(new mxConnectionConstraint(new mxPoint(0, 0), false, null, (w - size) * 0.5 + size, h));
376	constr.push(new mxConnectionConstraint(new mxPoint(0, 0), false, null, (w - size) * 0.75 + size, h));
377	constr.push(new mxConnectionConstraint(new mxPoint(1, 1), false));
378	constr.push(new mxConnectionConstraint(new mxPoint(0, 0), false, null, w, size));
379	constr.push(new mxConnectionConstraint(new mxPoint(0, 0), false, null, w, size + (h - size) * 0.25));
380	constr.push(new mxConnectionConstraint(new mxPoint(0, 0), false, null, w, size + (h - size) * 0.5));
381	constr.push(new mxConnectionConstraint(new mxPoint(0, 0), false, null, w, size + (h - size) * 0.75));
382	constr.push(new mxConnectionConstraint(new mxPoint(0, 0), false, null, 0, (h - size) * 0.25));
383	constr.push(new mxConnectionConstraint(new mxPoint(0, 0), false, null, 0, (h - size) * 0.5));
384	constr.push(new mxConnectionConstraint(new mxPoint(0, 0), false, null, 0, (h - size) * 0.75));
385	constr.push(new mxConnectionConstraint(new mxPoint(0, 0), false, null, 0, h - size));
386
387	return (constr);
388}
389
390//**********************************************************************************************************************************************************
391//Loop
392//**********************************************************************************************************************************************************
393/**
394* Extends mxShape.
395*/
396function mxShapeDFDLoop(bounds, fill, stroke, strokewidth)
397{
398	mxShape.call(this);
399	this.bounds = bounds;
400	this.fill = fill;
401	this.stroke = stroke;
402	this.strokewidth = (strokewidth != null) ? strokewidth : 1;
403};
404
405/**
406* Extends mxShape.
407*/
408mxUtils.extend(mxShapeDFDLoop, mxShape);
409
410mxShapeDFDLoop.prototype.cst = {LOOP : 'mxgraph.dfd.loop'};
411
412/**
413* Function: paintVertexShape
414*
415* Paints the vertex shape.
416*/
417mxShapeDFDLoop.prototype.paintVertexShape = function(c, x, y, w, h)
418{
419	c.translate(x, y);
420	var r = Math.min(h * 0.8, w * 0.8);
421
422	c.begin();
423	c.moveTo(w - r * 0.25, 0);
424	c.arcTo(r, r, 0, 0, 1, w - r * 0.25, h);
425	c.lineTo(r * 0.25, h);
426	c.arcTo(r, r, 0, 0, 1, r * 0.25, 0);
427	c.close();
428	c.fillAndStroke();
429};
430
431mxCellRenderer.registerShape(mxShapeDFDLoop.prototype.cst.LOOP, mxShapeDFDLoop);
432
433mxShapeDFDLoop.prototype.getConstraints = function(style, w, h)
434{
435	var constr = [];
436	var r = Math.min(h * 0.8, w * 0.8);
437
438	constr.push(new mxConnectionConstraint(new mxPoint(0, 0), false, null, w - r * 0.25, 0));
439	constr.push(new mxConnectionConstraint(new mxPoint(0, 0), false, null, w - r * 0.25, h));
440	constr.push(new mxConnectionConstraint(new mxPoint(0, 0), false, null, r * 0.25, 0));
441	constr.push(new mxConnectionConstraint(new mxPoint(0, 0), false, null, r * 0.25, h));
442	constr.push(new mxConnectionConstraint(new mxPoint(0.5, 0), false));
443	constr.push(new mxConnectionConstraint(new mxPoint(0.5, 1), false));
444
445	return (constr);
446}
447
448