123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620162116221623162416251626162716281629163016311632163316341635163616371638163916401641164216431644164516461647164816491650165116521653 |
- /**
- * $Id: mxIOS7Ui.js,v 1.6 2013/12/04 16:48:54 mate Exp $
- * Copyright (c) 2006-2013, JGraph Ltd
- */
- var mxIOS7C =
- {
- MAIN_TEXT : 'mainText',
- SUB_TEXT : 'subText',
- TEXT_COLOR : 'textColor',
- TEXT_SIZE : 'textSize',
- BAR_POS : 'barPos',
- BUTTON_TEXT : 'buttonText',
- BUTTON_STATE : 'buttonState',
- SELECTED : '+', //has to be one character long
- STATE_ON : 'on',
- STATE_OFF : 'off',
- GRID_SIZE : 'gridSize',
-
- SHAPE_IOS7_APP_BAR : 'mxgraph.ios7ui.appBar',
- SHAPE_IOS7_ON_OFF_BUTTON : 'mxgraph.ios7ui.onOffButton',
- SHAPE_IOS7_SLIDER : 'mxgraph.ios7ui.slider',
- SHAPE_IOS7_DOWNLOAD_BAR : 'mxgraph.ios7ui.downloadBar',
- SHAPE_IOS7_ICON : 'mxgraph.ios7ui.icon',
- SHAPE_IOS7_HOR_BUTTON_BAR : 'mxgraph.ios7ui.horButtonBar',
- SHAPE_IOS7_PAGE_CONTROL : 'mxgraph.ios7ui.pageControl',
- SHAPE_IOS7_EXPAND : 'mxgraph.ios7ui.expand',
- SHAPE_IOS7_ICON_GRID : 'mxgraph.ios7ui.iconGrid',
- SHAPE_IOS7_PHONE : 'mxgraph.ios7ui.phone',
- SHAPE_IOS7_SEARCH_BOX : 'mxgraph.ios7ui.searchBox',
- SHAPE_IOS7_URL : 'mxgraph.ios7ui.url',
- SHAPE_IOS7_ACTION_DIALOG : 'mxgraph.ios7ui.actionDialog',
-
- STYLE_FILLCOLOR2 : 'fillColor2',
- STYLE_FILLCOLOR3 : 'fillColor3',
- STYLE_TEXTCOLOR : 'textColor',
- STYLE_TEXTCOLOR2 : 'textColor2',
- STYLE_STROKECOLOR2 : 'strokeColor2',
- STYLE_STROKECOLOR3 : 'strokeColor3',
- STYLE_TEXTSIZE : 'textSize'
- };
- //**********************************************************************************************************************************************************
- //iOS7 Application Bar
- //**********************************************************************************************************************************************************
- /**
- * Extends mxShape.
- */
- function mxShapeIOS7AppBar(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(mxShapeIOS7AppBar, mxShape);
- /**
- * Function: paintVertexShape
- *
- * Paints the vertex shape.
- */
- mxShapeIOS7AppBar.prototype.paintVertexShape = function(c, x, y, w, h)
- {
- c.translate(x, y);
- this.background(c, x, y, w, h);
- c.setShadow(false);
- this.foreground(c, x, y, w, h);
- };
- mxShapeIOS7AppBar.prototype.background = function(c, x, y, w, h)
- {
- c.rect(0, 0, w, h);
- c.fill();
- };
- mxShapeIOS7AppBar.prototype.foreground = function(c, x, y, w, h)
- {
- c.setFillColor(mxUtils.getValue(this.style, mxIOS7C.STYLE_FILLCOLOR2, '#222222'));
- c.ellipse(5, h * 0.5 - 1.5, 3, 3);
- c.fill();
- c.ellipse(9, h * 0.5 - 1.5, 3, 3);
- c.fill();
- c.ellipse(13, h * 0.5 - 1.5, 3, 3);
- c.fill();
- c.ellipse(17, h * 0.5 - 1.5, 3, 3);
- c.fill();
- c.ellipse(21, h * 0.5 - 1.5, 3, 3);
- c.fill();
-
- c.ellipse(54, h * 0.5 + 2, 2, 2);
- c.fillAndStroke();
-
- c.setStrokeWidth(2);
- c.begin();
- c.moveTo(52, h * 0.5 + 1);
- c.arcTo(3.5, 3.5, 0, 0, 1, 58, h * 0.5 + 1);
- c.stroke();
-
- c.begin();
- c.moveTo(50, h * 0.5 - 1);
- c.arcTo(6, 6, 0, 0, 1, 60, h * 0.5 - 1);
- c.stroke();
-
- c.begin();
- c.moveTo(w - 19, h * 0.5 - 2);
- c.lineTo(w - 6, h * 0.5 - 2);
- c.lineTo(w - 6, h * 0.5 + 2);
- c.lineTo(w - 19, h * 0.5 + 2);
- c.close();
- c.fill();
- c.setStrokeWidth(1);
- c.begin();
- c.moveTo(w - 44, h * 0.5 - 2.5);
- c.lineTo(w - 36, h * 0.5 + 2.5);
- c.lineTo(w - 40, h * 0.5 + 5);
- c.lineTo(w - 40, h * 0.5 - 5);
- c.lineTo(w - 36, h * 0.5 - 2.5);
- c.lineTo(w - 44, h * 0.5 + 2.5);
- c.stroke();
-
- c.begin();
- c.moveTo(w - 20, h * 0.5 - 3);
- c.lineTo(w - 5, h * 0.5 - 3);
- c.lineTo(w - 5, h * 0.5 - 1);
- c.lineTo(w - 3.5, h * 0.5 - 1);
- c.lineTo(w - 3.5, h * 0.5 + 1);
- c.lineTo(w - 5, h * 0.5 + 1);
- c.lineTo(w - 5, h * 0.5 + 3);
- c.lineTo(w - 20, h * 0.5 + 3);
- c.close();
- c.stroke();
- };
- mxCellRenderer.prototype.defaultShapes[mxIOS7C.SHAPE_IOS7_APP_BAR] = mxShapeIOS7AppBar;
- //**********************************************************************************************************************************************************
- //On-Off Button
- //**********************************************************************************************************************************************************
- /**
- * Extends mxShape.
- */
- function mxShapeIOS7OnOffButton(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(mxShapeIOS7OnOffButton, mxShape);
- /**
- * Function: paintVertexShape
- *
- * Paints the vertex shape.
- */
- mxShapeIOS7OnOffButton.prototype.paintVertexShape = function(c, x, y, w, h)
- {
- c.translate(x, y);
- w = Math.max(w, 2 * h);
- var state = mxUtils.getValue(this.style, mxIOS7C.BUTTON_STATE, mxIOS7C.STATE_ON);
- this.background(c, x, y, w, h, state);
- c.setShadow(false);
- this.foreground(c, x, y, w, h, state);
- };
- mxShapeIOS7OnOffButton.prototype.background = function(c, x, y, w, h, state)
- {
- if (state === mxIOS7C.STATE_ON)
- {
- c.roundrect(0, 0, w, h, h * 0.5, h * 0.5);
- c.fillAndStroke();
- }
- else if (state === mxIOS7C.STATE_OFF)
- {
- c.setStrokeColor(mxUtils.getValue(this.style, mxIOS7C.STYLE_STROKECOLOR2, '#aaaaaa'));
- c.setFillColor(mxUtils.getValue(this.style, mxIOS7C.STYLE_FILLCOLOR2, '#ffffff'));
- c.roundrect(0, 0, w, h, h * 0.5, h * 0.5);
- c.fillAndStroke();
- }
- };
- mxShapeIOS7OnOffButton.prototype.foreground = function(c, x, y, w, h, state)
- {
- c.setFillColor('#ffffff');
- if (state === mxIOS7C.STATE_ON)
- {
- c.ellipse(w - h + 1, 1, h - 2, h - 2);
- c.fill();
- }
- else
- {
- c.ellipse(0, 0, h, h);
- c.stroke();
- }
- };
- mxCellRenderer.prototype.defaultShapes[mxIOS7C.SHAPE_IOS7_ON_OFF_BUTTON] = mxShapeIOS7OnOffButton;
- //**********************************************************************************************************************************************************
- //Slider
- //**********************************************************************************************************************************************************
- /**
- * Extends mxShape.
- */
- function mxShapeIOS7Slider(bounds, fill, stroke, strokewidth)
- {
- mxShape.call(this);
- this.bounds = bounds;
- this.fill = fill;
- this.stroke = stroke;
- this.strokewidth = (strokewidth != null) ? strokewidth : 1;
- this.barPos = 80;
- };
- /**
- * Extends mxShape.
- */
- mxUtils.extend(mxShapeIOS7Slider, mxShape);
- /**
- * Function: paintVertexShape
- *
- * Paints the vertex shape.
- */
- mxShapeIOS7Slider.prototype.paintVertexShape = function(c, x, y, w, h)
- {
- c.translate(x, y);
- c.setShadow(false);
- this.foreground(c, w, h);
- };
- mxShapeIOS7Slider.prototype.foreground = function(c, w, h)
- {
- c.setStrokeWidth(2);
-
- c.begin();
- c.moveTo(0, h * 0.5);
- c.lineTo(w, h * 0.5);
- c.stroke();
- var barPos = mxUtils.getValue(this.style, mxIOS7C.BAR_POS, '80');
- barPos = Math.min(barPos, 100);
- barPos = Math.max(barPos, 0);
- var deadzone = 0;
- var virRange = w - 2 * deadzone;
- var truePos = deadzone + virRange * barPos / 100;
- c.setStrokeColor(mxUtils.getValue(this.style, mxIOS7C.STYLE_STROKECOLOR2, '#a0a0a0'));
- c.ellipse(truePos - 5, h * 0.5 - 5, 10, 10);
- c.fillAndStroke();
- };
- mxCellRenderer.prototype.defaultShapes[mxIOS7C.SHAPE_IOS7_SLIDER] = mxShapeIOS7Slider;
- Graph.handleFactory[mxIOS7C.SHAPE_IOS7_SLIDER] = function(state)
- {
- var handles = [Graph.createHandle(state, ['barPos'], function(bounds)
- {
- var barPos = Math.max(0, Math.min(100, parseFloat(mxUtils.getValue(this.state.style, 'barPos', this.barPos))));
- return new mxPoint(bounds.x + barPos / 100 * bounds.width, bounds.y + bounds.height / 2);
- }, function(bounds, pt)
- {
- this.state.style['barPos'] = Math.round(1000 * Math.max(0, Math.min(100, (pt.x - bounds.x) * 100 / bounds.width))) / 1000;
- })];
- return handles;
- }
- //**********************************************************************************************************************************************************
- //Download Bar
- //**********************************************************************************************************************************************************
- /**
- * Extends mxShape.
- */
- function mxShapeIOS7DownloadBar(bounds, fill, stroke, strokewidth)
- {
- mxShape.call(this);
- this.bounds = bounds;
- this.fill = fill;
- this.stroke = stroke;
- this.strokewidth = (strokewidth != null) ? strokewidth : 1;
- this.barPos = 80;
- };
- /**
- * Extends mxShape.
- */
- mxUtils.extend(mxShapeIOS7DownloadBar, mxShape);
- /**
- * Function: paintVertexShape
- *
- * Paints the vertex shape.
- */
- mxShapeIOS7DownloadBar.prototype.paintVertexShape = function(c, x, y, w, h)
- {
- c.translate(x, y);
- this.foreground(c, w, h);
- };
- mxShapeIOS7DownloadBar.prototype.foreground = function(c, w, h)
- {
- var fieldText = mxUtils.getValue(this.style, mxIOS7C.BUTTON_TEXT, '');
- c.setFontStyle(mxConstants.FONT_BOLD);
- c.text(w * 0.5, h * 0.2, 0, 0, fieldText, mxConstants.ALIGN_CENTER, mxConstants.ALIGN_MIDDLE, 0, null, 0, 0, 0);
- var barPos = mxUtils.getValue(this.style, mxIOS7C.BAR_POS, '80');
- barPos = Math.min(barPos, 100);
- barPos = Math.max(barPos, 0);
- var truePos = w * barPos / 100;
- c.setStrokeWidth(2);
- c.setStrokeColor(mxUtils.getValue(this.style, mxConstants.STYLE_FILLCOLOR, ''));
- c.begin();
- c.moveTo(0, h * 0.5);
- c.lineTo(w, h * 0.5);
- c.stroke();
- c.setStrokeColor(mxUtils.getValue(this.style, mxConstants.STYLE_STROKECOLOR, ''));
- c.begin();
- c.moveTo(0, h * 0.5);
- c.lineTo(truePos, h * 0.5);
- c.stroke();
- };
- mxCellRenderer.prototype.defaultShapes[mxIOS7C.SHAPE_IOS7_DOWNLOAD_BAR] = mxShapeIOS7DownloadBar;
- Graph.handleFactory[mxIOS7C.SHAPE_IOS7_DOWNLOAD_BAR] = function(state)
- {
- var handles = [Graph.createHandle(state, ['barPos'], function(bounds)
- {
- var barPos = Math.max(0, Math.min(100, parseFloat(mxUtils.getValue(this.state.style, 'barPos', this.barPos))));
- return new mxPoint(bounds.x + barPos / 100 * bounds.width, bounds.y + bounds.height / 2);
- }, function(bounds, pt)
- {
- this.state.style['barPos'] = Math.round(1000 * Math.max(0, Math.min(100, (pt.x - bounds.x) * 100 / bounds.width))) / 1000;
- })];
- return handles;
- }
- //**********************************************************************************************************************************************************
- //Icon
- //**********************************************************************************************************************************************************
- /**
- * Extends mxShape.
- */
- function mxShapeIOS7Icon(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(mxShapeIOS7Icon, mxShape);
- /**
- * Function: paintVertexShape
- *
- * Paints the vertex shape.
- */
- mxShapeIOS7Icon.prototype.paintVertexShape = function(c, x, y, w, h)
- {
- c.translate(x, y);
- this.foreground(c, w, h);
- };
- mxShapeIOS7Icon.prototype.foreground = function(c, w, h)
- {
- c.setGradient('#00D0F0', '#0080F0', w * 0.325, 0, w * 0.675, h * 0.5, mxConstants.DIRECTION_SOUTH, 1, 1);
- c.roundrect(0, 0, w, h, w * 0.1, h * 0.1);
- c.fill();
-
- var fieldText = mxUtils.getValue(this.style, mxIOS7C.BUTTON_TEXT, '');
- c.setFontColor('#ffffff');
- c.setFontStyle(mxConstants.FONT_BOLD);
- c.setFontSize(8);
- c.text(w * 0.5, h * 0.5, 0, 0, fieldText, mxConstants.ALIGN_CENTER, mxConstants.ALIGN_MIDDLE, 0, null, 0, 0, 0);
- };
- mxCellRenderer.prototype.defaultShapes[mxIOS7C.SHAPE_IOS7_ICON] = mxShapeIOS7Icon;
- //**********************************************************************************************************************************************************
- //Horizontal Button Bar
- //**********************************************************************************************************************************************************
- /**
- * Extends mxShape.
- */
- function mxShapeIOS7horButtonBar(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(mxShapeIOS7horButtonBar, mxShape);
- /**
- * Function: paintVertexShape
- *
- * Paints the vertex shape.
- */
- mxShapeIOS7horButtonBar.prototype.paintVertexShape = function(c, x, y, w, h)
- {
- var textStrings = mxUtils.getValue(this.style, mxIOS7C.BUTTON_TEXT, '+Button 1, Button 2, Button 3').toString().split(',');
- var fontColor = mxUtils.getValue(this.style, mxIOS7C.STYLE_TEXTCOLOR, '#666666');
- var selectedFontColor = mxUtils.getValue(this.style, mxIOS7C.STYLE_TEXTCOLOR2, '#ffffff');
- var fontSize = mxUtils.getValue(this.style, mxConstants.STYLE_FONTSIZE, '8.5').toString();
- var frameColor = mxUtils.getValue(this.style, mxConstants.STYLE_STROKECOLOR, '#666666');
- var bgColor = mxUtils.getValue(this.style, mxConstants.STYLE_FILLCOLOR, '#ffffff');
- var selectedFillColor = mxUtils.getValue(this.style, mxIOS7C.STYLE_FILLCOLOR2, '#008cff');
- var buttonNum = textStrings.length;
- var buttonWidths = new Array(buttonNum);
- var buttonTotalWidth = 0;
- var selectedButton = -1;
- var rSize = 2.5; //rounding size
- var labelOffset = 2.5;
- for (var i = 0; i < buttonNum; i++)
- {
- var buttonText = textStrings[i];
- if(buttonText.charAt(0) === mxIOS7C.SELECTED)
- {
- buttonText = textStrings[i].substring(1);
- selectedButton = i;
- }
- buttonWidths[i] = mxUtils.getSizeForString(buttonText, fontSize, mxConstants.DEFAULT_FONTFAMILY).width;
- buttonTotalWidth += buttonWidths[i];
- }
- var trueH = Math.max(h, fontSize * 1.5, 10);
- var minW = 2 * labelOffset * buttonNum + buttonTotalWidth;
- var trueW = Math.max(w, minW);
- c.translate(x, y);
- this.background(c, trueW, trueH, rSize, buttonNum, buttonWidths, labelOffset, minW, frameColor, bgColor, selectedFillColor, selectedButton);
- c.setShadow(false);
- var currWidth = 0;
- for (var i = 0; i < buttonNum; i++)
- {
- if (i === selectedButton)
- {
- c.setFontColor(selectedFontColor);
- }
- else
- {
- c.setFontColor(fontColor);
- }
- currWidth = currWidth + labelOffset;
- this.buttonText(c, currWidth, trueH, textStrings[i], buttonWidths[i], fontSize, minW, trueW);
- currWidth = currWidth + buttonWidths[i] + labelOffset;
- }
- };
- mxShapeIOS7horButtonBar.prototype.background = function(c, w, h, rSize, buttonNum, buttonWidths, labelOffset, minW, frameColor, bgColor, selectedFillColor, selectedButton)
- {
- c.begin();
- //draw the frame
- c.setStrokeColor(frameColor);
- c.setFillColor(bgColor);
- 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();
- //draw the button separators
- c.setStrokeColor(frameColor);
- c.begin();
- for (var i = 1; i < buttonNum; i++)
- {
- if (i !== selectedButton && i !== (selectedButton + 1))
- {
- var currWidth = 0;
- for (var j = 0; j < i; j++)
- {
- currWidth += buttonWidths[j] + 2 * labelOffset;
- }
- currWidth = currWidth * w / minW;
- c.moveTo(currWidth, 0);
- c.lineTo(currWidth, h);
- }
- }
- c.stroke();
- //draw the selected button
- var buttonLeft = 0;
- c.setStrokeColor(mxConstants.NONE);
- for (var i = 0; i < selectedButton; i++)
- {
- buttonLeft += buttonWidths[i] + 2 * labelOffset;
- }
- buttonLeft = buttonLeft * w / minW;
- var buttonRight = (buttonWidths[selectedButton] + 2 * labelOffset) * w / minW;
- buttonRight += buttonLeft;
- c.setFillColor('#0080F0');
- if (selectedButton === 0)
- {
- c.begin();
- // we draw a path for the first button
- c.moveTo(0, rSize);
- c.arcTo(rSize, rSize, 0, 0, 1, rSize, 0);
- c.lineTo(buttonRight, 0);
- c.lineTo(buttonRight, h);
- c.lineTo(rSize, h);
- c.arcTo(rSize, rSize, 0, 0, 1, 0, h - rSize);
- c.close();
- c.fill();
- }
- else if (selectedButton === buttonNum - 1)
- {
- c.begin();
- // we draw a path for the last button
- c.moveTo(buttonLeft, 0);
- c.lineTo(buttonRight - rSize, 0);
- c.arcTo(rSize, rSize, 0, 0, 1, buttonRight, rSize);
- c.lineTo(buttonRight, h - rSize);
- c.arcTo(rSize, rSize, 0, 0, 1, buttonRight - rSize, h);
- c.lineTo(buttonLeft, h);
- c.close();
- c.fill();
- }
- else if (selectedButton !== -1)
- {
- c.begin();
- // we draw a path rectangle for one of the buttons in the middle
- c.moveTo(buttonLeft, 0);
- c.lineTo(buttonRight, 0);
- c.lineTo(buttonRight, h);
- c.lineTo(buttonLeft, h);
- c.close();
- c.fill();
- }
- //draw the frame again, to achieve a nicer effect
- c.setStrokeColor(frameColor);
- c.setFillColor(bgColor);
- 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();
- };
- mxShapeIOS7horButtonBar.prototype.buttonText = function(c, w, h, textString, buttonWidth, fontSize, minW, trueW)
- {
- if(textString.charAt(0) === mxIOS7C.SELECTED)
- {
- textString = textString.substring(1);
- }
- c.begin();
- c.setFontSize(fontSize);
- c.text((w + buttonWidth * 0.5) * trueW / minW, h * 0.5, 0, 0, textString, mxConstants.ALIGN_CENTER, mxConstants.ALIGN_MIDDLE, 0, null, 0, 0, 0);
- };
- mxCellRenderer.prototype.defaultShapes[mxIOS7C.SHAPE_IOS7_HOR_BUTTON_BAR] = mxShapeIOS7horButtonBar;
- //**********************************************************************************************************************************************************
- //Page Control
- //**********************************************************************************************************************************************************
- /**
- * Extends mxShape.
- */
- function mxShapeIOS7pageControl(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(mxShapeIOS7pageControl, mxShape);
- /**
- * Function: paintVertexShape
- *
- * Paints the vertex shape.
- */
- mxShapeIOS7pageControl.prototype.paintVertexShape = function(c, x, y, w, h)
- {
- c.translate(x, y);
- var fillColor = mxUtils.getValue(this.style, mxConstants.STYLE_FILLCOLOR, '#000000');
- var strokeColor = mxUtils.getValue(this.style, mxConstants.STYLE_STROKECOLOR, '#000000');
- var rSize = Math.min(h * 0.5, w * 0.05);
- c.setFillColor(strokeColor);
- c.ellipse(0, h * 0.5 - rSize, 2 * rSize, 2 * rSize);
- c.fill();
- c.ellipse(w * 0.25 - rSize * 0.5, h * 0.5 - rSize, 2 * rSize, 2 * rSize);
- c.fill();
- c.ellipse(w * 0.5 - rSize, h * 0.5 - rSize, 2 * rSize, 2 * rSize);
- c.fill();
- c.ellipse(w * 0.75 - rSize * 1.5, h * 0.5 - rSize, 2 * rSize, 2 * rSize);
- c.fill();
- c.setFillColor(fillColor);
- c.ellipse(w - 2 * rSize, h * 0.5 - rSize, 2 * rSize, 2 * rSize);
- c.fill();
- };
- mxCellRenderer.prototype.defaultShapes[mxIOS7C.SHAPE_IOS7_PAGE_CONTROL] = mxShapeIOS7pageControl;
- //**********************************************************************************************************************************************************
- //Icon Grid
- //**********************************************************************************************************************************************************
- /**
- * Extends mxShape.
- */
- function mxShapeIOS7iconGrid(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(mxShapeIOS7iconGrid, mxShape);
- /**
- * Function: paintVertexShape
- *
- * Paints the vertex shape.
- */
- mxShapeIOS7iconGrid.prototype.paintVertexShape = function(c, x, y, w, h)
- {
- c.translate(x, y);
- var gridSize = mxUtils.getValue(this.style, mxIOS7C.GRID_SIZE, '4,7').toString().split(',');
- var boxSizeX = w / (parseInt(gridSize[0],10) + (gridSize[0]-1) * 0.1);
- var boxSizeY = h / (parseInt(gridSize[1],10) + (gridSize[1]-1) * 0.1);
-
- for (var i = 0; i < gridSize[0]; i++)
- {
- for (var j = 0; j < gridSize[1]; j++)
- {
- c.rect(boxSizeX * 1.1 * i, boxSizeY * 1.1 * j, boxSizeX, boxSizeY);
- c.fill();
- }
- }
- };
- mxCellRenderer.prototype.defaultShapes[mxIOS7C.SHAPE_IOS7_ICON_GRID] = mxShapeIOS7iconGrid;
- //**********************************************************************************************************************************************************
- //iPhone Vertical
- //**********************************************************************************************************************************************************
- /**
- * Extends mxShape.
- */
- function mxShapeIOS7phone(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(mxShapeIOS7phone, mxShape);
- /**
- * Function: paintVertexShape
- *
- * Paints the vertex shape.
- */
- mxShapeIOS7phone.prototype.paintVertexShape = function(c, x, y, w, h)
- {
- c.translate(x, y);
- var rSize = 25;
- c.roundrect(0, 0, w, h, rSize, rSize);
- c.fillAndStroke();
-
- c.setShadow(false);
-
- this.foreground(c, x, y, w, h, rSize);
- };
- mxShapeIOS7phone.prototype.foreground = function(c, x, y, w, h, rSize)
- {
- c.rect(w * 0.0625, h * 0.15, w * 0.875, h * 0.7);
- c.stroke();
- c.ellipse(w * 0.4875, h * 0.04125, w * 0.025, h * 0.0125);
- c.stroke();
- c.roundrect(w * 0.375, h * 0.075, w * 0.25, h * 0.01875, w * 0.02, h * 0.01);
- c.stroke();
- c.ellipse(w * 0.4, h * 0.875, w * 0.2, h * 0.1);
- c.stroke();
- c.roundrect(w * 0.4575, h * 0.905, w * 0.085, h * 0.04375, h * 0.00625, h * 0.00625);
- c.stroke();
- };
- mxCellRenderer.prototype.defaultShapes[mxIOS7C.SHAPE_IOS7_PHONE] = mxShapeIOS7phone;
- //**********************************************************************************************************************************************************
- //Search Box
- //**********************************************************************************************************************************************************
- /**
- * Extends mxShape.
- */
- function mxShapeIOS7searchBox(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(mxShapeIOS7searchBox, mxShape);
- /**
- * Function: paintVertexShape
- *
- * Paints the vertex shape.
- */
- mxShapeIOS7searchBox.prototype.paintVertexShape = function(c, x, y, w, h)
- {
- c.translate(x, y);
- this.background(c, w, h);
- c.setShadow(false);
- this.foreground(c, w, h);
- };
- mxShapeIOS7searchBox.prototype.background = function(c, w, h)
- {
- c.rect(0, 0, w, h);
- c.fill();
- };
- mxShapeIOS7searchBox.prototype.foreground = function(c, w, h)
- {
- var mainText = mxUtils.getValue(this.style, mxIOS7C.BUTTON_TEXT, 'Search');
- var fontColor = mxUtils.getValue(this.style, mxIOS7C.STYLE_TEXTCOLOR, '#666666');
- var strokeColor2 = mxUtils.getValue(this.style, mxIOS7C.STYLE_STROKECOLOR2, '#008cff');
- var fontSize = mxUtils.getValue(this.style, mxIOS7C.STYLE_TEXTSIZE, '17');
- var rSize = Math.min(w, h) * 0.1;
- c.setFillColor('#ffffff');
- c.roundrect(w * 0.05, h * 0.15, w * 0.5, h * 0.7, rSize, rSize);
- c.fillAndStroke();
-
- c.setFontColor(fontColor);
- c.setFontSize(Math.min(h * 0.7, w * 0.1));
- c.text(5, h * 0.5, 0, 0, mainText, mxConstants.ALIGN_LEFT, mxConstants.ALIGN_MIDDLE, 0, null, 0, 0, 0);
- c.setStrokeColor(strokeColor2);
- c.ellipse(w * 0.05 + 3, h * 0.5 - 3, 4, 4);
- c.stroke();
- c.begin();
- c.moveTo(w * 0.05 + 8, h * 0.5 + 3.5);
- c.lineTo(w * 0.05 + 6, h * 0.5 + 0.5);
- c.stroke();
- };
- mxCellRenderer.prototype.defaultShapes[mxIOS7C.SHAPE_IOS7_SEARCH_BOX] = mxShapeIOS7searchBox;
- //**********************************************************************************************************************************************************
- //URL
- //**********************************************************************************************************************************************************
- /**
- * Extends mxShape.
- */
- function mxShapeIOS7URL(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(mxShapeIOS7URL, mxShape);
- /**
- * Function: paintVertexShape
- *
- * Paints the vertex shape.
- */
- mxShapeIOS7URL.prototype.paintVertexShape = function(c, x, y, w, h)
- {
- c.translate(x, y);
- this.background(c, w, h);
- c.setShadow(false);
- this.foreground(c, w, h);
- };
- mxShapeIOS7URL.prototype.background = function(c, w, h)
- {
- c.rect(0, 0, w, h);
- c.fill();
- };
- mxShapeIOS7URL.prototype.foreground = function(c, w, h)
- {
- var mainText = mxUtils.getValue(this.style, mxIOS7C.BUTTON_TEXT, 'draw.io');
- var fontColor = mxUtils.getValue(this.style, mxIOS7C.STYLE_TEXTCOLOR, '#666666');
- var strokeColor2 = mxUtils.getValue(this.style, mxIOS7C.STYLE_STROKECOLOR2, '#008cff');
- var fontSize = mxUtils.getValue(this.style, mxIOS7C.STYLE_TEXTSIZE, '17');
- var rSize = Math.min(w, h) * 0.1;
- c.setFillColor('#d8d8d8');
- c.roundrect(w * 0.05, h * 0.15, w * 0.9, h * 0.7, rSize, rSize);
- c.fill();
-
- c.setFontColor(fontColor);
- c.setFontSize(Math.min(h * 0.7, w * 0.1));
- c.text(w * 0.5, h * 0.5, 0, 0, mainText, mxConstants.ALIGN_LEFT, mxConstants.ALIGN_MIDDLE, 0, null, 0, 0, 0);
- c.setStrokeColor(strokeColor2);
- c.begin();
- c.moveTo(w * 0.95 - 5, h * 0.5);
- c.arcTo(3, 3, 0, 1, 1, w * 0.95 - 8, h * 0.5 - 3);
- c.stroke();
- c.setFillColor(strokeColor2);
- c.begin();
- c.moveTo(w * 0.95 - 8, h * 0.5 - 4);
- c.lineTo(w * 0.95 - 6, h * 0.5 - 3);
- c.lineTo(w * 0.95 - 8, h * 0.5 - 2);
- c.close();
- c.fillAndStroke();
- };
- mxCellRenderer.prototype.defaultShapes[mxIOS7C.SHAPE_IOS7_URL] = mxShapeIOS7URL;
- //**********************************************************************************************************************************************************
- //Action Dialog
- //**********************************************************************************************************************************************************
- /**
- * Extends mxShape.
- */
- function mxShapeIOS7Actiondialog(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(mxShapeIOS7Actiondialog, mxShape);
- /**
- * Function: paintVertexShape
- *
- * Paints the vertex shape.
- */
- mxShapeIOS7Actiondialog.prototype.paintVertexShape = function(c, x, y, w, h)
- {
- var mainText = mxUtils.getValue(this.style, mxIOS7C.MAIN_TEXT, 'Main Text');
- var subText = mxUtils.getValue(this.style, mxIOS7C.SUB_TEXT, 'Sub Text');
- var fontColor = mxUtils.getValue(this.style, mxIOS7C.STYLE_TEXTCOLOR, '#666666');
- var fontSize = mxUtils.getValue(this.style, mxIOS7C.STYLE_TEXTSIZE, '17');
- c.translate(x, y);
- this.background(c, x, y, w, h);
-
- c.setShadow(false);
-
- c.setFillColor('#e0e0e0');
- c.roundrect(w * 0.05, h * 0.1, w * 0.9, h * 0.35, w * 0.025, h * 0.05);
- c.fill();
- c.roundrect(w * 0.05, h * 0.55, w * 0.9, h * 0.35, w * 0.025, h * 0.05);
- c.fill();
-
- c.setFontStyle(mxConstants.FONT_BOLD);
- this.mainText(c, x, y, w, h, mainText, fontSize, fontColor);
- this.subText(c, x, y, w, h, subText, fontSize / 1.4, fontColor);
- };
- mxShapeIOS7Actiondialog.prototype.background = function(c, x, y, w, h)
- {
- c.rect(0, 0, w, h);
- c.fill();
- };
- mxShapeIOS7Actiondialog.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.4, 0, 0, text, mxConstants.ALIGN_CENTER, mxConstants.ALIGN_MIDDLE, 0, null, 0, 0, 0);
- };
- mxShapeIOS7Actiondialog.prototype.subText = function(c, x, y, w, h, text, fontSize, fontColor)
- {
- c.begin();
- c.setFontSize(fontSize);
- c.text(w * 0.5, h * 0.7, 0, 0, text, mxConstants.ALIGN_CENTER, mxConstants.ALIGN_MIDDLE, 0, null, 0, 0, 0);
- };
- mxCellRenderer.prototype.defaultShapes[mxIOS7C.SHAPE_IOS7_ACTION_DIALOG] = mxShapeIOS7Actiondialog;
- //**********************************************************************************************************************************************************
- //Anchor (a dummy shape without visuals used for anchoring)
- //**********************************************************************************************************************************************************
- /**
- * Extends mxShape.
- */
- function mxShapeIOS7Anchor(bounds, fill, stroke, strokewidth)
- {
- mxShape.call(this);
- this.bounds = bounds;
- };
- /**
- * Extends mxShape.
- */
- mxUtils.extend(mxShapeIOS7Anchor, mxShape);
- mxShapeIOS7Anchor.prototype.cst = {
- ANCHOR : 'mxgraph.ios7ui.anchor'
- };
- /**
- * Function: paintVertexShape
- *
- * Paints the vertex shape.
- */
- mxShapeIOS7Anchor.prototype.paintVertexShape = function(c, x, y, w, h)
- {
- };
- mxCellRenderer.registerShape(mxShapeIOS7Anchor.prototype.cst.ANCHOR, mxShapeIOS7Anchor);
- //**********************************************************************************************************************************************************
- //Rounded rectangle (adjustable rounding)
- //**********************************************************************************************************************************************************
- /**
- * Extends mxShape.
- */
- function mxShapeIOS7RRect(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(mxShapeIOS7RRect, mxShape);
- mxShapeIOS7RRect.prototype.cst = {
- RRECT : 'mxgraph.ios7ui.rrect',
- R_SIZE : 'rSize'
- };
- /**
- * Function: paintVertexShape
- *
- * Paints the vertex shape.
- */
- mxShapeIOS7RRect.prototype.paintVertexShape = function(c, x, y, w, h)
- {
- c.translate(x, y);
- var rSize = parseInt(mxUtils.getValue(this.style, mxShapeIOS7RRect.prototype.cst.R_SIZE, '10'));
- c.roundrect(0, 0, w, h, rSize);
- c.fillAndStroke();
- };
- mxCellRenderer.registerShape(mxShapeIOS7RRect.prototype.cst.RRECT, mxShapeIOS7RRect);
- //**********************************************************************************************************************************************************
- //Left Button
- //**********************************************************************************************************************************************************
- /**
- * Extends mxShape.
- */
- function mxShapeIOS7LeftButton(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(mxShapeIOS7LeftButton, mxShape);
- mxShapeIOS7LeftButton.prototype.cst = {
- LEFT_BUTTON : 'mxgraph.ios7ui.leftButton',
- R_SIZE : 'rSize'
- };
- /**
- * Function: paintVertexShape
- *
- * Paints the vertex shape.
- */
- mxShapeIOS7LeftButton.prototype.paintVertexShape = function(c, x, y, w, h)
- {
- c.translate(x, y);
- var rSize = parseInt(mxUtils.getValue(this.style, mxShapeIOS7LeftButton.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(mxShapeIOS7LeftButton.prototype.cst.LEFT_BUTTON, mxShapeIOS7LeftButton);
- //**********************************************************************************************************************************************************
- //Right Button
- //**********************************************************************************************************************************************************
- /**
- * Extends mxShape.
- */
- function mxShapeIOS7RightButton(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(mxShapeIOS7RightButton, mxShape);
- mxShapeIOS7RightButton.prototype.cst = {
- RIGHT_BUTTON : 'mxgraph.ios7ui.rightButton',
- R_SIZE : 'rSize'
- };
- /**
- * Function: paintVertexShape
- *
- * Paints the vertex shape.
- */
- mxShapeIOS7RightButton.prototype.paintVertexShape = function(c, x, y, w, h)
- {
- c.translate(x, y);
- var rSize = parseInt(mxUtils.getValue(this.style, mxShapeIOS7RightButton.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(mxShapeIOS7RightButton.prototype.cst.RIGHT_BUTTON, mxShapeIOS7RightButton);
- //**********************************************************************************************************************************************************
- //Top Button
- //**********************************************************************************************************************************************************
- /**
- * Extends mxShape.
- */
- function mxShapeIOS7TopButton(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(mxShapeIOS7TopButton, mxShape);
- mxShapeIOS7TopButton.prototype.cst = {
- TOP_BUTTON : 'mxgraph.ios7ui.topButton',
- R_SIZE : 'rSize'
- };
- /**
- * Function: paintVertexShape
- *
- * Paints the vertex shape.
- */
- mxShapeIOS7TopButton.prototype.paintVertexShape = function(c, x, y, w, h)
- {
- c.translate(x, y);
- var rSize = parseInt(mxUtils.getValue(this.style, mxShapeIOS7TopButton.prototype.cst.R_SIZE, '10'));
- c.begin();
- c.moveTo(w, h);
- c.lineTo(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.close();
- c.fillAndStroke();
- };
- mxCellRenderer.registerShape(mxShapeIOS7TopButton.prototype.cst.TOP_BUTTON, mxShapeIOS7TopButton);
- //**********************************************************************************************************************************************************
- //Top Button
- //**********************************************************************************************************************************************************
- /**
- * Extends mxShape.
- */
- function mxShapeIOS7BottomButton(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(mxShapeIOS7BottomButton, mxShape);
- mxShapeIOS7BottomButton.prototype.cst = {
- BOTTOM_BUTTON : 'mxgraph.ios7ui.bottomButton',
- R_SIZE : 'rSize'
- };
- /**
- * Function: paintVertexShape
- *
- * Paints the vertex shape.
- */
- mxShapeIOS7BottomButton.prototype.paintVertexShape = function(c, x, y, w, h)
- {
- c.translate(x, y);
- var rSize = parseInt(mxUtils.getValue(this.style, mxShapeIOS7BottomButton.prototype.cst.R_SIZE, '10'));
- c.begin();
- c.moveTo(w, 0);
- c.lineTo(0, 0);
- c.lineTo(0, h - rSize);
- c.arcTo(rSize, rSize, 0, 0, 0, rSize, h);
- c.lineTo(w - rSize, h);
- c.arcTo(rSize, rSize, 0, 0, 0, w, h - rSize);
- c.close();
- c.fillAndStroke();
- };
- mxCellRenderer.registerShape(mxShapeIOS7BottomButton.prototype.cst.BOTTOM_BUTTON, mxShapeIOS7BottomButton);
- //**********************************************************************************************************************************************************
- //Horizontal Lines
- //**********************************************************************************************************************************************************
- /**
- * Extends mxShape.
- */
- function mxShapeIOS7HorLines(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(mxShapeIOS7HorLines, mxShape);
- mxShapeIOS7HorLines.prototype.cst = {
- HOR_LINES : 'mxgraph.ios7ui.horLines'
- };
- /**
- * Function: paintVertexShape
- *
- * Paints the vertex shape.
- */
- mxShapeIOS7HorLines.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(mxShapeIOS7HorLines.prototype.cst.HOR_LINES, mxShapeIOS7HorLines);
- //**********************************************************************************************************************************************************
- //rect with margins
- //**********************************************************************************************************************************************************
- /**
- * Extends mxShape.
- */
- function mxShapeIOS7MarginRect(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(mxShapeIOS7MarginRect, mxShape);
- mxShapeIOS7MarginRect.prototype.cst = {
- SHAPE_MARGIN_RECT : 'mxgraph.ios7ui.marginRect',
- MARGIN : 'rectMargin',
- RX : 'rx',
- RY : 'ry',
- MARGIN_TOP : 'rectMarginTop',
- MARGIN_LEFT : 'rectMarginLeft',
- MARGIN_BOTTOM : 'rectMarginBottom',
- MARGIN_RIGHT : 'rectMarginRight'
- };
- /**
- * Function: paintVertexShape
- *
- * Paints the vertex shape.
- */
- mxShapeIOS7MarginRect.prototype.paintVertexShape = function(c, x, y, w, h)
- {
-
- c.translate(x, y);
- this.background(c, x, y, w, h);
- };
- mxShapeIOS7MarginRect.prototype.background = function(c, x, y, w, h, state)
- {
- var margin = parseFloat(mxUtils.getValue(this.style, mxShapeIOS7MarginRect.prototype.cst.MARGIN, '0'));
- var marginTop = parseFloat(mxUtils.getValue(this.style, mxShapeIOS7MarginRect.prototype.cst.MARGIN_TOP, '0'));
- var marginLeft = parseFloat(mxUtils.getValue(this.style, mxShapeIOS7MarginRect.prototype.cst.MARGIN_LEFT, '0'));
- var marginBottom = parseFloat(mxUtils.getValue(this.style, mxShapeIOS7MarginRect.prototype.cst.MARGIN_BOTTOM, '0'));
- var marginRight = parseFloat(mxUtils.getValue(this.style, mxShapeIOS7MarginRect.prototype.cst.MARGIN_RIGHT, '0'));
- var rx = parseFloat(mxUtils.getValue(this.style, mxShapeIOS7MarginRect.prototype.cst.RX, '0'));
- var ry = parseFloat(mxUtils.getValue(this.style, mxShapeIOS7MarginRect.prototype.cst.RY, '0'));
- var x1 = margin + marginLeft;
- var y1 = margin + marginTop;
- var w1 = w - marginRight - x1 - margin;
- var h1 = h - marginBottom - y1 - margin;
- if (w1 >0 && h1 > 0)
- {
- c.begin();
- c.roundrect(x1, y1, w1, h1, rx, ry);
- c.fillAndStroke();
- }
- };
- mxCellRenderer.prototype.defaultShapes[mxShapeIOS7MarginRect.prototype.cst.SHAPE_MARGIN_RECT] = mxShapeIOS7MarginRect;
- //**********************************************************************************************************************************************************
- //Callout
- //**********************************************************************************************************************************************************
- /**
- * Extends mxShape.
- */
- function mxShapeIOS7Callout(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(mxShapeIOS7Callout, mxShape);
- mxShapeIOS7Callout.prototype.cst = {
- SHAPE_CALLOUT : 'mxgraph.ios7ui.callout'
- };
- /**
- * Function: paintVertexShape
- *
- * Paints the vertex shape.
- */
- mxShapeIOS7Callout.prototype.paintVertexShape = function(c, x, y, w, h)
- {
-
- c.translate(x, y);
- this.background(c, x, y, w, h);
- };
- mxShapeIOS7Callout.prototype.background = function(c, x, y, w, h, state)
- {
- var r = 10;
-
- if (w >= 30 && h >= 20)
- {
- c.begin();
- c.moveTo(15, h - r * 0.3);
- c.arcTo(r * 2, r, 0, 0, 1, 0, h);
- c.arcTo(r * 1.5, r * 1.5, 0, 0, 0, 10, h - r * 1);
- c.lineTo(r, r);
- c.arcTo(r, r, 0, 0, 1, r * 2, 0);
- c.lineTo(w - r, 0);
- c.arcTo(r, r, 0, 0, 1, w, r);
- c.lineTo(w, h - r);
- c.arcTo(r, r, 0, 0, 1, w - r, h);
- c.lineTo(r * 2, h);
- c.arcTo(r, r, 0, 0, 1, r * 1.5, h - r * 0.3);
- c.close();
- c.fillAndStroke();
- }
- };
- mxCellRenderer.prototype.defaultShapes[mxShapeIOS7Callout.prototype.cst.SHAPE_CALLOUT] = mxShapeIOS7Callout;
- //**********************************************************************************************************************************************************
- //Select Bar
- //**********************************************************************************************************************************************************
- /**
- * Extends mxShape.
- */
- function mxShapeIOS7SelectBar(bounds, fill, stroke, strokewidth)
- {
- mxShape.call(this);
- this.bounds = bounds;
- this.fill = fill;
- this.stroke = stroke;
- this.strokewidth = (strokewidth != null) ? strokewidth : 1;
- this.dy = 0.5;
- this.dx = 0.5;
- this.dx2 = 70;
- this.size = 10;
- };
- /**
- * Extends mxShape.
- */
- mxUtils.extend(mxShapeIOS7SelectBar, mxActor);
- mxShapeIOS7SelectBar.prototype.cst = {
- SELECT_BAR : 'mxgraph.ios7ui.selectBar'
- };
- /**
- * Function: paintVertexShape
- *
- * Paints the vertex shape.
- */
- mxShapeIOS7SelectBar.prototype.paintVertexShape = function(c, x, y, w, h)
- {
- c.translate(x, y);
- var dx = Math.max(0, Math.min(w, parseFloat(mxUtils.getValue(this.style, 'dx', this.dx))));
- var dx2 = Math.max(0, Math.min(w, parseFloat(mxUtils.getValue(this.style, 'dx2', this.dx2))));
- var r = Math.max(0, Math.min(h, parseFloat(mxUtils.getValue(this.style, 'size', this.size))));
- var dy = Math.max(0, Math.min(h, (w - Math.max(20, r) - r) / 2, parseFloat(mxUtils.getValue(this.style, 'dy', this.dy))));
- r = Math.min(h / 2, w / 2, r);
- dx = Math.max(r + dy, dx);
- dx = Math.min(w - r - dy, w - 20 - dy, dx);
-
- c.begin();
- c.moveTo(dx - dy, h);
- c.lineTo(r, h);
- c.arcTo(r, r, 0, 0, 1, 0, h - r);
- c.lineTo(0, r);
- c.arcTo(r, r, 0, 0, 1, r, 0);
- c.lineTo(w - r, 0);
- c.arcTo(r, r, 0, 0, 1, w, r);
- c.lineTo(w, h - r);
- c.arcTo(r, r, 0, 0, 1, w - r, h);
- c.lineTo(dx + dy, h);
- c.lineTo(dx, h + dy);
- c.close();
- c.fillAndStroke();
-
- c.setShadow(false);
-
- c.begin();
- c.moveTo(w - Math.max(20, r), 0);
- c.lineTo(w - Math.max(20, r), h);
- c.stroke();
- var currDx = dx2;
-
- c.begin();
-
- while (currDx < (w - Math.max(20, r)))
- {
- c.moveTo(currDx, 0);
- c.lineTo(currDx, h);
-
- currDx = currDx + dx2;
- }
-
- c.stroke();
-
- var w1 = Math.min(Math.max(20, r), h);
- var x1 = w - w1 * 0.5;
- var y1 = h * 0.5;
-
- c.setFillColor(mxUtils.getValue(this.style, mxConstants.STYLE_STROKECOLOR, ''));
- c.begin();
- c.moveTo(x1 - w1 * 0.15, y1 - w1 * 0.225);
- c.lineTo(x1 + w1 * 0.25, y1);
- c.lineTo(x1 - w1 * 0.15, y1 + w1 * 0.225);
- c.close();
- c.fill();
- };
- mxCellRenderer.registerShape(mxShapeIOS7SelectBar.prototype.cst.SELECT_BAR, mxShapeIOS7SelectBar);
- mxShapeIOS7SelectBar.prototype.constraints = null;
- Graph.handleFactory[mxShapeIOS7SelectBar.prototype.cst.SELECT_BAR] = function(state)
- {
- var handles = [Graph.createHandle(state, ['dx'], function(bounds)
- {
- var dx = Math.max(0, Math.min(bounds.width, parseFloat(mxUtils.getValue(this.state.style, 'dx', this.dx))));
- return new mxPoint(bounds.x + dx, bounds.y + bounds.height);
- }, function(bounds, pt)
- {
- var y = parseFloat(mxUtils.getValue(this.state.style, 'dy', this.dy)) * 0.6;
- this.state.style['dx'] = Math.round(100 * Math.max(y, Math.min(bounds.width - y, pt.x - bounds.x))) / 100;
- })];
- var handle2 = Graph.createHandle(state, ['dy'], function(bounds)
- {
- var dy = Math.max(0, Math.min(bounds.height, parseFloat(mxUtils.getValue(this.state.style, 'dy', this.dy))));
- return new mxPoint(bounds.x + parseFloat(mxUtils.getValue(this.state.style, 'dx', this.dx)), bounds.y + bounds.height + dy);
- }, function(bounds, pt)
- {
- this.state.style['dy'] = Math.round(100 * Math.max(0, Math.min(bounds.height, pt.y - bounds.y - bounds.height))) / 100;
- });
- handles.push(handle2);
- var handle3 = Graph.createHandle(state, ['size'], function(bounds)
- {
- var size = Math.max(0, Math.min(bounds.width, parseFloat(mxUtils.getValue(this.state.style, 'size', this.size))));
- return new mxPoint(bounds.x + bounds.width - size, bounds.y + 10);
- }, function(bounds, pt)
- {
- this.state.style['size'] = Math.round(100 * Math.max(0, Math.min(bounds.width / 2, bounds.height / 2, bounds.x + bounds.width - pt.x))) / 100;
- });
-
- handles.push(handle3);
- var handle4 = Graph.createHandle(state, ['dx2'], function(bounds)
- {
- var dx2 = Math.max(0, Math.min(bounds.width, parseFloat(mxUtils.getValue(this.state.style, 'dx2', this.dx2))));
- return new mxPoint(bounds.x + dx2, bounds.y + bounds.height / 2);
- }, function(bounds, pt)
- {
- this.state.style['dx2'] = Math.round(100 * Math.max(0, Math.min(bounds.width, pt.x - bounds.x))) / 100;
- });
- handles.push(handle4);
- return handles;
- }
- //**********************************************************************************************************************************************************
- //slider
- //**********************************************************************************************************************************************************
- /**
- * Extends mxShape.
- */
- mxShapeIOS7SelectBar
- function mxShapeIOS7Slider2(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(mxShapeIOS7Slider2, mxShape);
- mxShapeIOS7Slider2.prototype.cst = {
- SHAPE_SLIDER : 'mxgraph.ios7ui.slider',
- BAR_POS : 'barPos',
- HANDLE_SIZE : 'handleSize'
- };
- /**
- * Function: paintVertexShape
- *
- * Paints the vertex shape.
- */
- mxShapeIOS7Slider2.prototype.paintVertexShape = function(c, x, y, w, h)
- {
-
- c.translate(x, y);
- this.background(c, x, y, w, h);
- c.setShadow(true);
- };
- mxShapeIOS7Slider2.prototype.background = function(c, x, y, w, h)
- {
- var hSize = parseFloat(mxUtils.getValue(this.style, mxShapeIOS7Slider2.prototype.cst.HANDLE_SIZE, '10'));
- var barPos = parseFloat(mxUtils.getValue(this.style, mxShapeIOS7Slider2.prototype.cst.BAR_POS, '40')) / 100;
- barPos = Math.max(0, Math.min(1, barPos));
- c.save();
- c.setStrokeColor('#bbbbbb');
- c.begin();
- c.moveTo(0, h * 0.5);
- c.lineTo(w, h * 0.5);
- c.fillAndStroke();
-
- c.restore();
- c.begin();
- c.moveTo(0, h * 0.5);
- c.lineTo(barPos * w, h * 0.5);
- c.fillAndStroke();
-
- c.setStrokeColor('#bbbbbb');
- c.begin();
- c.ellipse(barPos * w - hSize * 0.5, h * 0.5 - hSize * 0.5, hSize, hSize);
- c.fillAndStroke();
- };
- mxCellRenderer.prototype.defaultShapes[mxShapeIOS7Slider2.prototype.cst.SHAPE_SLIDER] = mxShapeIOS7Slider2;
- mxShapeIOS7Slider2.prototype.constraints = null;
- Graph.handleFactory[mxShapeIOS7Slider2.prototype.cst.SHAPE_SLIDER] = function(state)
- {
- var handles = [Graph.createHandle(state, ['barPos'], function(bounds)
- {
- var barPos = Math.max(0, Math.min(bounds.width, parseFloat(mxUtils.getValue(this.state.style, 'barPos', 0.4))));
- return new mxPoint(bounds.x + barPos * bounds.width / 100, bounds.y + bounds.height / 2);
- }, function(bounds, pt)
- {
- this.state.style['barPos'] = Math.round(100 * Math.max(0, Math.min(100, (pt.x - bounds.x) * 100 / bounds.width))) / 100;
- })];
-
- return handles;
- };
|