| 12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445144614471448144914501451145214531454145514561457145814591460146114621463146414651466146714681469147014711472147314741475147614771478147914801481148214831484148514861487148814891490149114921493149414951496149714981499150015011502 |
- /**
- * Copyright (c) 2006-2014, JGraph Holdings Ltd
- */
- //**********************************************************************************************************************************************************
- //Rounded rectangle (adjustable rounding)
- //**********************************************************************************************************************************************************
- /**
- * Extends mxShape.
- */
- function mxShapeBootstrapRRect(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(mxShapeBootstrapRRect, mxShape);
- mxShapeBootstrapRRect.prototype.cst = {
- PACKAGE : 'mxgraph.bootstrap.rrect',
- R_SIZE : 'rSize'
- };
- mxShapeBootstrapRRect.prototype.customProperties = [
- {name: 'rSize', dispName: 'Arc Size', type: 'float', min:0, defVal:10}
- ];
- /**
- * Function: paintVertexShape
- *
- * Paints the vertex shape.
- */
- mxShapeBootstrapRRect.prototype.paintVertexShape = function(c, x, y, w, h)
- {
- c.translate(x, y);
- var rSize = parseInt(mxUtils.getValue(this.style, mxShapeBootstrapRRect.prototype.cst.R_SIZE, '10'));
- c.roundrect(0, 0, w, h, rSize);
- c.fillAndStroke();
- };
- mxCellRenderer.registerShape(mxShapeBootstrapRRect.prototype.cst.PACKAGE, mxShapeBootstrapRRect);
- //**********************************************************************************************************************************************************
- //Top Button
- //**********************************************************************************************************************************************************
- /**
- * Extends mxShape.
- */
- function mxShapeBootstrapTopButton(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(mxShapeBootstrapTopButton, mxShape);
- mxShapeBootstrapTopButton.prototype.cst = {
- TOP_BUTTON : 'mxgraph.bootstrap.topButton',
- R_SIZE : 'rSize'
- };
- mxShapeBootstrapTopButton.prototype.customProperties = [
- {name: 'rSize', dispName: 'Arc Size', type: 'float', min:0, defVal:10}
- ];
- /**
- * Function: paintVertexShape
- *
- * Paints the vertex shape.
- */
- mxShapeBootstrapTopButton.prototype.paintVertexShape = function(c, x, y, w, h)
- {
- c.translate(x, y);
- var rSize = parseInt(mxUtils.getValue(this.style, mxShapeBootstrapTopButton.prototype.cst.R_SIZE, '10'));
- 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);
- c.lineTo(0, h);
- c.close();
- c.fillAndStroke();
- };
- mxCellRenderer.registerShape(mxShapeBootstrapTopButton.prototype.cst.TOP_BUTTON, mxShapeBootstrapTopButton);
- //**********************************************************************************************************************************************************
- //Bottom Button
- //**********************************************************************************************************************************************************
- /**
- * Extends mxShape.
- */
- function mxShapeBootstrapBottomButton(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(mxShapeBootstrapBottomButton, mxShape);
- mxShapeBootstrapBottomButton.prototype.cst = {
- BOTTOM_BUTTON : 'mxgraph.bootstrap.bottomButton',
- R_SIZE : 'rSize'
- };
- mxShapeBootstrapBottomButton.prototype.customProperties = [
- {name: 'rSize', dispName: 'Arc Size', type: 'float', min:0, defVal:10}
- ];
- /**
- * Function: paintVertexShape
- *
- * Paints the vertex shape.
- */
- mxShapeBootstrapBottomButton.prototype.paintVertexShape = function(c, x, y, w, h)
- {
- c.translate(x, y);
- var rSize = parseInt(mxUtils.getValue(this.style, mxShapeBootstrapBottomButton.prototype.cst.R_SIZE, '10'));
- c.begin();
- c.moveTo(0, 0);
- c.lineTo(w, 0);
- 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();
- };
- mxCellRenderer.registerShape(mxShapeBootstrapBottomButton.prototype.cst.BOTTOM_BUTTON, mxShapeBootstrapBottomButton);
- //**********************************************************************************************************************************************************
- //Right Button
- //**********************************************************************************************************************************************************
- /**
- * Extends mxShape.
- */
- function mxShapeBootstrapRightButton(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(mxShapeBootstrapRightButton, mxShape);
- mxShapeBootstrapRightButton.prototype.cst = {
- RIGHT_BUTTON : 'mxgraph.bootstrap.rightButton',
- R_SIZE : 'rSize'
- };
- mxShapeBootstrapRightButton.prototype.customProperties = [
- {name: 'rSize', dispName: 'Arc Size', type: 'float', min:0, defVal:10}
- ];
- /**
- * Function: paintVertexShape
- *
- * Paints the vertex shape.
- */
- mxShapeBootstrapRightButton.prototype.paintVertexShape = function(c, x, y, w, h)
- {
- c.translate(x, y);
- var rSize = parseInt(mxUtils.getValue(this.style, mxShapeBootstrapRightButton.prototype.cst.R_SIZE, '10'));
- c.begin();
- c.moveTo(0, 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(0, h);
- c.close();
- c.fillAndStroke();
- };
- mxCellRenderer.registerShape(mxShapeBootstrapRightButton.prototype.cst.RIGHT_BUTTON, mxShapeBootstrapRightButton);
- //**********************************************************************************************************************************************************
- //Left Button
- //**********************************************************************************************************************************************************
- /**
- * Extends mxShape.
- */
- function mxShapeBootstrapLeftButton(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(mxShapeBootstrapLeftButton, mxShape);
- mxShapeBootstrapLeftButton.prototype.cst = {
- LEFT_BUTTON : 'mxgraph.bootstrap.leftButton',
- R_SIZE : 'rSize'
- };
- mxShapeBootstrapLeftButton.prototype.customProperties = [
- {name: 'rSize', dispName: 'Arc Size', type: 'float', min:0, defVal:10}
- ];
- /**
- * Function: paintVertexShape
- *
- * Paints the vertex shape.
- */
- mxShapeBootstrapLeftButton.prototype.paintVertexShape = function(c, x, y, w, h)
- {
- c.translate(x, y);
- var rSize = parseInt(mxUtils.getValue(this.style, mxShapeBootstrapLeftButton.prototype.cst.R_SIZE, '10'));
- c.begin();
- c.moveTo(w, 0);
- c.lineTo(w, h);
- c.lineTo(rSize, h);
- c.arcTo(rSize, rSize, 0, 0, 1, 0, h - rSize);
- c.lineTo(0, rSize);
- c.arcTo(rSize, rSize, 0, 0, 1, rSize, 0);
- c.close();
- c.fillAndStroke();
- };
- mxCellRenderer.registerShape(mxShapeBootstrapLeftButton.prototype.cst.LEFT_BUTTON, mxShapeBootstrapLeftButton);
- //**********************************************************************************************************************************************************
- //Left Button (Striped)
- //**********************************************************************************************************************************************************
- /**
- * Extends mxShape.
- */
- function mxShapeBootstrapLeftButtonStriped(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(mxShapeBootstrapLeftButtonStriped, mxShape);
- mxShapeBootstrapLeftButtonStriped.prototype.cst = {
- LEFT_BUTTON_STRIPED : 'mxgraph.bootstrap.leftButtonStriped'
- };
- /**
- * Function: paintVertexShape
- *
- * Paints the vertex shape.
- */
- mxShapeBootstrapLeftButtonStriped.prototype.paintVertexShape = function(c, x, y, w, h)
- {
- c.translate(x, y);
- rSize = 5;
- c.begin();
- c.moveTo(w, 0);
- c.lineTo(w, h);
- c.lineTo(rSize, h);
- c.arcTo(rSize, rSize, 0, 0, 1, 0, h - rSize);
- c.lineTo(0, rSize);
- c.arcTo(rSize, rSize, 0, 0, 1, rSize, 0);
- c.close();
- c.fill();
-
- var fillColor = '#ffffff';
- c.setAlpha('0.2');
- var stripeW = h * 0.5;
- c.setFillColor(fillColor);
- c.begin();
- c.moveTo(0, h * 0.75);
- c.lineTo(0, h * 0.25);
- c.lineTo(h * 0.75, h);
- c.lineTo(h * 0.25, h);
- c.close();
- c.fill();
-
- var end = false;
- var startX = stripeW * 0.5;
-
- while (!end)
- {
- c.begin();
- c.moveTo(startX, 0);
-
- if (startX + stripeW >= w)
- {
- c.lineTo(w, 0);
- c.lineTo(w, w - startX);
- }
- else
- {
- c.lineTo(startX + stripeW, 0);
-
- if (startX + stripeW + h > w)
- {
- c.lineTo(w, w - startX - stripeW);
-
- if (w - startX > h)
- {
- c.lineTo(w, h);
- c.lineTo(startX + h, h);
- }
- else
- {
- c.lineTo(w, w - startX);
- }
- }
- else
- {
- c.lineTo(startX + stripeW + h, h);
- c.lineTo(startX + h, h);
- }
- }
- c.close();
- c.fill();
-
- startX = startX + 2 * stripeW;
-
- if (startX > w)
- {
- end = true;
- }
- }
- };
- mxCellRenderer.registerShape(mxShapeBootstrapLeftButtonStriped.prototype.cst.LEFT_BUTTON_STRIPED, mxShapeBootstrapLeftButtonStriped);
- //**********************************************************************************************************************************************************
- //Rounded Button
- //**********************************************************************************************************************************************************
- /**
- * Extends mxShape.
- */
- function mxShapeBootstrapRoundedButton(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(mxShapeBootstrapRoundedButton, mxShape);
- mxShapeBootstrapRoundedButton.prototype.cst = {
- ROUNDED_BUTTON : 'mxgraph.bootstrap.roundedButton'
- };
- /**
- * Function: paintVertexShape
- *
- * Paints the vertex shape.
- */
- mxShapeBootstrapRoundedButton.prototype.paintVertexShape = function(c, x, y, w, h)
- {
- c.translate(x, y);
- if (w > h)
- {
- var r = h * 0.5;
-
- c.begin();
- c.moveTo(w - r, 0);
- c.arcTo(r, r, 0, 0, 1, w - r, h);
- c.lineTo(r, h);
- c.arcTo(r, r, 0, 0, 1, r, 0);
- c.close();
- c.fillAndStroke();
- }
- else
- {
- var r = w * 0.5;
-
- c.begin();
- c.moveTo(0, h - r);
- c.arcTo(r, r, 0, 0, 0, w, h - r);
- c.lineTo(w, r);
- c.arcTo(r, r, 0, 0, 0, 0, r);
- c.close();
- c.fillAndStroke();
- }
- };
- mxCellRenderer.registerShape(mxShapeBootstrapRoundedButton.prototype.cst.ROUNDED_BUTTON, mxShapeBootstrapRoundedButton);
- //**********************************************************************************************************************************************************
- //Arrow
- //**********************************************************************************************************************************************************
- /**
- * Extends mxShape.
- */
- function mxShapeBootstrapArrow(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(mxShapeBootstrapArrow, mxShape);
- mxShapeBootstrapArrow.prototype.cst = {
- ARROW : 'mxgraph.bootstrap.arrow'
- };
- /**
- * Function: paintVertexShape
- *
- * Paints the vertex shape.
- */
- mxShapeBootstrapArrow.prototype.paintVertexShape = function(c, x, y, w, h)
- {
- c.translate(x, y);
- c.begin();
- c.moveTo(0, h * 0.5);
- c.lineTo(w, h * 0.5);
- c.moveTo(w * 0.9, 0);
- c.lineTo(w, h * 0.5);
- c.lineTo(w * 0.9, h);
- c.stroke();
- };
- mxCellRenderer.registerShape(mxShapeBootstrapArrow.prototype.cst.ARROW, mxShapeBootstrapArrow);
- //**********************************************************************************************************************************************************
- //Tab Top
- //**********************************************************************************************************************************************************
- /**
- * Extends mxShape.
- */
- function mxShapeBootstrapTabTop(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(mxShapeBootstrapTabTop, mxShape);
- mxShapeBootstrapTabTop.prototype.cst = {
- TAB_TOP : 'mxgraph.bootstrap.tabTop',
- R_SIZE : 'rSize'
- };
- mxShapeBootstrapTabTop.prototype.customProperties = [
- {name: 'rSize', dispName: 'Arc Size', type: 'float', min:0, defVal:5}
- ];
- /**
- * Function: paintVertexShape
- *
- * Paints the vertex shape.
- */
- mxShapeBootstrapTabTop.prototype.paintVertexShape = function(c, x, y, w, h)
- {
- c.translate(x, y);
- var rSize = parseInt(mxUtils.getValue(this.style, mxShapeBootstrapTopButton.prototype.cst.R_SIZE, '10'));
- var strokeColor = mxUtils.getValue(this.style, mxConstants.STYLE_STROKECOLOR, '#000000');
- var fillColor = mxUtils.getValue(this.style, mxConstants.STYLE_FILLCOLOR, '#ffffff');
- c.setStrokeColor(fillColor);
- 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);
- c.lineTo(0, h);
- c.close();
- c.fillAndStroke();
- c.setStrokeColor(strokeColor);
- c.begin();
- c.moveTo(0, h);
- c.lineTo(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);
- c.stroke();
- };
- mxCellRenderer.registerShape(mxShapeBootstrapTabTop.prototype.cst.TAB_TOP, mxShapeBootstrapTabTop);
- //**********************************************************************************************************************************************************
- //Image
- //**********************************************************************************************************************************************************
- /**
- * Extends mxShape.
- */
- function mxShapeBootstrapImage(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(mxShapeBootstrapImage, mxShape);
- mxShapeBootstrapImage.prototype.cst = {
- IMAGE : 'mxgraph.bootstrap.image',
- R_SIZE : 'rSize'
- };
- mxShapeBootstrapImage.prototype.customProperties = [
- {name: 'rSize', dispName: 'Arc Size', type: 'float', min:0, defVal:5}
- ];
- /**
- * Function: paintVertexShape
- *
- * Paints the vertex shape.
- */
- mxShapeBootstrapImage.prototype.paintVertexShape = function(c, x, y, w, h)
- {
- c.translate(x, y);
- var rSize = Math.max(0, parseInt(mxUtils.getValue(this.style, mxShapeBootstrapTopButton.prototype.cst.R_SIZE, '10')));
- var strokeColor = mxUtils.getValue(this.style, mxConstants.STYLE_STROKECOLOR, '#000000');
- var fillColor = mxUtils.getValue(this.style, mxConstants.STYLE_FILLCOLOR, '#ffffff');
- 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.stroke();
- var rsHalf = rSize * 0.5;
- c.translate(rsHalf, rsHalf);
- w = Math.max(0, w - rSize);
- h = Math.max(0, h - rSize);
-
- c.begin();
- c.moveTo(0, rsHalf);
- c.arcTo(rsHalf, rsHalf, 0, 0, 1, rsHalf, 0);
- c.lineTo(w - rsHalf, 0);
- c.arcTo(rsHalf, rsHalf, 0, 0, 1, w, rsHalf);
- c.lineTo(w, h - rsHalf);
- c.arcTo(rsHalf, rsHalf, 0, 0, 1, w - rsHalf, h);
- c.lineTo(rsHalf, h);
- c.arcTo(rsHalf, rsHalf, 0, 0, 1, 0, h - rsHalf);
- c.close();
- c.fill();
- };
- mxCellRenderer.registerShape(mxShapeBootstrapImage.prototype.cst.IMAGE, mxShapeBootstrapImage);
- //**********************************************************************************************************************************************************
- //Checkbox
- //**********************************************************************************************************************************************************
- /**
- * Extends mxShape.
- */
- function mxShapeBootstrapCheckbox(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(mxShapeBootstrapCheckbox, mxShape);
- mxShapeBootstrapCheckbox.prototype.cst = {
- CHECKBOX : 'mxgraph.bootstrap.checkbox'
- };
- /**
- * Function: paintVertexShape
- *
- * Paints the vertex shape.
- */
- mxShapeBootstrapCheckbox.prototype.paintVertexShape = function(c, x, y, w, h)
- {
- c.translate(x, y);
- var rSize = 3;
- c.roundrect(0, 0, w, h, rSize, rSize);
- c.fillAndStroke();
-
- c.setStrokeWidth('3');
- c.begin();
- c.moveTo(w * 0.8, h * 0.2);
- c.lineTo(w * 0.4, h * 0.8);
- c.lineTo(w * 0.25, h * 0.6);
- c.stroke();
- };
- mxCellRenderer.registerShape(mxShapeBootstrapCheckbox.prototype.cst.CHECKBOX, mxShapeBootstrapCheckbox);
- //**********************************************************************************************************************************************************
- //Checkbox v2
- //**********************************************************************************************************************************************************
- /**
- * Extends mxShape.
- */
- function mxShapeBootstrapCheckbox2(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(mxShapeBootstrapCheckbox2, mxShape);
- mxShapeBootstrapCheckbox2.prototype.customProperties = [
- {name: 'checked', dispName: 'Checked', type: 'bool', defVal: false},
- {name: 'checkedFill', dispName: 'Checked Fill Color', type: 'color', defVal: '#ffffff'},
- {name: 'checkedStroke', dispName: 'Checked Stroke Color', type: 'color', defVal: '#000000'}
- ];
- mxShapeBootstrapCheckbox2.prototype.cst = {
- CHECKBOX2 : 'mxgraph.bootstrap.checkbox2'
- };
- /**
- * Function: paintVertexShape
- *
- * Paints the vertex shape.
- */
- mxShapeBootstrapCheckbox2.prototype.paintVertexShape = function(c, x, y, w, h)
- {
- var isChecked = mxUtils.getValue(this.style, 'checked', false);
- var checkedFill = mxUtils.getValue(this.style, 'checkedFill', '#ffffff');
- var checkedStroke = mxUtils.getValue(this.style, 'checkedStroke', '#000000');
-
- c.translate(x, y);
- var rSize = 2;
-
- if (isChecked)
- {
- c.setFillColor(checkedFill);
- c.setStrokeColor(checkedStroke);
-
- c.roundrect(0, 0, w, h, rSize, rSize);
- c.fill();
-
- c.setStrokeWidth('2');
- c.begin();
- c.moveTo(w * 0.8, h * 0.2);
- c.lineTo(w * 0.4, h * 0.75);
- c.lineTo(w * 0.25, h * 0.6);
- c.stroke();
- }
- else
- {
- c.roundrect(0, 0, w, h, rSize, rSize);
- c.fillAndStroke();
- }
- };
- mxCellRenderer.registerShape(mxShapeBootstrapCheckbox2.prototype.cst.CHECKBOX2, mxShapeBootstrapCheckbox2);
- //**********************************************************************************************************************************************************
- //Radio Button
- //**********************************************************************************************************************************************************
- /**
- * Extends mxShape.
- */
- function mxShapeBootstrapRadioButton(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(mxShapeBootstrapRadioButton, mxShape);
- mxShapeBootstrapRadioButton.prototype.cst = {
- RADIO_BUTTON : 'mxgraph.bootstrap.radioButton'
- };
- /**
- * Function: paintVertexShape
- *
- * Paints the vertex shape.
- */
- mxShapeBootstrapRadioButton.prototype.paintVertexShape = function(c, x, y, w, h)
- {
- c.translate(x, y);
-
- var strokeColor = mxUtils.getValue(this.style, mxConstants.STYLE_STROKECOLOR, '#000000');
- c.ellipse(0, 0, w, h);
- c.fillAndStroke();
-
- c.setFillColor(strokeColor);
- c.ellipse(w * 0.25, h * 0.25, w * 0.5, h * 0.5);
- c.fill();
- };
- mxCellRenderer.registerShape(mxShapeBootstrapRadioButton.prototype.cst.RADIO_BUTTON, mxShapeBootstrapRadioButton);
- //**********************************************************************************************************************************************************
- //Radio Button v2
- //**********************************************************************************************************************************************************
- /**
- * Extends mxShape.
- */
- function mxShapeBootstrapRadioButton2(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(mxShapeBootstrapRadioButton2, mxShape);
- mxShapeBootstrapRadioButton2.prototype.customProperties = [
- {name: 'checked', dispName: 'Checked', type: 'bool', defVal: false},
- {name: 'checkedFill', dispName: 'Checked Fill Color', type: 'color', defVal: '#ffffff'},
- {name: 'checkedStroke', dispName: 'Checked Stroke Color', type: 'color', defVal: '#000000'}
- ];
- mxShapeBootstrapRadioButton2.prototype.cst = {
- RADIO_BUTTON2 : 'mxgraph.bootstrap.radioButton2'
- };
- /**
- * Function: paintVertexShape
- *
- * Paints the vertex shape.
- */
- mxShapeBootstrapRadioButton2.prototype.paintVertexShape = function(c, x, y, w, h)
- {
- var isChecked = mxUtils.getValue(this.style, 'checked', false);
- var checkedFill = mxUtils.getValue(this.style, 'checkedFill', '#ffffff');
- var checkedStroke = mxUtils.getValue(this.style, 'checkedStroke', '#000000');
-
- c.translate(x, y);
-
- if (isChecked)
- {
- c.setFillColor(checkedFill);
- c.setStrokeColor(checkedFill);
-
- c.ellipse(0, 0, w, h);
- c.fillAndStroke();
-
- c.setFillColor(checkedStroke);
- c.ellipse(w * 0.2, h * 0.2, w * 0.6, h * 0.6);
- c.fill();
- }
- else
- {
- c.ellipse(0, 0, w, h);
- c.fillAndStroke();
- }
- };
- mxCellRenderer.registerShape(mxShapeBootstrapRadioButton2.prototype.cst.RADIO_BUTTON2, mxShapeBootstrapRadioButton2);
- //**********************************************************************************************************************************************************
- //Horizontal Lines
- //**********************************************************************************************************************************************************
- /**
- * Extends mxShape.
- */
- function mxShapeBootstrapHorLines(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(mxShapeBootstrapHorLines, mxShape);
- mxShapeBootstrapHorLines.prototype.cst = {
- HOR_LINES : 'mxgraph.bootstrap.horLines'
- };
- /**
- * Function: paintVertexShape
- *
- * Paints the vertex shape.
- */
- mxShapeBootstrapHorLines.prototype.paintVertexShape = function(c, x, y, w, h)
- {
- c.translate(x, y);
- c.rect(0, 0, w, h);
- c.fill();
-
- c.begin();
- c.moveTo(0, 0);
- c.lineTo(w, 0);
- c.moveTo(0, h);
- c.lineTo(w, h);
- c.stroke();
- };
- mxCellRenderer.registerShape(mxShapeBootstrapHorLines.prototype.cst.HOR_LINES, mxShapeBootstrapHorLines);
- //**********************************************************************************************************************************************************
- //User 2
- //**********************************************************************************************************************************************************
- /**
- * Extends mxShape.
- */
- function mxShapeBootstrapUserTwo(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(mxShapeBootstrapUserTwo, mxShape);
- mxShapeBootstrapUserTwo.prototype.cst = {
- USER2 : 'mxgraph.bootstrap.user2'
- };
- /**
- * Function: paintVertexShape
- *
- * Paints the vertex shape.
- */
- mxShapeBootstrapUserTwo.prototype.paintVertexShape = function(c, x, y, w, h)
- {
- c.translate(x, y);
- c.begin();
- c.moveTo(0, h * 0.95);
- c.arcTo(w * 0.3, h * 0.3, 0, 0, 1, w * 0.02, h * 0.87);
- c.arcTo(w * 0.1, h * 0.1, 0, 0, 1, w * 0.08, h * 0.812);
- c.arcTo(w * 3, h * 3, 0, 0, 1, w * 0.29, h * 0.732);
- c.arcTo(w * 0.15, h * 0.15, 0, 0, 0, w * 0.385, h * 0.607);
- c.arcTo(w * 0.11, h * 0.11, 0, 0, 0, w * 0.355, h * 0.53);
- c.arcTo(w * 0.3, h * 0.3, 0, 0, 1, w * 0.305, h * 0.44);
- c.arcTo(w * 0.33, h * 0.38, 0, 0, 1, w * 0.312, h * 0.15);
- c.arcTo(w * 0.218, h * 0.218 , 0, 0, 1, w * 0.688, h * 0.15);
- c.arcTo(w * 0.33, h * 0.38, 0, 0, 1, w * 0.693, h * 0.44);
- c.arcTo(w * 0.25, h * 0.25, 0, 0, 1, w * 0.645, h * 0.53);
- c.arcTo(w * 0.1, h * 0.1, 0, 0, 0, w * 0.612, h * 0.6);
- c.arcTo(w * 0.15, h * 0.15, 0, 0, 0, w * 0.7, h * 0.726);
- c.arcTo(w * 3, h * 3, 0, 0, 1, w * 0.92, h * 0.812);
- c.arcTo(w * 0.1, h * 0.1, 0, 0, 1, w * 0.97, h * 0.865);
- c.arcTo(w * 0.2, h * 0.2, 0, 0, 1, w * 0.995, h * 0.952);
- c.close();
- c.fill();
- };
- mxCellRenderer.registerShape(mxShapeBootstrapUserTwo.prototype.cst.USER2, mxShapeBootstrapUserTwo);
- //**********************************************************************************************************************************************************
- //Rating
- //**********************************************************************************************************************************************************
- /**
- * Extends mxShape.
- */
- function mxShapeBootstrapRating(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(mxShapeBootstrapRating, mxShape);
- mxShapeBootstrapRating.prototype.cst = {
- RATING : 'mxgraph.bootstrap.rating',
- RATING_STYLE : 'ratingStyle',
- RATING_SCALE : 'ratingScale',
- RATING_HEART : 'heart',
- RATING_STAR : 'star',
- EMPTY_FILL_COLOR : 'emptyFillColor',
- GRADE : 'grade'
- };
- mxShapeBootstrapRating.prototype.customProperties = [
- {name: 'ratingStyle', dispName: 'Rating Style', type: 'enum',
- enumList: [{val: 'heart', dispName: 'Heart'},
- {val: 'star', dispName: 'Star'}]
- },
- {name: 'ratingScale', dispName: 'Rating Scale', type: 'int', min:1, defVal:5},
- {name: 'emptyFillColor', dispName: 'Inactive Color', type: 'color', defVal:'none'},
- {name: 'grade', dispName: 'Grade', type: 'int', min:1, defVal:3}
- ];
- /**
- * Function: paintVertexShape
- *
- * Paints the vertex shape.
- */
- mxShapeBootstrapRating.prototype.paintVertexShape = function(c, x, y, w, h)
- {
- var ratingStyle = mxUtils.getValue(this.style, mxShapeBootstrapRating.prototype.cst.RATING_STYLE, mxShapeBootstrapRating.prototype.cst.RATING_STAR);
- var grade = mxUtils.getValue(this.style, mxShapeBootstrapRating.prototype.cst.GRADE, '5');
- var ratingScale = mxUtils.getValue(this.style, mxShapeBootstrapRating.prototype.cst.RATING_SCALE, '10');
- c.translate(x, y);
- if (ratingStyle === mxShapeBootstrapRating.prototype.cst.RATING_STAR)
- {
- for (var i = 0; i < grade; i++)
- {
- c.begin();
- c.moveTo(i * h * 1.2, 0.33 * h);
- c.lineTo(i * h * 1.2 + 0.364 * h, 0.33 * h);
- c.lineTo(i * h * 1.2 + 0.475 * h, 0);
- c.lineTo(i * h * 1.2 + 0.586 * h, 0.33 * h);
- c.lineTo(i * h * 1.2 + 0.95 * h, 0.33 * h);
- c.lineTo(i * h * 1.2 + 0.66 * h, 0.551 * h);
- c.lineTo(i * h * 1.2 + 0.775 * h, 0.9 * h);
- c.lineTo(i * h * 1.2 + 0.475 * h, 0.684 * h);
- c.lineTo(i * h * 1.2 + 0.175 * h, 0.9 * h);
- c.lineTo(i * h * 1.2 + 0.29 * h, 0.551 * h);
- c.close();
- c.fillAndStroke();
- }
- }
- else if (ratingStyle === mxShapeBootstrapRating.prototype.cst.RATING_HEART)
- {
- for (var i = 0; i < grade; i++)
- {
- c.begin();
- c.moveTo(i * h * 1.2 + h * 0.519, h * 0.947);
- c.curveTo(i * h * 1.2 + h * 0.558, h * 0.908,
- i * h * 1.2 + h * 0.778, h * 0.682,
- i * h * 1.2 + h * 0.916, h * 0.54);
- c.curveTo(i * h * 1.2 + h * 1.039, h * 0.414,
- i * h * 1.2 + h * 1.036, h * 0.229,
- i * h * 1.2 + h * 0.924, h * 0.115);
- c.curveTo(i * h * 1.2 + h * 0.812, 0,
- i * h * 1.2 + h * 0.631, 0,
- i * h * 1.2 + h * 0.519, h * 0.115);
- c.curveTo(i * h * 1.2 + h * 0.408, 0,
- i * h * 1.2 + h * 0.227, 0,
- i * h * 1.2 + h * 0.115, h * 0.115);
- c.curveTo(i * h * 1.2 + h * 0.03, h * 0.229,
- i * h * 1.2, h * 0.414,
- i * h * 1.2 + h * 0.123, h * 0.54);
- c.close();
- c.fillAndStroke();
- }
- }
- var emptyFillColor = mxUtils.getValue(this.style, mxShapeBootstrapRating.prototype.cst.EMPTY_FILL_COLOR, '#ffffff');
- c.setFillColor(emptyFillColor);
- if (ratingStyle === mxShapeBootstrapRating.prototype.cst.RATING_STAR)
- {
- for (var i = grade; i < ratingScale; i++)
- {
- c.begin();
- c.moveTo(i * h * 1.2, 0.33 * h);
- c.lineTo(i * h * 1.2 + 0.364 * h, 0.33 * h);
- c.lineTo(i * h * 1.2 + 0.475 * h, 0);
- c.lineTo(i * h * 1.2 + 0.586 * h, 0.33 * h);
- c.lineTo(i * h * 1.2 + 0.95 * h, 0.33 * h);
- c.lineTo(i * h * 1.2 + 0.66 * h, 0.551 * h);
- c.lineTo(i * h * 1.2 + 0.775 * h, 0.9 * h);
- c.lineTo(i * h * 1.2 + 0.475 * h, 0.684 * h);
- c.lineTo(i * h * 1.2 + 0.175 * h, 0.9 * h);
- c.lineTo(i * h * 1.2 + 0.29 * h, 0.551 * h);
- c.close();
- c.fillAndStroke();
- }
- }
- else if (ratingStyle === mxShapeBootstrapRating.prototype.cst.RATING_HEART)
- {
- for (var i = grade; i < ratingScale; i++)
- {
- c.begin();
- c.moveTo(i * h * 1.2 + h * 0.519, h * 0.947);
- c.curveTo(i * h * 1.2 + h * 0.558, h * 0.908,
- i * h * 1.2 + h * 0.778, h * 0.682,
- i * h * 1.2 + h * 0.916, h * 0.54);
- c.curveTo(i * h * 1.2 + h * 1.039, h * 0.414,
- i * h * 1.2 + h * 1.036, h * 0.229,
- i * h * 1.2 + h * 0.924, h * 0.115);
- c.curveTo(i * h * 1.2 + h * 0.812, 0,
- i * h * 1.2 + h * 0.631, 0,
- i * h * 1.2 + h * 0.519, h * 0.115);
- c.curveTo(i * h * 1.2 + h * 0.408, 0,
- i * h * 1.2 + h * 0.227, 0,
- i * h * 1.2 + h * 0.115, h * 0.115);
- c.curveTo(i * h * 1.2 + h * 0.03, h * 0.229,
- i * h * 1.2, h * 0.414,
- i * h * 1.2 + h * 0.123, h * 0.54);
- c.close();
- c.fillAndStroke();
- }
- }
- };
- mxCellRenderer.registerShape(mxShapeBootstrapRating.prototype.cst.RATING, mxShapeBootstrapRating);
- //**********************************************************************************************************************************************************
- //Anchor (a dummy shape without visuals used for anchoring)
- //**********************************************************************************************************************************************************
- /**
- * Extends mxShape.
- */
- function mxShapeBoostrapAnchor(bounds, fill, stroke, strokewidth)
- {
- mxShape.call(this);
- this.bounds = bounds;
- };
- /**
- * Extends mxShape.
- */
- mxUtils.extend(mxShapeBoostrapAnchor, mxShape);
- mxShapeBoostrapAnchor.prototype.cst = {
- ANCHOR : 'mxgraph.bootstrap.anchor'
- };
- /**
- * Function: paintVertexShape
- *
- * Paints the vertex shape.
- */
- mxShapeBoostrapAnchor.prototype.paintVertexShape = function(c, x, y, w, h)
- {
- };
- mxCellRenderer.registerShape(mxShapeBoostrapAnchor.prototype.cst.ANCHOR, mxShapeBoostrapAnchor);
- //**********************************************************************************************************************************************************
- //Range input
- //**********************************************************************************************************************************************************
- /**
- * Extends mxShape.
- */
- function mxShapeBootstrapRangeInput(bounds, fill, stroke, strokewidth)
- {
- mxShape.call(this);
- this.bounds = bounds;
- this.fill = fill;
- this.stroke = stroke;
- this.strokewidth = (strokewidth != null) ? strokewidth : 1;
- this.dx = 0.3;
- };
- /**
- * Extends mxShape.
- */
- mxUtils.extend(mxShapeBootstrapRangeInput, mxShape);
- mxShapeBootstrapRangeInput.prototype.customProperties = [
- {name: 'dx', dispName: 'Handle Position', type: 'float', min:0, max:1, defVal:0.3},
- {name: 'rangeStyle', dispName: 'Range Style', type: 'enum',
- enumList: [{val: 'rect', dispName: 'Rectangle'},
- {val: 'rounded', dispName: 'Rounded'}]
- },
- {name: 'handleStyle', dispName: 'Handle Style', type: 'enum',
- enumList: [{val: 'rect', dispName: 'Rectangle'},
- {val: 'circle', dispName: 'Circle'}]
- }
- ];
- mxShapeBootstrapRangeInput.prototype.cst = {
- RANGE_INPUT : 'mxgraph.bootstrap.rangeInput'
- };
- /**
- * Function: paintVertexShape
- *
- * Paints the vertex shape.
- */
- mxShapeBootstrapRangeInput.prototype.paintVertexShape = function(c, x, y, w, h)
- {
- var dx = w * Math.max(0, Math.min(w, parseFloat(mxUtils.getValue(this.style, 'dx', this.dx))));
- var gradientColor = mxUtils.getValue(this.style, 'gradientColor', 'none');
- var fillColor = mxUtils.getValue(this.state.style, 'fillColor', '#ffffff');
- var strokeColor = mxUtils.getValue(this.state.style, 'strokeColor', '#000000');
- var gradientDir = mxUtils.getValue(this.state.style, 'gradientDirection', 'south');
- var rangeStyle = mxUtils.getValue(this.state.style, 'rangeStyle', 'rounded');
- var handleStyle = mxUtils.getValue(this.state.style, 'handleStyle', 'circle');
- var barH = Math.min(h * 0.5, w * 0.5);
- var r = barH * 0.5;
-
- c.translate(x, y);
-
- if (rangeStyle == 'rect')
- {
- var opacity = parseFloat(mxUtils.getValue(this.style, 'opacity', '100'));
- var op1 = opacity;
- var op2 = opacity;
-
- if (fillColor == 'none')
- {
- op1 = 0;
- }
-
- if (gradientColor == 'none')
- {
- op2 = 0;
- }
-
- c.setGradient(fillColor, fillColor, 0, 0, w, h, gradientDir, op1, op2);
-
- c.rect(0, h * 0.5 - 2, w, 4);
- c.fill();
- }
- else if (rangeStyle == 'rounded')
- {
- c.begin();
- c.moveTo(0, h * 0.5);
- c.arcTo(r, r, 0, 0, 1, r, h * 0.5 - r);
- c.lineTo(w - r, h * 0.5 - r);
- c.arcTo(r, r, 0, 0, 1, w, h * 0.5);
- c.arcTo(r, r, 0, 0, 1, w - r, h * 0.5 + r);
- c.lineTo(r, h * 0.5 + r);
- c.arcTo(r, r, 0, 0, 1, 0, h * 0.5);
- c.close();
- c.fill();
- }
-
- if (handleStyle == 'rect')
- {
- c.setGradient(fillColor, gradientColor, 0, 0, w, h, gradientDir, op1, op2);
-
- var hw = h * 0.5;
- c.rect(dx - hw * 0.5, 0, hw, h);
- c.fillAndStroke();
-
- c.begin();
- c.moveTo(dx - hw * 0.25, h * 0.3);
- c.lineTo(dx + hw * 0.25, h * 0.3);
- c.moveTo(dx - hw * 0.25, h * 0.5);
- c.lineTo(dx + hw * 0.25, h * 0.5);
- c.moveTo(dx - hw * 0.25, h * 0.7);
- c.lineTo(dx + hw * 0.25, h * 0.7);
- c.stroke();
- }
- else if (handleStyle == 'circle')
- {
- c.setFillColor(strokeColor);
- c.ellipse(dx - barH, 0, 2 * barH, 2 * barH);
- c.fill();
- }
- };
- mxCellRenderer.registerShape(mxShapeBootstrapRangeInput.prototype.cst.RANGE_INPUT, mxShapeBootstrapRangeInput);
- mxShapeBootstrapRangeInput.prototype.constraints = null;
- Graph.handleFactory[mxShapeBootstrapRangeInput.prototype.cst.RANGE_INPUT] = function(state)
- {
- var handles = [Graph.createHandle(state, ['dx'], function(bounds)
- {
- var dx = Math.max(0, Math.min(1, parseFloat(mxUtils.getValue(this.state.style, 'dx', this.dx))));
- return new mxPoint(bounds.x + dx * bounds.width, bounds.y + bounds.height / 2);
- }, function(bounds, pt)
- {
- this.state.style['dx'] = Math.round(100 * Math.max(0, Math.min(1, (pt.x - bounds.x) / bounds.width))) / 100;
- })];
- return handles;
- }
- //**********************************************************************************************************************************************************
- //Switch
- //**********************************************************************************************************************************************************
- /**
- * Extends mxShape.
- */
- function mxShapeBootstrapSwitch(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(mxShapeBootstrapSwitch, mxShape);
- mxShapeBootstrapSwitch.prototype.customProperties = [
- {name: 'buttonState', dispName: 'Button State', type: 'bool', defVal : true},
- {name: 'onStrokeColor', dispName: 'On Stroke Color', type: 'color'},
- {name: 'onFillColor', dispName: 'On Fill Color', type: 'color'},
- ];
- mxShapeBootstrapSwitch.prototype.cst = {
- SHAPE_SWITCH : 'mxgraph.bootstrap.switch'
- };
- /**
- * Function: paintVertexShape
- *
- * Paints the vertex shape.
- */
- mxShapeBootstrapSwitch.prototype.paintVertexShape = function(c, x, y, w, h)
- {
- c.translate(x, y);
- w = Math.max(w, 2 * h);
- var state = mxUtils.getValue(this.style, 'buttonState', true);
- this.background(c, x, y, w, h, state);
- c.setShadow(false);
- this.foreground(c, x, y, w, h, state);
- };
- mxShapeBootstrapSwitch.prototype.background = function(c, x, y, w, h, state)
- {
- if (state == true)
- {
- c.setStrokeColor(mxUtils.getValue(this.style, 'onStrokeColor', '#ffffff'));
- c.setFillColor(mxUtils.getValue(this.style, 'onFillColor', '#0085FC'));
-
- c.roundrect(0, 0, w, h, h * 0.5, h * 0.5);
- c.fill();
- }
- else
- {
- c.roundrect(0, 0, w, h, h * 0.5, h * 0.5);
- c.fillAndStroke();
- }
- };
- mxShapeBootstrapSwitch.prototype.foreground = function(c, x, y, w, h, state)
- {
- var r = h * 0.8;
-
- if (state == true)
- {
- c.setFillColor(mxUtils.getValue(this.style, 'onStrokeColor', '#ffffff'));
- c.ellipse(w - h * 0.9, h * 0.1, r, r);
- c.fill();
- }
- else
- {
- c.setFillColor(mxUtils.getValue(this.style, 'strokeColor', '#000000'));
- c.ellipse(h * 0.1, h * 0.1, r, r);
- c.fill();
- }
- };
- mxCellRenderer.registerShape(mxShapeBootstrapSwitch.prototype.cst.SHAPE_SWITCH, mxShapeBootstrapSwitch);
- //**********************************************************************************************************************************************************
- //X
- //**********************************************************************************************************************************************************
- /**
- * Extends mxShape.
- */
- function mxShapeBootstrapX(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(mxShapeBootstrapX, mxShape);
- mxShapeBootstrapX.prototype.cst = {
- SHAPE_X : 'mxgraph.bootstrap.x'
- };
- /**
- * Function: paintVertexShape
- *
- * Paints the vertex shape.
- */
- mxShapeBootstrapX.prototype.paintVertexShape = function(c, x, y, w, h)
- {
- c.translate(x, y);
-
- c.begin();
- c.moveTo(0, 0);
- c.lineTo(w, h);
- c.moveTo(w, 0);
- c.lineTo(0, h);
- c.stroke();
- };
- mxCellRenderer.registerShape(mxShapeBootstrapX.prototype.cst.SHAPE_X, mxShapeBootstrapX);
- //**********************************************************************************************************************************************************
- //Popover
- //**********************************************************************************************************************************************************
- /**
- * Extends mxShape.
- */
- function mxShapeInfographicPopover(bounds, fill, stroke, strokewidth)
- {
- mxShape.call(this);
- this.bounds = bounds;
- this.fill = fill;
- this.stroke = stroke;
- this.strokewidth = (strokewidth != null) ? strokewidth : 1;
- this.dx = 0.5;
- this.dy = 0.5;
- };
- /**
- * Extends mxShape.
- */
- mxUtils.extend(mxShapeInfographicPopover, mxActor);
- mxShapeInfographicPopover.prototype.cst = {SHAPE_POPOVER : 'mxgraph.bootstrap.popover'};
- mxShapeInfographicPopover.prototype.customProperties = [
- {name: 'rSize', dispName: 'Arc Size', type: 'float', min:0, defVal:10},
- {name:'dx', dispName:'Callout Position', min:0, defVal: 100},
- {name:'dy', dispName:'Callout Size', min:0, defVal: 30}
- ];
- /**
- * Function: paintVertexShape
- *
- * Paints the vertex shape.
- */
- mxShapeInfographicPopover.prototype.paintVertexShape = function(c, x, y, w, h)
- {
- c.translate(x, y);
- var r = parseInt(mxUtils.getValue(this.style, 'rSize', '10'));
- var dx = Math.max(0, Math.min(w, parseFloat(mxUtils.getValue(this.style, 'dx', this.dx))));
- var dy = Math.max(0, Math.min(h, parseFloat(mxUtils.getValue(this.style, 'dy', this.dy))));
- var x1 = Math.max(dx - dy, 0);
- var x2 = Math.min(dx + dy, w);
-
- c.begin();
- c.moveTo(r, 0);
- c.lineTo(w - r, 0);
- c.arcTo(r, r, 0, 0, 1, w, r);
- c.lineTo(w, h - dy - r);
- c.arcTo(r, r, 0, 0, 1, w - r, h - dy);
- c.lineTo(x2, h - dy);
- c.lineTo(dx, h);
- c.lineTo(x1, h - dy);
- c.lineTo(r, h - dy);
- c.arcTo(r, r, 0, 0, 1, 0, h - dy - r);
- c.lineTo(0, r);
- c.arcTo(r, r, 0, 0, 1, r, 0);
- c.close();
- c.fillAndStroke();
- };
- mxCellRenderer.registerShape(mxShapeInfographicPopover.prototype.cst.SHAPE_POPOVER, mxShapeInfographicPopover);
- mxShapeInfographicPopover.prototype.constraints = null;
- Graph.handleFactory[mxShapeInfographicPopover.prototype.cst.SHAPE_POPOVER] = function(state)
- {
- var handles = [Graph.createHandle(state, ['dx', 'dy'], function(bounds)
- {
- var dx = Math.max(0, Math.min(bounds.width, parseFloat(mxUtils.getValue(this.state.style, 'dx', this.dx))));
- var dy = Math.max(0, Math.min(bounds.height, parseFloat(mxUtils.getValue(this.state.style, 'dy', this.dy))));
- return new mxPoint(bounds.x + dx, bounds.y + bounds.height - dy);
- }, function(bounds, pt)
- {
- this.state.style['dx'] = Math.round(100 * Math.max(0, Math.min(bounds.width, pt.x - bounds.x))) / 100;
- this.state.style['dy'] = Math.round(100 * Math.max(0, Math.min(bounds.height, bounds.y + bounds.height - pt.y))) / 100;
- })];
-
- return handles;
- };
- mxShapeInfographicPopover.prototype.getConstraints = function(style, w, h)
- {
- var constr = [];
- var dx = Math.max(0, Math.min(w, parseFloat(mxUtils.getValue(this.style, 'dx', this.dx))));
- var dy = Math.max(0, Math.min(h, parseFloat(mxUtils.getValue(this.style, 'dy', this.dy))));
- var x1 = Math.max(dx - dy * 0.35, 0);
- var x2 = Math.min(dx + dy * 0.35, w);
- constr.push(new mxConnectionConstraint(new mxPoint(0, 0), false));
- constr.push(new mxConnectionConstraint(new mxPoint(0.25, 0), false));
- constr.push(new mxConnectionConstraint(new mxPoint(0.5, 0), false));
- constr.push(new mxConnectionConstraint(new mxPoint(0.75, 0), false));
- constr.push(new mxConnectionConstraint(new mxPoint(1, 0), false));
- constr.push(new mxConnectionConstraint(new mxPoint(0, 0), false, null, w, (h - dy) * 0.5));
- constr.push(new mxConnectionConstraint(new mxPoint(0, 0), false, null, w, h - dy));
- constr.push(new mxConnectionConstraint(new mxPoint(0.75, 0), false, null, 0, h - dy));
- constr.push(new mxConnectionConstraint(new mxPoint(0.25, 0), false, null, 0, h - dy));
- constr.push(new mxConnectionConstraint(new mxPoint(0, 0), false, null, dx, h));
- constr.push(new mxConnectionConstraint(new mxPoint(0, 0), false, null, 0, h - dy));
- return (constr);
- };
|