clone

a browser-first diagram editor with live svg previews, local drafts and encrypted, accountless sharing

main
diagramzip / renderers / browser-run / frames / diagramsnet / vendor / assets / shapes / mxAndroid.js
mxAndroid.js 43.4K
1/**2 * Copyright (c) 2006-2013, JGraph Holdings Ltd3 */45//**********************************************************************************************************************************************************6//Horizontal Tab Bar (LEGACY)7//**********************************************************************************************************************************************************8/**9 * Extends mxShape.10 */11function mxShapeAndroidTabBar(bounds, fill, stroke, strokewidth)12{13 mxShape.call(this);14 this.bounds = bounds;15 this.fill = fill;16 this.stroke = stroke;17 this.strokewidth = (strokewidth != null) ? strokewidth : 1;18};1920/**21 * Extends mxShape.22 */23mxUtils.extend(mxShapeAndroidTabBar, mxShape);2425mxShapeAndroidTabBar.prototype.cst = {26 MAIN_TEXT : 'mainText',27 SHAPE_TAB_BAR : 'mxgraph.android.tabBar',28 TEXT_COLOR : 'textColor',29 TEXT_COLOR2 : 'textColor2',30 STROKE_COLOR2 : 'strokeColor2',31 FILL_COLOR2 : 'fillColor2',32 SELECTED : '+', //must be 1 char33 TEXT_SIZE : 'textSize'34};3536/**37 * Function: paintVertexShape38 * 39 * Paints the vertex shape.40 */41mxShapeAndroidTabBar.prototype.paintVertexShape = function(c, x, y, w, h)42{43 var textStrings = mxUtils.getValue(this.style, mxShapeAndroidTabBar.prototype.cst.MAIN_TEXT, '+Tab 1, Tab 2, Tab 3').toString().split(',');44 var fontColor = mxUtils.getValue(this.style, mxShapeAndroidTabBar.prototype.cst.TEXT_COLOR, 'none');45 var selectedFontColor = mxUtils.getValue(this.style, mxShapeAndroidTabBar.prototype.cst.TEXT_COLOR2, 'none');46 var fontSize = mxUtils.getValue(this.style, mxShapeAndroidTabBar.prototype.cst.TEXT_SIZE, '17').toString();47 var frameColor = mxUtils.getValue(this.style, mxConstants.STYLE_STROKECOLOR, 'none');48 var separatorColor = mxUtils.getValue(this.style, mxShapeAndroidTabBar.prototype.cst.STROKE_COLOR2, 'none');49 var bgColor = mxUtils.getValue(this.style, mxConstants.STYLE_FILLCOLOR, 'none');50 var selectedFillColor = mxUtils.getValue(this.style, mxShapeAndroidTabBar.prototype.cst.FILL_COLOR2, 'none');51 var buttonNum = textStrings.length;52 var buttonWidths = new Array(buttonNum);53 var buttonTotalWidth = 0;54 var selectedButton = -1;55 var labelOffset = 5;5657 for (var i = 0; i < buttonNum; i++)58 {59 var buttonText = textStrings[i];6061 if(buttonText.charAt(0) === mxShapeAndroidTabBar.prototype.cst.SELECTED)62 {63 buttonText = textStrings[i].substring(1);64 selectedButton = i;65 }6667 buttonWidths[i] = mxUtils.getSizeForString(buttonText, fontSize, mxConstants.DEFAULT_FONTFAMILY).width;6869 buttonTotalWidth += buttonWidths[i];70 }7172 var trueH = Math.max(h, fontSize * 1.5, 7);73 var minW = 2 * labelOffset * buttonNum + buttonTotalWidth;74 var trueW = Math.max(w, minW);7576 c.translate(x, y);77 this.background(c, trueW, trueH, buttonNum, buttonWidths, labelOffset, minW, frameColor, separatorColor, bgColor, selectedFillColor, selectedButton);78 c.setShadow(false);7980 c.setFontStyle(mxConstants.FONT_BOLD);81 var currWidth = 0;8283 for (var i = 0; i < buttonNum; i++)84 {85 if (i === selectedButton)86 {87 c.setFontColor(selectedFontColor);88 }89 else90 {91 c.setFontColor(fontColor);92 }9394 currWidth = currWidth + labelOffset;95 this.buttonText(c, currWidth, trueH, textStrings[i], buttonWidths[i], fontSize, minW, trueW);96 currWidth = currWidth + buttonWidths[i] + labelOffset;97 }98};99100mxShapeAndroidTabBar.prototype.background = function(c, w, h, buttonNum, buttonWidths, labelOffset, minW, frameColor, separatorColor, bgColor, selectedFillColor, selectedButton)101{102 c.begin();103104 //draw the frame105 c.setStrokeColor(frameColor);106 c.setFillColor(bgColor);107 c.rect(0, 0, w, h);108 c.fillAndStroke();109110 //draw the button separators111 c.setStrokeColor(separatorColor);112 c.begin();113 for (var i = 1; i < buttonNum; i++)114 {115 if (i !== selectedButton && i !== (selectedButton + 1))116 {117 var currWidth = 0;118119 for (var j = 0; j < i; j++)120 {121 currWidth += buttonWidths[j] + 2 * labelOffset;122 }123124 currWidth = currWidth * w / minW;125 c.moveTo(currWidth, h * 0.2);126 c.lineTo(currWidth, h * 0.8);127 }128 }129130 c.stroke();131132 //draw the selected button133 var buttonLeft = 0;134 c.setFillColor(selectedFillColor);135136 for (var i = 0; i < selectedButton; i++)137 {138 buttonLeft += buttonWidths[i] + 2 * labelOffset;139 }140141 buttonLeft = buttonLeft * w / minW;142 var buttonRight = (buttonWidths[selectedButton] + 2 * labelOffset) * w / minW;143 buttonRight += buttonLeft;144145 c.rect(buttonLeft, 0, buttonRight - buttonLeft, h);146 c.fill();147148 c.setAlpha(1);149 c.setFillColor('#33b5e5');150 c.rect(buttonLeft, h * 0.9, buttonRight - buttonLeft, h * 0.1);151 c.fill();152};153154mxShapeAndroidTabBar.prototype.buttonText = function(c, w, h, textString, buttonWidth, fontSize, minW, trueW)155{156 if(textString.charAt(0) === mxShapeAndroidTabBar.prototype.cst.SELECTED)157 {158 textString = textString.substring(1);159 }160161 c.begin();162 c.setFontSize(fontSize);163 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);164};165166mxCellRenderer.registerShape(mxShapeAndroidTabBar.prototype.cst.SHAPE_TAB_BAR, mxShapeAndroidTabBar);167168//**********************************************************************************************************************************************************169//Android Phone Vertical170//**********************************************************************************************************************************************************171/**172* Extends mxShape.173*/174function mxShapeAndroidPhone(bounds, fill, stroke, strokewidth)175{176 mxShape.call(this);177 this.bounds = bounds;178 this.fill = fill;179 this.stroke = stroke;180 this.strokewidth = (strokewidth != null) ? strokewidth : 1;181};182183/**184* Extends mxShape.185*/186mxUtils.extend(mxShapeAndroidPhone, mxShape);187188/**189* Function: paintVertexShape190* 191* Paints the vertex shape.192*/193mxShapeAndroidPhone.prototype.paintVertexShape = function(c, x, y, w, h)194{195 c.translate(x, y);196 var rSize = 25;197198 c.roundrect(0, 0, w, h, rSize, rSize);199 c.fillAndStroke();200 201 c.setShadow(false);202 203 this.foreground(c, x, y, w, h, rSize);204};205206mxShapeAndroidPhone.prototype.foreground = function(c, x, y, w, h, rSize)207{208 c.rect(w * 0.0625, h * 0.15, w * 0.875, h * 0.7);209 c.stroke();210211 c.ellipse(w * 0.4875, h * 0.04125, w * 0.025, h * 0.0125);212 c.stroke();213214 c.roundrect(w * 0.375, h * 0.075, w * 0.25, h * 0.01875, w * 0.02, h * 0.01);215 c.stroke();216 c.ellipse(w * 0.4, h * 0.875, w * 0.2, h * 0.1);217 c.stroke();218 c.roundrect(w * 0.4575, h * 0.905, w * 0.085, h * 0.04375, h * 0.00625, h * 0.00625);219 c.stroke();220};221222mxCellRenderer.registerShape('mxgraph.android.phone', mxShapeAndroidPhone);223224//**********************************************************************************************************************************************************225//Android Status Bar226//**********************************************************************************************************************************************************227/**228* Extends mxShape.229*/230function mxShapeAndroidStatusBar(bounds, fill, stroke, strokewidth)231{232 mxShape.call(this);233 this.bounds = bounds;234 this.fill = fill;235 this.stroke = stroke;236 this.strokewidth = (strokewidth != null) ? strokewidth : 1;237};238239/**240* Extends mxShape.241*/242mxUtils.extend(mxShapeAndroidStatusBar, mxShape);243244/**245* Function: paintVertexShape246* 247* Paints the vertex shape.248*/249mxShapeAndroidStatusBar.prototype.paintVertexShape = function(c, x, y, w, h)250{251 c.translate(x, y);252 this.background(c, x, y, w, h);253 c.setShadow(false);254 this.foreground(c, x, y, w, h);255};256257mxShapeAndroidStatusBar.prototype.background = function(c, x, y, w, h)258{259 c.rect(0, 0, w, h);260 c.fill();261};262263mxShapeAndroidStatusBar.prototype.foreground = function(c, x, y, w, h)264{265 c.rect(0, 0, w, h);266 c.fill();267268 c.setFontColor(mxUtils.getValue(this.style, mxConstants.STYLE_FONTCOLOR, '#222222'));269 c.setFontSize(mxUtils.getValue(this.style, mxConstants.STYLE_FONTSIZE, '5'));270 c.text(w - 30, h * 0.5 + 1, 0, 0, '12:00', mxConstants.ALIGN_LEFT, mxConstants.ALIGN_MIDDLE, 0, null, 0, 0, 0);271272 c.setFillColor('#444444');273 c.begin();274 c.moveTo(w - 37, h * 0.5 + 6);275 c.lineTo(w - 37, h * 0.5 - 5);276 c.lineTo(w - 36, h * 0.5 - 5);277 c.lineTo(w - 36, h * 0.5 - 6);278 c.lineTo(w - 32, h * 0.5 - 6);279 c.lineTo(w - 32, h * 0.5 - 5);280 c.lineTo(w - 31, h * 0.5 - 5);281 c.lineTo(w - 31, h * 0.5 + 6);282 c.close();283 c.fill();284 285 c.setFillColor(mxUtils.getValue(this.style, mxConstants.STYLE_STROKECOLOR, 'none'));286 c.ellipse(w - 56, h * 0.5 + 2, 2, 2);287 c.fillAndStroke();288 289 c.setStrokeWidth(2);290 c.begin();291 c.moveTo(w - 52, h * 0.5 + 1);292 c.arcTo(3.5, 3.5, 0, 0, 0, w - 58, h * 0.5 + 1);293 c.stroke();294 295 c.begin();296 c.moveTo(w - 50, h * 0.5 - 1);297 c.arcTo(6, 6, 0, 0, 0, w - 60, h * 0.5 - 1);298 c.stroke();299 300 c.setStrokeWidth(1);301 302 c.rect(w - 51, h * 0.5 + 5, 2, 1);303 c.fill();304 305 c.rect(w - 48, h * 0.5 + 2, 2, 4);306 c.fill();307 308 c.rect(w - 45, h * 0.5 - 1, 2, 7);309 c.fill();310 311 c.rect(w - 42, h * 0.5 - 4, 2, 10);312 c.fill();313314 c.rect(w - 37, h * 0.5 - 2, 6, 8);315 c.fill();316 317};318319mxCellRenderer.registerShape('mxgraph.android.statusBar', mxShapeAndroidStatusBar);320321//**********************************************************************************************************************************************************322//Checkbox Button Group323//**********************************************************************************************************************************************************324/**325* Extends mxShape.326*/327function mxShapeAndroidCheckboxGroup(bounds, fill, stroke, strokewidth)328{329 mxShape.call(this);330 this.bounds = bounds;331 this.fill = fill;332 this.stroke = stroke;333 this.strokewidth = (strokewidth != null) ? strokewidth : 1;334};335336/**337* Extends mxShape.338*/339mxUtils.extend(mxShapeAndroidCheckboxGroup, mxShape);340341mxShapeAndroidCheckboxGroup.prototype.cst = {342 STYLE_TEXTCOLOR2 : 'textColor2',343 STYLE_STROKECOLOR2 : 'strokeColor2',344 BUTTON_TEXT : 'buttonText',345 SELECTED : '+' //has to be one character long346};347348/**349* Function: paintVertexShape350* 351* Paints the vertex shape.352*/353mxShapeAndroidCheckboxGroup.prototype.paintVertexShape = function(c, x, y, w, h)354{355 c.translate(x, y);356357 var fontColor = mxUtils.getValue(this.style, mxConstants.STYLE_TEXTCOLOR, '#666666');358 var fontSize = mxUtils.getValue(this.style, mxConstants.STYLE_FONTSIZE, '8').toString();359 var optionText = mxUtils.getValue(this.style, mxShapeAndroidCheckboxGroup.prototype.cst.BUTTON_TEXT, 'Option 1').toString().split(',');360 var strokeColor = mxUtils.getValue(this.style, mxConstants.STYLE_STROKECOLOR, 'none');361 var strokeColor2 = mxUtils.getValue(this.style, mxShapeAndroidCheckboxGroup.prototype.cst.STYLE_STROKECOLOR2, 'none');362 363 c.setStrokeColor(strokeColor2);364 var optionNum = optionText.length;365 var buttonSize = 5;366 var lineH = Math.max(fontSize * 1.5, buttonSize);367 var maxTextWidth = 0;368 var selected = -1;369 var labelOffset = 2.5;370 var minH = optionNum * lineH;371 var trueH = Math.max(h, minH);372373 //get min width and selected option 374 for (var i = 0; i < optionNum; i++)375 {376 var currText = optionText[i];377378 if(currText.charAt(0) === mxShapeAndroidCheckboxGroup.prototype.cst.SELECTED)379 {380 currText = optionText[i].substring(1);381 selected = i;382 }383384 var currWidth = mxUtils.getSizeForString(currText, fontSize, mxConstants.DEFAULT_FONTFAMILY).width;385386 if (currWidth > maxTextWidth)387 {388 maxTextWidth = currWidth;389 }390 }391392 var minW = 2 * labelOffset + maxTextWidth + 2 * buttonSize;393 var trueW = Math.max(w, minW);394395 //draw the background396 c.roundrect(0, 0, trueW, trueH, 2.5, 2.5);397 c.fillAndStroke();398 c.setShadow(false);399400 c.setFontSize(fontSize);401 c.setFontColor(fontColor);402 c.setStrokeColor(strokeColor);403404 for (var i = 0; i < optionNum; i++)405 {406 var currHeight = (i * lineH + lineH * 0.5) * trueH / minH;407408 var currText = optionText[i];409410 if(currText.charAt(0) === mxShapeAndroidCheckboxGroup.prototype.cst.SELECTED)411 {412 currText = optionText[i].substring(1);413 selected = i;414 }415416 c.text(buttonSize * 2 + labelOffset, currHeight, 0, 0, currText, mxConstants.ALIGN_LEFT, mxConstants.ALIGN_MIDDLE, 0, null, 0, 0, 0);417418 var iconX = buttonSize * 0.5;419 var iconY = currHeight - buttonSize * 0.5;420421 if (selected === i)422 {423 c.rect(iconX, iconY, buttonSize, buttonSize);424 c.fillAndStroke();425 c.begin();426 c.moveTo(iconX + buttonSize * 0.25, iconY + buttonSize * 0.5);427 c.lineTo(iconX + buttonSize * 0.5, iconY + buttonSize * 0.75);428 c.lineTo(iconX + buttonSize * 0.75, iconY + buttonSize * 0.25);429 c.stroke();430 }431 else432 {433 c.rect(iconX, iconY, buttonSize, buttonSize);434 c.fillAndStroke();435 }436437 selected = -1;438 }439};440441mxCellRenderer.registerShape('mxgraph.android.checkboxGroup', mxShapeAndroidCheckboxGroup);442443//**********************************************************************************************************************************************************444//Radio Button Group445//**********************************************************************************************************************************************************446/**447* Extends mxShape.448*/449function mxShapeAndroidRadioGroup(bounds, fill, stroke, strokewidth)450{451 mxShape.call(this);452 this.bounds = bounds;453 this.fill = fill;454 this.stroke = stroke;455 this.strokewidth = (strokewidth != null) ? strokewidth : 1;456};457458/**459* Extends mxShape.460*/461mxUtils.extend(mxShapeAndroidRadioGroup, mxShape);462463mxShapeAndroidRadioGroup.prototype.cst = {464 STYLE_TEXTCOLOR2 : 'textColor2',465 STYLE_STROKECOLOR2 : 'strokeColor2',466 BUTTON_TEXT : 'buttonText',467 SELECTED : '+' //has to be one character long468};469470/**471* Function: paintVertexShape472* 473* Paints the vertex shape.474*/475mxShapeAndroidRadioGroup.prototype.paintVertexShape = function(c, x, y, w, h)476{477 c.translate(x, y);478479 var fontColor = mxUtils.getValue(this.style, mxConstants.STYLE_TEXTCOLOR, '#666666');480 var fontSize = mxUtils.getValue(this.style, mxConstants.STYLE_FONTSIZE, '8').toString();481 var optionText = mxUtils.getValue(this.style, mxShapeAndroidRadioGroup.prototype.cst.BUTTON_TEXT, 'Option 1').toString().split(',');482 var strokeColor = mxUtils.getValue(this.style, mxConstants.STYLE_STROKECOLOR, 'none');483 var strokeColor2 = mxUtils.getValue(this.style, mxShapeAndroidRadioGroup.prototype.cst.STYLE_STROKECOLOR2, 'none');484485 c.setStrokeColor(strokeColor2);486487 var optionNum = optionText.length;488 var buttonSize = 5;489 var lineH = Math.max(fontSize * 1.5, buttonSize);490 var maxTextWidth = 0;491 var selected = -1;492 var labelOffset = 2.5;493 var minH = optionNum * lineH;494 var trueH = Math.max(h, minH);495496 //get min width and selected option 497 for (var i = 0; i < optionNum; i++)498 {499 var currText = optionText[i];500501 if(currText.charAt(0) === mxShapeAndroidRadioGroup.prototype.cst.SELECTED)502 {503 currText = optionText[i].substring(1);504 selected = i;505 }506507 var currWidth = mxUtils.getSizeForString(currText, fontSize, mxConstants.DEFAULT_FONTFAMILY).width;508509 if (currWidth > maxTextWidth)510 {511 maxTextWidth = currWidth;512 }513 }514515 var minW = 2 * labelOffset + maxTextWidth + 2 * buttonSize;516 var trueW = Math.max(w, minW);517518 //draw the background519 c.roundrect(0, 0, trueW, trueH, 2.5, 2.5);520 c.fillAndStroke();521 c.setShadow(false);522523 c.setFontSize(fontSize);524 c.setFontColor(fontColor);525 c.setStrokeColor(strokeColor);526 c.setFillColor(strokeColor);527528 for (var i = 0; i < optionNum; i++)529 {530 var currHeight = (i * lineH + lineH * 0.5) * trueH / minH;531532 var currText = optionText[i];533534 if(currText.charAt(0) === mxShapeAndroidRadioGroup.prototype.cst.SELECTED)535 {536 currText = optionText[i].substring(1);537 selected = i;538 }539540 c.text(buttonSize * 2 + labelOffset, currHeight, 0, 0, currText, mxConstants.ALIGN_LEFT, mxConstants.ALIGN_MIDDLE, 0, null, 0, 0, 0);541542 var iconX = buttonSize * 0.5;543 var iconY = currHeight - buttonSize * 0.5;544545 if (selected === i)546 {547 c.ellipse(iconX, iconY, buttonSize, buttonSize);548 c.stroke();549 c.ellipse(iconX + buttonSize * 0.25, iconY + buttonSize * 0.25, buttonSize * 0.5, buttonSize * 0.5);550 c.fillAndStroke();551 }552 else553 {554 c.ellipse(iconX, iconY, buttonSize, buttonSize);555 c.stroke();556 }557 }558};559560mxCellRenderer.registerShape('mxgraph.android.radioGroup', mxShapeAndroidRadioGroup);561562//**********************************************************************************************************************************************************563//Menu Bar (LEGACY)564//**********************************************************************************************************************************************************565/**566* Extends mxShape.567*/568function mxShapeAndroidMenuBar(bounds, fill, stroke, strokewidth)569{570 mxShape.call(this);571 this.bounds = bounds;572 this.fill = fill;573 this.stroke = stroke;574 this.strokewidth = (strokewidth != null) ? strokewidth : 1;575};576577/**578* Extends mxShape.579*/580mxUtils.extend(mxShapeAndroidMenuBar, mxShape);581582mxShapeAndroidMenuBar.prototype.cst = {583 MENU_TEXT : 'menuText'584};585586/**587* Function: paintVertexShape588* 589* Paints the vertex shape.590*/591mxShapeAndroidMenuBar.prototype.paintVertexShape = function(c, x, y, w, h)592{593 var textStrings = mxUtils.getValue(this.style, mxShapeAndroidMenuBar.prototype.cst.MENU_TEXT, 'Item 1, Item 2, Item 3').toString().split(',');594 var fontSize = mxUtils.getValue(this.style, mxConstants.STYLE_FONTSIZE, '12');595 var buttonNum = textStrings.length;596 var maxButtonWidth = 0;597 var labelOffset = 2.5;598599 for (var i = 0; i < buttonNum; i++)600 {601 var buttonText = textStrings[i];602603 var currWidth = mxUtils.getSizeForString(buttonText, fontSize, mxConstants.DEFAULT_FONTFAMILY).width;604605 if (currWidth > maxButtonWidth)606 {607 maxButtonWidth = currWidth;608 }609 }610611 var minButtonHeight = fontSize * 1.5;612 var minH = buttonNum * minButtonHeight;613 var trueH = Math.max(h, minH);614 var minW = 2 * labelOffset + maxButtonWidth;615 var trueW = Math.max(w, minW);616617 c.translate(x, y);618619 c.rect(0, 0, w, trueH);620 c.fillAndStroke();621622 c.setShadow(false);623624 //draw the button separators625 c.begin();626627 for (var i = 1; i < buttonNum; i++)628 {629 var currHeight = i * minButtonHeight * trueH / minH;630 c.moveTo(0, currHeight);631 c.lineTo(w, currHeight);632 }633634 c.stroke();635636 for (var i = 0; i < buttonNum; i++)637 {638 currWidth = currWidth + labelOffset;639 var currHeight = (i * minButtonHeight + minButtonHeight * 0.5) * trueH / minH;640 c.text(10, currHeight, 0, 0, textStrings[i], mxConstants.ALIGN_LEFT, mxConstants.ALIGN_MIDDLE, 0, null, 0, 0, 0);641 }642};643644mxCellRenderer.registerShape('mxgraph.android.menuBar', mxShapeAndroidMenuBar);645646//**********************************************************************************************************************************************************647//Text Selection Handles648//**********************************************************************************************************************************************************649/**650* Extends mxShape.651*/652function mxShapeAndroidTextSelHandles(bounds, fill, stroke, strokewidth)653{654 mxShape.call(this);655 this.bounds = bounds;656 this.fill = fill;657 this.stroke = stroke;658 this.strokewidth = (strokewidth != null) ? strokewidth : 1;659};660661/**662* Extends mxShape.663*/664mxUtils.extend(mxShapeAndroidTextSelHandles, mxShape);665666/**667* Function: paintVertexShape668* 669* Paints the vertex shape.670*/671mxShapeAndroidTextSelHandles.prototype.paintVertexShape = function(c, x, y, w, h)672{673 var strokeColor = mxUtils.getValue(this.style, mxConstants.STYLE_STROKECOLOR, 'none');674 c.translate(x, y);675676 var handleSizeX = 15;677 var barH = Math.max(0, h - handleSizeX * 1.5);678 c.setAlpha(0.5);679 680 c.rect(handleSizeX, 0, w - 2 * handleSizeX, barH);681 c.fill();682 683 c.begin();684 c.moveTo(0, h - handleSizeX);685 c.lineTo(handleSizeX * 0.5, h - handleSizeX * 1.5);686 c.lineTo(handleSizeX, h - handleSizeX);687 c.close();688 c.moveTo(w - handleSizeX, h - handleSizeX);689 c.lineTo(w - handleSizeX * 0.5, h - handleSizeX * 1.5);690 c.lineTo(w, h - handleSizeX);691 c.close();692 c.fill();693 694 c.setFillColor(strokeColor);695 c.rect(0, h - handleSizeX, handleSizeX, handleSizeX);696 c.fill();697 c.rect(w - handleSizeX, h - handleSizeX, handleSizeX, handleSizeX);698 c.fill();699};700701mxCellRenderer.registerShape('mxgraph.android.textSelHandles', mxShapeAndroidTextSelHandles);702703//**********************************************************************************************************************************************************704//Android Indeterminate Spinner705//**********************************************************************************************************************************************************706/**707* Extends mxShape.708*/709function mxShapeAndroidIndeterminateSpinner(bounds, fill, stroke, strokewidth)710{711 mxShape.call(this);712 this.bounds = bounds;713 this.fill = fill;714 this.stroke = stroke;715 this.strokewidth = (strokewidth != null) ? strokewidth : 1;716};717718/**719* Extends mxShape.720*/721mxUtils.extend(mxShapeAndroidIndeterminateSpinner, mxShape);722723/**724* Function: paintVertexShape725* 726* Paints the vertex shape.727*/728mxShapeAndroidIndeterminateSpinner.prototype.paintVertexShape = function(c, x, y, w, h)729{730 c.translate(x, y);731 this.background(c, x, y, w, h);732};733734mxShapeAndroidIndeterminateSpinner.prototype.background = function(c, x, y, w, h)735{736 c.setGradient('#aaaaaa', '#dddddd', w * 0.325, 0, w * 0.675, h * 0.5, mxConstants.DIRECTION_SOUTH, 1, 1);737 c.begin();738 c.moveTo(w * 0.5, h * 0.1);739 c.arcTo(w * 0.4, h * 0.4, 0, 0, 0, w * 0.5, h * 0.9);740 c.lineTo(w * 0.5, h);741 c.arcTo(w * 0.5, h * 0.5, 0, 0, 1, w * 0.5, 0);742 c.close();743 c.fill();744745 c.setGradient('#ffffff', '#dddddd', w * 0.325, 0, w * 0.675, h * 0.5, mxConstants.DIRECTION_SOUTH, 1, 1);746 c.begin();747 c.moveTo(w * 0.5, h * 0.1);748 c.arcTo(w * 0.4, h * 0.4, 0, 0, 1, w * 0.5, h * 0.9);749 c.lineTo(w * 0.5, h);750 c.arcTo(w * 0.5, h * 0.5, 0, 0, 0, w * 0.5, 0);751 c.close();752 c.fill();753};754755mxCellRenderer.registerShape('mxgraph.android.indeterminateSpinner', mxShapeAndroidIndeterminateSpinner);756757//**********************************************************************************************************************************************************758//Anchor (a dummy shape without visuals used for anchoring)759//**********************************************************************************************************************************************************760/**761* Extends mxShape.762*/763function mxShapeAndroidAnchor(bounds, fill, stroke, strokewidth)764{765 mxShape.call(this);766 this.bounds = bounds;767};768769/**770* Extends mxShape.771*/772mxUtils.extend(mxShapeAndroidAnchor, mxShape);773774mxShapeAndroidAnchor.prototype.cst = {775 ANCHOR : 'mxgraph.android.anchor'776};777778/**779* Function: paintVertexShape780* 781* Paints the vertex shape.782*/783mxShapeAndroidAnchor.prototype.paintVertexShape = function(c, x, y, w, h)784{785};786787mxCellRenderer.registerShape(mxShapeAndroidAnchor.prototype.cst.ANCHOR, mxShapeAndroidAnchor);788789//**********************************************************************************************************************************************************790//Rounded rectangle (adjustable rounding)791//**********************************************************************************************************************************************************792/**793* Extends mxShape.794*/795function mxShapeAndroidRRect(bounds, fill, stroke, strokewidth)796{797 mxShape.call(this);798 this.bounds = bounds;799 this.fill = fill;800 this.stroke = stroke;801 this.strokewidth = (strokewidth != null) ? strokewidth : 1;802};803804/**805* Extends mxShape.806*/807mxUtils.extend(mxShapeAndroidRRect, mxShape);808809mxShapeAndroidRRect.prototype.cst = {810 RRECT : 'mxgraph.android.rrect',811 R_SIZE : 'rSize'812};813814/**815* Function: paintVertexShape816* 817* Paints the vertex shape.818*/819mxShapeAndroidRRect.prototype.paintVertexShape = function(c, x, y, w, h)820{821 c.translate(x, y);822823 var rSize = parseInt(mxUtils.getValue(this.style, mxShapeAndroidRRect.prototype.cst.R_SIZE, '10'));824 c.roundrect(0, 0, w, h, rSize);825 c.fillAndStroke();826};827828mxCellRenderer.registerShape(mxShapeAndroidRRect.prototype.cst.RRECT, mxShapeAndroidRRect);829830//**********************************************************************************************************************************************************831//Checkbox832//**********************************************************************************************************************************************************833/**834* Extends mxShape.835*/836function mxShapeAndroidCheckbox(bounds, fill, stroke, strokewidth)837{838 mxShape.call(this);839 this.bounds = bounds;840 this.fill = fill;841 this.stroke = stroke;842 this.strokewidth = (strokewidth != null) ? strokewidth : 1;843};844845/**846* Extends mxShape.847*/848mxUtils.extend(mxShapeAndroidCheckbox, mxShape);849850mxShapeAndroidCheckbox.prototype.cst = {851 CHECKBOX : 'mxgraph.android.checkbox'852};853854/**855* Function: paintVertexShape856* 857* Paints the vertex shape.858*/859mxShapeAndroidCheckbox.prototype.paintVertexShape = function(c, x, y, w, h)860{861 c.translate(x, y);862 c.rect(0, 0, w, h);863 c.fillAndStroke();864 865 c.begin();866 c.moveTo(w * 0.8, h * 0.2);867 c.lineTo(w * 0.4, h * 0.8);868 c.lineTo(w * 0.25, h * 0.6);869 c.stroke();870};871872mxCellRenderer.registerShape(mxShapeAndroidCheckbox.prototype.cst.CHECKBOX, mxShapeAndroidCheckbox);873874//**********************************************************************************************************************************************************875//Progress Bar876//**********************************************************************************************************************************************************877/**878* Extends mxShape.879*/880function mxShapeAndroidProgressBar(bounds, fill, stroke, strokewidth)881{882 mxShape.call(this);883 this.bounds = bounds;884 this.fill = fill;885 this.stroke = stroke;886 this.strokewidth = (strokewidth != null) ? strokewidth : 1;887 this.dx1 = 0.8;888 this.dx2 = 0.6;889};890891/**892* Extends mxShape.893*/894mxUtils.extend(mxShapeAndroidProgressBar, mxShape);895896mxShapeAndroidProgressBar.prototype.customProperties = [897 {name: 'strokeColor2', dispName: 'Stroke Color 2', type: 'color', defVal:"#444444", primary: true},898 {name: 'dx1', dispName: 'Middle Bar Length', type: 'float', min:0, max:1, defVal:0.8},899 {name: 'dx2', dispName: 'Left Bar Length', type: 'float', min:0, max:1, defVal:0.6}900];901902mxShapeAndroidProgressBar.prototype.cst = {903 PROGRESS_BAR : 'mxgraph.android.progressBar'904};905906/**907* Function: paintVertexShape908* 909* Paints the vertex shape.910*/911mxShapeAndroidProgressBar.prototype.paintVertexShape = function(c, x, y, w, h)912{913 var dx1 = w * Math.max(0, Math.min(w, parseFloat(mxUtils.getValue(this.style, 'dx1', this.dx1))));914 var dx2 = w * Math.max(0, Math.min(w, parseFloat(mxUtils.getValue(this.style, 'dx2', this.dx2))));915 var strokeColor2 = mxUtils.getValue(this.style, 'strokeColor2', '#444444');916917 c.translate(x, y);918 919 c.save();920 c.save();921 c.setStrokeColor(strokeColor2);922 c.begin();923 c.moveTo(0, h * 0.5);924 c.lineTo(w , h * 0.5);925 c.stroke();926 927 c.restore();928 c.setShadow(false);929 c.begin();930 c.moveTo(0, h * 0.5);931 c.lineTo(dx1, h * 0.5);932 c.stroke();933 934 c.setStrokeColor("#000000");935 c.setAlpha('0.2');936 c.begin();937 c.moveTo(0, h * 0.5);938 c.lineTo(dx1, h * 0.5);939 c.stroke();940 941 c.restore();942 c.setShadow(false);943 c.begin();944 c.moveTo(0, h * 0.5);945 c.lineTo(dx2, h * 0.5);946 c.stroke();947};948949mxCellRenderer.registerShape(mxShapeAndroidProgressBar.prototype.cst.PROGRESS_BAR, mxShapeAndroidProgressBar);950951mxShapeAndroidProgressBar.prototype.constraints = null;952953Graph.handleFactory[mxShapeAndroidProgressBar.prototype.cst.PROGRESS_BAR] = function(state)954{955 var handles = [Graph.createHandle(state, ['dx1'], function(bounds)956 {957 var dx1 = Math.max(0, Math.min(1, parseFloat(mxUtils.getValue(this.state.style, 'dx1', this.dx1))));958959 return new mxPoint(bounds.x + dx1 * bounds.width, bounds.y + bounds.height / 2);960 }, function(bounds, pt)961 {962 this.state.style['dx1'] = Math.round(100 * Math.max(0, Math.min(1, (pt.x - bounds.x) / bounds.width))) / 100;963 })];964965 var handle2 = Graph.createHandle(state, ['dx2'], function(bounds)966 {967 var dx2 = Math.max(0, Math.min(1, parseFloat(mxUtils.getValue(this.state.style, 'dx2', this.dx1))));968969 return new mxPoint(bounds.x + dx2 * bounds.width, bounds.y + bounds.height / 2);970 }, function(bounds, pt)971 {972 this.state.style['dx2'] = Math.round(100 * Math.max(0, Math.min(1, (pt.x - bounds.x) / bounds.width))) / 100;973 });974 975 handles.push(handle2);976977 return handles;978}979980//**********************************************************************************************************************************************************981//Progress Scrubber Disabled982//**********************************************************************************************************************************************************983/**984* Extends mxShape.985*/986function mxShapeAndroidProgressScrubberDisabled(bounds, fill, stroke, strokewidth)987{988 mxShape.call(this);989 this.bounds = bounds;990 this.fill = fill;991 this.stroke = stroke;992 this.strokewidth = (strokewidth != null) ? strokewidth : 1;993 this.dx = 0.3;994};995996/**997* Extends mxShape.998*/999mxUtils.extend(mxShapeAndroidProgressScrubberDisabled, mxShape);10001001mxShapeAndroidProgressScrubberDisabled.prototype.customProperties = [1002 {name: 'strokeColor2', dispName: 'Stroke Color 2', type: 'color', defVal:"#444444", primary: true},1003 {name: 'dx', dispName: 'Handle Position', type: 'float', min:0, max:1, defVal:0.3}1004];10051006mxShapeAndroidProgressScrubberDisabled.prototype.cst = {1007 PROGRESS_SCRUBBER_DISABLED : 'mxgraph.android.progressScrubberDisabled'1008};10091010/**1011* Function: paintVertexShape1012* 1013* Paints the vertex shape.1014*/1015mxShapeAndroidProgressScrubberDisabled.prototype.paintVertexShape = function(c, x, y, w, h)1016{1017 var dx = w * Math.max(0, Math.min(w, parseFloat(mxUtils.getValue(this.style, 'dx', this.dx))));1018 var strokeColor2 = mxUtils.getValue(this.style, 'strokeColor2', '#444444');10191020 c.translate(x, y);1021 1022 c.save();1023 c.save();1024 c.setStrokeColor(strokeColor2);1025 c.begin();1026 c.moveTo(0, h * 0.5);1027 c.lineTo(w, h * 0.5);1028 c.stroke();1029 1030 c.restore();1031 c.setShadow(false);1032 c.setAlpha('0.5');1033 c.setFillColor('#666666');1034 c.begin();1035 var r = Math.min(h, w * 0.1) / 2;1036 c.ellipse(dx - r, h * 0.5 - r, 2 * r, 2 * r);1037 c.fill();1038 1039 c.restore();1040 c.setShadow(false);1041 c.begin();1042 var r = Math.min(h, w * 0.1) / 8;1043 c.ellipse(dx - r, h * 0.5 - r, 2 * r, 2 * r);1044 c.fill();1045 1046};10471048mxCellRenderer.registerShape(mxShapeAndroidProgressScrubberDisabled.prototype.cst.PROGRESS_SCRUBBER_DISABLED, mxShapeAndroidProgressScrubberDisabled);10491050mxShapeAndroidProgressScrubberDisabled.prototype.constraints = null;10511052Graph.handleFactory[mxShapeAndroidProgressScrubberDisabled.prototype.cst.PROGRESS_SCRUBBER_DISABLED] = function(state)1053{1054 var handles = [Graph.createHandle(state, ['dx'], function(bounds)1055 {1056 var dx = Math.max(0, Math.min(1, parseFloat(mxUtils.getValue(this.state.style, 'dx', this.dx))));10571058 return new mxPoint(bounds.x + dx * bounds.width, bounds.y + bounds.height / 2);1059 }, function(bounds, pt)1060 {1061 this.state.style['dx'] = Math.round(100 * Math.max(0, Math.min(1, (pt.x - bounds.x) / bounds.width))) / 100;1062 })];10631064 return handles;1065}10661067//**********************************************************************************************************************************************************1068//Progress Scrubber Focused1069//**********************************************************************************************************************************************************1070/**1071* Extends mxShape.1072*/1073function mxShapeAndroidProgressScrubberFocused(bounds, fill, stroke, strokewidth)1074{1075 mxShape.call(this);1076 this.bounds = bounds;1077 this.fill = fill;1078 this.stroke = stroke;1079 this.strokewidth = (strokewidth != null) ? strokewidth : 1;1080 this.dx = 0.3;1081};10821083/**1084* Extends mxShape.1085*/1086mxUtils.extend(mxShapeAndroidProgressScrubberFocused, mxShape);10871088mxShapeAndroidProgressScrubberFocused.prototype.customProperties = [1089 {name: 'strokeColor2', dispName: 'Stroke Color 2', type: 'color', defVal:"#444444", primary: true},1090 {name: 'dx', dispName: 'Handle Position', type: 'float', min:0, max:1, defVal:0.3}1091];10921093mxShapeAndroidProgressScrubberFocused.prototype.cst = {1094 PROGRESS_SCRUBBER_FOCUSED : 'mxgraph.android.progressScrubberFocused'1095};10961097/**1098* Function: paintVertexShape1099* 1100* Paints the vertex shape.1101*/1102mxShapeAndroidProgressScrubberFocused.prototype.paintVertexShape = function(c, x, y, w, h)1103{1104 var dx = w * Math.max(0, Math.min(w, parseFloat(mxUtils.getValue(this.style, 'dx', this.dx))));1105 var fillColor = mxUtils.getValue(this.style, 'fillColor', '#ffffff');1106 var strokeColor2 = mxUtils.getValue(this.style, 'strokeColor2', '#444444');11071108 c.translate(x, y);1109 1110 c.save();1111 c.save();1112 c.setStrokeColor(strokeColor2);1113 c.begin();1114 c.moveTo(0, h * 0.5);1115 c.lineTo(w, h * 0.5);1116 c.stroke();1117 1118 c.restore();1119 c.setShadow(false);1120 c.setAlpha('0.75');1121 c.begin();1122 var r = Math.min(h, w * 0.1) / 2;1123 c.ellipse(dx - r, h * 0.5 - r, 2 * r, 2 * r);1124 c.fill();1125 1126 c.restore();1127 c.setShadow(false);1128 c.setStrokeColor(fillColor);1129 1130 c.begin();1131 c.moveTo(0, h * 0.5);1132 c.lineTo(dx, h * 0.5);1133 c.stroke();1134 1135 c.begin();1136 var r = Math.min(h, w * 0.1) / 8;1137 c.ellipse(dx - r, h * 0.5 - r, 2 * r, 2 * r);1138 c.fill();1139 1140};11411142mxCellRenderer.registerShape(mxShapeAndroidProgressScrubberFocused.prototype.cst.PROGRESS_SCRUBBER_FOCUSED, mxShapeAndroidProgressScrubberFocused);11431144mxShapeAndroidProgressScrubberFocused.prototype.constraints = null;11451146Graph.handleFactory[mxShapeAndroidProgressScrubberFocused.prototype.cst.PROGRESS_SCRUBBER_FOCUSED] = function(state)1147{1148 var handles = [Graph.createHandle(state, ['dx'], function(bounds)1149 {1150 var dx = Math.max(0, Math.min(1, parseFloat(mxUtils.getValue(this.state.style, 'dx', this.dx))));11511152 return new mxPoint(bounds.x + dx * bounds.width, bounds.y + bounds.height / 2);1153 }, function(bounds, pt)1154 {1155 this.state.style['dx'] = Math.round(100 * Math.max(0, Math.min(1, (pt.x - bounds.x) / bounds.width))) / 100;1156 })];11571158 return handles;1159}11601161//**********************************************************************************************************************************************************1162//Progress Scrubber Pressed1163//**********************************************************************************************************************************************************1164/**1165* Extends mxShape.1166*/1167function mxShapeAndroidProgressScrubberPressed(bounds, fill, stroke, strokewidth)1168{1169 mxShape.call(this);1170 this.bounds = bounds;1171 this.fill = fill;1172 this.stroke = stroke;1173 this.strokewidth = (strokewidth != null) ? strokewidth : 1;1174 this.dx = 0.3;1175};11761177/**1178* Extends mxShape.1179*/1180mxUtils.extend(mxShapeAndroidProgressScrubberPressed, mxShape);11811182mxShapeAndroidProgressScrubberPressed.prototype.customProperties = [1183 {name: 'strokeColor2', dispName: 'Stroke Color 2', type: 'color', defVal:"#444444", primary: true},1184 {name: 'dx', dispName: 'Handle Position', type: 'float', min:0, max:1, defVal:0.3}1185];11861187mxShapeAndroidProgressScrubberPressed.prototype.cst = {1188 PROGRESS_SCRUBBER_PRESSED : 'mxgraph.android.progressScrubberPressed'1189};11901191/**1192* Function: paintVertexShape1193* 1194* Paints the vertex shape.1195*/1196mxShapeAndroidProgressScrubberPressed.prototype.paintVertexShape = function(c, x, y, w, h)1197{1198 var dx = w * Math.max(0, Math.min(w, parseFloat(mxUtils.getValue(this.style, 'dx', this.dx))));1199 var fillColor = mxUtils.getValue(this.style, 'fillColor', '#ffffff');1200 var strokeColor2 = mxUtils.getValue(this.style, 'strokeColor2', '#444444');12011202 c.translate(x, y);1203 1204 c.save();1205 c.save();1206 c.setStrokeColor(strokeColor2);1207 c.begin();1208 c.moveTo(0, h * 0.5);1209 c.lineTo(w, h * 0.5);1210 c.stroke();1211 1212 c.restore();1213 c.setShadow(false);1214 c.setStrokeColor(fillColor);1215 c.setAlpha('0.5');1216 c.begin();1217 var r = Math.min(h, w * 0.1) / 2;1218 c.ellipse(dx - r, h * 0.5 - r, 2 * r, 2 * r);1219 c.fillAndStroke();1220 1221 c.restore();1222 c.setShadow(false);1223 c.setStrokeColor(fillColor);1224 1225 c.begin();1226 c.moveTo(0, h * 0.5);1227 c.lineTo(dx, h * 0.5);1228 c.stroke();1229 1230 c.begin();1231 var r = Math.min(h, w * 0.1) / 8;1232 c.ellipse(dx - r, h * 0.5 - r, 2 * r, 2 * r);1233 c.fill();1234 1235};12361237mxCellRenderer.registerShape(mxShapeAndroidProgressScrubberPressed.prototype.cst.PROGRESS_SCRUBBER_PRESSED, mxShapeAndroidProgressScrubberPressed);12381239mxShapeAndroidProgressScrubberPressed.prototype.constraints = null;12401241Graph.handleFactory[mxShapeAndroidProgressScrubberPressed.prototype.cst.PROGRESS_SCRUBBER_PRESSED] = function(state)1242{1243 var handles = [Graph.createHandle(state, ['dx'], function(bounds)1244 {1245 var dx = Math.max(0, Math.min(1, parseFloat(mxUtils.getValue(this.state.style, 'dx', this.dx))));12461247 return new mxPoint(bounds.x + dx * bounds.width, bounds.y + bounds.height / 2);1248 }, function(bounds, pt)1249 {1250 this.state.style['dx'] = Math.round(100 * Math.max(0, Math.min(1, (pt.x - bounds.x) / bounds.width))) / 100;1251 })];12521253 return handles;1254}12551256//**********************************************************************************************************************************************************1257//Quickscroll21258//**********************************************************************************************************************************************************1259/**1260* Extends mxShape.1261*/1262function mxShapeAndroidQuickscroll2(bounds, fill, stroke, strokewidth)1263{1264 mxShape.call(this);1265 this.bounds = bounds;1266 this.fill = fill;1267 this.stroke = stroke;1268 this.strokewidth = (strokewidth != null) ? strokewidth : 1;1269 this.dy = 0.5;1270};12711272/**1273* Extends mxShape.1274*/1275mxUtils.extend(mxShapeAndroidQuickscroll2, mxShape);12761277mxShapeAndroidQuickscroll2.prototype.customProperties = [1278 {name: 'fillColor2', dispName: 'Fill Color 2', type: 'color', defVal:"#cccccc", primary: true},1279 {name: 'fillColor3', dispName: 'Fill Color 3', type: 'color', defVal:"#666666", primary: true},1280 {name: 'dy', dispName: 'Handle Position', type: 'float', min:0, max:1, defVal:0.5}1281];12821283mxShapeAndroidQuickscroll2.prototype.cst = {1284 QUICKSCROLL : 'mxgraph.android.quickscroll2'1285};12861287/**1288* Function: paintVertexShape1289* 1290* Paints the vertex shape.1291*/1292mxShapeAndroidQuickscroll2.prototype.paintVertexShape = function(c, x, y, w, h)1293{1294 var dy = Math.min(h - 20, Math.max(20, h * Math.max(0, Math.min(h, parseFloat(mxUtils.getValue(this.style, 'dy', this.dy))))));1295 var fillColor = mxUtils.getValue(this.style, 'fillColor', '#ffffff');1296 var fillColor2 = mxUtils.getValue(this.style, 'fillColor2', '#cccccc');1297 var fillColor3 = mxUtils.getValue(this.style, 'fillColor3', '#666666');12981299 c.translate(x, y);1300 1301 c.save();1302 c.save();1303 c.setStrokeColor(fillColor2);1304 c.begin();1305 c.moveTo(w - 3, 0);1306 c.lineTo(w - 3, h);1307 c.stroke();1308 1309 c.restore();1310 c.begin();1311 c.roundrect(w - 6, dy - 10, 6, 20, 1, 1);1312 c.fillAndStroke();1313 1314 c.setFillColor(fillColor2);1315 c.begin();1316 c.rect(0, dy - 20, w - 18, 40);1317 c.fill();1318 1319 c.setFillColor(fillColor3);1320 c.begin();1321 c.moveTo(w - 18, dy - 20);1322 c.lineTo(w - 6, dy);1323 c.lineTo(w - 18, dy + 20);1324 c.close();1325 c.fill();1326 1327 c.setFontSize('12');1328 c.text((w - 18) * 0.5, dy, 0, 0, 'Aa', mxConstants.ALIGN_CENTER, mxConstants.ALIGN_MIDDLE, 0, null, 0, 0, 0);1329};13301331mxCellRenderer.registerShape(mxShapeAndroidQuickscroll2.prototype.cst.QUICKSCROLL, mxShapeAndroidQuickscroll2);13321333mxShapeAndroidQuickscroll2.prototype.constraints = null;13341335Graph.handleFactory[mxShapeAndroidQuickscroll2.prototype.cst.QUICKSCROLL] = function(state)1336{1337 var handles = [Graph.createHandle(state, ['dy'], function(bounds)1338 {1339 var dy = Math.max(0, Math.min(1, parseFloat(mxUtils.getValue(this.state.style, 'dy', this.dy))));13401341 return new mxPoint(bounds.x + bounds.width - 3, bounds.y + Math.min(bounds.height - 20, Math.max(20, dy * bounds.height)));1342 }, function(bounds, pt)1343 {1344 this.state.style['dy'] = Math.round(1000 * Math.max(0, Math.min(1, (pt.y - bounds.y) / bounds.height))) / 1000;1345 })];13461347 return handles;1348}13491350//**********************************************************************************************************************************************************1351//Quickscroll31352//**********************************************************************************************************************************************************1353/**1354* Extends mxShape.1355*/1356function mxShapeAndroidQuickscroll3(bounds, fill, stroke, strokewidth)1357{1358 mxShape.call(this);1359 this.bounds = bounds;1360 this.fill = fill;1361 this.stroke = stroke;1362 this.strokewidth = (strokewidth != null) ? strokewidth : 1;1363 this.dy = 0.5;1364};13651366/**1367* Extends mxShape.1368*/1369mxUtils.extend(mxShapeAndroidQuickscroll3, mxShape);13701371mxShapeAndroidQuickscroll3.prototype.customProperties = [1372 {name: 'fillColor2', dispName: 'Fill Color 2', type: 'color', defVal:"#cccccc", primary: true},1373 {name: 'dy', dispName: 'Handle Position', type: 'float', min:0, max:1, defVal:0.5}1374];13751376mxShapeAndroidQuickscroll3.prototype.cst = {1377 QUICKSCROLL : 'mxgraph.android.quickscroll3'1378};13791380/**1381* Function: paintVertexShape1382* 1383* Paints the vertex shape.1384*/1385mxShapeAndroidQuickscroll3.prototype.paintVertexShape = function(c, x, y, w, h)1386{1387 var dy = Math.min(h - 10, Math.max(10, h * Math.max(0, Math.min(h, parseFloat(mxUtils.getValue(this.style, 'dy', this.dy))))));1388 var fillColor = mxUtils.getValue(this.style, 'fillColor', '#ffffff');1389 var fillColor2 = mxUtils.getValue(this.style, 'fillColor2', '#cccccc');13901391 c.translate(x, y);1392 1393 c.save();1394 c.setStrokeColor(fillColor2);1395 c.begin();1396 c.moveTo(w * 0.5, 0);1397 c.lineTo(w * 0.5, h);1398 c.stroke();1399 1400 c.restore();1401 c.begin();1402 c.roundrect(w * 0.5 - 3, dy - 10, 6, 20, 1, 1);1403 c.fillAndStroke();1404};14051406mxCellRenderer.registerShape(mxShapeAndroidQuickscroll3.prototype.cst.QUICKSCROLL, mxShapeAndroidQuickscroll3);14071408mxShapeAndroidQuickscroll3.prototype.constraints = null;14091410Graph.handleFactory[mxShapeAndroidQuickscroll3.prototype.cst.QUICKSCROLL] = function(state)1411{1412 var handles = [Graph.createHandle(state, ['dy'], function(bounds)1413 {1414 var dy = Math.max(0, Math.min(1, parseFloat(mxUtils.getValue(this.state.style, 'dy', this.dy))));14151416 return new mxPoint(bounds.x + bounds.width * 0.5, bounds.y + Math.min(bounds.height - 10, Math.max(10, dy * bounds.height)));1417 }, function(bounds, pt)1418 {1419 this.state.style['dy'] = Math.round(1000 * Math.max(0, Math.min(1, (pt.y - bounds.y) / bounds.height))) / 1000;1420 })];14211422 return handles;1423}14241425//**********************************************************************************************************************************************************1426//Scrollbars1427//**********************************************************************************************************************************************************1428/**1429* Extends mxShape.1430*/1431function mxShapeAndroidScrollbars2(bounds, fill, stroke, strokewidth)1432{1433 mxShape.call(this);1434 this.bounds = bounds;1435 this.fill = fill;1436 this.stroke = stroke;1437 this.strokewidth = (strokewidth != null) ? strokewidth : 1;1438};14391440/**1441* Extends mxShape.1442*/1443mxUtils.extend(mxShapeAndroidScrollbars2, mxShape);14441445mxShapeAndroidScrollbars2.prototype.cst = {1446 SCROLLBARS : 'mxgraph.android.scrollbars2'1447};14481449/**1450* Function: paintVertexShape1451* 1452* Paints the vertex shape.1453*/1454mxShapeAndroidScrollbars2.prototype.paintVertexShape = function(c, x, y, w, h)1455{14561457 c.translate(x, y);1458 1459 c.begin();1460 c.rect(w - 5, 0, 5, h - 7);1461 c.fillAndStroke();14621463 c.begin();1464 c.rect(0, h - 5, w - 7, 5);1465 c.fillAndStroke();1466};14671468mxCellRenderer.registerShape(mxShapeAndroidScrollbars2.prototype.cst.SCROLLBARS, mxShapeAndroidScrollbars2);14691470mxShapeAndroidScrollbars2.prototype.constraints = null;14711472//**********************************************************************************************************************************************************1473//Spinner1474//**********************************************************************************************************************************************************1475/**1476* Extends mxShape.1477*/1478function mxShapeAndroidSpinner2(bounds, fill, stroke, strokewidth)1479{1480 mxShape.call(this);1481 this.bounds = bounds;1482 this.fill = fill;1483 this.stroke = stroke;1484 this.strokewidth = (strokewidth != null) ? strokewidth : 1;1485};14861487/**1488* Extends mxShape.1489*/1490mxUtils.extend(mxShapeAndroidSpinner2, mxShape);14911492mxShapeAndroidSpinner2.prototype.cst = {1493 SPINNER : 'mxgraph.android.spinner2'1494};14951496/**1497* Function: paintVertexShape1498* 1499* Paints the vertex shape.1500*/1501mxShapeAndroidSpinner2.prototype.paintVertexShape = function(c, x, y, w, h)1502{15031504 c.translate(x, y);1505 1506 c.begin();1507 c.moveTo(0, h);1508 c.lineTo(w, h);1509 c.stroke();1510 1511 var s = Math.min(w / 10, h)1512 c.begin();1513 c.moveTo(w - s, h);1514 c.lineTo(w, h - s);1515 c.lineTo(w, h);1516 c.close();1517 c.fillAndStroke();1518};15191520mxCellRenderer.registerShape(mxShapeAndroidSpinner2.prototype.cst.SPINNER, mxShapeAndroidSpinner2);15211522mxShapeAndroidSpinner2.prototype.constraints = null;1523