123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926 |
- /**
- * $Id: mxGmdl.js,v 1.0 2015/09/09 17:05:39 mate Exp $
- * Copyright (c) 2006-2015, JGraph Ltd
- */
- //**********************************************************************************************************************************************************
- //player
- //**********************************************************************************************************************************************************
- /**
- * Extends mxShape.
- */
- function mxShapeGmdlPlayer(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(mxShapeGmdlPlayer, mxShape);
- mxShapeGmdlPlayer.prototype.cst = {
- SHAPE_PLAYER : 'mxgraph.gmdl.player'
- };
- /**
- * Function: paintVertexShape
- *
- * Paints the vertex shape.
- */
- mxShapeGmdlPlayer.prototype.paintVertexShape = function(c, x, y, w, h)
- {
- c.translate(x, y);
- c.begin();
- c.rect(0, 0, w, h);
- c.fill();
- c.setShadow(false);
- this.foreground(c, x, y, w, h);
- };
- mxShapeGmdlPlayer.prototype.foreground = function(c, x, y, w, h)
- {
- if ( h >= 4)
- {
- c.setFillColor('#FFED00');
- c.begin();
- c.rect(0, 0, w * 0.8, 4);
- c.fill();
- }
-
- if ( h >= 14 && w >= 33)
- {
- c.setFillColor('#717171');
- c.begin();
- c.rect(w - 33, h * 0.5 - 7, 4, 14);
- c.fill();
- c.begin();
- c.rect(w - 25, h * 0.5 - 7, 4, 14);
- c.fill();
- }
- };
- mxCellRenderer.prototype.defaultShapes[mxShapeGmdlPlayer.prototype.cst.SHAPE_PLAYER] = mxShapeGmdlPlayer;
- //**********************************************************************************************************************************************************
- //switch
- //**********************************************************************************************************************************************************
- /**
- * Extends mxShape.
- */
- function mxShapeGmdlSwitch(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(mxShapeGmdlSwitch, mxShape);
- mxShapeGmdlSwitch.prototype.cst = {
- SHAPE_SWITCH : 'mxgraph.gmdl.switch',
- STATE : 'switchState',
- STATE_ON : 'on',
- STATE_OFF : 'off'
- };
- /**
- * Function: paintVertexShape
- *
- * Paints the vertex shape.
- */
- mxShapeGmdlSwitch.prototype.paintVertexShape = function(c, x, y, w, h)
- {
-
- c.translate(x, y);
- var state = mxUtils.getValue(this.style, mxShapeGmdlSwitch.prototype.cst.STATE, mxShapeGmdlSwitch.prototype.cst.STATE_ON);
- this.background(c, x, y, w, h, state);
- c.setShadow(true);
- this.foreground(c, x, y, w, h, state);
- };
- mxShapeGmdlSwitch.prototype.background = function(c, x, y, w, h, state)
- {
- c.begin();
- if (state === mxShapeGmdlSwitch.prototype.cst.STATE_ON)
- {
- c.save();
- c.setAlpha('0.5');
- c.moveTo(w * 0.135, h * 0.8);
- c.arcTo(w * 0.135, h * 0.3, 0, 0, 1, w * 0.135, h * 0.2);
- c.lineTo(w * 0.675, h * 0.2);
- c.arcTo(w * 0.135, h * 0.3, 0, 0, 1, w * 0.675, h * 0.8);
- c.close();
- c.fillAndStroke();
- c.restore();
- }
- else
- {
- c.setFillColor('#BCBBBB');
- c.moveTo(w * 0.225, h * 0.8);
- c.arcTo(w * 0.135, h * 0.3, 0, 0, 1, w * 0.225, h * 0.2);
- c.lineTo(w * 0.865, h * 0.2);
- c.arcTo(w * 0.135, h * 0.3, 0, 0, 1, w * 0.865, h * 0.8);
- c.close();
- c.fillAndStroke();
- }
- };
- mxShapeGmdlSwitch.prototype.foreground = function(c, x, y, w, h, state)
- {
- c.begin();
- if (state === mxShapeGmdlSwitch.prototype.cst.STATE_ON)
- {
- c.ellipse(w * 0.36, 0, w * 0.64, h);
- }
- else
- {
- c.setFillColor('#F1F1F1');
- c.ellipse(0, 0, w * 0.64, h);
- }
- c.fillAndStroke();
- };
- mxCellRenderer.prototype.defaultShapes[mxShapeGmdlSwitch.prototype.cst.SHAPE_SWITCH] = mxShapeGmdlSwitch;
- //**********************************************************************************************************************************************************
- //rect with margins
- //**********************************************************************************************************************************************************
- /**
- * Extends mxShape.
- */
- function mxShapeGmdlMarginRect(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(mxShapeGmdlMarginRect, mxShape);
- mxShapeGmdlMarginRect.prototype.cst = {
- SHAPE_MARGIN_RECT : 'mxgraph.gmdl.marginRect',
- MARGIN : 'rectMargin',
- MARGIN_TOP : 'rectMarginTop',
- MARGIN_LEFT : 'rectMarginLeft',
- MARGIN_BOTTOM : 'rectMarginBottom',
- MARGIN_RIGHT : 'rectMarginRight'
- };
- /**
- * Function: paintVertexShape
- *
- * Paints the vertex shape.
- */
- mxShapeGmdlMarginRect.prototype.paintVertexShape = function(c, x, y, w, h)
- {
-
- c.translate(x, y);
- this.background(c, x, y, w, h);
- };
- mxShapeGmdlMarginRect.prototype.background = function(c, x, y, w, h, state)
- {
- var margin = parseFloat(mxUtils.getValue(this.style, mxShapeGmdlMarginRect.prototype.cst.MARGIN, '0'));
- var marginTop = parseFloat(mxUtils.getValue(this.style, mxShapeGmdlMarginRect.prototype.cst.MARGIN_TOP, '0'));
- var marginLeft = parseFloat(mxUtils.getValue(this.style, mxShapeGmdlMarginRect.prototype.cst.MARGIN_LEFT, '0'));
- var marginBottom = parseFloat(mxUtils.getValue(this.style, mxShapeGmdlMarginRect.prototype.cst.MARGIN_BOTTOM, '0'));
- var marginRight = parseFloat(mxUtils.getValue(this.style, mxShapeGmdlMarginRect.prototype.cst.MARGIN_RIGHT, '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.rect(x1, y1, w1, h1);
- c.fillAndStroke();
- }
- };
- mxCellRenderer.prototype.defaultShapes[mxShapeGmdlMarginRect.prototype.cst.SHAPE_MARGIN_RECT] = mxShapeGmdlMarginRect;
- //**********************************************************************************************************************************************************
- //slider normal
- //**********************************************************************************************************************************************************
- /**
- * Extends mxShape.
- */
- function mxShapeGmdlSliderNormal(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(mxShapeGmdlSliderNormal, mxShape);
- mxShapeGmdlSliderNormal.prototype.cst = {
- SHAPE_SLIDER_NORMAL : 'mxgraph.gmdl.sliderNormal',
- HANDLE_SIZE : 'handleSize'
- };
- /**
- * Function: paintVertexShape
- *
- * Paints the vertex shape.
- */
- mxShapeGmdlSliderNormal.prototype.paintVertexShape = function(c, x, y, w, h)
- {
-
- c.translate(x, y);
- this.background(c, x, y, w, h);
- c.setShadow(true);
- };
- mxShapeGmdlSliderNormal.prototype.background = function(c, x, y, w, h)
- {
- var hSize = parseFloat(mxUtils.getValue(this.style, mxShapeGmdlSliderNormal.prototype.cst.HANDLE_SIZE, '10'));
- c.ellipse(0, h * 0.5 - hSize * 0.5, hSize, hSize);
- c.stroke();
-
- c.begin();
- c.moveTo(hSize, h * 0.5);
- c.lineTo(w, h * 0.5);
- c.fillAndStroke();
- };
- mxCellRenderer.prototype.defaultShapes[mxShapeGmdlSliderNormal.prototype.cst.SHAPE_SLIDER_NORMAL] = mxShapeGmdlSliderNormal;
- //**********************************************************************************************************************************************************
- //slider normal v2
- //**********************************************************************************************************************************************************
- /**
- * Extends mxShape.
- */
- function mxShapeGmdlSlider2(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(mxShapeGmdlSlider2, mxShape);
- mxShapeGmdlSlider2.prototype.cst = {
- SHAPE_SLIDER : 'mxgraph.gmdl.slider2',
- BAR_POS : 'barPos',
- HANDLE_SIZE : 'handleSize'
- };
- /**
- * Function: paintVertexShape
- *
- * Paints the vertex shape.
- */
- mxShapeGmdlSlider2.prototype.paintVertexShape = function(c, x, y, w, h)
- {
-
- c.translate(x, y);
- this.background(c, x, y, w, h);
- c.setShadow(true);
- };
- mxShapeGmdlSlider2.prototype.background = function(c, x, y, w, h)
- {
- var hSize = parseFloat(mxUtils.getValue(this.style, mxShapeGmdlSlider2.prototype.cst.HANDLE_SIZE, '10'));
- var barPos = parseFloat(mxUtils.getValue(this.style, mxShapeGmdlSlider2.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.begin();
- c.ellipse(barPos * w - hSize * 0.5, h * 0.5 - hSize * 0.5, hSize, hSize);
- c.fillAndStroke();
- };
- mxCellRenderer.prototype.defaultShapes[mxShapeGmdlSlider2.prototype.cst.SHAPE_SLIDER] = mxShapeGmdlSlider2;
- mxShapeGmdlSlider2.prototype.constraints = null;
- Graph.handleFactory[mxShapeGmdlSlider2.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;
- };
- //**********************************************************************************************************************************************************
- //slider focused v2
- //**********************************************************************************************************************************************************
- /**
- * Extends mxShape.
- */
- function mxShapeGmdlSliderFocused(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(mxShapeGmdlSliderFocused, mxShape);
- mxShapeGmdlSliderFocused.prototype.cst = {
- SHAPE_SLIDER_FOCUSED : 'mxgraph.gmdl.sliderFocused',
- BAR_POS : 'barPos',
- HANDLE_SIZE : 'handleSize'
- };
- /**
- * Function: paintVertexShape
- *
- * Paints the vertex shape.
- */
- mxShapeGmdlSliderFocused.prototype.paintVertexShape = function(c, x, y, w, h)
- {
-
- c.translate(x, y);
- this.background(c, x, y, w, h);
- c.setShadow(true);
- };
- mxShapeGmdlSliderFocused.prototype.background = function(c, x, y, w, h)
- {
- var hSize = parseFloat(mxUtils.getValue(this.style, mxShapeGmdlSliderFocused.prototype.cst.HANDLE_SIZE, '10'));
- var barPos = parseFloat(mxUtils.getValue(this.style, mxShapeGmdlSliderFocused.prototype.cst.BAR_POS, '40')) / 100;
- var strokeColor = mxUtils.getValue(this.style, mxConstants.STYLE_STROKECOLOR, '#ffffff');
- 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.begin();
- c.ellipse(barPos * w - hSize * 0.167, h * 0.5 - hSize * 0.167, hSize * 0.33, hSize * 0.33);
- c.fillAndStroke();
- c.setFillColor(strokeColor);
- c.setAlpha(0.15);
- c.begin();
- c.ellipse(barPos * w - hSize * 0.5, h * 0.5 - hSize * 0.5, hSize, hSize);
- c.fill();
- };
- mxCellRenderer.prototype.defaultShapes[mxShapeGmdlSliderFocused.prototype.cst.SHAPE_SLIDER_FOCUSED] = mxShapeGmdlSliderFocused;
- mxShapeGmdlSliderFocused.prototype.constraints = null;
- Graph.handleFactory[mxShapeGmdlSliderFocused.prototype.cst.SHAPE_SLIDER_FOCUSED] = 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;
- };
- //**********************************************************************************************************************************************************
- //slider disabled
- //**********************************************************************************************************************************************************
- /**
- * Extends mxShape.
- */
- function mxShapeGmdlSliderDisabled(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(mxShapeGmdlSliderDisabled, mxShape);
- mxShapeGmdlSliderDisabled.prototype.cst = {
- SHAPE_SLIDER_DISABLED : 'mxgraph.gmdl.sliderDisabled',
- HANDLE_POSITION : 'hPos',
- HANDLE_SIZE : 'handleSize'
- };
- /**
- * Function: paintVertexShape
- *
- * Paints the vertex shape.
- */
- mxShapeGmdlSliderDisabled.prototype.paintVertexShape = function(c, x, y, w, h)
- {
- c.translate(x, y);
- this.background(c, x, y, w, h);
- c.setShadow(true);
- };
- mxShapeGmdlSliderDisabled.prototype.background = function(c, x, y, w, h)
- {
- var hSize = parseFloat(mxUtils.getValue(this.style, mxShapeGmdlSliderDisabled.prototype.cst.HANDLE_SIZE, '10'));
- var hPos = parseFloat(mxUtils.getValue(this.style, mxShapeGmdlSliderDisabled.prototype.cst.HANDLE_POSITION, '50')) / 100;
-
- hPos = Math.max(hPos, 0);
- hPos = Math.min(hPos, 1);
- c.ellipse(w * hPos - hSize * 0.5, (h - hSize) * 0.5, hSize, hSize);
- c.fillAndStroke();
-
- var endL = w * hPos - 7;
- var startR = w * hPos + 7;
-
- if (endL > 0)
- {
- c.begin();
- c.moveTo(0, h * 0.5);
- c.lineTo(endL, h * 0.5);
- c.stroke();
- }
-
- if (startR < w)
- {
- c.begin();
- c.moveTo(startR, h * 0.5);
- c.lineTo(w, h * 0.5);
- c.stroke();
- }
- };
- mxCellRenderer.prototype.defaultShapes[mxShapeGmdlSliderDisabled.prototype.cst.SHAPE_SLIDER_DISABLED] = mxShapeGmdlSliderDisabled;
- //**********************************************************************************************************************************************************
- //slider disabled v2
- //**********************************************************************************************************************************************************
- /**
- * Extends mxShape.
- */
- function mxShapeGmdlSliderDisabled2(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(mxShapeGmdlSliderDisabled2, mxShape);
- mxShapeGmdlSliderDisabled2.prototype.cst = {
- SHAPE_SLIDER_DISABLED : 'mxgraph.gmdl.sliderDisabled2',
- HANDLE_POSITION : 'hPos',
- HANDLE_SIZE : 'handleSize'
- };
- /**
- * Function: paintVertexShape
- *
- * Paints the vertex shape.
- */
- mxShapeGmdlSliderDisabled2.prototype.paintVertexShape = function(c, x, y, w, h)
- {
- c.translate(x, y);
- this.background(c, x, y, w, h);
- c.setShadow(true);
- };
- mxShapeGmdlSliderDisabled2.prototype.background = function(c, x, y, w, h)
- {
- var hSize = parseFloat(mxUtils.getValue(this.style, mxShapeGmdlSliderDisabled2.prototype.cst.HANDLE_SIZE, '10'));
- var hPos = parseFloat(mxUtils.getValue(this.style, mxShapeGmdlSliderDisabled2.prototype.cst.HANDLE_POSITION, '50')) / 100;
-
- hPos = Math.min(Math.max(hPos, 0), 1);
- c.ellipse(w * hPos - hSize * 0.5, (h - hSize) * 0.5, hSize, hSize);
- c.fillAndStroke();
-
- var endL = w * hPos - 7;
- var startR = w * hPos + 7;
-
- if (endL > 0)
- {
- c.begin();
- c.moveTo(0, h * 0.5);
- c.lineTo(endL, h * 0.5);
- c.stroke();
- }
-
- if (startR < w)
- {
- c.begin();
- c.moveTo(startR, h * 0.5);
- c.lineTo(w, h * 0.5);
- c.stroke();
- }
- };
- mxCellRenderer.prototype.defaultShapes[mxShapeGmdlSliderDisabled2.prototype.cst.SHAPE_SLIDER_DISABLED] = mxShapeGmdlSliderDisabled2;
- mxShapeGmdlSlider2.prototype.constraints = null;
- Graph.handleFactory[mxShapeGmdlSliderDisabled2.prototype.cst.SHAPE_SLIDER_DISABLED] = function(state)
- {
- var handles = [Graph.createHandle(state, ['hPos'], function(bounds)
- {
- var hPos = Math.max(0, Math.min(bounds.width, parseFloat(mxUtils.getValue(this.state.style, 'hPos', 0.4))));
- return new mxPoint(bounds.x + hPos * bounds.width / 100, bounds.y + bounds.height / 2);
- }, function(bounds, pt)
- {
- this.state.style['hPos'] = Math.round(100 * Math.max(0, Math.min(100, (pt.x - bounds.x) * 100 / bounds.width))) / 100;
- })];
-
- return handles;
- };
- //**********************************************************************************************************************************************************
- //slider discrete
- //**********************************************************************************************************************************************************
- /**
- * Extends mxShape.
- */
- function mxShapeGmdlSliderDiscrete(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(mxShapeGmdlSliderDiscrete, mxShape);
- mxShapeGmdlSliderDiscrete.prototype.cst = {
- SHAPE_DISCRETE : 'mxgraph.gmdl.sliderDiscrete',
- BAR_POS : 'barPos',
- HANDLE_SIZE : 'handleSize'
- };
- /**
- * Function: paintVertexShape
- *
- * Paints the vertex shape.
- */
- mxShapeGmdlSliderDiscrete.prototype.paintVertexShape = function(c, x, y, w, h)
- {
-
- c.translate(x, y);
- this.background(c, x, y, w, h);
- c.setShadow(true);
- };
- mxShapeGmdlSliderDiscrete.prototype.background = function(c, x, y, w, h)
- {
- var hSize = parseFloat(mxUtils.getValue(this.style, mxShapeGmdlSliderDiscrete.prototype.cst.HANDLE_SIZE, '10'));
- var barPos = parseFloat(mxUtils.getValue(this.style, mxShapeGmdlSliderDiscrete.prototype.cst.BAR_POS, '40')) / 100;
- var fontSize = parseFloat(mxUtils.getValue(this.style, mxConstants.STYLE_FONTSIZE, '12'));
- var fontColor = mxUtils.getValue(this.style, mxConstants.STYLE_FONTCOLOR, '#000000');
- barPos = Math.max(0, Math.min(1, barPos));
- c.save();
- c.setStrokeColor('#bbbbbb');
- c.begin();
- c.moveTo(0, h * 0.5 + 22.5);
- c.lineTo(w, h * 0.5 + 22.5);
- c.fillAndStroke();
-
- c.restore();
- c.begin();
- c.moveTo(0, h * 0.5 + 22.5);
- c.lineTo(barPos * w, h * 0.5 + 22.5);
- c.fillAndStroke();
-
- c.begin();
- c.moveTo(barPos * w, h * 0.5 + 15.5);
- c.lineTo(barPos * w - 10.5, h * 0.5 + 2.5);
- c.arcTo(15, 15, 0, 0, 1, barPos * w, h * 0.5 - 22.5);
- c.arcTo(15, 15, 0, 0, 1, barPos * w + 10.5, h * 0.5 + 2.5);
- c.close();
- c.fillAndStroke();
- c.setFontSize(fontSize);
- c.setFontColor(fontColor);
- var p = Math.round(barPos * 100);
- c.text(barPos * w, h * 0.5 - 9, 0, 0, p.toString() , mxConstants.ALIGN_CENTER, mxConstants.ALIGN_MIDDLE, 0, null, 0, 0, 0);
- };
- mxCellRenderer.prototype.defaultShapes[mxShapeGmdlSliderDiscrete.prototype.cst.SHAPE_DISCRETE] = mxShapeGmdlSliderDiscrete;
- mxShapeGmdlSliderDiscrete.prototype.constraints = null;
- Graph.handleFactory[mxShapeGmdlSliderDiscrete.prototype.cst.SHAPE_DISCRETE] = 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 + 22.5);
- }, 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;
- };
- //**********************************************************************************************************************************************************
- //slider discrete with dots
- //**********************************************************************************************************************************************************
- /**
- * Extends mxShape.
- */
- function mxShapeGmdlSliderDiscreteDots(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(mxShapeGmdlSliderDiscreteDots, mxShape);
- mxShapeGmdlSliderDiscreteDots.prototype.cst = {
- SHAPE_DISCRETE_DOTS : 'mxgraph.gmdl.sliderDiscreteDots',
- BAR_POS : 'barPos',
- HANDLE_SIZE : 'handleSize'
- };
- /**
- * Function: paintVertexShape
- *
- * Paints the vertex shape.
- */
- mxShapeGmdlSliderDiscreteDots.prototype.paintVertexShape = function(c, x, y, w, h)
- {
-
- c.translate(x, y);
- this.background(c, x, y, w, h);
- c.setShadow(true);
- };
- mxShapeGmdlSliderDiscreteDots.prototype.background = function(c, x, y, w, h)
- {
- var hSize = parseFloat(mxUtils.getValue(this.style, mxShapeGmdlSliderDiscreteDots.prototype.cst.HANDLE_SIZE, '10'));
- var barPos = parseFloat(mxUtils.getValue(this.style, mxShapeGmdlSliderDiscreteDots.prototype.cst.BAR_POS, '40')) / 100;
- var fontSize = parseFloat(mxUtils.getValue(this.style, mxConstants.STYLE_FONTSIZE, '12'));
- var fontColor = mxUtils.getValue(this.style, mxConstants.STYLE_FONTCOLOR, '#000000');
- var bright = mxUtils.getValue(this.style, 'bright', '1');
- barPos = Math.max(0, Math.min(1, barPos));
- c.save();
- c.setStrokeColor('#bebebe');
- c.begin();
- c.moveTo(0, h * 0.5 + 22.5);
- c.lineTo(w, h * 0.5 + 22.5);
- c.fillAndStroke();
-
- c.restore();
- if (barPos <= 0.1)
- {
- c.setFillColor('#bebebe');
- }
-
- c.begin();
- c.moveTo(0, h * 0.5 + 22.5);
- c.lineTo(barPos * w, h * 0.5 + 22.5);
- c.fillAndStroke();
-
- c.begin();
- c.moveTo(barPos * w, h * 0.5 + 15.5);
- c.lineTo(barPos * w - 10.5, h * 0.5 + 2.5);
- c.arcTo(15, 15, 0, 0, 1, barPos * w, h * 0.5 - 22.5);
- c.arcTo(15, 15, 0, 0, 1, barPos * w + 10.5, h * 0.5 + 2.5);
- c.close();
- c.fill();
-
- if (bright == '1')
- {
- c.setFillColor('#000000');
- }
- else
- {
- c.setFillColor('#ffffff');
- }
-
- c.ellipse(-1.5, h * 0.5 + 21, 3, 3);
- c.fill();
-
- c.ellipse(w * 0.2 - 1.5, h * 0.5 + 21, 3, 3);
- c.fill();
-
- c.ellipse(w * 0.4 - 1.5, h * 0.5 + 21, 3, 3);
- c.fill();
-
- c.ellipse(w * 0.6 - 1.5, h * 0.5 + 21, 3, 3);
- c.fill();
-
- c.ellipse(w * 0.8 - 1.5, h * 0.5 + 21, 3, 3);
- c.fill();
-
- c.ellipse(w - 1.5, h * 0.5 + 21, 3, 3);
- c.fill();
-
- c.setFontSize(fontSize);
- c.setFontColor(fontColor);
- var p = Math.round(barPos * 100);
- c.text(barPos * w, h * 0.5 - 9, 0, 0, p.toString() , mxConstants.ALIGN_CENTER, mxConstants.ALIGN_MIDDLE, 0, null, 0, 0, 0);
- };
- mxCellRenderer.prototype.defaultShapes[mxShapeGmdlSliderDiscreteDots.prototype.cst.SHAPE_DISCRETE_DOTS] = mxShapeGmdlSliderDiscreteDots;
- mxShapeGmdlSliderDiscreteDots.prototype.constraints = null;
- Graph.handleFactory[mxShapeGmdlSliderDiscreteDots.prototype.cst.SHAPE_DISCRETE_DOTS] = 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 + 22.5);
- }, function(bounds, pt)
- {
- this.state.style['barPos'] = Math.round(0.05 * Math.max(0, Math.min(100, (pt.x - bounds.x) * 100 / bounds.width))) / 0.05;
- })];
-
- return handles;
- };
- //**********************************************************************************************************************************************************
- //Progress Bar
- //**********************************************************************************************************************************************************
- /**
- * Extends mxShape.
- */
- function mxShapeGmdlProgressBar(bounds, fill, stroke, strokewidth)
- {
- mxShape.call(this);
- this.bounds = bounds;
- this.fill = fill;
- this.stroke = stroke;
- this.strokewidth = (strokewidth != null) ? strokewidth : 1;
- this.dx1 = 0.8;
- };
- /**
- * Extends mxShape.
- */
- mxUtils.extend(mxShapeGmdlProgressBar, mxShape);
- mxShapeGmdlProgressBar.prototype.cst = {
- PROGRESS_BAR : 'mxgraph.gmdl.progressBar'
- };
- /**
- * Function: paintVertexShape
- *
- * Paints the vertex shape.
- */
- mxShapeGmdlProgressBar.prototype.paintVertexShape = function(c, x, y, w, h)
- {
- var dx1 = w * Math.max(0, Math.min(w, parseFloat(mxUtils.getValue(this.style, 'dx1', this.dx1))));
- c.translate(x, y);
-
- c.save();
- c.setStrokeColor('#aaaaaa');
- c.begin();
- c.moveTo(0, h * 0.5);
- c.lineTo(w , h * 0.5);
- c.stroke();
-
- c.restore();
- c.setShadow(false);
- c.begin();
- c.moveTo(0, h * 0.5);
- c.lineTo(dx1, h * 0.5);
- c.stroke();
-
- // c.setStrokeColor('#000000');
- // c.setAlpha('0.2');
- // c.begin();
- // c.moveTo(0, h * 0.5);
- // c.lineTo(dx1, h * 0.5);
- // c.stroke();
-
- };
- mxCellRenderer.registerShape(mxShapeGmdlProgressBar.prototype.cst.PROGRESS_BAR, mxShapeGmdlProgressBar);
- mxShapeGmdlProgressBar.prototype.constraints = null;
- Graph.handleFactory[mxShapeGmdlProgressBar.prototype.cst.PROGRESS_BAR] = function(state)
- {
- var handles = [Graph.createHandle(state, ['dx1'], function(bounds)
- {
- var dx1 = Math.max(0, Math.min(1, parseFloat(mxUtils.getValue(this.state.style, 'dx1', this.dx1))));
- return new mxPoint(bounds.x + dx1 * bounds.width, bounds.y + bounds.height / 2);
- }, function(bounds, pt)
- {
- this.state.style['dx1'] = Math.round(100 * Math.max(0, Math.min(1, (pt.x - bounds.x) / bounds.width))) / 100;
- })];
- var handle2 = Graph.createHandle(state, ['dx2'], function(bounds)
- {
- var dx2 = Math.max(0, Math.min(1, parseFloat(mxUtils.getValue(this.state.style, 'dx2', this.dx1))));
- return new mxPoint(bounds.x + dx2 * bounds.width, bounds.y + bounds.height / 2);
- }, function(bounds, pt)
- {
- this.state.style['dx2'] = Math.round(100 * Math.max(0, Math.min(1, (pt.x - bounds.x) / bounds.width))) / 100;
- });
-
- handles.push(handle2);
- return handles;
- };
|