1/** 2 * $Id: mxC4.js,v 1.5 2018/26/11 12:32:06 mate Exp $ 3 * Copyright (c) 2006-2018, JGraph Ltd 4 */ 5//********************************************************************************************************************************************************** 6// Person 7//********************************************************************************************************************************************************** 8/** 9* Extends mxShape. 10*/ 11function mxShapeC4Person(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(mxShapeC4Person, mxShape); 24 25mxShapeC4Person.prototype.cst = {PERSONSHAPE : 'mxgraph.c4.person'}; 26 27/** 28* Function: paintVertexShape 29* 30* Paints the vertex shape. 31*/ 32mxShapeC4Person.prototype.paintVertexShape = function(c, x, y, w, h) 33{ 34 c.translate(x, y); 35 var headSize = Math.min(w / 2, h / 3); 36 var r = headSize / 2; 37 38 c.ellipse(w * 0.5 - headSize * 0.5, 0, headSize, headSize); 39 c.fillAndStroke(); 40 41 c.begin(); 42 c.moveTo(0, headSize * 0.8 + r); 43 c.arcTo(r, r, 0, 0, 1, r, headSize * 0.8); 44 c.lineTo(w - r, headSize * 0.8); 45 c.arcTo(r, r, 0, 0, 1, w, headSize * 0.8 + r); 46 c.lineTo(w, h - r); 47 c.arcTo(r, r, 0, 0, 1, w - r, h); 48 c.lineTo(r, h); 49 c.arcTo(r, r, 0, 0, 1, 0, h -r); 50 c.close(); 51 c.fillAndStroke(); 52 53 c.setShadow(false); 54 55 c.ellipse(w * 0.5 - headSize * 0.5, 0, headSize, headSize); 56 c.fillAndStroke(); 57 58}; 59 60mxShapeC4Person.prototype.getLabelMargins = function(rect) 61{ 62 var headSize = Math.min(rect.width / 2, rect.height / 3); 63 64 return new mxRectangle(0, headSize * 0.8, 0, 0); 65}; 66 67mxCellRenderer.registerShape(mxShapeC4Person.prototype.cst.PERSONSHAPE, mxShapeC4Person); 68 69//********************************************************************************************************************************************************** 70// Person 71//********************************************************************************************************************************************************** 72/** 73* Extends mxShape. 74*/ 75function mxShapeC4Person2(bounds, fill, stroke, strokewidth) 76{ 77 mxShape.call(this); 78 this.bounds = bounds; 79 this.fill = fill; 80 this.stroke = stroke; 81 this.strokewidth = (strokewidth != null) ? strokewidth : 1; 82}; 83 84/** 85* Extends mxShape. 86*/ 87mxUtils.extend(mxShapeC4Person2, mxShape); 88 89mxShapeC4Person2.prototype.cst = {PERSONSHAPE : 'mxgraph.c4.person2'}; 90 91/** 92* Function: paintVertexShape 93* 94* Paints the vertex shape. 95*/ 96mxShapeC4Person2.prototype.paintVertexShape = function(c, x, y, w, h) 97{ 98 c.translate(x, y); 99 var headSize = Math.min(w * 0.45, h * 0.45); 100 var r = headSize / 2; 101 102 c.ellipse(w * 0.5 - headSize * 0.5, 0, headSize, headSize); 103 c.fillAndStroke(); 104 105 c.begin(); 106 c.moveTo(0, headSize * 0.8 + r); 107 c.arcTo(r, r, 0, 0, 1, r, headSize * 0.8); 108 c.lineTo(w - r, headSize * 0.8); 109 c.arcTo(r, r, 0, 0, 1, w, headSize * 0.8 + r); 110 c.lineTo(w, h - r); 111 c.arcTo(r, r, 0, 0, 1, w - r, h); 112 c.lineTo(r, h); 113 c.arcTo(r, r, 0, 0, 1, 0, h -r); 114 c.close(); 115 c.fillAndStroke(); 116 117 c.setShadow(false); 118 119 c.ellipse(w * 0.5 - headSize * 0.5, 0, headSize, headSize); 120 c.fillAndStroke(); 121 122}; 123 124mxShapeC4Person2.prototype.getLabelMargins = function(rect) 125{ 126 var headSize = Math.min(rect.width * 0.45, rect.height * 0.45); 127 128 return new mxRectangle(0, headSize * 0.8, 0, 0); 129}; 130 131mxCellRenderer.registerShape(mxShapeC4Person2.prototype.cst.PERSONSHAPE , mxShapeC4Person2); 132 133//********************************************************************************************************************************************************** 134// Web Browser Container 135//********************************************************************************************************************************************************** 136/** 137* Extends mxShape. 138*/ 139function mxShapeC4WebBrowserContainer(bounds, fill, stroke, strokewidth) 140{ 141 mxShape.call(this); 142 this.bounds = bounds; 143 this.fill = fill; 144 this.stroke = stroke; 145 this.strokewidth = (strokewidth != null) ? strokewidth : 1; 146}; 147 148/** 149* Extends mxShape. 150*/ 151mxUtils.extend(mxShapeC4WebBrowserContainer, mxShape); 152 153mxShapeC4WebBrowserContainer.prototype.cst = {WEB_BROWSER_CONTAINER_SHAPE : 'mxgraph.c4.webBrowserContainer'}; 154 155/** 156* Function: paintVertexShape 157* 158* Paints the vertex shape. 159*/ 160mxShapeC4WebBrowserContainer.prototype.paintVertexShape = function(c, x, y, w, h) 161{ 162 c.translate(x, y); 163 var r = 8; 164 165 c.begin(); 166 c.moveTo(0, r); 167 c.arcTo(r, r, 0, 0, 1, r, 0); 168 c.lineTo(w - r, 0); 169 c.arcTo(r, r, 0, 0, 1, w, r); 170 c.lineTo(w, h - r); 171 c.arcTo(r, r, 0, 0, 1, w - r, h); 172 c.lineTo(r, h); 173 c.arcTo(r, r, 0, 0, 1, 0, h - r); 174 c.close(); 175 c.fillAndStroke(); 176 177 c.setShadow(false); 178 179 var ins = 5; 180 var r2 = 3; 181 var h2 = 12; 182 183 if (w > (ins * 5 + h2 * 3) && h > (2 * h2 + 3 * ins)) 184 { 185 c.setFillColor('#23A2D9'); 186 187 c.begin(); 188 c.moveTo(ins, ins + r2); 189 c.arcTo(r2, r2, 0, 0, 1, ins + r2, ins); 190 c.lineTo(w - 3 * h2 - 4 * ins - r2, ins); 191 c.arcTo(r2, r2, 0, 0, 1, w - 3 * h2 - 4 * ins, ins + r2); 192 c.lineTo(w - 3 * h2 - 4 * ins, ins + h2 - r2); 193 c.arcTo(r2, r2, 0, 0, 1, w - 3 * h2 - 4 * ins - r2, ins + h2); 194 c.lineTo(ins + r2, ins + h2); 195 c.arcTo(r2, r2, 0, 0, 1, ins, ins + h2 - r2); 196 c.close(); 197 198 c.moveTo(w - 3 * h2 - 3 * ins, ins + r2); 199 c.arcTo(r2, r2, 0, 0, 1, w - 3 * h2 - 3 * ins + r2, ins); 200 c.lineTo(w - 2 * h2 - 3 * ins - r2, ins); 201 c.arcTo(r2, r2, 0, 0, 1, w - 2 * h2 - 3 * ins, ins + r2); 202 c.lineTo(w - 2 * h2 - 3 * ins, ins + h2 - r2); 203 c.arcTo(r2, r2, 0, 0, 1, w - 2 * h2 - 3 * ins - r2, ins + h2); 204 c.lineTo(w - 3 * h2 - 3 * ins + r2, ins + h2); 205 c.arcTo(r2, r2, 0, 0, 1, w - 3 * h2 - 3 * ins, ins + h2 - r2); 206 c.close(); 207 208 c.moveTo(w - 2 * h2 - 2 * ins, ins + r2); 209 c.arcTo(r2, r2, 0, 0, 1, w - 2 * h2 - 2 * ins + r2, ins); 210 c.lineTo(w - h2 - 2 * ins - r2, ins); 211 c.arcTo(r2, r2, 0, 0, 1, w - h2 - 2 * ins, ins + r2); 212 c.lineTo(w - h2 - 2 * ins, ins + h2 - r2); 213 c.arcTo(r2, r2, 0, 0, 1, w - h2 - 2 * ins - r2, ins + h2); 214 c.lineTo(w - 2 * h2 - 2 * ins + r2, ins + h2); 215 c.arcTo(r2, r2, 0, 0, 1, w - 2 * h2 - 2 * ins, ins + h2 - r2); 216 c.close(); 217 218 c.moveTo(w - h2 - ins, ins + r2); 219 c.arcTo(r2, r2, 0, 0, 1, w - h2 - ins + r2, ins); 220 c.lineTo(w - ins - r2, ins); 221 c.arcTo(r2, r2, 0, 0, 1, w - ins, ins + r2); 222 c.lineTo(w - ins, ins + h2 - r2); 223 c.arcTo(r2, r2, 0, 0, 1, w - ins - r2, ins + h2); 224 c.lineTo(w - h2 - ins + r2, ins + h2); 225 c.arcTo(r2, r2, 0, 0, 1, w - h2 - ins, ins + h2 - r2); 226 c.close(); 227 228 c.moveTo(ins, h2 + 2 * ins + r); 229 c.arcTo(r, r, 0, 0, 1, ins + r, h2 + 2 * ins); 230 c.lineTo(w - r - ins, h2 + 2 * ins); 231 c.arcTo(r, r, 0, 0, 1, w - ins, h2 + 2 * ins + r); 232 c.lineTo(w - ins, h - r - ins); 233 c.arcTo(r, r, 0, 0, 1, w - r - ins, h - ins); 234 c.lineTo(ins + r, h - ins); 235 c.arcTo(r, r, 0, 0, 1, ins, h - r - ins); 236 c.close(); 237 c.fill(); 238 239 c.fill(); 240 } 241}; 242 243mxCellRenderer.registerShape(mxShapeC4WebBrowserContainer.prototype.cst.WEB_BROWSER_CONTAINER_SHAPE, mxShapeC4WebBrowserContainer); 244 245