mxCiscoSafe.js 4.4 KB

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