clone

a browser-first diagram editor with live svg previews, local drafts and encrypted, accountless sharing

main
diagramzip / renderers / browser-run / frames / diagramsnet / vendor / assets / shapes / mxDFD.js
mxDFD.js 13.9K
1/**2 * Copyright (c) 2006-2018, JGraph Holdings Ltd3 */4//**********************************************************************************************************************************************************5// Start6//**********************************************************************************************************************************************************7/**8* Extends mxShape.9*/10function mxShapeDFDStart(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};1819/**20* Extends mxShape.21*/22mxUtils.extend(mxShapeDFDStart, mxShape);2324mxShapeDFDStart.prototype.cst = {START : 'mxgraph.dfd.start'};2526/**27* Function: paintVertexShape28* 29* Paints the vertex shape.30*/31mxShapeDFDStart.prototype.paintVertexShape = function(c, x, y, w, h)32{33 c.translate(x, y);34 var r = Math.min(h * 0.5, w * 0.5);35 36 c.begin();37 c.moveTo(w - r, h * 0.5 - r);38 c.arcTo(r, r, 0, 0, 1, w, h * 0.5);39 c.arcTo(r, r, 0, 0, 1, w - r, h * 0.5 + r);40 c.lineTo(r, h * 0.5 + r);41 c.arcTo(r, r, 0, 0, 1, 0, h * 0.5);42 c.arcTo(r, r, 0, 0, 1, r, h * 0.5 - r);43 c.close();44 c.fillAndStroke();45};4647mxCellRenderer.registerShape(mxShapeDFDStart.prototype.cst.START, mxShapeDFDStart);4849mxShapeDFDStart.prototype.getConstraints = function(style, w, h)50{51 var constr = [];52 var r = Math.min(h * 0.5, w * 0.5);53 54 constr.push(new mxConnectionConstraint(new mxPoint(0, 0.5), false));55 constr.push(new mxConnectionConstraint(new mxPoint(0.5, 0.5), false, null, 0, -r));56 constr.push(new mxConnectionConstraint(new mxPoint(1, 0.5), false));57 constr.push(new mxConnectionConstraint(new mxPoint(0.5, 0.5), false, null, 0, r));58 constr.push(new mxConnectionConstraint(new mxPoint(0, 0), false, null, r * 0.293, h * 0.5 - r * 0.707));59 constr.push(new mxConnectionConstraint(new mxPoint(0, 0), false, null, w - r * 0.293, h * 0.5 - r * 0.707));60 constr.push(new mxConnectionConstraint(new mxPoint(0, 0), false, null, w - r * 0.293, h * 0.5 + r * 0.707));61 constr.push(new mxConnectionConstraint(new mxPoint(0, 0), false, null, r * 0.293, h * 0.5 + r * 0.707));62 63 if (w >= 4 * h)64 {65 constr.push(new mxConnectionConstraint(new mxPoint(0.25, 0), false));66 constr.push(new mxConnectionConstraint(new mxPoint(0.75, 0), false));67 constr.push(new mxConnectionConstraint(new mxPoint(0.75, 1), false));68 constr.push(new mxConnectionConstraint(new mxPoint(0.25, 1), false));69 }7071 return (constr);72}7374//**********************************************************************************************************************************************************75//Archive76//**********************************************************************************************************************************************************77/**78* Extends mxShape.79*/80function mxShapeDFDArchive(bounds, fill, stroke, strokewidth)81{82 mxShape.call(this);83 this.bounds = bounds;84 this.fill = fill;85 this.stroke = stroke;86 this.strokewidth = (strokewidth != null) ? strokewidth : 1;87};8889/**90* Extends mxShape.91*/92mxUtils.extend(mxShapeDFDArchive, mxShape);9394mxShapeDFDArchive.prototype.cst = {ARCHIVE : 'mxgraph.dfd.archive'};9596/**97* Function: paintVertexShape98* 99* Paints the vertex shape.100*/101mxShapeDFDArchive.prototype.paintVertexShape = function(c, x, y, w, h)102{103 c.translate(x, y);104 105 c.begin();106 c.moveTo(0,0);107 c.lineTo(w, 0);108 c.lineTo(w * 0.5, h);109 c.close();110 c.fillAndStroke();111 112 c.setShadow(false);113 114 c.begin();115 c.moveTo(w * 0.1, h * 0.2);116 c.lineTo(w * 0.9, h * 0.2);117 c.stroke();118};119120mxCellRenderer.registerShape(mxShapeDFDArchive.prototype.cst.ARCHIVE, mxShapeDFDArchive);121122mxShapeDFDArchive.prototype.getConstraints = function(style, w, h)123{124 var constr = [];125 126 constr.push(new mxConnectionConstraint(new mxPoint(0, 0), false));127 constr.push(new mxConnectionConstraint(new mxPoint(0.25, 0), false));128 constr.push(new mxConnectionConstraint(new mxPoint(0.5, 0), false));129 constr.push(new mxConnectionConstraint(new mxPoint(0.75, 0), false));130 constr.push(new mxConnectionConstraint(new mxPoint(1, 0), false));131 constr.push(new mxConnectionConstraint(new mxPoint(0.875, 0.25), false));132 constr.push(new mxConnectionConstraint(new mxPoint(0.75, 0.5), false));133 constr.push(new mxConnectionConstraint(new mxPoint(0.625, 0.75), false));134 constr.push(new mxConnectionConstraint(new mxPoint(0.5, 1), false));135 constr.push(new mxConnectionConstraint(new mxPoint(0.375, 0.75), false));136 constr.push(new mxConnectionConstraint(new mxPoint(0.25, 0.5), false));137 constr.push(new mxConnectionConstraint(new mxPoint(0.125, 0.25), false));138139 return (constr);140}141142//**********************************************************************************************************************************************************143//Check2144//**********************************************************************************************************************************************************145/**146* Extends mxShape.147*/148function mxShapeDFDCheck2(bounds, fill, stroke, strokewidth)149{150 mxShape.call(this);151 this.bounds = bounds;152 this.fill = fill;153 this.stroke = stroke;154 this.strokewidth = (strokewidth != null) ? strokewidth : 1;155};156157/**158* Extends mxShape.159*/160mxUtils.extend(mxShapeDFDCheck2, mxShape);161162mxShapeDFDCheck2.prototype.cst = {CHECK2 : 'mxgraph.dfd.check2'};163164/**165* Function: paintVertexShape166* 167* Paints the vertex shape.168*/169mxShapeDFDCheck2.prototype.paintVertexShape = function(c, x, y, w, h)170{171 c.translate(x, y);172 var size = Math.min(h * 0.5, w * 0.5);173 174 c.begin();175 c.moveTo(0, h * 0.5);176 c.lineTo(size, 0);177 c.lineTo(w - size, 0);178 c.lineTo(w, h * 0.5);179 c.lineTo(w - size, h);180 c.lineTo(size, h);181 c.lineTo(0, h * 0.5);182 c.close();183 c.fillAndStroke();184 185 c.setShadow(false);186 187 c.begin();188 c.moveTo(w - size, 0);189 c.lineTo(w - 2 * size, h * 0.5);190 c.lineTo(w - size, h);191 c.stroke();192};193194mxCellRenderer.registerShape(mxShapeDFDCheck2.prototype.cst.CHECK2, mxShapeDFDCheck2);195196mxShapeDFDCheck2.prototype.getConstraints = function(style, w, h)197{198 var constr = [];199 var size = Math.min(h * 0.5, w * 0.5);200 201 constr.push(new mxConnectionConstraint(new mxPoint(0.5, 0), false));202 constr.push(new mxConnectionConstraint(new mxPoint(1, 0.5), false));203 constr.push(new mxConnectionConstraint(new mxPoint(0.5, 1), false));204 constr.push(new mxConnectionConstraint(new mxPoint(0, 0.5), false));205 constr.push(new mxConnectionConstraint(new mxPoint(0, 0), false, null, size * 0.5, h * 0.25));206 constr.push(new mxConnectionConstraint(new mxPoint(0, 0), false, null, w - size * 0.5, h * 0.25));207 constr.push(new mxConnectionConstraint(new mxPoint(0, 0), false, null, size * 0.5, h * 0.75));208 constr.push(new mxConnectionConstraint(new mxPoint(0, 0), false, null, w - size * 0.5, h * 0.75));209210 if (w > h)211 {212 constr.push(new mxConnectionConstraint(new mxPoint(0, 0), false, null, size, 0));213 constr.push(new mxConnectionConstraint(new mxPoint(0, 0), false, null, w - size, 0));214 constr.push(new mxConnectionConstraint(new mxPoint(0, 0), false, null, size, h));215 constr.push(new mxConnectionConstraint(new mxPoint(0, 0), false, null, w - size, h));216 }217218 if(size * 4 <= w)219 {220 constr.push(new mxConnectionConstraint(new mxPoint(0.25, 0), false));221 constr.push(new mxConnectionConstraint(new mxPoint(0.75, 0), false));222 constr.push(new mxConnectionConstraint(new mxPoint(0.25, 1), false));223 constr.push(new mxConnectionConstraint(new mxPoint(0.75, 1), false));224 }225226 return (constr);227}228229//**********************************************************************************************************************************************************230//Data Store with ID231//**********************************************************************************************************************************************************232/**233* Extends mxShape.234*/235function mxShapeDFDDataStoreID(bounds, fill, stroke, strokewidth)236{237 mxShape.call(this);238 this.bounds = bounds;239 this.fill = fill;240 this.stroke = stroke;241 this.strokewidth = (strokewidth != null) ? strokewidth : 1;242};243244/**245* Extends mxShape.246*/247mxUtils.extend(mxShapeDFDDataStoreID, mxShape);248249mxShapeDFDDataStoreID.prototype.cst = {DATA_STORE_ID : 'mxgraph.dfd.dataStoreID'};250251/**252* Function: paintVertexShape253* 254* Paints the vertex shape.255*/256mxShapeDFDDataStoreID.prototype.paintVertexShape = function(c, x, y, w, h)257{258 c.translate(x, y);259 var size = Math.min(h * 0.5, w * 0.5);260 261 c.begin();262 c.moveTo(w, h);263 c.lineTo(0, h);264 c.lineTo(0, 0);265 c.lineTo(w, 0);266 c.fillAndStroke();267 268 c.setShadow(false);269 270 var s = Math.min(30, w);271 272 c.begin();273 c.moveTo(s, 0);274 c.lineTo(s, h);275 c.stroke();276};277278mxCellRenderer.registerShape(mxShapeDFDDataStoreID.prototype.cst.DATA_STORE_ID, mxShapeDFDDataStoreID);279280mxShapeDFDDataStoreID.prototype.constraints = null;281282//**********************************************************************************************************************************************************283//External Entity284//**********************************************************************************************************************************************************285/**286* Extends mxShape.287*/288function mxShapeDFDExternalEntity(bounds, fill, stroke, strokewidth)289{290 mxShape.call(this);291 this.bounds = bounds;292 this.fill = fill;293 this.stroke = stroke;294 this.strokewidth = (strokewidth != null) ? strokewidth : 1;295};296297/**298* Extends mxShape.299*/300mxUtils.extend(mxShapeDFDExternalEntity, mxShape);301302mxShapeDFDExternalEntity.prototype.cst = {EXTERNAL_ENTITY : 'mxgraph.dfd.externalEntity'};303304/**305* Function: paintVertexShape306* 307* Paints the vertex shape.308*/309mxShapeDFDExternalEntity.prototype.paintVertexShape = function(c, x, y, w, h)310{311 c.translate(x, y);312 var size = 10;313 314 c.begin();315 c.moveTo(0, 0);316 c.lineTo(w - size, 0);317 c.lineTo(w, size);318 c.lineTo(w, h);319 c.lineTo(size, h);320 c.lineTo(0, h - size);321 c.close();322 c.fillAndStroke();323 324 c.setShadow(false);325326327 c.setFillColor('#000000');328 c.setAlpha(0.5);329 330 c.begin();331 c.moveTo(0, 0);332 c.lineTo(w - size, 0);333 c.lineTo(w, size);334 c.lineTo(size, size);335 c.lineTo(size, h);336 c.lineTo(0, h - size);337 c.close();338 c.fill();339340 var opacity = parseFloat(mxUtils.getValue(this.style, 'opacity', '100'));341342 c.setAlpha(opacity / 100);343 344 c.begin();345 c.moveTo(0, 0);346 c.lineTo(w - size, 0);347 c.lineTo(w, size);348 c.lineTo(w, h);349 c.lineTo(size, h);350 c.lineTo(0, h - size);351 c.close();352 c.moveTo(size, h);353 c.lineTo(size, size);354 c.lineTo(w, size);355 c.moveTo(0, 0);356 c.lineTo(size, size);357 c.stroke();358};359360mxCellRenderer.registerShape(mxShapeDFDExternalEntity.prototype.cst.EXTERNAL_ENTITY, mxShapeDFDExternalEntity);361362mxShapeDFDExternalEntity.prototype.getConstraints = function(style, w, h)363{364 var constr = [];365 var size = 10;366 367 constr.push(new mxConnectionConstraint(new mxPoint(0, 0), false));368 constr.push(new mxConnectionConstraint(new mxPoint(0, 0), false, null, (w - size) * 0.25, 0));369 constr.push(new mxConnectionConstraint(new mxPoint(0, 0), false, null, (w - size) * 0.5, 0));370 constr.push(new mxConnectionConstraint(new mxPoint(0, 0), false, null, (w - size) * 0.75, 0));371 constr.push(new mxConnectionConstraint(new mxPoint(0, 0), false, null, w - size, 0));372 constr.push(new mxConnectionConstraint(new mxPoint(0, 0), false, null, size, h));373 constr.push(new mxConnectionConstraint(new mxPoint(0, 0), false, null, (w - size) * 0.25 + size, h));374 constr.push(new mxConnectionConstraint(new mxPoint(0, 0), false, null, (w - size) * 0.5 + size, h));375 constr.push(new mxConnectionConstraint(new mxPoint(0, 0), false, null, (w - size) * 0.75 + size, h));376 constr.push(new mxConnectionConstraint(new mxPoint(1, 1), false));377 constr.push(new mxConnectionConstraint(new mxPoint(0, 0), false, null, w, size));378 constr.push(new mxConnectionConstraint(new mxPoint(0, 0), false, null, w, size + (h - size) * 0.25));379 constr.push(new mxConnectionConstraint(new mxPoint(0, 0), false, null, w, size + (h - size) * 0.5));380 constr.push(new mxConnectionConstraint(new mxPoint(0, 0), false, null, w, size + (h - size) * 0.75));381 constr.push(new mxConnectionConstraint(new mxPoint(0, 0), false, null, 0, (h - size) * 0.25));382 constr.push(new mxConnectionConstraint(new mxPoint(0, 0), false, null, 0, (h - size) * 0.5));383 constr.push(new mxConnectionConstraint(new mxPoint(0, 0), false, null, 0, (h - size) * 0.75));384 constr.push(new mxConnectionConstraint(new mxPoint(0, 0), false, null, 0, h - size));385386 return (constr);387}388389//**********************************************************************************************************************************************************390//Loop391//**********************************************************************************************************************************************************392/**393* Extends mxShape.394*/395function mxShapeDFDLoop(bounds, fill, stroke, strokewidth)396{397 mxShape.call(this);398 this.bounds = bounds;399 this.fill = fill;400 this.stroke = stroke;401 this.strokewidth = (strokewidth != null) ? strokewidth : 1;402};403404/**405* Extends mxShape.406*/407mxUtils.extend(mxShapeDFDLoop, mxShape);408409mxShapeDFDLoop.prototype.cst = {LOOP : 'mxgraph.dfd.loop'};410411/**412* Function: paintVertexShape413* 414* Paints the vertex shape.415*/416mxShapeDFDLoop.prototype.paintVertexShape = function(c, x, y, w, h)417{418 c.translate(x, y);419 var r = Math.min(h * 0.8, w * 0.8);420 421 c.begin();422 c.moveTo(w - r * 0.25, 0);423 c.arcTo(r, r, 0, 0, 1, w - r * 0.25, h);424 c.lineTo(r * 0.25, h);425 c.arcTo(r, r, 0, 0, 1, r * 0.25, 0);426 c.close();427 c.fillAndStroke();428};429430mxCellRenderer.registerShape(mxShapeDFDLoop.prototype.cst.LOOP, mxShapeDFDLoop);431432mxShapeDFDLoop.prototype.getConstraints = function(style, w, h)433{434 var constr = [];435 var r = Math.min(h * 0.8, w * 0.8);436 437 constr.push(new mxConnectionConstraint(new mxPoint(0, 0), false, null, w - r * 0.25, 0));438 constr.push(new mxConnectionConstraint(new mxPoint(0, 0), false, null, w - r * 0.25, h));439 constr.push(new mxConnectionConstraint(new mxPoint(0, 0), false, null, r * 0.25, 0));440 constr.push(new mxConnectionConstraint(new mxPoint(0, 0), false, null, r * 0.25, h));441 constr.push(new mxConnectionConstraint(new mxPoint(0.5, 0), false));442 constr.push(new mxConnectionConstraint(new mxPoint(0.5, 1), false));443444 return (constr);445}446