12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445144614471448144914501451145214531454145514561457145814591460146114621463 |
- /**
- * $Id: mxER.js,v 1.6 2013/05/17 13:46:41 mate Exp $
- * Copyright (c) 2006-2010, JGraph Ltd
- */
- //TODO markers.html probably isn't needed, because it was used for testing during development before the new canvas was introduced
- //**********************************************************************************************************************************************************
- //Entity
- //**********************************************************************************************************************************************************
- /**
- * Extends mxShape.
- */
- function mxShapeEREntity(bounds, fill, stroke, strokewidth)
- {
- mxShape.call(this);
- this.bounds = bounds;
- this.fill = fill;
- this.stroke = stroke;
- this.strokewidth = (strokewidth != null) ? strokewidth : 1;
- };
- /**
- * Extends mxShape.
- */
- mxUtils.extend(mxShapeEREntity, mxShape);
- /**
- * Function: paintVertexShape
- *
- * Paints the vertex shape.
- */
- mxShapeEREntity.prototype.paintVertexShape = function(c, x, y, w, h)
- {
- var mainText = mxUtils.getValue(this.style, 'buttonText', 'Entity');
- var fontColor = mxUtils.getValue(this.style, 'textColor', '#666666');
- var fontSize = mxUtils.getValue(this.style, mxConstants.STYLE_FONTSIZE, '17');
- c.translate(x, y);
- var rSize = 10;
- w = Math.max(w, 2 * rSize);
- h = Math.max(h, 2 * rSize);
- this.background(c, x, y, w, h, rSize, fontColor);
- c.setShadow(false);
- this.mainText(c, x, y, w, h, mainText, fontSize, fontColor);
- };
- mxShapeEREntity.prototype.background = function(c, x, y, w, h, rSize, fontColor)
- {
- var buttonStyle = mxUtils.getValue(this.style, 'buttonStyle', 'round').toString();
- if (buttonStyle === 'round')
- {
- c.begin();
- c.moveTo(0, rSize);
- c.arcTo(rSize, rSize, 0, 0, 1, rSize, 0);
- c.lineTo(w - rSize, 0);
- c.arcTo(rSize, rSize, 0, 0, 1, w, rSize);
- c.lineTo(w, h - rSize);
- c.arcTo(rSize, rSize, 0, 0, 1, w - rSize, h);
- c.lineTo(rSize, h);
- c.arcTo(rSize, rSize, 0, 0, 1, 0, h - rSize);
- c.close();
- c.fillAndStroke();
- }
- else if (buttonStyle === 'rect')
- {
- c.begin();
- c.moveTo(0, 0);
- c.lineTo(w, 0);
- c.lineTo(w, h);
- c.lineTo(0, h);
- c.close();
- c.fillAndStroke();
- }
- else if (buttonStyle === 'dblFrame')
- {
- var fillColor = mxUtils.getValue(this.style, mxConstants.STYLE_FILLCOLOR, '#ffffff');
- c.setFillColor(fillColor);
- c.begin();
- c.moveTo(0, 0);
- c.lineTo(w, 0);
- c.lineTo(w, h);
- c.lineTo(0, h);
- c.close();
- c.fillAndStroke();
- rSize = Math.min(w, h);
- c.begin();
- c.moveTo(rSize * 0.1, rSize * 0.1);
- c.lineTo(w - rSize * 0.1, rSize * 0.1);
- c.lineTo(w - rSize * 0.1, h - rSize * 0.1);
- c.lineTo(rSize * 0.1, h - rSize * 0.1);
- c.close();
- c.stroke();
- }
- };
- mxShapeEREntity.prototype.mainText = function(c, x, y, w, h, text, fontSize, fontColor)
- {
- c.begin();
- c.setFontSize(fontSize);
- c.setFontColor(fontColor);
- c.text(w * 0.5, h * 0.5, 0, 0, text, mxConstants.ALIGN_CENTER, mxConstants.ALIGN_MIDDLE, 0, null, 0, 0, 0);
- };
- mxCellRenderer.prototype.defaultShapes['mxgraph.er.entity'] = mxShapeEREntity;
- mxShapeEREntity.prototype.constraints = [
- new mxConnectionConstraint(new mxPoint(0.25, 0), true),
- new mxConnectionConstraint(new mxPoint(0.5, 0), true),
- new mxConnectionConstraint(new mxPoint(0.75, 0), true),
- new mxConnectionConstraint(new mxPoint(0, 0.25), true),
- new mxConnectionConstraint(new mxPoint(0, 0.5), true),
- new mxConnectionConstraint(new mxPoint(0, 0.75), true),
- new mxConnectionConstraint(new mxPoint(1, 0.25), true),
- new mxConnectionConstraint(new mxPoint(1, 0.5), true),
- new mxConnectionConstraint(new mxPoint(1, 0.75), true),
- new mxConnectionConstraint(new mxPoint(0.25, 1), true),
- new mxConnectionConstraint(new mxPoint(0.5, 1), true),
- new mxConnectionConstraint(new mxPoint(0.75, 1), true)
- ];
- //**********************************************************************************************************************************************************
- //Entity Extended
- //**********************************************************************************************************************************************************
- /**
- * Extends mxShape.
- */
- function mxShapeEREntityExt(bounds, fill, stroke, strokewidth)
- {
- mxShape.call(this);
- this.bounds = bounds;
- this.fill = fill;
- this.stroke = stroke;
- this.strokewidth = (strokewidth != null) ? strokewidth : 1;
- };
- /**
- * Extends mxShape.
- */
- mxUtils.extend(mxShapeEREntityExt, mxShape);
- /**
- * Function: paintVertexShape
- *
- * Paints the vertex shape.
- */
- mxShapeEREntityExt.prototype.paintVertexShape = function(c, x, y, w, h)
- {
- var mainText = mxUtils.getValue(this.style, 'buttonText', 'Entity');
- var attributes = mxUtils.getValue(this.style, 'subText', '+ attribute 1,+ attribute 2,+ attribute 3').toString().split(',');
- var strokeColor = mxUtils.getValue(this.style, mxConstants.STYLE_STROKECOLOR, '#666666');
- var fontSize = mxUtils.getValue(this.style, mxConstants.STYLE_FONTSIZE, '17');
- var mainColor = mxUtils.getValue(this.style, mxConstants.STYLE_FILLCOLOR, '#008cff');
- var attrColor = mxUtils.getValue(this.style, 'fillColor2', '#ffffff');
- var maxTextWidth = 0;
- c.translate(x, y);
- var rSize = 10;
- var barY = fontSize * 1.25;
- for (var i = 0; i < attributes.length; i++)
- {
- var currWidth = mxUtils.getSizeForString(attributes[i], fontSize, mxConstants.DEFAULT_FONTFAMILY).width;
- if (currWidth > maxTextWidth)
- {
- maxTextWidth = currWidth;
- }
- }
- w = Math.max(w, 2 * rSize, maxTextWidth + rSize);
- h = Math.max(h, 2 * rSize, (attributes.length + 1) * barY);
- this.background(c, x, y, w, h, rSize);
- c.setShadow(false);
- this.shapes(c, x, y, w, h, fontSize, mainColor, attrColor, rSize, barY);
- this.mainText(c, x, y, w, h, mainText, fontSize, attrColor);
- this.attrText(c, x, y, w, h, attributes, fontSize, strokeColor, barY, rSize);
- };
- mxShapeEREntityExt.prototype.background = function(c, x, y, w, h, rSize)
- {
- var buttonStyle = mxUtils.getValue(this.style, 'buttonStyle', 'round').toString();
- c.begin();
- if (buttonStyle === 'round')
- {
- c.moveTo(0, rSize);
- c.arcTo(rSize, rSize, 0, 0, 1, rSize, 0);
- c.lineTo(w - rSize, 0);
- c.arcTo(rSize, rSize, 0, 0, 1, w, rSize);
- c.lineTo(w, h - rSize);
- c.arcTo(rSize, rSize, 0, 0, 1, w - rSize, h);
- c.lineTo(rSize, h);
- c.arcTo(rSize, rSize, 0, 0, 1, 0, h - rSize);
- }
- else if (buttonStyle === 'rect')
- {
- c.moveTo(0, 0);
- c.lineTo(w, 0);
- c.lineTo(w, h);
- c.lineTo(0, h);
- }
- c.close();
- c.fillAndStroke();
- };
- mxShapeEREntityExt.prototype.mainText = function(c, x, y, w, h, text, fontSize, fontColor)
- {
- c.begin();
- c.setFontSize(fontSize);
- c.setFontColor(fontColor);
- c.text(w * 0.5, fontSize * 0.5, 0, 0, text, mxConstants.ALIGN_CENTER, mxConstants.ALIGN_MIDDLE, 0, null, 0, 0, 0);
- };
- mxShapeEREntityExt.prototype.shapes = function(c, x, y, w, h, fontSize, mainColor, attrColor, rSize, barY)
- {
- var buttonStyle = mxUtils.getValue(this.style, 'buttonStyle', 'round').toString();
- if (buttonStyle === 'round')
- {
- c.begin();
- c.moveTo(0, rSize);
- c.arcTo(rSize, rSize, 0, 0, 1, rSize, 0);
- c.lineTo(w - rSize, 0);
- c.arcTo(rSize, rSize, 0, 0, 1, w, rSize);
- c.lineTo(w, barY);
- c.lineTo(0, barY);
- c.close();
- c.fill();
- c.setFillColor(attrColor);
- c.begin();
- c.moveTo(w, barY);
- c.lineTo(w, h - rSize);
- c.arcTo(rSize, rSize, 0, 0, 1, w - rSize, h);
- c.lineTo(rSize, h);
- c.arcTo(rSize, rSize, 0, 0, 1, 0, h - rSize);
- c.lineTo(0, barY);
- c.close();
- c.fill();
- }
- else if (buttonStyle === 'rect')
- {
- c.begin();
- c.moveTo(0, 0);
- c.lineTo(w, 0);
- c.lineTo(w, barY);
- c.lineTo(0, barY);
- c.close();
- c.fill();
- c.setFillColor(attrColor);
- c.begin();
- c.moveTo(0, barY);
- c.lineTo(w, barY);
- c.lineTo(w, h);
- c.lineTo(0, h);
- c.close();
- c.fill();
- }
- c.begin();
- if (buttonStyle === 'round')
- {
- c.moveTo(0, rSize);
- c.arcTo(rSize, rSize, 0, 0, 1, rSize, 0);
- c.lineTo(w - rSize, 0);
- c.arcTo(rSize, rSize, 0, 0, 1, w, rSize);
- c.lineTo(w, h - rSize);
- c.arcTo(rSize, rSize, 0, 0, 1, w - rSize, h);
- c.lineTo(rSize, h);
- c.arcTo(rSize, rSize, 0, 0, 1, 0, h - rSize);
- }
- else if (buttonStyle === 'rect')
- {
- c.moveTo(0, 0);
- c.lineTo(w, 0);
- c.lineTo(w, h);
- c.lineTo(0, h);
- }
- c.close();
- c.stroke();
- };
- mxShapeEREntityExt.prototype.attrText = function(c, x, y, w, h, attributes, fontSize, fontColor, barY, rSize)
- {
- for (var i = 0; i < attributes.length; i++)
- {
- c.begin();
- c.setFontSize(fontSize);
- c.setFontColor(fontColor);
- c.text(rSize * 0.5, (i + 1.5) * barY, 0, 0, attributes[i], mxConstants.ALIGN_LEFT, mxConstants.ALIGN_MIDDLE, 0, null, 0, 0, 0);
- }
- };
- mxCellRenderer.prototype.defaultShapes['mxgraph.er.entityExt'] = mxShapeEREntityExt;
- mxShapeEREntityExt.prototype.constraints = [
- new mxConnectionConstraint(new mxPoint(0.25, 0), true),
- new mxConnectionConstraint(new mxPoint(0.5, 0), true),
- new mxConnectionConstraint(new mxPoint(0.75, 0), true),
- new mxConnectionConstraint(new mxPoint(0, 0.25), true),
- new mxConnectionConstraint(new mxPoint(0, 0.5), true),
- new mxConnectionConstraint(new mxPoint(0, 0.75), true),
- new mxConnectionConstraint(new mxPoint(1, 0.25), true),
- new mxConnectionConstraint(new mxPoint(1, 0.5), true),
- new mxConnectionConstraint(new mxPoint(1, 0.75), true),
- new mxConnectionConstraint(new mxPoint(0.25, 1), true),
- new mxConnectionConstraint(new mxPoint(0.5, 1), true),
- new mxConnectionConstraint(new mxPoint(0.75, 1), true)
- ];
- //**********************************************************************************************************************************************************
- //Attribute
- //**********************************************************************************************************************************************************
- /**
- * Extends mxShape.
- */
- function mxShapeERAttribute(bounds, fill, stroke, strokewidth)
- {
- mxShape.call(this);
- this.bounds = bounds;
- this.fill = fill;
- this.stroke = stroke;
- this.strokewidth = (strokewidth != null) ? strokewidth : 1;
- };
- /**
- * Extends mxShape.
- */
- mxUtils.extend(mxShapeERAttribute, mxShape);
- /**
- * Function: paintVertexShape
- *
- * Paints the vertex shape.
- */
- mxShapeERAttribute.prototype.paintVertexShape = function(c, x, y, w, h)
- {
- var mainText = mxUtils.getValue(this.style, 'buttonText', 'Entity');
- var fontColor = mxUtils.getValue(this.style, 'textColor', '#666666');
- var fontSize = mxUtils.getValue(this.style, mxConstants.STYLE_FONTSIZE, '17');
- c.translate(x, y);
- var rSize = 10;
- w = Math.max(w, 2 * rSize);
- h = Math.max(h, 2 * rSize);
- this.background(c, x, y, w, h, rSize, fontColor);
- c.setShadow(false);
- this.mainText(c, x, y, w, h, mainText, fontSize, fontColor);
- };
- mxShapeERAttribute.prototype.background = function(c, x, y, w, h, rSize, fontColor)
- {
- var buttonStyle = mxUtils.getValue(this.style, 'buttonStyle', 'simple').toString();
- if (buttonStyle === 'simple')
- {
- c.begin();
- c.ellipse(0, 0, w, h);
- c.fillAndStroke();
- }
- else if (buttonStyle === 'dblFrame')
- {
- var fillColor = mxUtils.getValue(this.style, mxConstants.STYLE_FILLCOLOR, '#666666');
- c.setFillColor(fillColor);
- c.begin();
- c.ellipse(0, 0, w, h);
- c.fillAndStroke();
- rSize = Math.min(w, h);
- c.begin();
- c.ellipse(rSize * 0.1, rSize * 0.1, w - rSize * 0.2, h - rSize * 0.2);
- c.stroke();
- }
- };
- mxShapeERAttribute.prototype.mainText = function(c, x, y, w, h, text, fontSize, fontColor)
- {
- c.begin();
- c.setFontSize(fontSize);
- c.setFontColor(fontColor);
- c.text(w * 0.5, h * 0.5, 0, 0, text, mxConstants.ALIGN_CENTER, mxConstants.ALIGN_MIDDLE, 0, null, 0, 0, 0);
- };
- mxCellRenderer.prototype.defaultShapes['mxgraph.er.attribute'] = mxShapeERAttribute;
- mxShapeERAttribute.prototype.constraints = [
- new mxConnectionConstraint(new mxPoint(0.144, 0.144), false),
- new mxConnectionConstraint(new mxPoint(0.856, 0.144), false),
- new mxConnectionConstraint(new mxPoint(0.856, 0.856), false),
- new mxConnectionConstraint(new mxPoint(0.144, 0.856), false),
- new mxConnectionConstraint(new mxPoint(0, 0.5), true),
- new mxConnectionConstraint(new mxPoint(1, 0.5), true),
- new mxConnectionConstraint(new mxPoint(0.5, 0), true),
- new mxConnectionConstraint(new mxPoint(0.5, 1), true)
- ];
- //**********************************************************************************************************************************************************
- //Has
- //**********************************************************************************************************************************************************
- /**
- * Extends mxShape.
- */
- function mxShapeERHas(bounds, fill, stroke, strokewidth)
- {
- mxShape.call(this);
- this.bounds = bounds;
- this.fill = fill;
- this.stroke = stroke;
- this.strokewidth = (strokewidth != null) ? strokewidth : 1;
- };
- /**
- * Extends mxShape.
- */
- mxUtils.extend(mxShapeERHas, mxShape);
- /**
- * Function: paintVertexShape
- *
- * Paints the vertex shape.
- */
- mxShapeERHas.prototype.paintVertexShape = function(c, x, y, w, h)
- {
- var mainText = mxUtils.getValue(this.style, 'buttonText', 'Entity');
- var fontColor = mxUtils.getValue(this.style, 'textColor', '#666666');
- var fontSize = mxUtils.getValue(this.style, mxConstants.STYLE_FONTSIZE, '17');
- c.translate(x, y);
- var rSize = 10;
- w = Math.max(w, 2 * rSize);
- h = Math.max(h, 2 * rSize);
- this.background(c, x, y, w, h, rSize, fontColor);
- c.setShadow(false);
- this.mainText(c, x, y, w, h, mainText, fontSize, fontColor);
- };
- mxShapeERHas.prototype.background = function(c, x, y, w, h, rSize, fontColor)
- {
- var buttonStyle = mxUtils.getValue(this.style, 'buttonStyle', 'rhombus').toString();
- if (buttonStyle === 'rhombus')
- {
- c.begin();
- c.moveTo(0, h * 0.5);
- c.lineTo(w * 0.5, 0);
- c.lineTo(w, h * 0.5);
- c.lineTo(w * 0.5, h);
- c.close();
- c.fillAndStroke();
- }
- else if (buttonStyle === 'dblFrame')
- {
- var fillColor = mxUtils.getValue(this.style, mxConstants.STYLE_FILLCOLOR, '#666666');
- c.setFillColor(fillColor);
- c.begin();
- c.moveTo(0, h * 0.5);
- c.lineTo(w * 0.5, 0);
- c.lineTo(w, h * 0.5);
- c.lineTo(w * 0.5, h);
- c.close();
- c.fillAndStroke();
- c.begin();
- c.moveTo(w * 0.1, h * 0.5);
- c.lineTo(w * 0.5, h * 0.1);
- c.lineTo(w * 0.9, h * 0.5);
- c.lineTo(w * 0.5, h * 0.9);
- c.close();
- c.stroke();
- }
- };
- mxShapeERHas.prototype.mainText = function(c, x, y, w, h, text, fontSize, fontColor)
- {
- c.begin();
- c.setFontSize(fontSize);
- c.setFontColor(fontColor);
- c.text(w * 0.5, h * 0.5, 0, 0, text, mxConstants.ALIGN_CENTER, mxConstants.ALIGN_MIDDLE, 0, null, 0, 0, 0);
- };
- mxCellRenderer.prototype.defaultShapes['mxgraph.er.has'] = mxShapeERHas;
- mxShapeERHas.prototype.constraints = [
- new mxConnectionConstraint(new mxPoint(0.5, 0), true),
- new mxConnectionConstraint(new mxPoint(0.5, 1), true),
- new mxConnectionConstraint(new mxPoint(0, 0.5), true),
- new mxConnectionConstraint(new mxPoint(1, 0.5), true),
- new mxConnectionConstraint(new mxPoint(0.25, 0.25), false),
- new mxConnectionConstraint(new mxPoint(0.25, 0.75), false),
- new mxConnectionConstraint(new mxPoint(0.75, 0.25), false),
- new mxConnectionConstraint(new mxPoint(0.75, 0.75), false)
- ];
- //**********************************************************************************************************************************************************
- //Cloud
- //**********************************************************************************************************************************************************
- /**
- * Extends mxShape.
- */
- function mxShapeERCloud(bounds, fill, stroke, strokewidth)
- {
- mxShape.call(this);
- this.bounds = bounds;
- this.fill = fill;
- this.stroke = stroke;
- this.strokewidth = (strokewidth != null) ? strokewidth : 1;
- };
- /**
- * Extends mxShape.
- */
- mxUtils.extend(mxShapeERCloud, mxShape);
- /**
- * Function: paintVertexShape
- *
- * Paints the vertex shape.
- */
- mxShapeERCloud.prototype.paintVertexShape = function(c, x, y, w, h)
- {
- var mainText = mxUtils.getValue(this.style, 'buttonText', 'Entity');
- var fontColor = mxUtils.getValue(this.style, 'textColor', '#666666');
- var fontSize = mxUtils.getValue(this.style, mxConstants.STYLE_FONTSIZE, '17');
- c.translate(x, y);
- var rSize = 10;
- w = Math.max(w, 2 * rSize);
- h = Math.max(h, 2 * rSize);
- this.background(c, x, y, w, h, rSize, fontColor);
- c.setShadow(false);
- this.mainText(c, x, y, w, h, mainText, fontSize, fontColor);
- };
- mxShapeERCloud.prototype.background = function(c, x, y, w, h, rSize, fontColor)
- {
- c.begin();
- c.moveTo(0.25 * w, 0.25 * h);
- c.curveTo(0.05 * w, 0.25 * h, 0, 0.5 * h, 0.16 * w, 0.55 * h);
- c.curveTo(0, 0.66 * h, 0.18 * w, 0.9 * h, 0.31 * w, 0.8 * h);
- c.curveTo(0.4 * w, h, 0.7 * w, h, 0.8 * w, 0.8 * h);
- c.curveTo(w, 0.8 * h, w, 0.6 * h, 0.875 * w, 0.5 * h);
- c.curveTo(w, 0.3 * h, 0.8 * w, 0.1 * h, 0.625 * w, 0.2 * h);
- c.curveTo(0.5 * w, 0.05 * h, 0.3 * w, 0.05 * h, 0.25 * w, 0.25 * h);
- c.fillAndStroke();
- };
- mxShapeERCloud.prototype.mainText = function(c, x, y, w, h, text, fontSize, fontColor)
- {
- c.begin();
- c.setFontSize(fontSize);
- c.setFontColor(fontColor);
- c.text(w * 0.5, h * 0.5, 0, 0, text, mxConstants.ALIGN_CENTER, mxConstants.ALIGN_MIDDLE, 0, null, 0, 0, 0);
- };
- mxCellRenderer.prototype.defaultShapes['mxgraph.er.cloud'] = mxShapeERCloud;
- mxShapeERCloud.prototype.constraints = [
- new mxConnectionConstraint(new mxPoint(0.08, 0.5), false),
- new mxConnectionConstraint(new mxPoint(0.9, 0.5), false),
- new mxConnectionConstraint(new mxPoint(0.5, 0.1), false),
- new mxConnectionConstraint(new mxPoint(0.5, 0.92), false),
- new mxConnectionConstraint(new mxPoint(0.24, 0.24), false),
- new mxConnectionConstraint(new mxPoint(0.22, 0.8), false),
- new mxConnectionConstraint(new mxPoint(0.81, 0.2), false),
- new mxConnectionConstraint(new mxPoint(0.78, 0.78), false)
- ];
- //**********************************************************************************************************************************************************
- //Hierarchy (LEGACY)
- //**********************************************************************************************************************************************************
- /**
- * Extends mxShape.
- */
- function mxShapeERHierarchy(bounds, fill, stroke, strokewidth)
- {
- mxShape.call(this);
- this.bounds = bounds;
- this.fill = fill;
- this.stroke = stroke;
- this.strokewidth = (strokewidth != null) ? strokewidth : 1;
- };
- /**
- * Extends mxShape.
- */
- mxUtils.extend(mxShapeERHierarchy, mxShape);
- /**
- * Function: paintVertexShape
- *
- * Paints the vertex shape.
- */
- mxShapeERHierarchy.prototype.paintVertexShape = function(c, x, y, w, h)
- {
- var mainText = mxUtils.getValue(this.style, 'buttonText', 'main').toString().split(',');
- var subText = mxUtils.getValue(this.style, 'subText', 'sub').toString().split(',');
- var fontColor = mxUtils.getValue(this.style, 'textColor', '#666666');
- var fontSize = mxUtils.getValue(this.style, mxConstants.STYLE_FONTSIZE, '17');
- c.translate(x, y);
- var rSize = 10;
- w = Math.max(w, 2 * rSize);
- h = Math.max(h, 2 * rSize);
- this.background(c, x, y, w, h, rSize, fontColor);
- c.setShadow(false);
- this.shapeText(c, x, y, w, h, mainText, subText, fontSize, fontColor);
- };
- mxShapeERHierarchy.prototype.background = function(c, x, y, w, h, rSize, fontColor)
- {
- var buttonStyle = mxUtils.getValue(this.style, 'buttonStyle', 'round').toString();
- if (buttonStyle === 'round')
- {
- c.begin();
- c.moveTo(0, rSize);
- c.arcTo(rSize, rSize, 0, 0, 1, rSize, 0);
- c.lineTo(w - rSize, 0);
- c.arcTo(rSize, rSize, 0, 0, 1, w, rSize);
- c.lineTo(w, h - rSize);
- c.arcTo(rSize, rSize, 0, 0, 1, w - rSize, h);
- c.lineTo(rSize, h);
- c.arcTo(rSize, rSize, 0, 0, 1, 0, h - rSize);
- c.close();
- c.fillAndStroke();
- }
- else if (buttonStyle === 'rect')
- {
- c.begin();
- c.moveTo(0, 0);
- c.lineTo(w, 0);
- c.lineTo(w, h);
- c.lineTo(0, h);
- c.close();
- c.fillAndStroke();
- }
- else if (buttonStyle === 'dblFrame')
- {
- var fillColor = mxUtils.getValue(this.style, mxConstants.STYLE_FILLCOLOR, '#666666');
- c.setFillColor(fillColor);
- c.begin();
- c.moveTo(0, 0);
- c.lineTo(w, 0);
- c.lineTo(w, h);
- c.lineTo(0, h);
- c.close();
- c.fillAndStroke();
- rSize = Math.min(w, h);
- c.begin();
- c.moveTo(rSize * 0.1, rSize * 0.1);
- c.lineTo(w - rSize * 0.1, rSize * 0.1);
- c.lineTo(w - rSize * 0.1, h - rSize * 0.1);
- c.lineTo(rSize * 0.1, h - rSize * 0.1);
- c.close();
- c.stroke();
- }
- var trX = 0;
- var trY = 0;
- if (buttonStyle === 'round')
- {
- trX = w * 0.5;
- trY = rSize;
- c.translate(trX, trY);
- w = w * 0.5 - rSize;
- h = h - 2 * rSize;
- c.begin();
- c.moveTo(0, rSize);
- c.arcTo(rSize, rSize, 0, 0, 1, rSize, 0);
- c.lineTo(w - rSize, 0);
- c.arcTo(rSize, rSize, 0, 0, 1, w, rSize);
- c.lineTo(w, h - rSize);
- c.arcTo(rSize, rSize, 0, 0, 1, w - rSize, h);
- c.lineTo(rSize, h);
- c.arcTo(rSize, rSize, 0, 0, 1, 0, h - rSize);
- c.close();
- c.fillAndStroke();
- }
- else if (buttonStyle === 'rect')
- {
- trX = w * 0.5;
- trY = rSize;
- c.translate(trX, trY);
- w = w * 0.5 - rSize;
- h = h - 2 * rSize;
- c.begin();
- c.moveTo(0, 0);
- c.lineTo(w, 0);
- c.lineTo(w, h);
- c.lineTo(0, h);
- c.close();
- c.fillAndStroke();
- }
- else if (buttonStyle === 'dblFrame')
- {
- trX = w * 0.5;
- trY = rSize * 0.15;
- c.translate(trX, trY);
- w = w * 0.5 - rSize * 0.15;
- h = h - rSize * 0.3;
- var fillColor = mxUtils.getValue(this.style, mxConstants.STYLE_FILLCOLOR, '#666666');
- c.setFillColor(fillColor);
- c.begin();
- c.moveTo(0, 0);
- c.lineTo(w, 0);
- c.lineTo(w, h);
- c.lineTo(0, h);
- c.close();
- c.fillAndStroke();
- rSize = Math.min(w, h);
- c.begin();
- c.moveTo(rSize * 0.1, rSize * 0.1);
- c.lineTo(w - rSize * 0.1, rSize * 0.1);
- c.lineTo(w - rSize * 0.1, h - rSize * 0.1);
- c.lineTo(rSize * 0.1, h - rSize * 0.1);
- c.close();
- c.stroke();
- }
- c.translate(- trX, - trY);
- };
- mxShapeERHierarchy.prototype.shapeText = function(c, x, y, w, h, text, subText, fontSize, fontColor, rSize)
- {
- c.begin();
- c.setFontSize(fontSize);
- c.setFontColor(fontColor);
- c.text(w * 0.25, (h - fontSize) * 0.5, 0, 0, text[0], mxConstants.ALIGN_CENTER, mxConstants.ALIGN_MIDDLE, 0, null, 0, 0, 0);
- c.text(w * 0.25, (h + fontSize) * 0.5, 0, 0, text[1], mxConstants.ALIGN_CENTER, mxConstants.ALIGN_MIDDLE, 0, null, 0, 0, 0);
- c.text(w * 0.7, (h - fontSize) * 0.5, 0, 0, subText[0], mxConstants.ALIGN_CENTER, mxConstants.ALIGN_MIDDLE, 0, null, 0, 0, 0);
- c.text(w * 0.7, (h + fontSize) * 0.5, 0, 0, subText[1], mxConstants.ALIGN_CENTER, mxConstants.ALIGN_MIDDLE, 0, null, 0, 0, 0);
- };
- mxCellRenderer.prototype.defaultShapes['mxgraph.er.hierarchy'] = mxShapeERHierarchy;
- mxShapeERHierarchy.prototype.constraints = [
- new mxConnectionConstraint(new mxPoint(0.25, 0), true),
- new mxConnectionConstraint(new mxPoint(0.5, 0), true),
- new mxConnectionConstraint(new mxPoint(0.75, 0), true),
- new mxConnectionConstraint(new mxPoint(0, 0.25), true),
- new mxConnectionConstraint(new mxPoint(0, 0.5), true),
- new mxConnectionConstraint(new mxPoint(0, 0.75), true),
- new mxConnectionConstraint(new mxPoint(1, 0.25), true),
- new mxConnectionConstraint(new mxPoint(1, 0.5), true),
- new mxConnectionConstraint(new mxPoint(1, 0.75), true),
- new mxConnectionConstraint(new mxPoint(0.25, 1), true),
- new mxConnectionConstraint(new mxPoint(0.5, 1), true),
- new mxConnectionConstraint(new mxPoint(0.75, 1), true)
- ];
- //**********************************************************************************************************************************************************
- //Note
- //**********************************************************************************************************************************************************
- /**
- * Extends mxShape.
- */
- function mxShapeERNote(bounds, fill, stroke, strokewidth)
- {
- mxShape.call(this);
- this.bounds = bounds;
- this.fill = fill;
- this.stroke = stroke;
- this.strokewidth = (strokewidth != null) ? strokewidth : 1;
- };
- /**
- * Extends mxShape.
- */
- mxUtils.extend(mxShapeERNote, mxShape);
- /**
- * Function: paintVertexShape
- *
- * Paints the vertex shape.
- */
- mxShapeERNote.prototype.paintVertexShape = function(c, x, y, w, h)
- {
- var mainText = mxUtils.getValue(this.style, 'buttonText', 'Entity');
- var fontColor = mxUtils.getValue(this.style, 'textColor', '#666666');
- var fontSize = mxUtils.getValue(this.style, mxConstants.STYLE_FONTSIZE, '17');
- var backColor = mxUtils.getValue(this.style, 'fillColor2', '#ffffff');
- c.translate(x, y);
- var flipSize = 20;
- w = Math.max(w, flipSize * 2);
- h = Math.max(h, flipSize * 2);
- this.background(c, x, y, w, h, flipSize);
- c.setShadow(false);
- this.flipShape(c, x, y, w, h, flipSize, backColor);
- this.mainText(c, x, y, w, h, mainText, fontSize, fontColor);
- };
- mxShapeERNote.prototype.background = function(c, x, y, w, h, flipSize)
- {
- c.begin();
- c.moveTo(0, 0);
- c.lineTo(w - flipSize, 0);
- c.lineTo(w, flipSize);
- c.lineTo(w, h);
- c.lineTo(0, h);
- c.close();
- c.fillAndStroke();
- };
- mxShapeERNote.prototype.flipShape = function(c, x, y, w, h, flipSize, backColor)
- {
- c.setLineJoin('round');
- c.setFillColor(backColor);
- c.begin();
- c.moveTo(w - flipSize, 0);
- c.lineTo(w, flipSize);
- c.lineTo(w - flipSize, flipSize);
- c.close();
- c.fillAndStroke();
- };
- mxShapeERNote.prototype.mainText = function(c, x, y, w, h, text, fontSize, fontColor)
- {
- c.begin();
- c.setFontSize(fontSize);
- c.setFontColor(fontColor);
- c.text(w * 0.5, h * 0.5, 0, 0, text, mxConstants.ALIGN_CENTER, mxConstants.ALIGN_MIDDLE, 0, null, 0, 0, 0);
- };
- mxCellRenderer.prototype.defaultShapes['mxgraph.er.note'] = mxShapeERNote;
- mxShapeERNote.prototype.constraints = [
- new mxConnectionConstraint(new mxPoint(0, 0), true),
- new mxConnectionConstraint(new mxPoint(0, 1), true),
- new mxConnectionConstraint(new mxPoint(1, 1), true),
- new mxConnectionConstraint(new mxPoint(0.25, 0), true),
- new mxConnectionConstraint(new mxPoint(0.5, 0), true),
- new mxConnectionConstraint(new mxPoint(0.75, 0), true),
- new mxConnectionConstraint(new mxPoint(0, 0.25), true),
- new mxConnectionConstraint(new mxPoint(0, 0.5), true),
- new mxConnectionConstraint(new mxPoint(0, 0.75), true),
- new mxConnectionConstraint(new mxPoint(1, 0.25), true),
- new mxConnectionConstraint(new mxPoint(1, 0.5), true),
- new mxConnectionConstraint(new mxPoint(1, 0.75), true),
- new mxConnectionConstraint(new mxPoint(0.25, 1), true),
- new mxConnectionConstraint(new mxPoint(0.5, 1), true),
- new mxConnectionConstraint(new mxPoint(0.75, 1), true)
- ];
- //**********************************************************************************************************************************************************
- //Chen's Notation Legend (LEGACY)
- //**********************************************************************************************************************************************************
- /**
- * Extends mxShape.
- */
- function mxShapeERChen(bounds, fill, stroke, strokewidth)
- {
- mxShape.call(this);
- this.bounds = bounds;
- this.fill = fill;
- this.stroke = stroke;
- this.strokewidth = (strokewidth != null) ? strokewidth : 1;
- };
- /**
- * Extends mxShape.
- */
- mxUtils.extend(mxShapeERChen, mxShape);
- /**
- * Function: paintVertexShape
- *
- * Paints the vertex shape.
- */
- mxShapeERChen.prototype.paintVertexShape = function(c, x, y, w, h)
- {
- var fontColor = mxUtils.getValue(this.style, 'textColor', '#666666');
- var fontSize = mxUtils.getValue(this.style, mxConstants.STYLE_FONTSIZE, '17');
- c.translate(x, y);
- var flipSize = 20;
- w = Math.max(w, flipSize * 2);
- h = Math.max(h, flipSize * 2);
- this.background(c, x, y, w, h);
- c.setShadow(false);
- this.foreground(c, x, y, w, h, fontSize, fontColor);
- };
- mxShapeERChen.prototype.background = function(c, x, y, w, h)
- {
- c.begin();
- c.moveTo(0, 0);
- c.lineTo(w, 0);
- c.lineTo(w, h);
- c.lineTo(0, h);
- c.close();
- c.fillAndStroke();
- };
- mxShapeERChen.prototype.foreground = function(c, x, y, w, h, fontSize, fontColor)
- {
- c.begin();
- c.moveTo(0, h * 0.25);
- c.lineTo(w, h * 0.25);
- c.moveTo(0, h * 0.5);
- c.lineTo(w, h * 0.5);
- c.moveTo(0, h * 0.75);
- c.lineTo(w, h * 0.75);
- c.moveTo(w * 0.25, h * 0.5);
- c.lineTo(w * 0.25, h);
- c.moveTo(w * 0.5, h * 0.25);
- c.lineTo(w * 0.5, h);
- c.moveTo(w * 0.75, h * 0.5);
- c.lineTo(w * 0.75, h);
- c.stroke();
- c.begin();
- c.setFontSize(fontSize);
- c.setFontColor(fontColor);
- 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);
- c.setFontSize(fontSize * 0.85);
- c.text(w * 0.25, h * 0.375, 0, 0, 'Cardinality', mxConstants.ALIGN_CENTER, mxConstants.ALIGN_MIDDLE, 0, null, 0, 0, 0);
- c.text(w * 0.75, h * 0.375, 0, 0, 'Optionality', mxConstants.ALIGN_CENTER, mxConstants.ALIGN_MIDDLE, 0, null, 0, 0, 0);
- c.setFontSize(fontSize * 0.7);
- c.text(w * 0.125, h * 0.625, 0, 0, '1', mxConstants.ALIGN_CENTER, mxConstants.ALIGN_MIDDLE, 0, null, 0, 0, 0);
- c.text(w * 0.375, h * 0.625, 0, 0, 'One', mxConstants.ALIGN_CENTER, mxConstants.ALIGN_MIDDLE, 0, null, 0, 0, 0);
- c.text(w * 0.625, h * 0.625, 0, 0, '0', mxConstants.ALIGN_CENTER, mxConstants.ALIGN_MIDDLE, 0, null, 0, 0, 0);
- c.text(w * 0.875, h * 0.625, 0, 0, 'Optional', mxConstants.ALIGN_CENTER, mxConstants.ALIGN_MIDDLE, 0, null, 0, 0, 0);
- c.text(w * 0.125, h * 0.875, 0, 0, 'N', mxConstants.ALIGN_CENTER, mxConstants.ALIGN_MIDDLE, 0, null, 0, 0, 0);
- c.text(w * 0.375, h * 0.875, 0, 0, 'Many', mxConstants.ALIGN_CENTER, mxConstants.ALIGN_MIDDLE, 0, null, 0, 0, 0);
- c.text(w * 0.625, h * 0.875, 0, 0, '1', mxConstants.ALIGN_CENTER, mxConstants.ALIGN_MIDDLE, 0, null, 0, 0, 0);
- c.text(w * 0.875, h * 0.875, 0, 0, 'Mandatory', mxConstants.ALIGN_CENTER, mxConstants.ALIGN_MIDDLE, 0, null, 0, 0, 0);
- };
- mxCellRenderer.prototype.defaultShapes['mxgraph.er.chens'] = mxShapeERChen;
- mxShapeERChen.prototype.constraints = [
- new mxConnectionConstraint(new mxPoint(0, 0), true),
- new mxConnectionConstraint(new mxPoint(1, 0), true),
- new mxConnectionConstraint(new mxPoint(0, 1), true),
- new mxConnectionConstraint(new mxPoint(1, 1), true),
- new mxConnectionConstraint(new mxPoint(0.25, 0), true),
- new mxConnectionConstraint(new mxPoint(0.5, 0), true),
- new mxConnectionConstraint(new mxPoint(0.75, 0), true),
- new mxConnectionConstraint(new mxPoint(0, 0.25), true),
- new mxConnectionConstraint(new mxPoint(0, 0.5), true),
- new mxConnectionConstraint(new mxPoint(0, 0.75), true),
- new mxConnectionConstraint(new mxPoint(1, 0.25), true),
- new mxConnectionConstraint(new mxPoint(1, 0.5), true),
- new mxConnectionConstraint(new mxPoint(1, 0.75), true),
- new mxConnectionConstraint(new mxPoint(0.25, 1), true),
- new mxConnectionConstraint(new mxPoint(0.5, 1), true),
- new mxConnectionConstraint(new mxPoint(0.75, 1), true)
- ];
- //**********************************************************************************************************************************************************
- //Bachman's Notation Legend (LEGACY)
- //**********************************************************************************************************************************************************
- /**
- * Extends mxShape.
- */
- function mxShapeERBachman(bounds, fill, stroke, strokewidth)
- {
- mxShape.call(this);
- this.bounds = bounds;
- this.fill = fill;
- this.stroke = stroke;
- this.strokewidth = (strokewidth != null) ? strokewidth : 1;
- };
- /**
- * Extends mxShape.
- */
- mxUtils.extend(mxShapeERBachman, mxShape);
- /**
- * Function: paintVertexShape
- *
- * Paints the vertex shape.
- */
- mxShapeERBachman.prototype.paintVertexShape = function(c, x, y, w, h)
- {
- var fontColor = mxUtils.getValue(this.style, 'textColor', '#666666');
- var fontSize = mxUtils.getValue(this.style, mxConstants.STYLE_FONTSIZE, '17');
- c.translate(x, y);
- this.background(c, x, y, w, h);
- c.setShadow(false);
- this.foreground(c, x, y, w, h, fontSize, fontColor);
- };
- mxShapeERBachman.prototype.background = function(c, x, y, w, h)
- {
- c.begin();
- c.moveTo(0, 0);
- c.lineTo(w, 0);
- c.lineTo(w, h);
- c.lineTo(0, h);
- c.close();
- c.fillAndStroke();
- };
- mxShapeERBachman.prototype.foreground = function(c, x, y, w, h, fontSize, fontColor)
- {
- c.begin();
- c.moveTo(0, h * 0.125);
- c.lineTo(w, h * 0.125);
- c.moveTo(0, h * 0.25);
- c.lineTo(w, h * 0.25);
- c.moveTo(0, h * 0.375);
- c.lineTo(w, h * 0.375);
- c.moveTo(0, h * 0.5);
- c.lineTo(w, h * 0.5);
- c.moveTo(0, h * 0.625);
- c.lineTo(w, h * 0.625);
- c.moveTo(0, h * 0.75);
- c.lineTo(w, h * 0.75);
- c.moveTo(0, h * 0.875);
- c.lineTo(w, h * 0.875);
- c.moveTo(w * 0.5, h * 0.125);
- c.lineTo(w * 0.5, h);
- c.stroke();
- c.begin();
- c.setFontSize(fontSize);
- c.setFontColor(fontColor);
- 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);
- c.setFontSize(fontSize * 0.85);
- c.text(w * 0.52, h * 0.1875, 0, 0, 'Relationship', mxConstants.ALIGN_LEFT, mxConstants.ALIGN_MIDDLE, 0, null, 0, 0, 0);
- c.text(w * 0.52, h * 0.3125, 0, 0, 'Cardinality (One)', mxConstants.ALIGN_LEFT, mxConstants.ALIGN_MIDDLE, 0, null, 0, 0, 0);
- c.text(w * 0.52, h * 0.4375, 0, 0, 'Cardinality (Many)', mxConstants.ALIGN_LEFT, mxConstants.ALIGN_MIDDLE, 0, null, 0, 0, 0);
- c.text(w * 0.52, h * 0.5625, 0, 0, 'Mandatory, One', mxConstants.ALIGN_LEFT, mxConstants.ALIGN_MIDDLE, 0, null, 0, 0, 0);
- c.text(w * 0.52, h * 0.6875, 0, 0, 'Mandatory, Many', mxConstants.ALIGN_LEFT, mxConstants.ALIGN_MIDDLE, 0, null, 0, 0, 0);
- c.text(w * 0.52, h * 0.8125, 0, 0, 'Optional, One', mxConstants.ALIGN_LEFT, mxConstants.ALIGN_MIDDLE, 0, null, 0, 0, 0);
- c.text(w * 0.52, h * 0.9375, 0, 0, 'Optional, Many', mxConstants.ALIGN_LEFT, mxConstants.ALIGN_MIDDLE, 0, null, 0, 0, 0);
- var textWidth = mxUtils.getSizeForString('has/forms', fontSize, mxConstants.DEFAULT_FONTFAMILY).width;
- c.begin();
- c.moveTo(w * 0.04, h * 0.1875);
- c.lineTo(w * 0.25 - textWidth * 0.5, h * 0.1875);
- c.moveTo(w * 0.25 + textWidth * 0.5, h * 0.1875);
- c.lineTo(w * 0.46, h * 0.1875);
- c.text(w * 0.25, h * 0.1875, 0, 0, 'has/forms', mxConstants.ALIGN_CENTER, mxConstants.ALIGN_MIDDLE, 0, null, true, 0, 0);
- c.moveTo(w * 0.04, h * 0.3125);
- c.lineTo(w * 0.46, h * 0.3125);
- c.moveTo(w * 0.04, h * 0.4375);
- c.lineTo(w * 0.46, h * 0.4375);
- c.moveTo(w * 0.46, h * 0.4050);
- c.lineTo(w * 0.4, h * 0.4375);
- c.lineTo(w * 0.46, h * 0.47);
- c.moveTo(w * 0.04, h * 0.5625);
- c.lineTo(w * 0.46, h * 0.5625);
- c.moveTo(w * 0.38, h * 0.53);
- c.lineTo(w * 0.38, h * 0.595);
- c.moveTo(w * 0.04, h * 0.6875);
- c.lineTo(w * 0.46, h * 0.6875);
- c.moveTo(w * 0.46, h * 0.655);
- c.lineTo(w * 0.4, h * 0.6875);
- c.lineTo(w * 0.46, h * 0.72);
- c.moveTo(w * 0.38, h * 0.655);
- c.lineTo(w * 0.38, h * 0.72);
- c.moveTo(w * 0.04, h * 0.8125);
- c.lineTo(w * 0.46, h * 0.8125);
- c.moveTo(w * 0.04, h * 0.9375);
- c.lineTo(w * 0.46, h * 0.9375);
- c.moveTo(w * 0.46, h * 0.9050);
- c.lineTo(w * 0.4, h * 0.9375);
- c.lineTo(w * 0.46, h * 0.97);
- c.stroke();
- var ellSize = h / 15;
- c.begin();
- c.ellipse(w * 0.46 - ellSize, h * 0.8125 - ellSize * 0.5, ellSize, ellSize);
- c.fillAndStroke();
- c.begin();
- c.ellipse(w * 0.4 - ellSize, h * 0.9375 - ellSize * 0.5, ellSize, ellSize);
- c.fillAndStroke();
- };
- mxCellRenderer.prototype.defaultShapes['mxgraph.er.bachmans'] = mxShapeERBachman;
- mxShapeERBachman.prototype.constraints = [
- new mxConnectionConstraint(new mxPoint(0, 0), true),
- new mxConnectionConstraint(new mxPoint(1, 0), true),
- new mxConnectionConstraint(new mxPoint(0, 1), true),
- new mxConnectionConstraint(new mxPoint(1, 1), true),
- new mxConnectionConstraint(new mxPoint(0.25, 0), true),
- new mxConnectionConstraint(new mxPoint(0.5, 0), true),
- new mxConnectionConstraint(new mxPoint(0.75, 0), true),
- new mxConnectionConstraint(new mxPoint(0, 0.25), true),
- new mxConnectionConstraint(new mxPoint(0, 0.5), true),
- new mxConnectionConstraint(new mxPoint(0, 0.75), true),
- new mxConnectionConstraint(new mxPoint(1, 0.25), true),
- new mxConnectionConstraint(new mxPoint(1, 0.5), true),
- new mxConnectionConstraint(new mxPoint(1, 0.75), true),
- new mxConnectionConstraint(new mxPoint(0.25, 1), true),
- new mxConnectionConstraint(new mxPoint(0.5, 1), true),
- new mxConnectionConstraint(new mxPoint(0.75, 1), true)
- ];
- //**********************************************************************************************************************************************************
- //Information Engineering Notation Legend (LEGACY)
- //**********************************************************************************************************************************************************
- /**
- * Extends mxShape.
- */
- function mxShapeERInfEng(bounds, fill, stroke, strokewidth)
- {
- mxShape.call(this);
- this.bounds = bounds;
- this.fill = fill;
- this.stroke = stroke;
- this.strokewidth = (strokewidth != null) ? strokewidth : 1;
- };
- /**
- * Extends mxShape.
- */
- mxUtils.extend(mxShapeERInfEng, mxShape);
- /**
- * Function: paintVertexShape
- *
- * Paints the vertex shape.
- */
- mxShapeERInfEng.prototype.paintVertexShape = function(c, x, y, w, h)
- {
- var fontColor = mxUtils.getValue(this.style, 'textColor', '#666666');
- var fontSize = mxUtils.getValue(this.style, mxConstants.STYLE_FONTSIZE, '17');
- c.translate(x, y);
- w = Math.max(w, h / 1.5);
- h = Math.max(h, fontSize * 5);
- this.background(c, x, y, w, h);
- c.setShadow(false);
- this.foreground(c, x, y, w, h, fontSize, fontColor);
- };
- mxShapeERInfEng.prototype.background = function(c, x, y, w, h)
- {
- c.begin();
- c.moveTo(0, 0);
- c.lineTo(w, 0);
- c.lineTo(w, h);
- c.lineTo(0, h);
- c.close();
- c.fillAndStroke();
- };
- mxShapeERInfEng.prototype.foreground = function(c, x, y, w, h, fontSize, fontColor)
- {
- c.begin();
- c.moveTo(0, h * 0.2);
- c.lineTo(w, h * 0.2);
- c.moveTo(0, h * 0.4);
- c.lineTo(w, h * 0.4);
- c.moveTo(0, h * 0.6);
- c.lineTo(w, h * 0.6);
- c.moveTo(0, h * 0.8);
- c.lineTo(w, h * 0.8);
- c.moveTo(w * 0.5, h * 0.2);
- c.lineTo(w * 0.5, h);
- c.stroke();
- c.begin();
- c.setFontSize(fontSize);
- c.setFontColor(fontColor);
- 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);
- c.setFontSize(fontSize * 0.85);
- c.text(w * 0.52, h * 0.3, 0, 0, 'Zero or one', mxConstants.ALIGN_LEFT, mxConstants.ALIGN_MIDDLE, 0, null, 0, 0, 0);
- c.text(w * 0.52, h * 0.5, 0, 0, 'One only', mxConstants.ALIGN_LEFT, mxConstants.ALIGN_MIDDLE, 0, null, 0, 0, 0);
- c.text(w * 0.52, h * 0.7, 0, 0, 'Zero or more', mxConstants.ALIGN_LEFT, mxConstants.ALIGN_MIDDLE, 0, null, 0, 0, 0);
- c.text(w * 0.52, h * 0.9, 0, 0, 'One or more', mxConstants.ALIGN_LEFT, mxConstants.ALIGN_MIDDLE, 0, null, 0, 0, 0);
- var ellSize = h / 12;
- c.begin();
- c.moveTo(w * 0.04, h * 0.3);
- c.lineTo(w * 0.46, h * 0.3);
- c.moveTo(w * 0.46 - ellSize, h * 0.25);
- c.lineTo(w * 0.46 - ellSize, h * 0.35);
- c.moveTo(w * 0.04, h * 0.5);
- c.lineTo(w * 0.46, h * 0.5);
- c.moveTo(w * 0.46 - ellSize * 2, h * 0.45);
- c.lineTo(w * 0.46 - ellSize * 2, h * 0.55);
- c.moveTo(w * 0.46 - ellSize * 2.5, h * 0.45);
- c.lineTo(w * 0.46 - ellSize * 2.5, h * 0.55);
- c.moveTo(w * 0.04, h * 0.7);
- c.lineTo(w * 0.46, h * 0.7);
- c.moveTo(w * 0.46, h * 0.65);
- c.lineTo(w * 0.46 - ellSize * 2, h * 0.7);
- c.lineTo(w * 0.46, h * 0.75);
- c.stroke();
- c.moveTo(w * 0.04, h * 0.9);
- c.lineTo(w * 0.46, h * 0.9);
- c.moveTo(w * 0.46, h * 0.85);
- c.lineTo(w * 0.46 - ellSize * 2, h * 0.9);
- c.lineTo(w * 0.46, h * 0.95);
- c.moveTo(w * 0.46 - ellSize * 2.5, h * 0.85);
- c.lineTo(w * 0.46 - ellSize * 2.5, h * 0.95);
- c.stroke();
- c.begin();
- c.ellipse(w * 0.46 - ellSize * 3, h * 0.3 - ellSize * 0.5, ellSize, ellSize);
- c.fillAndStroke();
- c.begin();
- c.ellipse(w * 0.46 - ellSize * 3, h * 0.7 - ellSize * 0.5, ellSize, ellSize);
- c.fillAndStroke();
- };
- mxCellRenderer.prototype.defaultShapes['mxgraph.er.ie'] = mxShapeERInfEng;
- mxShapeERInfEng.prototype.constraints = [
- new mxConnectionConstraint(new mxPoint(0, 0), true),
- new mxConnectionConstraint(new mxPoint(1, 0), true),
- new mxConnectionConstraint(new mxPoint(0, 1), true),
- new mxConnectionConstraint(new mxPoint(1, 1), true),
- new mxConnectionConstraint(new mxPoint(0.25, 0), true),
- new mxConnectionConstraint(new mxPoint(0.5, 0), true),
- new mxConnectionConstraint(new mxPoint(0.75, 0), true),
- new mxConnectionConstraint(new mxPoint(0, 0.25), true),
- new mxConnectionConstraint(new mxPoint(0, 0.5), true),
- new mxConnectionConstraint(new mxPoint(0, 0.75), true),
- new mxConnectionConstraint(new mxPoint(1, 0.25), true),
- new mxConnectionConstraint(new mxPoint(1, 0.5), true),
- new mxConnectionConstraint(new mxPoint(1, 0.75), true),
- new mxConnectionConstraint(new mxPoint(0.25, 1), true),
- new mxConnectionConstraint(new mxPoint(0.5, 1), true),
- new mxConnectionConstraint(new mxPoint(0.75, 1), true)
- ];
- // ER markers
- mxMarker.addMarker('ERone', function(c, shape, type, pe, unitX, unitY, size, source, sw, filled)
- {
- var nx = unitX * (size + sw + 1);
- var ny = unitY * (size + sw + 1);
- return function()
- {
- c.begin();
- c.moveTo(pe.x - nx / 2 - ny / 2, pe.y - ny / 2 + nx / 2);
- c.lineTo(pe.x - nx / 2 + ny / 2, pe.y - ny / 2 - nx / 2);
- c.stroke();
- };
- });
- mxMarker.addMarker('ERmandOne', function(c, shape, type, pe, unitX, unitY, size, source, sw, filled)
- {
- var nx = unitX * (size + sw + 1);
- var ny = unitY * (size + sw + 1);
- return function()
- {
- c.begin();
- c.moveTo(pe.x - nx / 2 - ny / 2, pe.y - ny / 2 + nx / 2);
- c.lineTo(pe.x - nx / 2 + ny / 2, pe.y - ny / 2 - nx / 2);
- c.moveTo(pe.x - nx - ny / 2, pe.y - ny + nx / 2);
- c.lineTo(pe.x - nx + ny / 2, pe.y - ny - nx / 2);
- c.stroke();
- };
- });
- mxMarker.addMarker('ERmany', function(c, shape, type, pe, unitX, unitY, size, source, sw, filled)
- {
- var nx = unitX * (size + sw + 1);
- var ny = unitY * (size + sw + 1);
- return function()
- {
- c.begin();
- c.moveTo(pe.x + ny / 2, pe.y - nx / 2);
- c.lineTo(pe.x - nx, pe.y - ny);
- c.lineTo(pe.x - ny / 2, pe.y + nx / 2);
- c.stroke();
- };
- });
- mxMarker.addMarker('ERoneToMany', function(c, shape, type, pe, unitX, unitY, size, source, sw, filled)
- {
- var nx = unitX * (size + sw + 1);
- var ny = unitY * (size + sw + 1);
- return function()
- {
- c.begin();
- c.moveTo(pe.x - nx - ny / 2, pe.y - ny + nx / 2);
- c.lineTo(pe.x - nx + ny / 2, pe.y - ny - nx / 2);
- c.moveTo(pe.x + ny / 2, pe.y - nx / 2);
- c.lineTo(pe.x - nx, pe.y - ny);
- c.lineTo(pe.x - ny / 2, pe.y + nx / 2);
- c.stroke();
- };
- });
- mxMarker.addMarker('ERzeroToMany', function(c, shape, type, pe, unitX, unitY, size, source, sw, filled)
- {
- var nx = unitX * (size + sw + 1);
- var ny = unitY * (size + sw + 1);
- var a = size / 2;
- return function()
- {
- c.begin();
- c.ellipse(pe.x - 1.5 * nx - a, pe.y - 1.5 * ny - a, 2 * a, 2 * a);
- if (filled)
- {
- // TODO not sure if this is ok, because by default, markers use strokeColor for filling
- var oldColor = mxUtils.getValue(shape.style, mxConstants.STYLE_STROKECOLOR, '#666666');
-
- c.setFillColor('#ffffff');
- c.fillAndStroke();
- c.setFillColor(oldColor);
- }
- else
- {
- c.stroke();
- }
- c.begin();
- c.moveTo(pe.x + ny / 2, pe.y - nx / 2);
- c.lineTo(pe.x - nx, pe.y - ny);
- c.lineTo(pe.x - ny / 2, pe.y + nx / 2);
- c.stroke();
- };
- });
- mxMarker.addMarker('ERzeroToOne', function(c, shape, type, pe, unitX, unitY, size, source, sw, filled)
- {
- var nx = unitX * (size + sw + 1);
- var ny = unitY * (size + sw + 1);
- var a = size / 2;
- return function()
- {
- c.begin();
- c.ellipse(pe.x - 1.5 * nx - a, pe.y - 1.5 * ny - a, 2 * a, 2 * a);
- if (filled)
- {
- // TODO not sure if this is ok, because by default, markers use strokeColor for filling
- var oldColor = mxUtils.getValue(shape.style, mxConstants.STYLE_STROKECOLOR, '#666666');
-
- c.setFillColor('#ffffff');
- c.fillAndStroke();
- c.setFillColor(oldColor);
- }
- else
- {
- c.stroke();
- }
- c.begin();
- c.moveTo(pe.x - nx / 2 - ny / 2, pe.y - ny / 2 + nx / 2);
- c.lineTo(pe.x - nx / 2 + ny / 2, pe.y - ny / 2 - nx / 2);
- c.stroke();
- };
- });
- //**********************************************************************************************************************************************************
- //Rounded rectangle (adjustable rounding)
- //**********************************************************************************************************************************************************
- /**
- * Extends mxShape.
- */
- function mxShapeERRRect(bounds, fill, stroke, strokewidth)
- {
- mxShape.call(this);
- this.bounds = bounds;
- this.fill = fill;
- this.stroke = stroke;
- this.strokewidth = (strokewidth != null) ? strokewidth : 1;
- };
- /**
- * Extends mxShape.
- */
- mxUtils.extend(mxShapeERRRect, mxShape);
- mxShapeERRRect.prototype.cst = {
- RRECT : 'mxgraph.er.rrect',
- R_SIZE : 'rSize'
- };
- /**
- * Function: paintVertexShape
- *
- * Paints the vertex shape.
- */
- mxShapeERRRect.prototype.paintVertexShape = function(c, x, y, w, h)
- {
- c.translate(x, y);
- var rSize = parseInt(mxUtils.getValue(this.style, mxShapeERRRect.prototype.cst.R_SIZE, '10'));
- c.roundrect(0, 0, w, h, rSize);
- c.fillAndStroke();
- };
- mxCellRenderer.registerShape(mxShapeERRRect.prototype.cst.RRECT, mxShapeERRRect);
- mxShapeERRRect.prototype.constraints = [
- new mxConnectionConstraint(new mxPoint(0.25, 0), true),
- new mxConnectionConstraint(new mxPoint(0.5, 0), true),
- new mxConnectionConstraint(new mxPoint(0.75, 0), true),
- new mxConnectionConstraint(new mxPoint(0, 0.25), true),
- new mxConnectionConstraint(new mxPoint(0, 0.5), true),
- new mxConnectionConstraint(new mxPoint(0, 0.75), true),
- new mxConnectionConstraint(new mxPoint(1, 0.25), true),
- new mxConnectionConstraint(new mxPoint(1, 0.5), true),
- new mxConnectionConstraint(new mxPoint(1, 0.75), true),
- new mxConnectionConstraint(new mxPoint(0.25, 1), true),
- new mxConnectionConstraint(new mxPoint(0.5, 1), true),
- new mxConnectionConstraint(new mxPoint(0.75, 1), true)
- ];
- //**********************************************************************************************************************************************************
- //Anchor (a dummy shape without visuals used for anchoring)
- //**********************************************************************************************************************************************************
- /**
- * Extends mxShape.
- */
- function mxShapeERAnchor(bounds, fill, stroke, strokewidth)
- {
- mxShape.call(this);
- this.bounds = bounds;
- };
- /**
- * Extends mxShape.
- */
- mxUtils.extend(mxShapeERAnchor, mxShape);
- mxShapeERAnchor.prototype.cst = {
- ANCHOR : 'mxgraph.er.anchor'
- };
- /**
- * Function: paintVertexShape
- *
- * Paints the vertex shape.
- */
- mxShapeERAnchor.prototype.paintVertexShape = function(c, x, y, w, h)
- {
- };
- mxCellRenderer.registerShape(mxShapeERAnchor.prototype.cst.ANCHOR, mxShapeERAnchor);
|