mxCiscoSafe.js 4.7 KB

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