| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497 |
- /**
- * Copyright (c) 2006-2010, JGraph Holdings 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.registerShape('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.registerShape('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.registerShape('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.registerShape('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.registerShape('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.registerShape('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.registerShape('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.registerShape('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.registerShape('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.registerShape('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;
- var px = pe.x;
- var py = pe.y;
-
- if (!filled)
- {
- pe.x -= 2 * nx - unitX * sw / 2;
- pe.y -= 2 * ny - unitY * sw / 2;
- }
- return function()
- {
- c.begin();
- c.ellipse(px - 1.5 * nx - a, py - 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(px + ny / 2, py - nx / 2);
- c.lineTo(px - nx, py - ny);
- c.lineTo(px - ny / 2, py + nx / 2);
- if (!filled)
- {
- c.moveTo(px - nx, py - ny);
- c.lineTo(px, py);
- }
- 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;
- var px = pe.x;
- var py = pe.y;
-
- if (!filled)
- {
- pe.x -= 2 * nx - unitX * sw / 2;
- pe.y -= 2 * ny - unitY * sw / 2;
- }
- return function()
- {
- c.begin();
- c.ellipse(px - 1.5 * nx - a, py - 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(px - nx / 2 - ny / 2, py - ny / 2 + nx / 2);
- c.lineTo(px - nx / 2 + ny / 2, py - ny / 2 - nx / 2);
- if (!filled)
- {
- c.moveTo(px - nx - unitX * sw / 2, py - ny - unitY * sw / 2);
- c.lineTo(px, py);
- }
- 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'
- };
- mxShapeERRRect.prototype.customProperties = [
- {name: 'rSize', dispName: 'Rounding Size', type: 'float'},
- ];
- /**
- * 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);
|