123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619 |
- /**
- * $Id: mxPidInstruments.js,v 1.4 2014/01/21 13:10:17 gaudenz Exp $
- * Copyright (c) 2006-2013, JGraph Ltd
- */
- //**********************************************************************************************************************************************************
- //Discrete Instrument
- //**********************************************************************************************************************************************************
- /**
- * Extends mxShape.
- */
- function mxShapePidDiscInst(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(mxShapePidDiscInst, mxShape);
- mxShapePidDiscInst.prototype.cst = {
- SHAPE_DISC_INST : 'mxgraph.pid2inst.discInst',
- MOUNTING : 'mounting',
- FIELD : 'field',
- ROOM : 'room',
- INACCESSIBLE : 'inaccessible',
- LOCAL : 'local'
- };
- /**
- * Function: paintVertexShape
- *
- * Paints the vertex shape.
- */
- mxShapePidDiscInst.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);
- };
- mxShapePidDiscInst.prototype.background = function(c, x, y, w, h)
- {
- c.ellipse(0, 0, w, h);
- c.fillAndStroke();
- };
- mxShapePidDiscInst.prototype.foreground = function(c, x, y, w, h)
- {
- var mounting = mxUtils.getValue(this.style, mxShapePidDiscInst.prototype.cst.MOUNTING, 'field');
- if (mounting === mxShapePidDiscInst.prototype.cst.ROOM)
- {
- c.begin();
- c.moveTo(0, h * 0.5);
- c.lineTo(w, h * 0.5);
- c.stroke();
- }
- else if (mounting === mxShapePidDiscInst.prototype.cst.INACCESSIBLE)
- {
- c.setDashed(true);
- c.begin();
- c.moveTo(0, h * 0.5);
- c.lineTo(w, h * 0.5);
- c.stroke();
- }
- else if (mounting === mxShapePidDiscInst.prototype.cst.LOCAL)
- {
- c.begin();
- c.moveTo(w * 0.005, h * 0.48);
- c.lineTo(w * 0.995, h * 0.48);
- c.moveTo(w * 0.005, h * 0.52);
- c.lineTo(w * 0.995, h * 0.52);
- c.stroke();
- }
- };
- mxCellRenderer.prototype.defaultShapes[mxShapePidDiscInst.prototype.cst.SHAPE_DISC_INST] = mxShapePidDiscInst;
- mxShapePidDiscInst.prototype.constraints = [
- new mxConnectionConstraint(new mxPoint(0.5, 0), true),
- new mxConnectionConstraint(new mxPoint(0.5, 1), true),
- new mxConnectionConstraint(new mxPoint(0, 0.5), true),
- new mxConnectionConstraint(new mxPoint(1, 0.5), true),
- new mxConnectionConstraint(new mxPoint(0.145, 0.145), false),
- new mxConnectionConstraint(new mxPoint(0.145, 0.855), false),
- new mxConnectionConstraint(new mxPoint(0.855, 0.145), false),
- new mxConnectionConstraint(new mxPoint(0.855, 0.855), false)
- ];
- //**********************************************************************************************************************************************************
- //Shared Control/Display
- //**********************************************************************************************************************************************************
- /**
- * Extends mxShape.
- */
- function mxShapePidSharedCont(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(mxShapePidSharedCont, mxShape);
- mxShapePidSharedCont.prototype.cst = {
- SHAPE_SHARED_CONT : 'mxgraph.pid2inst.sharedCont',
- MOUNTING : 'mounting',
- FIELD : 'field',
- ROOM : 'room',
- INACCESSIBLE : 'inaccessible',
- LOCAL : 'local'
- };
- /**
- * Function: paintVertexShape
- *
- * Paints the vertex shape.
- */
- mxShapePidSharedCont.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);
- };
- mxShapePidSharedCont.prototype.background = function(c, x, y, w, h)
- {
- c.rect(0, 0, w, h);
- c.fillAndStroke();
- };
- mxShapePidSharedCont.prototype.foreground = function(c, x, y, w, h)
- {
- var mounting = mxUtils.getValue(this.style, mxShapePidSharedCont.prototype.cst.MOUNTING, 'field');
- c.ellipse(0, 0, w, h);
- c.fillAndStroke();
- if (mounting === mxShapePidSharedCont.prototype.cst.ROOM)
- {
- c.begin();
- c.moveTo(0, h * 0.5);
- c.lineTo(w, h * 0.5);
- c.stroke();
- }
- else if (mounting === mxShapePidSharedCont.prototype.cst.INACCESSIBLE)
- {
- c.setDashed(true);
- c.begin();
- c.moveTo(0, h * 0.5);
- c.lineTo(w, h * 0.5);
- c.stroke();
- }
- else if (mounting === mxShapePidDiscInst.prototype.cst.LOCAL)
- {
- c.begin();
- c.moveTo(w * 0.005, h * 0.48);
- c.lineTo(w * 0.995, h * 0.48);
- c.moveTo(w * 0.005, h * 0.52);
- c.lineTo(w * 0.995, h * 0.52);
- c.stroke();
- }
- };
- mxCellRenderer.prototype.defaultShapes[mxShapePidSharedCont.prototype.cst.SHAPE_SHARED_CONT] = mxShapePidSharedCont;
- mxShapePidSharedCont.prototype.constraints = [
- new mxConnectionConstraint(new mxPoint(0.5, 0), true),
- new mxConnectionConstraint(new mxPoint(0.5, 1), true),
- new mxConnectionConstraint(new mxPoint(0, 0.5), true),
- new mxConnectionConstraint(new mxPoint(1, 0.5), true),
- new mxConnectionConstraint(new mxPoint(0, 0), false),
- new mxConnectionConstraint(new mxPoint(0, 1), false),
- new mxConnectionConstraint(new mxPoint(1, 0), false),
- new mxConnectionConstraint(new mxPoint(1, 1), false)
- ];
- //**********************************************************************************************************************************************************
- //Computer Function
- //**********************************************************************************************************************************************************
- /**
- * Extends mxShape.
- */
- function mxShapePidCompFunc(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(mxShapePidCompFunc, mxShape);
- mxShapePidCompFunc.prototype.cst = {
- SHAPE_COMP_FUNC : 'mxgraph.pid2inst.compFunc',
- MOUNTING : 'mounting',
- FIELD : 'field',
- ROOM : 'room',
- INACCESSIBLE : 'inaccessible',
- LOCAL : 'local'
- };
- /**
- * Function: paintVertexShape
- *
- * Paints the vertex shape.
- */
- mxShapePidCompFunc.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);
- };
- mxShapePidCompFunc.prototype.background = function(c, x, y, w, h)
- {
- c.begin();
- c.moveTo(0, h * 0.5);
- c.lineTo(w * 0.25, 0);
- c.lineTo(w * 0.75, 0);
- c.lineTo(w, h * 0.5);
- c.lineTo(w * 0.75, h);
- c.lineTo(w * 0.25, h);
- c.close();
- c.fillAndStroke();
- };
- mxShapePidCompFunc.prototype.foreground = function(c, x, y, w, h)
- {
- var mounting = mxUtils.getValue(this.style, mxShapePidCompFunc.prototype.cst.MOUNTING, 'field');
- if (mounting === mxShapePidCompFunc.prototype.cst.ROOM)
- {
- c.begin();
- c.moveTo(0, h * 0.5);
- c.lineTo(w, h * 0.5);
- c.stroke();
- }
- else if (mounting === mxShapePidCompFunc.prototype.cst.INACCESSIBLE)
- {
- c.setDashed(true);
- c.begin();
- c.moveTo(0, h * 0.5);
- c.lineTo(w, h * 0.5);
- c.stroke();
- }
- else if (mounting === mxShapePidDiscInst.prototype.cst.LOCAL)
- {
- c.begin();
- c.moveTo(w * 0.01, h * 0.48);
- c.lineTo(w * 0.99, h * 0.48);
- c.moveTo(w * 0.01, h * 0.52);
- c.lineTo(w * 0.99, h * 0.52);
- c.stroke();
- }
- };
- mxCellRenderer.prototype.defaultShapes[mxShapePidCompFunc.prototype.cst.SHAPE_COMP_FUNC] = mxShapePidCompFunc;
- mxShapePidCompFunc.prototype.constraints = [
- new mxConnectionConstraint(new mxPoint(0.5, 0), true),
- new mxConnectionConstraint(new mxPoint(0.5, 1), true),
- new mxConnectionConstraint(new mxPoint(0, 0.5), true),
- new mxConnectionConstraint(new mxPoint(1, 0.5), true),
- new mxConnectionConstraint(new mxPoint(0.25, 0), false),
- new mxConnectionConstraint(new mxPoint(0.75, 0), false),
- new mxConnectionConstraint(new mxPoint(0.25, 1), false),
- new mxConnectionConstraint(new mxPoint(0.75, 1), false)
- ];
- //**********************************************************************************************************************************************************
- //Computer Function
- //**********************************************************************************************************************************************************
- /**
- * Extends mxShape.
- */
- function mxShapePidProgLogCont(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(mxShapePidProgLogCont, mxShape);
- mxShapePidProgLogCont.prototype.cst = {
- SHAPE_PROG_LOG_CONT : 'mxgraph.pid2inst.progLogCont',
- MOUNTING : 'mounting',
- FIELD : 'field',
- ROOM : 'room',
- INACCESSIBLE : 'inaccessible',
- LOCAL : 'local'
- };
- /**
- * Function: paintVertexShape
- *
- * Paints the vertex shape.
- */
- mxShapePidProgLogCont.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);
- };
- mxShapePidProgLogCont.prototype.background = function(c, x, y, w, h)
- {
- c.rect(0, 0, w, h);
- c.fillAndStroke();
- };
- mxShapePidProgLogCont.prototype.foreground = function(c, x, y, w, h)
- {
- var mounting = mxUtils.getValue(this.style, mxShapePidProgLogCont.prototype.cst.MOUNTING, 'field');
- c.begin();
- c.moveTo(0, h * 0.5);
- c.lineTo(w * 0.5, 0);
- c.lineTo(w, h * 0.5);
- c.lineTo(w * 0.5, h);
- c.close();
- c.stroke();
-
- if (mounting === mxShapePidProgLogCont.prototype.cst.ROOM)
- {
- c.begin();
- c.moveTo(0, h * 0.5);
- c.lineTo(w, h * 0.5);
- c.stroke();
- }
- else if (mounting === mxShapePidProgLogCont.prototype.cst.INACCESSIBLE)
- {
- c.setDashed(true);
- c.begin();
- c.moveTo(0, h * 0.5);
- c.lineTo(w, h * 0.5);
- c.stroke();
- }
- else if (mounting === mxShapePidDiscInst.prototype.cst.LOCAL)
- {
- c.begin();
- c.moveTo(w * 0.02, h * 0.48);
- c.lineTo(w * 0.98, h * 0.48);
- c.moveTo(w * 0.02, h * 0.52);
- c.lineTo(w * 0.98, h * 0.52);
- c.stroke();
- }
- };
- mxCellRenderer.prototype.defaultShapes[mxShapePidProgLogCont.prototype.cst.SHAPE_PROG_LOG_CONT] = mxShapePidProgLogCont;
- mxShapePidProgLogCont.prototype.constraints = [
- new mxConnectionConstraint(new mxPoint(0.5, 0), true),
- new mxConnectionConstraint(new mxPoint(0.5, 1), true),
- new mxConnectionConstraint(new mxPoint(0, 0.5), true),
- new mxConnectionConstraint(new mxPoint(1, 0.5), true),
- new mxConnectionConstraint(new mxPoint(0, 0), false),
- new mxConnectionConstraint(new mxPoint(0, 1), false),
- new mxConnectionConstraint(new mxPoint(1, 0), false),
- new mxConnectionConstraint(new mxPoint(1, 1), false)
- ];
- //**********************************************************************************************************************************************************
- //Indicator
- //**********************************************************************************************************************************************************
- /**
- * Extends mxShape.
- */
- function mxShapePidIndicator(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(mxShapePidIndicator, mxShape);
- mxShapePidIndicator.prototype.cst = {
- SHAPE_INDICATOR : 'mxgraph.pid2inst.indicator',
- MOUNTING : 'mounting',
- FIELD : 'field',
- ROOM : 'room',
- INACCESSIBLE : 'inaccessible',
- LOCAL : 'local',
- IND_TYPE : 'indType',
- INSTRUMENT : 'inst',
- CONTROL : 'ctrl',
- FUNCTION : 'func',
- PLC : 'plc'
- };
- /**
- * Function: paintVertexShape
- *
- * Paints the vertex shape.
- */
- mxShapePidIndicator.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);
- };
- mxShapePidIndicator.prototype.background = function(c, x, y, w, h)
- {
- var type = mxUtils.getValue(this.style, mxShapePidIndicator.prototype.cst.IND_TYPE, 'inst');
-
- c.begin();
- c.moveTo(w * 0.5, w);
- c.lineTo(w * 0.5, h);
- c.stroke();
- if (type === mxShapePidIndicator.prototype.cst.INSTRUMENT)
- {
- c.ellipse(0, 0, w, w);
- c.fillAndStroke();
- }
- else if (type === mxShapePidIndicator.prototype.cst.CONTROL)
- {
- c.rect(0, 0, w, w);
- c.fillAndStroke();
- }
- else if (type === mxShapePidIndicator.prototype.cst.FUNCTION)
- {
- c.begin();
- c.moveTo(0, w * 0.5);
- c.lineTo(w * 0.25, 0);
- c.lineTo(w * 0.75, 0);
- c.lineTo(w, w * 0.5);
- c.lineTo(w * 0.75, w);
- c.lineTo(w * 0.25, w);
- c.close();
- c.fillAndStroke();
- }
- else if (type === mxShapePidIndicator.prototype.cst.PLC)
- {
- c.rect(0, 0, w, w);
- c.fillAndStroke();
- }
- };
- mxShapePidIndicator.prototype.foreground = function(c, x, y, w, h)
- {
- var mounting = mxUtils.getValue(this.style, mxShapePidIndicator.prototype.cst.MOUNTING, 'field');
- var type = mxUtils.getValue(this.style, mxShapePidIndicator.prototype.cst.IND_TYPE, 'inst');
- if (type === mxShapePidIndicator.prototype.cst.CONTROL)
- {
- c.ellipse(0, 0, w, w);
- c.stroke();
- }
- else if (type === mxShapePidIndicator.prototype.cst.PLC)
- {
- c.begin();
- c.moveTo(0, w * 0.5);
- c.lineTo(w * 0.5, 0);
- c.lineTo(w, w * 0.5);
- c.lineTo(w * 0.5, w);
- c.close();
- c.stroke();
- }
- if (mounting === mxShapePidIndicator.prototype.cst.ROOM)
- {
- c.begin();
- c.moveTo(0, w * 0.5);
- c.lineTo(w, w * 0.5);
- c.stroke();
- }
- else if (mounting === mxShapePidIndicator.prototype.cst.INACCESSIBLE)
- {
- c.setDashed(true);
- c.begin();
- c.moveTo(0, w * 0.5);
- c.lineTo(w, w * 0.5);
- c.stroke();
- }
- else if (mounting === mxShapePidIndicator.prototype.cst.LOCAL)
- {
- c.begin();
- c.moveTo(w * 0.005, w * 0.48);
- c.lineTo(w * 0.995, w * 0.48);
- c.moveTo(w * 0.005, w * 0.52);
- c.lineTo(w * 0.995, w * 0.52);
- c.stroke();
- }
- };
- mxCellRenderer.prototype.defaultShapes[mxShapePidIndicator.prototype.cst.SHAPE_INDICATOR] = mxShapePidIndicator;
- mxShapePidIndicator.prototype.constraints = [new mxConnectionConstraint(new mxPoint(0.5, 1), true)];
- //**********************************************************************************************************************************************************
- //Logic
- //**********************************************************************************************************************************************************
- /**
- * Extends mxShape.
- */
- function mxShapePidLogic(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(mxShapePidLogic, mxShape);
- mxShapePidLogic.prototype.cst = {
- SHAPE_LOGIC : 'mxgraph.pid2inst.logic',
- MOUNTING : 'mounting',
- FIELD : 'field',
- ROOM : 'room',
- INACCESSIBLE : 'inaccessible',
- LOCAL : 'local'
- };
- /**
- * Function: paintVertexShape
- *
- * Paints the vertex shape.
- */
- mxShapePidLogic.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);
- };
- mxShapePidLogic.prototype.background = function(c, x, y, w, h)
- {
- c.begin();
- c.moveTo(0, h * 0.5);
- c.lineTo(w * 0.5, 0);
- c.lineTo(w, h * 0.5);
- c.lineTo(w * 0.5, h);
- c.close();
- c.fillAndStroke();
- };
- mxShapePidLogic.prototype.foreground = function(c, x, y, w, h)
- {
- var mounting = mxUtils.getValue(this.style, mxShapePidLogic.prototype.cst.MOUNTING, 'field');
- if (mounting === mxShapePidLogic.prototype.cst.ROOM)
- {
- c.begin();
- c.moveTo(0, h * 0.5);
- c.lineTo(w, h * 0.5);
- c.stroke();
- }
- else if (mounting === mxShapePidLogic.prototype.cst.INACCESSIBLE)
- {
- c.setDashed(true);
- c.begin();
- c.moveTo(0, h * 0.5);
- c.lineTo(w, h * 0.5);
- c.stroke();
- }
- else if (mounting === mxShapePidLogic.prototype.cst.LOCAL)
- {
- c.begin();
- c.moveTo(w * 0.02, h * 0.48);
- c.lineTo(w * 0.98, h * 0.48);
- c.moveTo(w * 0.02, h * 0.52);
- c.lineTo(w * 0.98, h * 0.52);
- c.stroke();
- }
- };
- mxCellRenderer.prototype.defaultShapes[mxShapePidLogic.prototype.cst.SHAPE_LOGIC] = mxShapePidLogic;
- mxShapePidLogic.prototype.constraints = [
- new mxConnectionConstraint(new mxPoint(0.5, 0), true),
- new mxConnectionConstraint(new mxPoint(0.5, 1), true),
- new mxConnectionConstraint(new mxPoint(0, 0.5), true),
- new mxConnectionConstraint(new mxPoint(1, 0.5), true),
- new mxConnectionConstraint(new mxPoint(0.25, 0.25), false),
- new mxConnectionConstraint(new mxPoint(0.25, 0.75), false),
- new mxConnectionConstraint(new mxPoint(0.75, 0.25), false),
- new mxConnectionConstraint(new mxPoint(0.75, 0.75), false)
- ];
|