1/**2 * Copyright (c) 2006-2010, JGraph Holdings Ltd3 */45//TODO markers.html probably isn't needed, because it was used for testing during development before the new canvas was introduced67//**********************************************************************************************************************************************************8//Entity9//**********************************************************************************************************************************************************10/**11 * Extends mxShape.12 */13function mxShapeEREntity(bounds, fill, stroke, strokewidth)14{15 mxShape.call(this);16 this.bounds = bounds;17 this.fill = fill;18 this.stroke = stroke;19 this.strokewidth = (strokewidth != null) ? strokewidth : 1;20};2122/**23 * Extends mxShape.24 */25mxUtils.extend(mxShapeEREntity, mxShape);2627/**28 * Function: paintVertexShape29 * 30 * Paints the vertex shape.31 */32mxShapeEREntity.prototype.paintVertexShape = function(c, x, y, w, h)33{34 var mainText = mxUtils.getValue(this.style, 'buttonText', 'Entity');35 var fontColor = mxUtils.getValue(this.style, 'textColor', '#666666');36 var fontSize = mxUtils.getValue(this.style, mxConstants.STYLE_FONTSIZE, '17');37 c.translate(x, y);38 var rSize = 10;39 w = Math.max(w, 2 * rSize);40 h = Math.max(h, 2 * rSize);41 this.background(c, x, y, w, h, rSize, fontColor);42 c.setShadow(false);43 this.mainText(c, x, y, w, h, mainText, fontSize, fontColor);44};4546mxShapeEREntity.prototype.background = function(c, x, y, w, h, rSize, fontColor)47{48 var buttonStyle = mxUtils.getValue(this.style, 'buttonStyle', 'round').toString();4950 if (buttonStyle === 'round')51 {52 c.begin();53 c.moveTo(0, rSize);54 c.arcTo(rSize, rSize, 0, 0, 1, rSize, 0);55 c.lineTo(w - rSize, 0);56 c.arcTo(rSize, rSize, 0, 0, 1, w, rSize);57 c.lineTo(w, h - rSize);58 c.arcTo(rSize, rSize, 0, 0, 1, w - rSize, h);59 c.lineTo(rSize, h);60 c.arcTo(rSize, rSize, 0, 0, 1, 0, h - rSize);61 c.close(); 62 c.fillAndStroke();63 }64 else if (buttonStyle === 'rect')65 {66 c.begin();67 c.moveTo(0, 0);68 c.lineTo(w, 0);69 c.lineTo(w, h);70 c.lineTo(0, h);71 c.close(); 72 c.fillAndStroke();73 }74 else if (buttonStyle === 'dblFrame')75 {76 var fillColor = mxUtils.getValue(this.style, mxConstants.STYLE_FILLCOLOR, '#ffffff');77 c.setFillColor(fillColor);78 c.begin();79 c.moveTo(0, 0);80 c.lineTo(w, 0);81 c.lineTo(w, h);82 c.lineTo(0, h);83 c.close(); 84 c.fillAndStroke();85 rSize = Math.min(w, h);86 c.begin();87 c.moveTo(rSize * 0.1, rSize * 0.1);88 c.lineTo(w - rSize * 0.1, rSize * 0.1);89 c.lineTo(w - rSize * 0.1, h - rSize * 0.1);90 c.lineTo(rSize * 0.1, h - rSize * 0.1);91 c.close(); 92 c.stroke();93 }9495};9697mxShapeEREntity.prototype.mainText = function(c, x, y, w, h, text, fontSize, fontColor)98{99 c.begin();100 c.setFontSize(fontSize);101 c.setFontColor(fontColor);102 c.text(w * 0.5, h * 0.5, 0, 0, text, mxConstants.ALIGN_CENTER, mxConstants.ALIGN_MIDDLE, 0, null, 0, 0, 0);103};104105mxCellRenderer.registerShape('mxgraph.er.entity', mxShapeEREntity);106107mxShapeEREntity.prototype.constraints = [108 new mxConnectionConstraint(new mxPoint(0.25, 0), true),109 new mxConnectionConstraint(new mxPoint(0.5, 0), true),110 new mxConnectionConstraint(new mxPoint(0.75, 0), true),111 new mxConnectionConstraint(new mxPoint(0, 0.25), true),112 new mxConnectionConstraint(new mxPoint(0, 0.5), true),113 new mxConnectionConstraint(new mxPoint(0, 0.75), true),114 new mxConnectionConstraint(new mxPoint(1, 0.25), true),115 new mxConnectionConstraint(new mxPoint(1, 0.5), true),116 new mxConnectionConstraint(new mxPoint(1, 0.75), true),117 new mxConnectionConstraint(new mxPoint(0.25, 1), true),118 new mxConnectionConstraint(new mxPoint(0.5, 1), true),119 new mxConnectionConstraint(new mxPoint(0.75, 1), true)120 ];121122//**********************************************************************************************************************************************************123//Entity Extended124//**********************************************************************************************************************************************************125/**126 * Extends mxShape.127 */128function mxShapeEREntityExt(bounds, fill, stroke, strokewidth)129{130 mxShape.call(this);131 this.bounds = bounds;132 this.fill = fill;133 this.stroke = stroke;134 this.strokewidth = (strokewidth != null) ? strokewidth : 1;135};136137/**138 * Extends mxShape.139 */140mxUtils.extend(mxShapeEREntityExt, mxShape);141142/**143 * Function: paintVertexShape144 * 145 * Paints the vertex shape.146 */147mxShapeEREntityExt.prototype.paintVertexShape = function(c, x, y, w, h)148{149 var mainText = mxUtils.getValue(this.style, 'buttonText', 'Entity');150 var attributes = mxUtils.getValue(this.style, 'subText', '+ attribute 1,+ attribute 2,+ attribute 3').toString().split(',');151 var strokeColor = mxUtils.getValue(this.style, mxConstants.STYLE_STROKECOLOR, '#666666');152 var fontSize = mxUtils.getValue(this.style, mxConstants.STYLE_FONTSIZE, '17');153 var mainColor = mxUtils.getValue(this.style, mxConstants.STYLE_FILLCOLOR, '#008cff');154 var attrColor = mxUtils.getValue(this.style, 'fillColor2', '#ffffff');155 var maxTextWidth = 0;156 c.translate(x, y);157 var rSize = 10;158 var barY = fontSize * 1.25;159160 for (var i = 0; i < attributes.length; i++)161 {162 var currWidth = mxUtils.getSizeForString(attributes[i], fontSize, mxConstants.DEFAULT_FONTFAMILY).width;163164 if (currWidth > maxTextWidth)165 {166 maxTextWidth = currWidth;167 }168 }169170 w = Math.max(w, 2 * rSize, maxTextWidth + rSize);171 h = Math.max(h, 2 * rSize, (attributes.length + 1) * barY);172 this.background(c, x, y, w, h, rSize);173 c.setShadow(false);174 this.shapes(c, x, y, w, h, fontSize, mainColor, attrColor, rSize, barY);175 this.mainText(c, x, y, w, h, mainText, fontSize, attrColor);176 this.attrText(c, x, y, w, h, attributes, fontSize, strokeColor, barY, rSize);177};178179mxShapeEREntityExt.prototype.background = function(c, x, y, w, h, rSize)180{181 var buttonStyle = mxUtils.getValue(this.style, 'buttonStyle', 'round').toString();182 c.begin();183184 if (buttonStyle === 'round')185 {186 c.moveTo(0, rSize);187 c.arcTo(rSize, rSize, 0, 0, 1, rSize, 0);188 c.lineTo(w - rSize, 0);189 c.arcTo(rSize, rSize, 0, 0, 1, w, rSize);190 c.lineTo(w, h - rSize);191 c.arcTo(rSize, rSize, 0, 0, 1, w - rSize, h);192 c.lineTo(rSize, h);193 c.arcTo(rSize, rSize, 0, 0, 1, 0, h - rSize);194 }195 else if (buttonStyle === 'rect')196 {197 c.moveTo(0, 0);198 c.lineTo(w, 0);199 c.lineTo(w, h);200 c.lineTo(0, h);201 }202203 c.close(); 204 c.fillAndStroke();205};206207mxShapeEREntityExt.prototype.mainText = function(c, x, y, w, h, text, fontSize, fontColor)208{209 c.begin();210 c.setFontSize(fontSize);211 c.setFontColor(fontColor);212 c.text(w * 0.5, fontSize * 0.5, 0, 0, text, mxConstants.ALIGN_CENTER, mxConstants.ALIGN_MIDDLE, 0, null, 0, 0, 0);213};214215mxShapeEREntityExt.prototype.shapes = function(c, x, y, w, h, fontSize, mainColor, attrColor, rSize, barY)216{217 var buttonStyle = mxUtils.getValue(this.style, 'buttonStyle', 'round').toString();218219 if (buttonStyle === 'round')220 {221 c.begin();222 c.moveTo(0, rSize);223 c.arcTo(rSize, rSize, 0, 0, 1, rSize, 0);224 c.lineTo(w - rSize, 0);225 c.arcTo(rSize, rSize, 0, 0, 1, w, rSize);226 c.lineTo(w, barY);227 c.lineTo(0, barY);228 c.close();229 c.fill();230231 c.setFillColor(attrColor);232 c.begin();233 c.moveTo(w, barY);234 c.lineTo(w, h - rSize);235 c.arcTo(rSize, rSize, 0, 0, 1, w - rSize, h);236 c.lineTo(rSize, h);237 c.arcTo(rSize, rSize, 0, 0, 1, 0, h - rSize);238 c.lineTo(0, barY);239 c.close();240 c.fill();241 }242 else if (buttonStyle === 'rect')243 {244 c.begin();245 c.moveTo(0, 0);246 c.lineTo(w, 0);247 c.lineTo(w, barY);248 c.lineTo(0, barY);249 c.close();250 c.fill();251252 c.setFillColor(attrColor);253 c.begin();254 c.moveTo(0, barY);255 c.lineTo(w, barY);256 c.lineTo(w, h);257 c.lineTo(0, h);258 c.close();259 c.fill();260 }261262 c.begin();263264 if (buttonStyle === 'round')265 {266 c.moveTo(0, rSize);267 c.arcTo(rSize, rSize, 0, 0, 1, rSize, 0);268 c.lineTo(w - rSize, 0);269 c.arcTo(rSize, rSize, 0, 0, 1, w, rSize);270 c.lineTo(w, h - rSize);271 c.arcTo(rSize, rSize, 0, 0, 1, w - rSize, h);272 c.lineTo(rSize, h);273 c.arcTo(rSize, rSize, 0, 0, 1, 0, h - rSize);274 }275 else if (buttonStyle === 'rect')276 {277 c.moveTo(0, 0);278 c.lineTo(w, 0);279 c.lineTo(w, h);280 c.lineTo(0, h);281 }282283 c.close(); 284 c.stroke();285};286287mxShapeEREntityExt.prototype.attrText = function(c, x, y, w, h, attributes, fontSize, fontColor, barY, rSize)288{289 for (var i = 0; i < attributes.length; i++)290 {291 c.begin();292 c.setFontSize(fontSize);293 c.setFontColor(fontColor);294 c.text(rSize * 0.5, (i + 1.5) * barY, 0, 0, attributes[i], mxConstants.ALIGN_LEFT, mxConstants.ALIGN_MIDDLE, 0, null, 0, 0, 0);295 }296};297298mxCellRenderer.registerShape('mxgraph.er.entityExt', mxShapeEREntityExt);299300mxShapeEREntityExt.prototype.constraints = [301 new mxConnectionConstraint(new mxPoint(0.25, 0), true),302 new mxConnectionConstraint(new mxPoint(0.5, 0), true),303 new mxConnectionConstraint(new mxPoint(0.75, 0), true),304 new mxConnectionConstraint(new mxPoint(0, 0.25), true),305 new mxConnectionConstraint(new mxPoint(0, 0.5), true),306 new mxConnectionConstraint(new mxPoint(0, 0.75), true),307 new mxConnectionConstraint(new mxPoint(1, 0.25), true),308 new mxConnectionConstraint(new mxPoint(1, 0.5), true),309 new mxConnectionConstraint(new mxPoint(1, 0.75), true),310 new mxConnectionConstraint(new mxPoint(0.25, 1), true),311 new mxConnectionConstraint(new mxPoint(0.5, 1), true),312 new mxConnectionConstraint(new mxPoint(0.75, 1), true)313 ];314315//**********************************************************************************************************************************************************316//Attribute317//**********************************************************************************************************************************************************318/**319 * Extends mxShape.320 */321function mxShapeERAttribute(bounds, fill, stroke, strokewidth)322{323 mxShape.call(this);324 this.bounds = bounds;325 this.fill = fill;326 this.stroke = stroke;327 this.strokewidth = (strokewidth != null) ? strokewidth : 1;328};329330/**331 * Extends mxShape.332 */333mxUtils.extend(mxShapeERAttribute, mxShape);334335/**336 * Function: paintVertexShape337 * 338 * Paints the vertex shape.339 */340mxShapeERAttribute.prototype.paintVertexShape = function(c, x, y, w, h)341{342 var mainText = mxUtils.getValue(this.style, 'buttonText', 'Entity');343 var fontColor = mxUtils.getValue(this.style, 'textColor', '#666666');344 var fontSize = mxUtils.getValue(this.style, mxConstants.STYLE_FONTSIZE, '17');345 c.translate(x, y);346 var rSize = 10;347 w = Math.max(w, 2 * rSize);348 h = Math.max(h, 2 * rSize);349 this.background(c, x, y, w, h, rSize, fontColor);350 c.setShadow(false);351 this.mainText(c, x, y, w, h, mainText, fontSize, fontColor);352};353354mxShapeERAttribute.prototype.background = function(c, x, y, w, h, rSize, fontColor)355{356 var buttonStyle = mxUtils.getValue(this.style, 'buttonStyle', 'simple').toString();357358 if (buttonStyle === 'simple')359 {360 c.begin();361 c.ellipse(0, 0, w, h);362 c.fillAndStroke();363 }364 else if (buttonStyle === 'dblFrame')365 {366 var fillColor = mxUtils.getValue(this.style, mxConstants.STYLE_FILLCOLOR, '#666666');367 c.setFillColor(fillColor);368 c.begin();369 c.ellipse(0, 0, w, h);370 c.fillAndStroke();371 rSize = Math.min(w, h);372 c.begin();373 c.ellipse(rSize * 0.1, rSize * 0.1, w - rSize * 0.2, h - rSize * 0.2);374 c.stroke();375 }376};377378mxShapeERAttribute.prototype.mainText = function(c, x, y, w, h, text, fontSize, fontColor)379{380 c.begin();381 c.setFontSize(fontSize);382 c.setFontColor(fontColor);383 c.text(w * 0.5, h * 0.5, 0, 0, text, mxConstants.ALIGN_CENTER, mxConstants.ALIGN_MIDDLE, 0, null, 0, 0, 0);384};385386mxCellRenderer.registerShape('mxgraph.er.attribute', mxShapeERAttribute);387388mxShapeERAttribute.prototype.constraints = [389 new mxConnectionConstraint(new mxPoint(0.144, 0.144), false),390 new mxConnectionConstraint(new mxPoint(0.856, 0.144), false),391 new mxConnectionConstraint(new mxPoint(0.856, 0.856), false),392 new mxConnectionConstraint(new mxPoint(0.144, 0.856), false),393 new mxConnectionConstraint(new mxPoint(0, 0.5), true),394 new mxConnectionConstraint(new mxPoint(1, 0.5), true),395 new mxConnectionConstraint(new mxPoint(0.5, 0), true),396 new mxConnectionConstraint(new mxPoint(0.5, 1), true)397 ];398399//**********************************************************************************************************************************************************400//Has401//**********************************************************************************************************************************************************402/**403 * Extends mxShape.404 */405function mxShapeERHas(bounds, fill, stroke, strokewidth)406{407 mxShape.call(this);408 this.bounds = bounds;409 this.fill = fill;410 this.stroke = stroke;411 this.strokewidth = (strokewidth != null) ? strokewidth : 1;412};413414/**415 * Extends mxShape.416 */417mxUtils.extend(mxShapeERHas, mxShape);418419/**420 * Function: paintVertexShape421 * 422 * Paints the vertex shape.423 */424mxShapeERHas.prototype.paintVertexShape = function(c, x, y, w, h)425{426 var mainText = mxUtils.getValue(this.style, 'buttonText', 'Entity');427 var fontColor = mxUtils.getValue(this.style, 'textColor', '#666666');428 var fontSize = mxUtils.getValue(this.style, mxConstants.STYLE_FONTSIZE, '17');429 c.translate(x, y);430 var rSize = 10;431 w = Math.max(w, 2 * rSize);432 h = Math.max(h, 2 * rSize);433 this.background(c, x, y, w, h, rSize, fontColor);434 c.setShadow(false);435 this.mainText(c, x, y, w, h, mainText, fontSize, fontColor);436};437438mxShapeERHas.prototype.background = function(c, x, y, w, h, rSize, fontColor)439{440 var buttonStyle = mxUtils.getValue(this.style, 'buttonStyle', 'rhombus').toString();441442 if (buttonStyle === 'rhombus')443 {444 c.begin();445 c.moveTo(0, h * 0.5);446 c.lineTo(w * 0.5, 0);447 c.lineTo(w, h * 0.5);448 c.lineTo(w * 0.5, h);449 c.close(); 450 c.fillAndStroke();451 }452 else if (buttonStyle === 'dblFrame')453 {454 var fillColor = mxUtils.getValue(this.style, mxConstants.STYLE_FILLCOLOR, '#666666');455 c.setFillColor(fillColor);456 c.begin();457 c.moveTo(0, h * 0.5);458 c.lineTo(w * 0.5, 0);459 c.lineTo(w, h * 0.5);460 c.lineTo(w * 0.5, h);461 c.close(); 462 c.fillAndStroke();463 c.begin();464 c.moveTo(w * 0.1, h * 0.5);465 c.lineTo(w * 0.5, h * 0.1);466 c.lineTo(w * 0.9, h * 0.5);467 c.lineTo(w * 0.5, h * 0.9);468 c.close(); 469 c.stroke();470 }471};472473mxShapeERHas.prototype.mainText = function(c, x, y, w, h, text, fontSize, fontColor)474{475 c.begin();476 c.setFontSize(fontSize);477 c.setFontColor(fontColor);478 c.text(w * 0.5, h * 0.5, 0, 0, text, mxConstants.ALIGN_CENTER, mxConstants.ALIGN_MIDDLE, 0, null, 0, 0, 0);479};480481mxCellRenderer.registerShape('mxgraph.er.has', mxShapeERHas);482483mxShapeERHas.prototype.constraints = [484 new mxConnectionConstraint(new mxPoint(0.5, 0), true),485 new mxConnectionConstraint(new mxPoint(0.5, 1), true),486 new mxConnectionConstraint(new mxPoint(0, 0.5), true),487 new mxConnectionConstraint(new mxPoint(1, 0.5), true),488 new mxConnectionConstraint(new mxPoint(0.25, 0.25), false),489 new mxConnectionConstraint(new mxPoint(0.25, 0.75), false),490 new mxConnectionConstraint(new mxPoint(0.75, 0.25), false),491 new mxConnectionConstraint(new mxPoint(0.75, 0.75), false)492 ];493494//**********************************************************************************************************************************************************495//Cloud496//**********************************************************************************************************************************************************497/**498 * Extends mxShape.499 */500function mxShapeERCloud(bounds, fill, stroke, strokewidth)501{502 mxShape.call(this);503 this.bounds = bounds;504 this.fill = fill;505 this.stroke = stroke;506 this.strokewidth = (strokewidth != null) ? strokewidth : 1;507};508509/**510 * Extends mxShape.511 */512mxUtils.extend(mxShapeERCloud, mxShape);513514/**515 * Function: paintVertexShape516 * 517 * Paints the vertex shape.518 */519mxShapeERCloud.prototype.paintVertexShape = function(c, x, y, w, h)520{521 var mainText = mxUtils.getValue(this.style, 'buttonText', 'Entity');522 var fontColor = mxUtils.getValue(this.style, 'textColor', '#666666');523 var fontSize = mxUtils.getValue(this.style, mxConstants.STYLE_FONTSIZE, '17');524 c.translate(x, y);525 var rSize = 10;526 w = Math.max(w, 2 * rSize);527 h = Math.max(h, 2 * rSize);528 this.background(c, x, y, w, h, rSize, fontColor);529 c.setShadow(false);530 this.mainText(c, x, y, w, h, mainText, fontSize, fontColor);531};532533mxShapeERCloud.prototype.background = function(c, x, y, w, h, rSize, fontColor)534{535 c.begin();536 c.moveTo(0.25 * w, 0.25 * h);537 c.curveTo(0.05 * w, 0.25 * h, 0, 0.5 * h, 0.16 * w, 0.55 * h);538 c.curveTo(0, 0.66 * h, 0.18 * w, 0.9 * h, 0.31 * w, 0.8 * h);539 c.curveTo(0.4 * w, h, 0.7 * w, h, 0.8 * w, 0.8 * h);540 c.curveTo(w, 0.8 * h, w, 0.6 * h, 0.875 * w, 0.5 * h); 541 c.curveTo(w, 0.3 * h, 0.8 * w, 0.1 * h, 0.625 * w, 0.2 * h);542 c.curveTo(0.5 * w, 0.05 * h, 0.3 * w, 0.05 * h, 0.25 * w, 0.25 * h);543 c.fillAndStroke();544};545546mxShapeERCloud.prototype.mainText = function(c, x, y, w, h, text, fontSize, fontColor)547{548 c.begin();549 c.setFontSize(fontSize);550 c.setFontColor(fontColor);551 c.text(w * 0.5, h * 0.5, 0, 0, text, mxConstants.ALIGN_CENTER, mxConstants.ALIGN_MIDDLE, 0, null, 0, 0, 0);552};553554mxCellRenderer.registerShape('mxgraph.er.cloud', mxShapeERCloud);555556mxShapeERCloud.prototype.constraints = [557 new mxConnectionConstraint(new mxPoint(0.08, 0.5), false),558 new mxConnectionConstraint(new mxPoint(0.9, 0.5), false),559 new mxConnectionConstraint(new mxPoint(0.5, 0.1), false),560 new mxConnectionConstraint(new mxPoint(0.5, 0.92), false),561 new mxConnectionConstraint(new mxPoint(0.24, 0.24), false),562 new mxConnectionConstraint(new mxPoint(0.22, 0.8), false),563 new mxConnectionConstraint(new mxPoint(0.81, 0.2), false),564 new mxConnectionConstraint(new mxPoint(0.78, 0.78), false)565 ];566567//**********************************************************************************************************************************************************568//Hierarchy (LEGACY)569//**********************************************************************************************************************************************************570/**571 * Extends mxShape.572 */573function mxShapeERHierarchy(bounds, fill, stroke, strokewidth)574{575 mxShape.call(this);576 this.bounds = bounds;577 this.fill = fill;578 this.stroke = stroke;579 this.strokewidth = (strokewidth != null) ? strokewidth : 1;580};581582/**583 * Extends mxShape.584 */585mxUtils.extend(mxShapeERHierarchy, mxShape);586587/**588 * Function: paintVertexShape589 * 590 * Paints the vertex shape.591 */592mxShapeERHierarchy.prototype.paintVertexShape = function(c, x, y, w, h)593{594 var mainText = mxUtils.getValue(this.style, 'buttonText', 'main').toString().split(',');595 var subText = mxUtils.getValue(this.style, 'subText', 'sub').toString().split(',');596 var fontColor = mxUtils.getValue(this.style, 'textColor', '#666666');597 var fontSize = mxUtils.getValue(this.style, mxConstants.STYLE_FONTSIZE, '17');598 c.translate(x, y);599 var rSize = 10;600 w = Math.max(w, 2 * rSize);601 h = Math.max(h, 2 * rSize);602 this.background(c, x, y, w, h, rSize, fontColor);603 c.setShadow(false);604 this.shapeText(c, x, y, w, h, mainText, subText, fontSize, fontColor);605};606607mxShapeERHierarchy.prototype.background = function(c, x, y, w, h, rSize, fontColor)608{609 var buttonStyle = mxUtils.getValue(this.style, 'buttonStyle', 'round').toString();610611 if (buttonStyle === 'round')612 {613 c.begin();614 c.moveTo(0, rSize);615 c.arcTo(rSize, rSize, 0, 0, 1, rSize, 0);616 c.lineTo(w - rSize, 0);617 c.arcTo(rSize, rSize, 0, 0, 1, w, rSize);618 c.lineTo(w, h - rSize);619 c.arcTo(rSize, rSize, 0, 0, 1, w - rSize, h);620 c.lineTo(rSize, h);621 c.arcTo(rSize, rSize, 0, 0, 1, 0, h - rSize);622 c.close(); 623 c.fillAndStroke();624 }625 else if (buttonStyle === 'rect')626 {627 c.begin();628 c.moveTo(0, 0);629 c.lineTo(w, 0);630 c.lineTo(w, h);631 c.lineTo(0, h);632 c.close(); 633 c.fillAndStroke();634 }635 else if (buttonStyle === 'dblFrame')636 {637 var fillColor = mxUtils.getValue(this.style, mxConstants.STYLE_FILLCOLOR, '#666666');638 c.setFillColor(fillColor);639 c.begin();640 c.moveTo(0, 0);641 c.lineTo(w, 0);642 c.lineTo(w, h);643 c.lineTo(0, h);644 c.close(); 645 c.fillAndStroke();646 rSize = Math.min(w, h);647 c.begin();648 c.moveTo(rSize * 0.1, rSize * 0.1);649 c.lineTo(w - rSize * 0.1, rSize * 0.1);650 c.lineTo(w - rSize * 0.1, h - rSize * 0.1);651 c.lineTo(rSize * 0.1, h - rSize * 0.1);652 c.close(); 653 c.stroke();654 }655656 var trX = 0;657 var trY = 0;658659 if (buttonStyle === 'round')660 {661 trX = w * 0.5;662 trY = rSize;663 c.translate(trX, trY);664 w = w * 0.5 - rSize;665 h = h - 2 * rSize;666 c.begin();667 c.moveTo(0, rSize);668 c.arcTo(rSize, rSize, 0, 0, 1, rSize, 0);669 c.lineTo(w - rSize, 0);670 c.arcTo(rSize, rSize, 0, 0, 1, w, rSize);671 c.lineTo(w, h - rSize);672 c.arcTo(rSize, rSize, 0, 0, 1, w - rSize, h);673 c.lineTo(rSize, h);674 c.arcTo(rSize, rSize, 0, 0, 1, 0, h - rSize);675 c.close(); 676 c.fillAndStroke();677 }678 else if (buttonStyle === 'rect')679 {680 trX = w * 0.5;681 trY = rSize;682 c.translate(trX, trY);683 w = w * 0.5 - rSize;684 h = h - 2 * rSize;685 c.begin();686 c.moveTo(0, 0);687 c.lineTo(w, 0);688 c.lineTo(w, h);689 c.lineTo(0, h);690 c.close(); 691 c.fillAndStroke();692 }693 else if (buttonStyle === 'dblFrame')694 {695 trX = w * 0.5;696 trY = rSize * 0.15;697 c.translate(trX, trY);698 w = w * 0.5 - rSize * 0.15;699 h = h - rSize * 0.3;700 var fillColor = mxUtils.getValue(this.style, mxConstants.STYLE_FILLCOLOR, '#666666');701 c.setFillColor(fillColor);702 c.begin();703 c.moveTo(0, 0);704 c.lineTo(w, 0);705 c.lineTo(w, h);706 c.lineTo(0, h);707 c.close(); 708 c.fillAndStroke();709 rSize = Math.min(w, h);710 c.begin();711 c.moveTo(rSize * 0.1, rSize * 0.1);712 c.lineTo(w - rSize * 0.1, rSize * 0.1);713 c.lineTo(w - rSize * 0.1, h - rSize * 0.1);714 c.lineTo(rSize * 0.1, h - rSize * 0.1);715 c.close(); 716 c.stroke();717 }718719 c.translate(- trX, - trY);720721};722723mxShapeERHierarchy.prototype.shapeText = function(c, x, y, w, h, text, subText, fontSize, fontColor, rSize)724{725 c.begin();726 c.setFontSize(fontSize);727 c.setFontColor(fontColor);728 c.text(w * 0.25, (h - fontSize) * 0.5, 0, 0, text[0], mxConstants.ALIGN_CENTER, mxConstants.ALIGN_MIDDLE, 0, null, 0, 0, 0);729 c.text(w * 0.25, (h + fontSize) * 0.5, 0, 0, text[1], mxConstants.ALIGN_CENTER, mxConstants.ALIGN_MIDDLE, 0, null, 0, 0, 0);730 c.text(w * 0.7, (h - fontSize) * 0.5, 0, 0, subText[0], mxConstants.ALIGN_CENTER, mxConstants.ALIGN_MIDDLE, 0, null, 0, 0, 0);731 c.text(w * 0.7, (h + fontSize) * 0.5, 0, 0, subText[1], mxConstants.ALIGN_CENTER, mxConstants.ALIGN_MIDDLE, 0, null, 0, 0, 0);732};733734mxCellRenderer.registerShape('mxgraph.er.hierarchy', mxShapeERHierarchy);735736mxShapeERHierarchy.prototype.constraints = [737 new mxConnectionConstraint(new mxPoint(0.25, 0), true),738 new mxConnectionConstraint(new mxPoint(0.5, 0), true),739 new mxConnectionConstraint(new mxPoint(0.75, 0), true),740 new mxConnectionConstraint(new mxPoint(0, 0.25), true),741 new mxConnectionConstraint(new mxPoint(0, 0.5), true),742 new mxConnectionConstraint(new mxPoint(0, 0.75), true),743 new mxConnectionConstraint(new mxPoint(1, 0.25), true),744 new mxConnectionConstraint(new mxPoint(1, 0.5), true),745 new mxConnectionConstraint(new mxPoint(1, 0.75), true),746 new mxConnectionConstraint(new mxPoint(0.25, 1), true),747 new mxConnectionConstraint(new mxPoint(0.5, 1), true),748 new mxConnectionConstraint(new mxPoint(0.75, 1), true)749 ];750751//**********************************************************************************************************************************************************752//Note753//**********************************************************************************************************************************************************754/**755 * Extends mxShape.756 */757function mxShapeERNote(bounds, fill, stroke, strokewidth)758{759 mxShape.call(this);760 this.bounds = bounds;761 this.fill = fill;762 this.stroke = stroke;763 this.strokewidth = (strokewidth != null) ? strokewidth : 1;764};765766/**767 * Extends mxShape.768 */769mxUtils.extend(mxShapeERNote, mxShape);770771/**772 * Function: paintVertexShape773 * 774 * Paints the vertex shape.775 */776mxShapeERNote.prototype.paintVertexShape = function(c, x, y, w, h)777{778 var mainText = mxUtils.getValue(this.style, 'buttonText', 'Entity');779 var fontColor = mxUtils.getValue(this.style, 'textColor', '#666666');780 var fontSize = mxUtils.getValue(this.style, mxConstants.STYLE_FONTSIZE, '17');781 var backColor = mxUtils.getValue(this.style, 'fillColor2', '#ffffff');782 c.translate(x, y);783 var flipSize = 20;784 w = Math.max(w, flipSize * 2);785 h = Math.max(h, flipSize * 2);786 this.background(c, x, y, w, h, flipSize);787 c.setShadow(false);788 this.flipShape(c, x, y, w, h, flipSize, backColor);789 this.mainText(c, x, y, w, h, mainText, fontSize, fontColor);790};791792mxShapeERNote.prototype.background = function(c, x, y, w, h, flipSize)793{794 c.begin();795 c.moveTo(0, 0);796 c.lineTo(w - flipSize, 0);797 c.lineTo(w, flipSize);798 c.lineTo(w, h);799 c.lineTo(0, h);800 c.close(); 801 c.fillAndStroke();802};803804mxShapeERNote.prototype.flipShape = function(c, x, y, w, h, flipSize, backColor)805{806 c.setLineJoin('round');807 c.setFillColor(backColor);808 c.begin();809 c.moveTo(w - flipSize, 0);810 c.lineTo(w, flipSize);811 c.lineTo(w - flipSize, flipSize);812 c.close(); 813 c.fillAndStroke();814};815816mxShapeERNote.prototype.mainText = function(c, x, y, w, h, text, fontSize, fontColor)817{818 c.begin();819 c.setFontSize(fontSize);820 c.setFontColor(fontColor);821 c.text(w * 0.5, h * 0.5, 0, 0, text, mxConstants.ALIGN_CENTER, mxConstants.ALIGN_MIDDLE, 0, null, 0, 0, 0);822};823824mxCellRenderer.registerShape('mxgraph.er.note', mxShapeERNote);825826mxShapeERNote.prototype.constraints = [827 new mxConnectionConstraint(new mxPoint(0, 0), true),828 new mxConnectionConstraint(new mxPoint(0, 1), true),829 new mxConnectionConstraint(new mxPoint(1, 1), true),830 new mxConnectionConstraint(new mxPoint(0.25, 0), true),831 new mxConnectionConstraint(new mxPoint(0.5, 0), true),832 new mxConnectionConstraint(new mxPoint(0.75, 0), true),833 new mxConnectionConstraint(new mxPoint(0, 0.25), true),834 new mxConnectionConstraint(new mxPoint(0, 0.5), true),835 new mxConnectionConstraint(new mxPoint(0, 0.75), true),836 new mxConnectionConstraint(new mxPoint(1, 0.25), true),837 new mxConnectionConstraint(new mxPoint(1, 0.5), true),838 new mxConnectionConstraint(new mxPoint(1, 0.75), true),839 new mxConnectionConstraint(new mxPoint(0.25, 1), true),840 new mxConnectionConstraint(new mxPoint(0.5, 1), true),841 new mxConnectionConstraint(new mxPoint(0.75, 1), true)842 ];843844//**********************************************************************************************************************************************************845//Chen's Notation Legend (LEGACY)846//**********************************************************************************************************************************************************847/**848 * Extends mxShape.849 */850function mxShapeERChen(bounds, fill, stroke, strokewidth)851{852 mxShape.call(this);853 this.bounds = bounds;854 this.fill = fill;855 this.stroke = stroke;856 this.strokewidth = (strokewidth != null) ? strokewidth : 1;857};858859/**860 * Extends mxShape.861 */862mxUtils.extend(mxShapeERChen, mxShape);863864/**865 * Function: paintVertexShape866 * 867 * Paints the vertex shape.868 */869mxShapeERChen.prototype.paintVertexShape = function(c, x, y, w, h)870{871 var fontColor = mxUtils.getValue(this.style, 'textColor', '#666666');872 var fontSize = mxUtils.getValue(this.style, mxConstants.STYLE_FONTSIZE, '17');873 c.translate(x, y);874 var flipSize = 20;875 w = Math.max(w, flipSize * 2);876 h = Math.max(h, flipSize * 2);877 this.background(c, x, y, w, h);878 c.setShadow(false);879 this.foreground(c, x, y, w, h, fontSize, fontColor);880};881882mxShapeERChen.prototype.background = function(c, x, y, w, h)883{884 c.begin();885 c.moveTo(0, 0);886 c.lineTo(w, 0);887 c.lineTo(w, h);888 c.lineTo(0, h);889 c.close(); 890 c.fillAndStroke();891};892893mxShapeERChen.prototype.foreground = function(c, x, y, w, h, fontSize, fontColor)894{895 c.begin();896 c.moveTo(0, h * 0.25);897 c.lineTo(w, h * 0.25);898 c.moveTo(0, h * 0.5);899 c.lineTo(w, h * 0.5);900 c.moveTo(0, h * 0.75);901 c.lineTo(w, h * 0.75);902903 c.moveTo(w * 0.25, h * 0.5);904 c.lineTo(w * 0.25, h);905906 c.moveTo(w * 0.5, h * 0.25);907 c.lineTo(w * 0.5, h);908909 c.moveTo(w * 0.75, h * 0.5);910 c.lineTo(w * 0.75, h);911 c.stroke();912913 c.begin();914 c.setFontSize(fontSize);915 c.setFontColor(fontColor);916 c.text(w * 0.5, h * 0.125, 0, 0, 'ERD Peter Chen\'s Notation', mxConstants.ALIGN_CENTER, mxConstants.ALIGN_MIDDLE, 0, null, 0, 0, 0);917918 c.setFontSize(fontSize * 0.85);919 c.text(w * 0.25, h * 0.375, 0, 0, 'Cardinality', mxConstants.ALIGN_CENTER, mxConstants.ALIGN_MIDDLE, 0, null, 0, 0, 0);920 c.text(w * 0.75, h * 0.375, 0, 0, 'Optionality', mxConstants.ALIGN_CENTER, mxConstants.ALIGN_MIDDLE, 0, null, 0, 0, 0);921922 c.setFontSize(fontSize * 0.7);923 c.text(w * 0.125, h * 0.625, 0, 0, '1', mxConstants.ALIGN_CENTER, mxConstants.ALIGN_MIDDLE, 0, null, 0, 0, 0);924 c.text(w * 0.375, h * 0.625, 0, 0, 'One', mxConstants.ALIGN_CENTER, mxConstants.ALIGN_MIDDLE, 0, null, 0, 0, 0);925 c.text(w * 0.625, h * 0.625, 0, 0, '0', mxConstants.ALIGN_CENTER, mxConstants.ALIGN_MIDDLE, 0, null, 0, 0, 0);926 c.text(w * 0.875, h * 0.625, 0, 0, 'Optional', mxConstants.ALIGN_CENTER, mxConstants.ALIGN_MIDDLE, 0, null, 0, 0, 0);927928 c.text(w * 0.125, h * 0.875, 0, 0, 'N', mxConstants.ALIGN_CENTER, mxConstants.ALIGN_MIDDLE, 0, null, 0, 0, 0);929 c.text(w * 0.375, h * 0.875, 0, 0, 'Many', mxConstants.ALIGN_CENTER, mxConstants.ALIGN_MIDDLE, 0, null, 0, 0, 0);930 c.text(w * 0.625, h * 0.875, 0, 0, '1', mxConstants.ALIGN_CENTER, mxConstants.ALIGN_MIDDLE, 0, null, 0, 0, 0);931 c.text(w * 0.875, h * 0.875, 0, 0, 'Mandatory', mxConstants.ALIGN_CENTER, mxConstants.ALIGN_MIDDLE, 0, null, 0, 0, 0);932};933934mxCellRenderer.registerShape('mxgraph.er.chens', mxShapeERChen);935936mxShapeERChen.prototype.constraints = [937 new mxConnectionConstraint(new mxPoint(0, 0), true),938 new mxConnectionConstraint(new mxPoint(1, 0), true),939 new mxConnectionConstraint(new mxPoint(0, 1), true),940 new mxConnectionConstraint(new mxPoint(1, 1), true),941 new mxConnectionConstraint(new mxPoint(0.25, 0), true),942 new mxConnectionConstraint(new mxPoint(0.5, 0), true),943 new mxConnectionConstraint(new mxPoint(0.75, 0), true),944 new mxConnectionConstraint(new mxPoint(0, 0.25), true),945 new mxConnectionConstraint(new mxPoint(0, 0.5), true),946 new mxConnectionConstraint(new mxPoint(0, 0.75), true),947 new mxConnectionConstraint(new mxPoint(1, 0.25), true),948 new mxConnectionConstraint(new mxPoint(1, 0.5), true),949 new mxConnectionConstraint(new mxPoint(1, 0.75), true),950 new mxConnectionConstraint(new mxPoint(0.25, 1), true),951 new mxConnectionConstraint(new mxPoint(0.5, 1), true),952 new mxConnectionConstraint(new mxPoint(0.75, 1), true)953 ];954955//**********************************************************************************************************************************************************956//Bachman's Notation Legend (LEGACY)957//**********************************************************************************************************************************************************958/**959 * Extends mxShape.960 */961function mxShapeERBachman(bounds, fill, stroke, strokewidth)962{963 mxShape.call(this);964 this.bounds = bounds;965 this.fill = fill;966 this.stroke = stroke;967 this.strokewidth = (strokewidth != null) ? strokewidth : 1;968};969970/**971 * Extends mxShape.972 */973mxUtils.extend(mxShapeERBachman, mxShape);974975/**976 * Function: paintVertexShape977 * 978 * Paints the vertex shape.979 */980mxShapeERBachman.prototype.paintVertexShape = function(c, x, y, w, h)981{982 var fontColor = mxUtils.getValue(this.style, 'textColor', '#666666');983 var fontSize = mxUtils.getValue(this.style, mxConstants.STYLE_FONTSIZE, '17');984 c.translate(x, y);985 this.background(c, x, y, w, h);986 c.setShadow(false);987 this.foreground(c, x, y, w, h, fontSize, fontColor);988};989990mxShapeERBachman.prototype.background = function(c, x, y, w, h)991{992 c.begin();993 c.moveTo(0, 0);994 c.lineTo(w, 0);995 c.lineTo(w, h);996 c.lineTo(0, h);997 c.close(); 998 c.fillAndStroke();999};10001001mxShapeERBachman.prototype.foreground = function(c, x, y, w, h, fontSize, fontColor)1002{1003 c.begin();1004 c.moveTo(0, h * 0.125);1005 c.lineTo(w, h * 0.125);1006 c.moveTo(0, h * 0.25);1007 c.lineTo(w, h * 0.25);1008 c.moveTo(0, h * 0.375);1009 c.lineTo(w, h * 0.375);1010 c.moveTo(0, h * 0.5);1011 c.lineTo(w, h * 0.5);1012 c.moveTo(0, h * 0.625);1013 c.lineTo(w, h * 0.625);1014 c.moveTo(0, h * 0.75);1015 c.lineTo(w, h * 0.75);1016 c.moveTo(0, h * 0.875);1017 c.lineTo(w, h * 0.875);10181019 c.moveTo(w * 0.5, h * 0.125);1020 c.lineTo(w * 0.5, h);1021 c.stroke();10221023 c.begin();1024 c.setFontSize(fontSize);1025 c.setFontColor(fontColor);1026 c.text(w * 0.5, h * 0.0625, 0, 0, 'ERD Bachman\'s Notation', mxConstants.ALIGN_CENTER, mxConstants.ALIGN_MIDDLE, 0, null, 0, 0, 0);10271028 c.setFontSize(fontSize * 0.85);1029 c.text(w * 0.52, h * 0.1875, 0, 0, 'Relationship', mxConstants.ALIGN_LEFT, mxConstants.ALIGN_MIDDLE, 0, null, 0, 0, 0);1030 c.text(w * 0.52, h * 0.3125, 0, 0, 'Cardinality (One)', mxConstants.ALIGN_LEFT, mxConstants.ALIGN_MIDDLE, 0, null, 0, 0, 0);1031 c.text(w * 0.52, h * 0.4375, 0, 0, 'Cardinality (Many)', mxConstants.ALIGN_LEFT, mxConstants.ALIGN_MIDDLE, 0, null, 0, 0, 0);1032 c.text(w * 0.52, h * 0.5625, 0, 0, 'Mandatory, One', mxConstants.ALIGN_LEFT, mxConstants.ALIGN_MIDDLE, 0, null, 0, 0, 0);1033 c.text(w * 0.52, h * 0.6875, 0, 0, 'Mandatory, Many', mxConstants.ALIGN_LEFT, mxConstants.ALIGN_MIDDLE, 0, null, 0, 0, 0);1034 c.text(w * 0.52, h * 0.8125, 0, 0, 'Optional, One', mxConstants.ALIGN_LEFT, mxConstants.ALIGN_MIDDLE, 0, null, 0, 0, 0);1035 c.text(w * 0.52, h * 0.9375, 0, 0, 'Optional, Many', mxConstants.ALIGN_LEFT, mxConstants.ALIGN_MIDDLE, 0, null, 0, 0, 0);10361037 var textWidth = mxUtils.getSizeForString('has/forms', fontSize, mxConstants.DEFAULT_FONTFAMILY).width;1038 c.begin();1039 c.moveTo(w * 0.04, h * 0.1875);1040 c.lineTo(w * 0.25 - textWidth * 0.5, h * 0.1875);1041 c.moveTo(w * 0.25 + textWidth * 0.5, h * 0.1875);1042 c.lineTo(w * 0.46, h * 0.1875);10431044 c.text(w * 0.25, h * 0.1875, 0, 0, 'has/forms', mxConstants.ALIGN_CENTER, mxConstants.ALIGN_MIDDLE, 0, null, true, 0, 0);10451046 c.moveTo(w * 0.04, h * 0.3125);1047 c.lineTo(w * 0.46, h * 0.3125);10481049 c.moveTo(w * 0.04, h * 0.4375);1050 c.lineTo(w * 0.46, h * 0.4375);1051 c.moveTo(w * 0.46, h * 0.4050);1052 c.lineTo(w * 0.4, h * 0.4375);1053 c.lineTo(w * 0.46, h * 0.47);10541055 c.moveTo(w * 0.04, h * 0.5625);1056 c.lineTo(w * 0.46, h * 0.5625);1057 c.moveTo(w * 0.38, h * 0.53);1058 c.lineTo(w * 0.38, h * 0.595);10591060 c.moveTo(w * 0.04, h * 0.6875);1061 c.lineTo(w * 0.46, h * 0.6875);1062 c.moveTo(w * 0.46, h * 0.655);1063 c.lineTo(w * 0.4, h * 0.6875);1064 c.lineTo(w * 0.46, h * 0.72);1065 c.moveTo(w * 0.38, h * 0.655);1066 c.lineTo(w * 0.38, h * 0.72);10671068 c.moveTo(w * 0.04, h * 0.8125);1069 c.lineTo(w * 0.46, h * 0.8125);10701071 c.moveTo(w * 0.04, h * 0.9375);1072 c.lineTo(w * 0.46, h * 0.9375);1073 c.moveTo(w * 0.46, h * 0.9050);1074 c.lineTo(w * 0.4, h * 0.9375);1075 c.lineTo(w * 0.46, h * 0.97);10761077 c.stroke();10781079 var ellSize = h / 15;1080 c.begin();1081 c.ellipse(w * 0.46 - ellSize, h * 0.8125 - ellSize * 0.5, ellSize, ellSize);1082 c.fillAndStroke();10831084 c.begin();1085 c.ellipse(w * 0.4 - ellSize, h * 0.9375 - ellSize * 0.5, ellSize, ellSize);1086 c.fillAndStroke();1087};10881089mxCellRenderer.registerShape('mxgraph.er.bachmans', mxShapeERBachman);10901091mxShapeERBachman.prototype.constraints = [1092 new mxConnectionConstraint(new mxPoint(0, 0), true),1093 new mxConnectionConstraint(new mxPoint(1, 0), true),1094 new mxConnectionConstraint(new mxPoint(0, 1), true),1095 new mxConnectionConstraint(new mxPoint(1, 1), true),1096 new mxConnectionConstraint(new mxPoint(0.25, 0), true),1097 new mxConnectionConstraint(new mxPoint(0.5, 0), true),1098 new mxConnectionConstraint(new mxPoint(0.75, 0), true),1099 new mxConnectionConstraint(new mxPoint(0, 0.25), true),1100 new mxConnectionConstraint(new mxPoint(0, 0.5), true),1101 new mxConnectionConstraint(new mxPoint(0, 0.75), true),1102 new mxConnectionConstraint(new mxPoint(1, 0.25), true),1103 new mxConnectionConstraint(new mxPoint(1, 0.5), true),1104 new mxConnectionConstraint(new mxPoint(1, 0.75), true),1105 new mxConnectionConstraint(new mxPoint(0.25, 1), true),1106 new mxConnectionConstraint(new mxPoint(0.5, 1), true),1107 new mxConnectionConstraint(new mxPoint(0.75, 1), true)1108 ];11091110//**********************************************************************************************************************************************************1111//Information Engineering Notation Legend (LEGACY)1112//**********************************************************************************************************************************************************1113/**1114 * Extends mxShape.1115 */1116function mxShapeERInfEng(bounds, fill, stroke, strokewidth)1117{1118 mxShape.call(this);1119 this.bounds = bounds;1120 this.fill = fill;1121 this.stroke = stroke;1122 this.strokewidth = (strokewidth != null) ? strokewidth : 1;1123};11241125/**1126 * Extends mxShape.1127 */1128mxUtils.extend(mxShapeERInfEng, mxShape);11291130/**1131 * Function: paintVertexShape1132 * 1133 * Paints the vertex shape.1134 */1135mxShapeERInfEng.prototype.paintVertexShape = function(c, x, y, w, h)1136{1137 var fontColor = mxUtils.getValue(this.style, 'textColor', '#666666');1138 var fontSize = mxUtils.getValue(this.style, mxConstants.STYLE_FONTSIZE, '17');1139 c.translate(x, y);1140 w = Math.max(w, h / 1.5);1141 h = Math.max(h, fontSize * 5);1142 this.background(c, x, y, w, h);1143 c.setShadow(false);1144 this.foreground(c, x, y, w, h, fontSize, fontColor);1145};11461147mxShapeERInfEng.prototype.background = function(c, x, y, w, h)1148{1149 c.begin();1150 c.moveTo(0, 0);1151 c.lineTo(w, 0);1152 c.lineTo(w, h);1153 c.lineTo(0, h);1154 c.close(); 1155 c.fillAndStroke();1156};11571158mxShapeERInfEng.prototype.foreground = function(c, x, y, w, h, fontSize, fontColor)1159{1160 c.begin();1161 c.moveTo(0, h * 0.2);1162 c.lineTo(w, h * 0.2);1163 c.moveTo(0, h * 0.4);1164 c.lineTo(w, h * 0.4);1165 c.moveTo(0, h * 0.6);1166 c.lineTo(w, h * 0.6);1167 c.moveTo(0, h * 0.8);1168 c.lineTo(w, h * 0.8);11691170 c.moveTo(w * 0.5, h * 0.2);1171 c.lineTo(w * 0.5, h);1172 c.stroke();11731174 c.begin();1175 c.setFontSize(fontSize);1176 c.setFontColor(fontColor);1177 c.text(w * 0.5, h * 0.1, 0, 0, 'ERD Information Engineering Notation', mxConstants.ALIGN_CENTER, mxConstants.ALIGN_MIDDLE, 0, null, 0, 0, 0);11781179 c.setFontSize(fontSize * 0.85);1180 c.text(w * 0.52, h * 0.3, 0, 0, 'Zero or one', mxConstants.ALIGN_LEFT, mxConstants.ALIGN_MIDDLE, 0, null, 0, 0, 0);1181 c.text(w * 0.52, h * 0.5, 0, 0, 'One only', mxConstants.ALIGN_LEFT, mxConstants.ALIGN_MIDDLE, 0, null, 0, 0, 0);1182 c.text(w * 0.52, h * 0.7, 0, 0, 'Zero or more', mxConstants.ALIGN_LEFT, mxConstants.ALIGN_MIDDLE, 0, null, 0, 0, 0);1183 c.text(w * 0.52, h * 0.9, 0, 0, 'One or more', mxConstants.ALIGN_LEFT, mxConstants.ALIGN_MIDDLE, 0, null, 0, 0, 0);11841185 var ellSize = h / 12;11861187 c.begin();1188 c.moveTo(w * 0.04, h * 0.3);1189 c.lineTo(w * 0.46, h * 0.3);1190 c.moveTo(w * 0.46 - ellSize, h * 0.25);1191 c.lineTo(w * 0.46 - ellSize, h * 0.35);11921193 c.moveTo(w * 0.04, h * 0.5);1194 c.lineTo(w * 0.46, h * 0.5);1195 c.moveTo(w * 0.46 - ellSize * 2, h * 0.45);1196 c.lineTo(w * 0.46 - ellSize * 2, h * 0.55);1197 c.moveTo(w * 0.46 - ellSize * 2.5, h * 0.45);1198 c.lineTo(w * 0.46 - ellSize * 2.5, h * 0.55);11991200 c.moveTo(w * 0.04, h * 0.7);1201 c.lineTo(w * 0.46, h * 0.7);1202 c.moveTo(w * 0.46, h * 0.65);1203 c.lineTo(w * 0.46 - ellSize * 2, h * 0.7);1204 c.lineTo(w * 0.46, h * 0.75);1205 c.stroke();12061207 c.moveTo(w * 0.04, h * 0.9);1208 c.lineTo(w * 0.46, h * 0.9);1209 c.moveTo(w * 0.46, h * 0.85);1210 c.lineTo(w * 0.46 - ellSize * 2, h * 0.9);1211 c.lineTo(w * 0.46, h * 0.95);1212 c.moveTo(w * 0.46 - ellSize * 2.5, h * 0.85);1213 c.lineTo(w * 0.46 - ellSize * 2.5, h * 0.95);1214 c.stroke();12151216 c.begin();1217 c.ellipse(w * 0.46 - ellSize * 3, h * 0.3 - ellSize * 0.5, ellSize, ellSize);1218 c.fillAndStroke();12191220 c.begin();1221 c.ellipse(w * 0.46 - ellSize * 3, h * 0.7 - ellSize * 0.5, ellSize, ellSize);1222 c.fillAndStroke();1223};12241225mxCellRenderer.registerShape('mxgraph.er.ie', mxShapeERInfEng);12261227mxShapeERInfEng.prototype.constraints = [1228 new mxConnectionConstraint(new mxPoint(0, 0), true),1229 new mxConnectionConstraint(new mxPoint(1, 0), true),1230 new mxConnectionConstraint(new mxPoint(0, 1), true),1231 new mxConnectionConstraint(new mxPoint(1, 1), true),1232 new mxConnectionConstraint(new mxPoint(0.25, 0), true),1233 new mxConnectionConstraint(new mxPoint(0.5, 0), true),1234 new mxConnectionConstraint(new mxPoint(0.75, 0), true),1235 new mxConnectionConstraint(new mxPoint(0, 0.25), true),1236 new mxConnectionConstraint(new mxPoint(0, 0.5), true),1237 new mxConnectionConstraint(new mxPoint(0, 0.75), true),1238 new mxConnectionConstraint(new mxPoint(1, 0.25), true),1239 new mxConnectionConstraint(new mxPoint(1, 0.5), true),1240 new mxConnectionConstraint(new mxPoint(1, 0.75), true),1241 new mxConnectionConstraint(new mxPoint(0.25, 1), true),1242 new mxConnectionConstraint(new mxPoint(0.5, 1), true),1243 new mxConnectionConstraint(new mxPoint(0.75, 1), true)1244 ];12451246// ER markers1247mxMarker.addMarker('ERone', function(c, shape, type, pe, unitX, unitY, size, source, sw, filled)1248{1249 var nx = unitX * (size + sw + 1);1250 var ny = unitY * (size + sw + 1);12511252 return function()1253 {1254 c.begin();1255 c.moveTo(pe.x - nx / 2 - ny / 2, pe.y - ny / 2 + nx / 2);1256 c.lineTo(pe.x - nx / 2 + ny / 2, pe.y - ny / 2 - nx / 2);1257 c.stroke();1258 };1259});12601261mxMarker.addMarker('ERmandOne', function(c, shape, type, pe, unitX, unitY, size, source, sw, filled)1262{1263 var nx = unitX * (size + sw + 1);1264 var ny = unitY * (size + sw + 1);12651266 return function()1267 {1268 c.begin();1269 c.moveTo(pe.x - nx / 2 - ny / 2, pe.y - ny / 2 + nx / 2);1270 c.lineTo(pe.x - nx / 2 + ny / 2, pe.y - ny / 2 - nx / 2);1271 c.moveTo(pe.x - nx - ny / 2, pe.y - ny + nx / 2);1272 c.lineTo(pe.x - nx + ny / 2, pe.y - ny - nx / 2);1273 c.stroke();1274 };1275});12761277mxMarker.addMarker('ERmany', function(c, shape, type, pe, unitX, unitY, size, source, sw, filled)1278{1279 var nx = unitX * (size + sw + 1);1280 var ny = unitY * (size + sw + 1);12811282 return function()1283 {1284 c.begin();1285 c.moveTo(pe.x + ny / 2, pe.y - nx / 2);1286 c.lineTo(pe.x - nx, pe.y - ny);1287 c.lineTo(pe.x - ny / 2, pe.y + nx / 2);1288 c.stroke();1289 };1290});12911292mxMarker.addMarker('ERoneToMany', function(c, shape, type, pe, unitX, unitY, size, source, sw, filled)1293{1294 var nx = unitX * (size + sw + 1);1295 var ny = unitY * (size + sw + 1);12961297 return function()1298 {1299 c.begin();1300 c.moveTo(pe.x - nx - ny / 2, pe.y - ny + nx / 2);1301 c.lineTo(pe.x - nx + ny / 2, pe.y - ny - nx / 2);1302 c.moveTo(pe.x + ny / 2, pe.y - nx / 2);1303 c.lineTo(pe.x - nx, pe.y - ny);1304 c.lineTo(pe.x - ny / 2, pe.y + nx / 2);1305 c.stroke();1306 };1307});13081309mxMarker.addMarker('ERzeroToMany', function(c, shape, type, pe, unitX, unitY, size, source, sw, filled)1310{1311 var nx = unitX * (size + sw + 1);1312 var ny = unitY * (size + sw + 1);1313 var a = size / 2;1314 var px = pe.x;1315 var py = pe.y;1316 1317 if (!filled)1318 {1319 pe.x -= 2 * nx - unitX * sw / 2;1320 pe.y -= 2 * ny - unitY * sw / 2;1321 }13221323 return function()1324 {1325 c.begin();1326 c.ellipse(px - 1.5 * nx - a, py - 1.5 * ny - a, 2 * a, 2 * a);13271328 if (filled)1329 {1330 // TODO not sure if this is ok, because by default, markers use strokeColor for filling 1331 var oldColor = mxUtils.getValue(shape.style, mxConstants.STYLE_STROKECOLOR, '#666666');1332 1333 c.setFillColor('#ffffff');1334 c.fillAndStroke();1335 c.setFillColor(oldColor);1336 }1337 else1338 {1339 c.stroke();1340 }13411342 c.begin();1343 c.moveTo(px + ny / 2, py - nx / 2);1344 c.lineTo(px - nx, py - ny);1345 c.lineTo(px - ny / 2, py + nx / 2);13461347 if (!filled)1348 {1349 c.moveTo(px - nx, py - ny);1350 c.lineTo(px, py);1351 }13521353 c.stroke();1354 };1355});13561357mxMarker.addMarker('ERzeroToOne', function(c, shape, type, pe, unitX, unitY, size, source, sw, filled)1358{1359 var nx = unitX * (size + sw + 1);1360 var ny = unitY * (size + sw + 1);1361 var a = size / 2;1362 var px = pe.x;1363 var py = pe.y;1364 1365 if (!filled)1366 {1367 pe.x -= 2 * nx - unitX * sw / 2;1368 pe.y -= 2 * ny - unitY * sw / 2;1369 }13701371 return function()1372 {1373 c.begin();1374 c.ellipse(px - 1.5 * nx - a, py - 1.5 * ny - a, 2 * a, 2 * a);13751376 if (filled)1377 {1378 // TODO not sure if this is ok, because by default, markers use strokeColor for filling 1379 var oldColor = mxUtils.getValue(shape.style, mxConstants.STYLE_STROKECOLOR, '#666666');1380 1381 c.setFillColor('#ffffff');1382 c.fillAndStroke();1383 c.setFillColor(oldColor);1384 }1385 else1386 {1387 c.stroke();1388 }13891390 c.begin();1391 c.moveTo(px - nx / 2 - ny / 2, py - ny / 2 + nx / 2);1392 c.lineTo(px - nx / 2 + ny / 2, py - ny / 2 - nx / 2);13931394 if (!filled)1395 {1396 c.moveTo(px - nx - unitX * sw / 2, py - ny - unitY * sw / 2);1397 c.lineTo(px, py);1398 }13991400 c.stroke();1401 };1402});14031404//**********************************************************************************************************************************************************1405//Rounded rectangle (adjustable rounding)1406//**********************************************************************************************************************************************************1407/**1408* Extends mxShape.1409*/1410function mxShapeERRRect(bounds, fill, stroke, strokewidth)1411{1412 mxShape.call(this);1413 this.bounds = bounds;1414 this.fill = fill;1415 this.stroke = stroke;1416 this.strokewidth = (strokewidth != null) ? strokewidth : 1;1417};14181419/**1420* Extends mxShape.1421*/1422mxUtils.extend(mxShapeERRRect, mxShape);14231424mxShapeERRRect.prototype.cst = {1425 RRECT : 'mxgraph.er.rrect',1426 R_SIZE : 'rSize'1427};14281429mxShapeERRRect.prototype.customProperties = [1430 {name: 'rSize', dispName: 'Rounding Size', type: 'float'},1431];14321433/**1434* Function: paintVertexShape1435* 1436* Paints the vertex shape.1437*/1438mxShapeERRRect.prototype.paintVertexShape = function(c, x, y, w, h)1439{1440 c.translate(x, y);14411442 var rSize = parseInt(mxUtils.getValue(this.style, mxShapeERRRect.prototype.cst.R_SIZE, '10'));1443 c.roundrect(0, 0, w, h, rSize);1444 c.fillAndStroke();1445};14461447mxCellRenderer.registerShape(mxShapeERRRect.prototype.cst.RRECT, mxShapeERRRect);14481449mxShapeERRRect.prototype.constraints = [1450 new mxConnectionConstraint(new mxPoint(0.25, 0), true),1451 new mxConnectionConstraint(new mxPoint(0.5, 0), true),1452 new mxConnectionConstraint(new mxPoint(0.75, 0), true),1453 new mxConnectionConstraint(new mxPoint(0, 0.25), true),1454 new mxConnectionConstraint(new mxPoint(0, 0.5), true),1455 new mxConnectionConstraint(new mxPoint(0, 0.75), true),1456 new mxConnectionConstraint(new mxPoint(1, 0.25), true),1457 new mxConnectionConstraint(new mxPoint(1, 0.5), true),1458 new mxConnectionConstraint(new mxPoint(1, 0.75), true),1459 new mxConnectionConstraint(new mxPoint(0.25, 1), true),1460 new mxConnectionConstraint(new mxPoint(0.5, 1), true),1461 new mxConnectionConstraint(new mxPoint(0.75, 1), true)1462 ];14631464//**********************************************************************************************************************************************************1465//Anchor (a dummy shape without visuals used for anchoring)1466//**********************************************************************************************************************************************************1467/**1468* Extends mxShape.1469*/1470function mxShapeERAnchor(bounds, fill, stroke, strokewidth)1471{1472 mxShape.call(this);1473 this.bounds = bounds;1474};14751476/**1477* Extends mxShape.1478*/1479mxUtils.extend(mxShapeERAnchor, mxShape);14801481mxShapeERAnchor.prototype.cst = {1482 ANCHOR : 'mxgraph.er.anchor'1483};1484148514861487/**1488* Function: paintVertexShape1489* 1490* Paints the vertex shape.1491*/1492mxShapeERAnchor.prototype.paintVertexShape = function(c, x, y, w, h)1493{1494};14951496mxCellRenderer.registerShape(mxShapeERAnchor.prototype.cst.ANCHOR, mxShapeERAnchor);1497