1/**
2 * $Id: mxKubernetes.js,v 1.5 2019/14/11 12:32:06 mate Exp $
3 * Copyright (c) 2006-2020, JGraph Ltd
4 */
5//**********************************************************************************************************************************************************
6// Kubernetes icon
7//**********************************************************************************************************************************************************
8/**
9* Extends mxShape.
10*/
11function mxShapeKubernetesIcon(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(mxShapeKubernetesIcon, mxShape);
24
25mxShapeKubernetesIcon.prototype.cst = {
26		ICON : 'mxgraph.kubernetes.icon'
27};
28
29mxShapeKubernetesIcon.prototype.customProperties = [
30	{name: 'prIcon', dispName: '', defVal: 'api', type: 'API',
31			enumList: [{val: 'c_c_m', dispName: 'C-C-M'},
32					   {val: 'c_m', dispName: 'C-M'},
33					   {val: 'c_role', dispName: 'C-Role'},
34					   {val: 'cm', dispName: 'CM'},
35					   {val: 'crb', dispName: 'CRB'},
36					   {val: 'crd', dispName: 'CRD'},
37					   {val: 'cronjob', dispName: 'Cronjob'},
38					   {val: 'deploy', dispName: 'Deploy'},
39					   {val: 'ds', dispName: 'DS'},
40					   {val: 'ep', dispName: 'EP'},
41					   {val: 'etcd', dispName: 'ETCD'},
42					   {val: 'group', dispName: 'Group'},
43					   {val: 'hpa', dispName: 'HPA'},
44					   {val: 'ing', dispName: 'ING'},
45					   {val: 'job', dispName: 'Job'},
46					   {val: 'k_proxy', dispName: 'K-Proxy'},
47					   {val: 'kubelet', dispName: 'Kubelet'},
48					   {val: 'limits', dispName: 'Limits'},
49					   {val: 'master', dispName: 'Master'},
50					   {val: 'netpol', dispName: 'Netpol'},
51					   {val: 'node', dispName: 'Node'},
52					   {val: 'ns', dispName: 'NS'},
53					   {val: 'pod', dispName: 'Pod'},
54					   {val: 'psp', dispName: 'PSP'},
55					   {val: 'pv', dispName: 'PV'},
56					   {val: 'pvc', dispName: 'PVC'},
57					   {val: 'quota', dispName: 'Quota'},
58					   {val: 'rb', dispName: 'RB'},
59					   {val: 'role', dispName: 'Role'},
60					   {val: 'rs', dispName: 'RS'},
61					   {val: 'sa', dispName: 'SA'},
62					   {val: 'sc', dispName: 'SC'},
63					   {val: 'sched', dispName: 'Sched'},
64					   {val: 'secret', dispName: 'Secret'},
65					   {val: 'sts', dispName: 'STS'},
66					   {val: 'svc', dispName: 'SVC'},
67					   {val: 'user', dispName: 'User'},
68				       {val: 'vol', dispName: 'Vol'}]}
69];
70
71
72/**
73* Function: paintVertexShape
74*
75* Paints the vertex shape.
76*/
77mxShapeKubernetesIcon.prototype.paintVertexShape = function(c, x, y, w, h)
78{
79	var prIcon = mxUtils.getValue(this.state.style, 'prIcon', '');
80
81	var fillColor = mxUtils.getValue(this.state.style, 'fillColor', '#ffffff');
82	var strokeColor = mxUtils.getValue(this.state.style, 'strokeColor', '#ffffff');
83
84	c.translate(x, y);
85
86	var frame = mxStencilRegistry.getStencil('mxgraph.kubernetes.frame');
87
88	c.setFillColor(strokeColor);
89	frame.drawShape(c, this, 0, 0, w, h);
90
91	c.setFillColor(fillColor);
92	frame.drawShape(c, this, w * 0.03, h * 0.03, w * 0.94, h * 0.94);
93
94	var prStencil = mxStencilRegistry.getStencil('mxgraph.kubernetes.' + prIcon);
95
96	if (prStencil != null)
97	{
98		c.setFillColor(strokeColor);
99		prStencil.drawShape(c, this, w * 0.2, h * 0.2, w * 0.6, h * 0.6);
100	}
101};
102
103mxCellRenderer.registerShape(mxShapeKubernetesIcon.prototype.cst.ICON, mxShapeKubernetesIcon);
104
105mxShapeKubernetesIcon.prototype.getConstraints = function(style, w, h)
106{
107	var constr = [];
108	var r = Math.min(h * 0.5, w * 0.5);
109
110	constr.push(new mxConnectionConstraint(new mxPoint(0, 0.5), false));
111
112	return (constr);
113}
114
115