1/**
2 * $Id: mxCiscoSafe.js,v 1.0 2020/14/05 13:05:39 mate Exp $
3 * Copyright (c) 2006-2020, JGraph Ltd
4 */
5
6//**********************************************************************************************************************************************************
7//Composite Icon
8//**********************************************************************************************************************************************************
9/**
10* Extends mxShape.
11*/
12function mxShapeCiscoSafeCompositeIcon(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(mxShapeCiscoSafeCompositeIcon, mxShape);
25
26mxShapeCiscoSafeCompositeIcon.prototype.cst = {
27		SHAPE_COMPOSITE_ICON : 'mxgraph.cisco_safe.compositeIcon'
28};
29
30/**
31* Function: paintVertexShape
32*
33* Paints the vertex shape.
34*/
35mxShapeCiscoSafeCompositeIcon.prototype.paintVertexShape = function(c, x, y, w, h)
36{
37	var strokeColor = mxUtils.getValue(this.state.style, 'strokeColor', 'none');
38	var bgColor = mxUtils.getValue(this.state.style, 'bgColor', '#C2E0AE');
39	var fillColor = mxUtils.getValue(this.state.style, 'fillColor', 'none');
40	var shadow = mxUtils.getValue(this.state.style, 'shadow', false);
41	var opacity = parseFloat(mxUtils.getValue(this.state.style, 'opacity', false));
42
43	c.translate(x, y);
44
45	var bgIcon = mxUtils.getValue(this.state.style, 'bgIcon', '');
46	var prIcon = mxUtils.getValue(this.state.style, 'resIcon', '');
47	stencil = mxStencilRegistry.getStencil(prIcon);
48
49	if (stencil != null && bgIcon != 'mxgraph.cisco_safe.architecture.generic_appliance')
50	{
51		stencil.drawShape(c, this, 0, 0, w, h);
52	}
53
54	c.setFillColor(strokeColor);
55	c.setStrokeColor('none');
56	c.setShadow(false);
57
58
59	if (bgIcon == 'ellipse')
60	{
61		c.begin();
62
63		(w < 100) ? c.ellipse(w * 0.01, h * 0.01, w * 0.98, h * 0.98) : c.ellipse(1, 1, w - 2, h - 2);
64
65		c.fill();
66	}
67	else if (bgIcon == 'threat1')
68	{
69		c.begin();
70		c.ellipse(w * 0.18, h * 0.16, w * 0.66, h * 0.65);
71		c.fill();
72	}
73	else if (bgIcon == 'threat2')
74	{
75		c.begin();
76		c.ellipse(w * 0.01, h * 0.01, w * 0.98, h * 0.6);
77		c.fill();
78	}
79	else if (bgIcon == 'threat3')
80	{
81		c.begin();
82		c.ellipse(w * 0.18, h * 0.2, w * 0.64, h * 0.79);
83		c.fill();
84	}
85	else if (bgIcon == 'threat4')
86	{
87		c.begin();
88		c.ellipse(w * 0.09, h * 0.03, w * 0.82, h * 0.77);
89		c.fill();
90	}
91	else if (bgIcon == 'threat5')
92	{
93		c.begin();
94		c.ellipse(w * 0.16, h * 0.01, w * 0.67, h * 0.72);
95		c.fill();
96	}
97	else if (bgIcon == 'mxgraph.cisco_safe.architecture.generic_appliance')
98	{
99		c.setShadow(shadow);
100		c.setFillColor(bgColor);
101
102		c.begin();
103		c.moveTo(0, h * 0.3);
104		c.arcTo(w * 0.3, h * 0.3, 0, 0, 1, w * 0.3, 0);
105		c.lineTo(w * 0.7, 0);
106		c.arcTo(w * 0.3, h * 0.3, 0, 0, 1, w, h * 0.3);
107		c.lineTo(w, h * 0.7);
108		c.arcTo(w * 0.3, h * 0.3, 0, 0, 1, w * 0.7, h);
109		c.lineTo(w * 0.3, h);
110		c.arcTo(w * 0.3, h * 0.3, 0, 0, 1, 0, h * 0.7);
111		c.close();
112		c.fill();
113
114		c.setShadow(false);
115
116		c.setFillColor(strokeColor);
117
118		var stencil = mxStencilRegistry.getStencil(bgIcon);
119
120		if (stencil != null)
121		{
122			stencil.drawShape(c, this, w * 0.26, h * 0.26, w * 0.48, h * 0.48)
123		}
124
125		c.setAlpha(0.5);
126		c.setFillColor('#ffffff');
127
128		c.ellipse(w * 0.105, h * 0.48, w * 0.04, h * 0.04);
129		c.fill();
130		c.ellipse(w * 0.855, h * 0.48, w * 0.04, h * 0.04);
131		c.fill();
132		c.ellipse(w * 0.48, h * 0.105, w * 0.04, h * 0.04);
133		c.fill();
134		c.ellipse(w * 0.48, h * 0.855, w * 0.04, h * 0.04);
135		c.fill();
136
137		c.ellipse(w * 0.17, h * 0.17, w * 0.04, h * 0.04);
138		c.fill();
139		c.ellipse(w * 0.79, h * 0.17, w * 0.04, h * 0.04);
140		c.fill();
141		c.ellipse(w * 0.79, h * 0.79, w * 0.04, h * 0.04);
142		c.fill();
143		c.ellipse(w * 0.17, h * 0.79, w * 0.04, h * 0.04);
144		c.fill();
145
146		c.setAlpha(opacity / 100);
147
148	}
149	else
150	{
151		var stencil = mxStencilRegistry.getStencil(bgIcon);
152
153		if (stencil != null)
154		{
155			(w < 100) ? stencil.drawShape(c, this, w * 0.01, h * 0.01, w * 0.98, h * 0.98) : stencil.drawShape(c, this, 1, 1, w - 2, h - 2);
156		}
157	}
158
159	stencil = mxStencilRegistry.getStencil(prIcon);
160
161	if (stencil != null )
162	{
163		c.setFillColor(fillColor);
164
165		if (bgIcon == 'mxgraph.cisco_safe.architecture.generic_appliance')
166		{
167			stencil.drawShape(c, this, w * 0.25, h * 0.25, w * 0.5, h * 0.5)
168		}
169		else
170		{
171			stencil.drawShape(c, this, 0, 0, w, h);
172		}
173	}
174
175};
176
177mxCellRenderer.registerShape(mxShapeCiscoSafeCompositeIcon.prototype.cst.SHAPE_COMPOSITE_ICON, mxShapeCiscoSafeCompositeIcon);