diff --git a/dist/graph_class.js b/dist/graph_class.js index cba65dfc..14883f05 100644 --- a/dist/graph_class.js +++ b/dist/graph_class.js @@ -170,7 +170,7 @@ eval("/**\n * Copyright (c) 2006-2015, JGraph Ltd\n */\n\n/**\n * Registers shap /***/ (function(module, __webpack_exports__, __webpack_require__) { "use strict"; -eval("__webpack_require__.r(__webpack_exports__);\n/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, \"default\", function() { return MxGraph; });\nfunction _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError(\"Cannot call a class as a function\"); } }\n\nfunction _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if (\"value\" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } }\n\nfunction _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); return Constructor; }\n\nwindow.mxLanguages = window.mxLanguages || [\"en\"];\n\nvar sanitizer = __webpack_require__(/*! sanitizer */ \"./node_modules/sanitizer/sanitizer.js\");\n\nvar mxgraph = __webpack_require__(/*! mxgraph */ \"./node_modules/mxgraph/javascript/dist/build.js\")({\n mxImageBasePath: \"public/plugins/agenty-flowcharting-panel/libs/mxgraph/javascript/src/images\",\n mxBasePath: \"public/plugins/agenty-flowcharting-panel/libs/mxgraph/javascript/dist\",\n mxLoadStylesheets: false,\n mxLanguage: \"en\",\n mxLoadResources: false\n});\n\nwindow.BASE_PATH = window.BASE_PATH || \"public/plugins/agenty-flowcharting-panel/libs/mxgraph/javascript/dist/\";\nwindow.RESOURCES_PATH = window.BASE_PATH || window.BASE_PATH + \"resources\";\nwindow.RESOURCE_BASE = window.RESOURCE_BASE || window.RESOURCES_PATH + \"/grapheditor\";\nwindow.STENCIL_PATH = window.STENCIL_PATH || window.BASE_PATH + \"stencils\";\nwindow.IMAGE_PATH = window.IMAGE_PATH || window.BASE_PATH + \"images\";\nwindow.STYLE_PATH = window.STYLE_PATH || window.BASE_PATH + \"styles\";\nwindow.CSS_PATH = window.CSS_PATH || window.BASE_PATH + \"styles\";\nwindow.mxLanguages = window.mxLanguages || [\"en\"]; // Put to global vars to work\n\nwindow.mxActor = window.mxActor || mxgraph.mxActor;\nwindow.mxArrow = window.mxArrow || mxgraph.mxArrow;\nwindow.mxArrowConnector = window.mxArrowConnector || mxgraph.mxArrowConnector;\nwindow.mxCell = window.mxCell || mxgraph.mxCell;\nwindow.mxCellEditor = window.mxCellEditor || mxgraph.mxCellEditor;\nwindow.mxCellHighlight = window.mxCellHighlight || mxgraph.mxCellHighlight;\nwindow.mxCellOverlay = window.mxCellOverlay || mxgraph.mxCellOverlay;\nwindow.mxCellRenderer = window.mxCellRenderer || mxgraph.mxCellRenderer;\nwindow.mxCellState = window.mxCellState || mxgraph.mxCellState;\nwindow.mxClient = window.mxClient || mxgraph.mxClient;\nmxClient.mxBasePath = \"public/plugins/agenty-flowcharting-panel/libs/mxgraph/javascript/dist\";\nmxClient.mxImageBasePath = \"public/plugins/agenty-flowcharting-panel/libs/mxgraph/javascript/src/images\";\nmxClient.mxLoadResources = true;\nmxClient.mxLanguage = \"en\";\nmxClient.mxLoadStylesheets = true;\nwindow.mxCloud = window.mxCloud || mxgraph.mxCloud;\nwindow.mxCodec = window.mxCodec || mxgraph.mxCodec;\nwindow.mxCompactTreeLayout = window.mxCompactTreeLayout || mxgraph.mxCompactTreeLayout;\nwindow.mxConnectionConstraint = window.mxConnectionConstraint || mxgraph.mxConnectionConstraint;\nwindow.mxConnectionHandler = window.mxConnectionHandler || mxgraph.mxConnectionHandler;\nwindow.mxConnector = window.mxConnector || mxgraph.mxConnector;\nwindow.mxConstants = window.mxConstants || mxgraph.mxConstants;\nwindow.mxConstraintHandler = window.mxConstraintHandler || mxgraph.mxConstraintHandler;\nwindow.mxCylinder = window.mxCylinder || mxgraph.mxCylinder;\nwindow.mxDefaultKeyHandler = window.mxDefaultKeyHandler || mxgraph.mxDefaultKeyHandler;\nwindow.mxDefaultPopupMenu = window.mxDefaultPopupMenu || mxgraph.mxDefaultPopupMenu;\nwindow.mxDefaultToolbar = window.mxDefaultToolbar || mxgraph.mxDefaultToolbar;\nwindow.mxDivResizer = window.mxDivResizer || mxgraph.mxDivResizer;\nwindow.mxDoubleEllipse = window.mxDoubleEllipse || mxgraph.mxDoubleEllipse;\nwindow.mxDragSource = window.mxDragSource || mxgraph.mxDragSource;\nwindow.mxEdgeStyle = window.mxEdgeStyle || mxgraph.mxEdgeStyle;\nwindow.mxEdgeHandler = window.mxEdgeHandler || mxgraph.mxEdgeHandler;\nwindow.mxEditor = window.mxEditor || mxgraph.mxEditor;\nwindow.mxElbowEdgeHandler = window.mxElbowEdgeHandler || mxgraph.mxElbowEdgeHandler;\nwindow.mxEllipse = window.mxEllipse || mxgraph.mxEllipse;\nwindow.mxEvent = window.mxEvent || mxgraph.mxEvent;\nwindow.mxEventObject = window.mxEventObject || mxgraph.mxEventObject;\nwindow.mxFile = window.mxFile || mxgraph.mxFile;\nwindow.mxGeometry = window.mxGeometry || mxgraph.mxGeometry;\nwindow.mxGraph = window.mxGraph || mxgraph.mxGraph;\nwindow.mxGraphHandler = window.mxGraphHandler || mxgraph.mxGraphHandler;\nwindow.mxGraphModel = window.mxGraphModel || mxgraph.mxGraphModel;\nwindow.mxGraphView = window.mxGraphView || mxgraph.mxGraphView;\nwindow.mxGuide = window.mxGuide || mxgraph.mxGuide;\nwindow.mxHexagon = window.mxHexagon || mxgraph.mxHexagon;\nwindow.mxHandle = window.mxHandle || mxgraph.mxHandle;\nwindow.mxImage = window.mxImage || mxgraph.mxImage;\nwindow.mxImageShape = window.mxImageShape || mxgraph.mxImageShape;\nwindow.mxKeyHandler = window.mxKeyHandler || mxgraph.mxKeyHandler;\nwindow.mxLabel = window.mxLabel || mxgraph.mxLabel;\nwindow.mxLayoutManager = window.mxLayoutManager || mxgraph.mxLayoutManager;\nwindow.mxLine = window.mxLine || mxgraph.mxLine;\nwindow.mxMarker = window.mxMarker || mxgraph.mxMarker;\nwindow.mxOutline = window.mxOutline || mxgraph.mxOutline;\nwindow.mxPanningHandler = window.mxPanningHandler || mxgraph.mxPanningHandler;\nwindow.mxPerimeter = window.mxPerimeter || mxgraph.mxPerimeter;\nwindow.mxPoint = window.mxPoint || mxgraph.mxPoint;\nwindow.mxPolyline = window.mxPolyline || mxgraph.mxPolyline;\nwindow.mxPopupMenu = window.mxPopupMenu || mxgraph.mxPopupMenu;\nwindow.mxPopupMenuHandler = window.mxPopupMenuHandler || mxgraph.mxPopupMenuHandler;\nwindow.mxPrintPreview = window.mxPrintPreview || mxgraph.mxPrintPreview;\nwindow.mxRectangle = window.mxRectangle || mxgraph.mxRectangle;\nwindow.mxRectangleShape = window.mxRectangleShape || mxgraph.mxRectangleShape;\nwindow.mxResources = window.mxResources || mxgraph.mxResources;\nwindow.mxRhombus = window.mxRhombus || mxgraph.mxRhombus;\nwindow.mxRubberband = window.mxRubberband || mxgraph.mxRubberband;\nwindow.mxShape = window.mxShape || mxgraph.mxShape;\nwindow.mxStackLayout = window.mxStackLayout || mxgraph.mxStackLayout;\nwindow.mxStencil = window.mxStencil || mxgraph.mxStencil;\nwindow.mxStencilRegistry = window.mxStencilRegistry || mxgraph.mxStencilRegistry;\nwindow.mxStylesheet = window.mxStylesheet || mxgraph.mxStylesheet;\nwindow.mxStyleRegistry = window.mxStyleRegistry || mxgraph.mxStyleRegistry;\nwindow.mxSvgCanvas2D = window.mxSvgCanvas2D || mxgraph.mxSvgCanvas2D;\nwindow.mxSwimlane = window.mxSwimlane || mxgraph.mxSwimlane;\nwindow.mxText = window.mxText || mxgraph.mxText;\nwindow.mxToolbar = window.mxToolbar || mxgraph.mxToolbar;\nwindow.mxTriangle = window.mxTriangle || mxgraph.mxTriangle;\nwindow.mxUndoManager = window.mxUndoManager || mxgraph.mxUndoManager;\nwindow.mxUtils = window.mxUtils || mxgraph.mxUtils;\nwindow.mxValueChange = window.mxValueChange || mxgraph.mxValueChange;\nwindow.mxVertexHandler = window.mxVertexHandler || mxgraph.mxVertexHandler;\n\nvar MxGraph =\n/*#__PURE__*/\nfunction () {\n /** @ngInject */\n function MxGraph($scope, elem, container, xmlGraph) {\n _classCallCheck(this, MxGraph);\n\n this.$scope = $scope;\n this.container = container;\n this.xmlGraph;\n if (u.isencoded(xmlGraph)) this.xmlGraph = u.decode(xmlGraph, true, true, true);else this.xmlGraph = xmlGraph;\n this.xmlGraph = xmlGraph;\n this.graph;\n this.scale = true;\n this.lock = true;\n this.center = true;\n this.zoom = false;\n this.zoomPercent = \"1\";\n this.initGraph();\n }\n\n _createClass(MxGraph, [{\n key: \"initGraph\",\n value: function initGraph() {\n // this.$elem.html(this.$graphCanvas);\n var Graph = __webpack_require__(/*! ./Graph */ \"./src/Graph.js\")({\n \"libs\": \"arrows;basic;bpmn;flowchart\"\n });\n\n var Shapes = __webpack_require__(/*! ./Shapes */ \"./src/Shapes.js\");\n\n this.graph = new Graph(this.container);\n }\n }, {\n key: \"drawGraph\",\n value: function drawGraph() {\n this.graph.getModel().beginUpdate();\n this.graph.getModel().clear();\n\n try {\n var xmlDoc = mxUtils.parseXml(text);\n var codec = new mxCodec(xmlDoc);\n codec.decode(xmlDoc.documentElement, this.graph.getModel());\n } catch (error) {\n console.error(error);\n } finally {\n this.graph.getModel().endUpdate();\n }\n }\n }, {\n key: \"refreshGraph\",\n value: function refreshGraph() {\n var width = this.container.width();\n var heigth = this.container.heigth();\n var size = Match.min(width, heigth);\n var cssGraph = {\n margin: \"auto\",\n position: \"relative\",\n height: size - 30 + \"px\"\n };\n this.$graphCanvas.css(cssGraph);\n if (this.lock) this.lockGraph();else this.unlock();\n if (this.center) this.centerGraph();else this.uncenterGraph();\n if (this.scale) this.scaleGraph();else this.unscaleGraph();\n if (this.zoom) this.zoomGraph(this.zoom);else this.unzoomGraph();\n }\n }, {\n key: \"lockGraph\",\n value: function lockGraph() {\n this.graph.setEnabled(false);\n this.lock = true;\n }\n }, {\n key: \"unlockGraph\",\n value: function unlockGraph() {\n this.graph.setEnabled(false);\n this.lock = false;\n }\n }, {\n key: \"centerGraph\",\n value: function centerGraph() {\n this.graph.center(true, true);\n this.center = true;\n }\n }, {\n key: \"uncenterGraph\",\n value: function uncenterGraph() {\n this.graph.center(false, false);\n this.center = false;\n }\n }, {\n key: \"scaleGraph\",\n value: function scaleGraph() {\n this.graph.fit();\n this.graph.view.rendering = true;\n this.scale = true;\n }\n }, {\n key: \"unscaleGraph\",\n value: function unscaleGraph() {\n this.scale = false;\n }\n }, {\n key: \"zoomGraph\",\n value: function zoomGraph(percent) {\n if (percent && percent.legth > 0 && percent != \"100%\" && percent != \"0%\") {\n var ratio = percent.replace(\"%\", \"\") / 100;\n this.graph.zoomTo(ration, true);\n this.zoomPercent = percent;\n }\n\n this.zoom = true;\n }\n }, {\n key: \"unzoomGraph\",\n value: function unzoomGraph() {\n this.zoom = false;\n this.graph.zoomActual();\n }\n }, {\n key: \"getMxGraph\",\n value: function getMxGraph() {\n return this.graph;\n }\n }, {\n key: \"getxmlGraph\",\n value: function getxmlGraph() {\n return this.xmlGraph;\n }\n }, {\n key: \"setXmlGraph\",\n value: function setXmlGraph(xmlGraph) {\n if (u.isencoded(xmlGraph)) this.xmlGraph = u.decode(xmlGraph, true, true, true);else this.xmlGraph = xmlGraph;\n this.drawGraph();\n }\n }, {\n key: \"updateCells\",\n value: function updateCells(states) {}\n }]);\n\n return MxGraph;\n}();\n\n\n\n//# sourceURL=webpack://graph_class/./src/graph_class.js?"); +eval("__webpack_require__.r(__webpack_exports__);\n/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, \"default\", function() { return MxGraph; });\nfunction _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError(\"Cannot call a class as a function\"); } }\n\nfunction _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if (\"value\" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } }\n\nfunction _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); return Constructor; }\n\nwindow.mxLanguages = window.mxLanguages || [\"en\"];\n\nvar sanitizer = __webpack_require__(/*! sanitizer */ \"./node_modules/sanitizer/sanitizer.js\");\n\nvar mxgraph = __webpack_require__(/*! mxgraph */ \"./node_modules/mxgraph/javascript/dist/build.js\")({\n mxImageBasePath: \"public/plugins/agenty-flowcharting-panel/libs/mxgraph/javascript/src/images\",\n mxBasePath: \"public/plugins/agenty-flowcharting-panel/libs/mxgraph/javascript/dist\",\n mxLoadStylesheets: false,\n mxLanguage: \"en\",\n mxLoadResources: false\n});\n\nwindow.BASE_PATH = window.BASE_PATH || \"public/plugins/agenty-flowcharting-panel/libs/mxgraph/javascript/dist/\";\nwindow.RESOURCES_PATH = window.BASE_PATH || window.BASE_PATH + \"resources\";\nwindow.RESOURCE_BASE = window.RESOURCE_BASE || window.RESOURCES_PATH + \"/grapheditor\";\nwindow.STENCIL_PATH = window.STENCIL_PATH || window.BASE_PATH + \"stencils\";\nwindow.IMAGE_PATH = window.IMAGE_PATH || window.BASE_PATH + \"images\";\nwindow.STYLE_PATH = window.STYLE_PATH || window.BASE_PATH + \"styles\";\nwindow.CSS_PATH = window.CSS_PATH || window.BASE_PATH + \"styles\";\nwindow.mxLanguages = window.mxLanguages || [\"en\"]; // Put to global vars to work\n\nwindow.mxActor = window.mxActor || mxgraph.mxActor;\nwindow.mxArrow = window.mxArrow || mxgraph.mxArrow;\nwindow.mxArrowConnector = window.mxArrowConnector || mxgraph.mxArrowConnector;\nwindow.mxCell = window.mxCell || mxgraph.mxCell;\nwindow.mxCellEditor = window.mxCellEditor || mxgraph.mxCellEditor;\nwindow.mxCellHighlight = window.mxCellHighlight || mxgraph.mxCellHighlight;\nwindow.mxCellOverlay = window.mxCellOverlay || mxgraph.mxCellOverlay;\nwindow.mxCellRenderer = window.mxCellRenderer || mxgraph.mxCellRenderer;\nwindow.mxCellState = window.mxCellState || mxgraph.mxCellState;\nwindow.mxClient = window.mxClient || mxgraph.mxClient;\nmxClient.mxBasePath = \"public/plugins/agenty-flowcharting-panel/libs/mxgraph/javascript/dist\";\nmxClient.mxImageBasePath = \"public/plugins/agenty-flowcharting-panel/libs/mxgraph/javascript/src/images\";\nmxClient.mxLoadResources = true;\nmxClient.mxLanguage = \"en\";\nmxClient.mxLoadStylesheets = true;\nwindow.mxCloud = window.mxCloud || mxgraph.mxCloud;\nwindow.mxCodec = window.mxCodec || mxgraph.mxCodec;\nwindow.mxCompactTreeLayout = window.mxCompactTreeLayout || mxgraph.mxCompactTreeLayout;\nwindow.mxConnectionConstraint = window.mxConnectionConstraint || mxgraph.mxConnectionConstraint;\nwindow.mxConnectionHandler = window.mxConnectionHandler || mxgraph.mxConnectionHandler;\nwindow.mxConnector = window.mxConnector || mxgraph.mxConnector;\nwindow.mxConstants = window.mxConstants || mxgraph.mxConstants;\nwindow.mxConstraintHandler = window.mxConstraintHandler || mxgraph.mxConstraintHandler;\nwindow.mxCylinder = window.mxCylinder || mxgraph.mxCylinder;\nwindow.mxDefaultKeyHandler = window.mxDefaultKeyHandler || mxgraph.mxDefaultKeyHandler;\nwindow.mxDefaultPopupMenu = window.mxDefaultPopupMenu || mxgraph.mxDefaultPopupMenu;\nwindow.mxDefaultToolbar = window.mxDefaultToolbar || mxgraph.mxDefaultToolbar;\nwindow.mxDivResizer = window.mxDivResizer || mxgraph.mxDivResizer;\nwindow.mxDoubleEllipse = window.mxDoubleEllipse || mxgraph.mxDoubleEllipse;\nwindow.mxDragSource = window.mxDragSource || mxgraph.mxDragSource;\nwindow.mxEdgeStyle = window.mxEdgeStyle || mxgraph.mxEdgeStyle;\nwindow.mxEdgeHandler = window.mxEdgeHandler || mxgraph.mxEdgeHandler;\nwindow.mxEditor = window.mxEditor || mxgraph.mxEditor;\nwindow.mxElbowEdgeHandler = window.mxElbowEdgeHandler || mxgraph.mxElbowEdgeHandler;\nwindow.mxEllipse = window.mxEllipse || mxgraph.mxEllipse;\nwindow.mxEvent = window.mxEvent || mxgraph.mxEvent;\nwindow.mxEventObject = window.mxEventObject || mxgraph.mxEventObject;\nwindow.mxFile = window.mxFile || mxgraph.mxFile;\nwindow.mxGeometry = window.mxGeometry || mxgraph.mxGeometry;\nwindow.mxGraph = window.mxGraph || mxgraph.mxGraph;\nwindow.mxGraphHandler = window.mxGraphHandler || mxgraph.mxGraphHandler;\nwindow.mxGraphModel = window.mxGraphModel || mxgraph.mxGraphModel;\nwindow.mxGraphView = window.mxGraphView || mxgraph.mxGraphView;\nwindow.mxGuide = window.mxGuide || mxgraph.mxGuide;\nwindow.mxHexagon = window.mxHexagon || mxgraph.mxHexagon;\nwindow.mxHandle = window.mxHandle || mxgraph.mxHandle;\nwindow.mxImage = window.mxImage || mxgraph.mxImage;\nwindow.mxImageShape = window.mxImageShape || mxgraph.mxImageShape;\nwindow.mxKeyHandler = window.mxKeyHandler || mxgraph.mxKeyHandler;\nwindow.mxLabel = window.mxLabel || mxgraph.mxLabel;\nwindow.mxLayoutManager = window.mxLayoutManager || mxgraph.mxLayoutManager;\nwindow.mxLine = window.mxLine || mxgraph.mxLine;\nwindow.mxMarker = window.mxMarker || mxgraph.mxMarker;\nwindow.mxOutline = window.mxOutline || mxgraph.mxOutline;\nwindow.mxPanningHandler = window.mxPanningHandler || mxgraph.mxPanningHandler;\nwindow.mxPerimeter = window.mxPerimeter || mxgraph.mxPerimeter;\nwindow.mxPoint = window.mxPoint || mxgraph.mxPoint;\nwindow.mxPolyline = window.mxPolyline || mxgraph.mxPolyline;\nwindow.mxPopupMenu = window.mxPopupMenu || mxgraph.mxPopupMenu;\nwindow.mxPopupMenuHandler = window.mxPopupMenuHandler || mxgraph.mxPopupMenuHandler;\nwindow.mxPrintPreview = window.mxPrintPreview || mxgraph.mxPrintPreview;\nwindow.mxRectangle = window.mxRectangle || mxgraph.mxRectangle;\nwindow.mxRectangleShape = window.mxRectangleShape || mxgraph.mxRectangleShape;\nwindow.mxResources = window.mxResources || mxgraph.mxResources;\nwindow.mxRhombus = window.mxRhombus || mxgraph.mxRhombus;\nwindow.mxRubberband = window.mxRubberband || mxgraph.mxRubberband;\nwindow.mxShape = window.mxShape || mxgraph.mxShape;\nwindow.mxStackLayout = window.mxStackLayout || mxgraph.mxStackLayout;\nwindow.mxStencil = window.mxStencil || mxgraph.mxStencil;\nwindow.mxStencilRegistry = window.mxStencilRegistry || mxgraph.mxStencilRegistry;\nwindow.mxStylesheet = window.mxStylesheet || mxgraph.mxStylesheet;\nwindow.mxStyleRegistry = window.mxStyleRegistry || mxgraph.mxStyleRegistry;\nwindow.mxSvgCanvas2D = window.mxSvgCanvas2D || mxgraph.mxSvgCanvas2D;\nwindow.mxSwimlane = window.mxSwimlane || mxgraph.mxSwimlane;\nwindow.mxText = window.mxText || mxgraph.mxText;\nwindow.mxToolbar = window.mxToolbar || mxgraph.mxToolbar;\nwindow.mxTriangle = window.mxTriangle || mxgraph.mxTriangle;\nwindow.mxUndoManager = window.mxUndoManager || mxgraph.mxUndoManager;\nwindow.mxUtils = window.mxUtils || mxgraph.mxUtils;\nwindow.mxValueChange = window.mxValueChange || mxgraph.mxValueChange;\nwindow.mxVertexHandler = window.mxVertexHandler || mxgraph.mxVertexHandler;\n\nvar MxGraph =\n/*#__PURE__*/\nfunction () {\n /** @ngInject */\n function MxGraph($scope, elem, container, xmlGraph) {\n _classCallCheck(this, MxGraph);\n\n this.$scope = $scope;\n this.container = container;\n this.xmlGraph;\n if (u.isencoded(xmlGraph)) this.xmlGraph = u.decode(xmlGraph, true, true, true);else this.xmlGraph = xmlGraph;\n this.xmlGraph = xmlGraph;\n this.graph;\n this.scale = true;\n this.lock = true;\n this.center = true;\n this.zoom = false;\n this.zoomPercent = \"1\";\n this.cells = {};\n this.cells.id = [];\n this.cells.value = [];\n this.cells.attributs = {};\n this.initGraph();\n }\n\n _createClass(MxGraph, [{\n key: \"initGraph\",\n value: function initGraph() {\n // this.$elem.html(this.$graphCanvas);\n var Graph = __webpack_require__(/*! ./Graph */ \"./src/Graph.js\")({\n \"libs\": \"arrows;basic;bpmn;flowchart\"\n });\n\n var Shapes = __webpack_require__(/*! ./Shapes */ \"./src/Shapes.js\");\n\n this.graph = new Graph(this.container);\n }\n }, {\n key: \"drawGraph\",\n value: function drawGraph() {\n this.graph.getModel().beginUpdate();\n this.graph.getModel().clear();\n\n try {\n var xmlDoc = mxUtils.parseXml(text);\n var codec = new mxCodec(xmlDoc);\n codec.decode(xmlDoc.documentElement, this.graph.getModel());\n } catch (error) {\n console.error(error);\n } finally {\n this.graph.getModel().endUpdate();\n this.cells[\"id\"] = this.getCurrentCells(\"id\");\n this.cells[\"value\"] = this.getCurrentCells(\"value\");\n }\n }\n }, {\n key: \"refreshGraph\",\n value: function refreshGraph() {\n var width = this.container.width();\n var heigth = this.container.heigth();\n var size = Match.min(width, heigth);\n var cssGraph = {\n margin: \"auto\",\n position: \"relative\",\n height: size - 30 + \"px\"\n };\n this.$graphCanvas.css(cssGraph);\n if (this.lock) this.lockGraph();else this.unlock();\n if (this.center) this.centerGraph();else this.uncenterGraph();\n if (this.scale) this.scaleGraph();else this.unscaleGraph();\n if (this.zoom) this.zoomGraph(this.zoom);else this.unzoomGraph();\n }\n }, {\n key: \"lockGraph\",\n value: function lockGraph() {\n this.graph.setEnabled(false);\n this.lock = true;\n }\n }, {\n key: \"unlockGraph\",\n value: function unlockGraph() {\n this.graph.setEnabled(false);\n this.lock = false;\n }\n }, {\n key: \"centerGraph\",\n value: function centerGraph() {\n this.graph.center(true, true);\n this.center = true;\n }\n }, {\n key: \"uncenterGraph\",\n value: function uncenterGraph() {\n this.graph.center(false, false);\n this.center = false;\n }\n }, {\n key: \"scaleGraph\",\n value: function scaleGraph() {\n this.graph.fit();\n this.graph.view.rendering = true;\n this.scale = true;\n }\n }, {\n key: \"unscaleGraph\",\n value: function unscaleGraph() {\n this.scale = false;\n }\n }, {\n key: \"zoomGraph\",\n value: function zoomGraph(percent) {\n if (percent && percent.legth > 0 && percent != \"100%\" && percent != \"0%\") {\n var ratio = percent.replace(\"%\", \"\") / 100;\n this.graph.zoomTo(ration, true);\n this.zoomPercent = percent;\n }\n\n this.zoom = true;\n }\n }, {\n key: \"unzoomGraph\",\n value: function unzoomGraph() {\n this.zoom = false;\n this.graph.zoomActual();\n }\n }, {\n key: \"getMxGraph\",\n value: function getMxGraph() {\n return this.graph;\n }\n }, {\n key: \"getxmlGraph\",\n value: function getxmlGraph() {\n return this.xmlGraph;\n }\n }, {\n key: \"setXmlGraph\",\n value: function setXmlGraph(xmlGraph) {\n if (u.isencoded(xmlGraph)) this.xmlGraph = u.decode(xmlGraph, true, true, true);else this.xmlGraph = xmlGraph;\n this.drawGraph();\n }\n }, {\n key: \"updateCells\",\n value: function updateCells(states) {}\n }, {\n key: \"getCurrentCells\",\n value: function getCurrentCells(prop) {\n cellIds = [];\n var model = this.graph.getModel();\n var cells = model.cells;\n\n if (prop === \"id\") {\n cells.forEach(function (cell) {\n cellIds.push(cell.getId());\n });\n } else if (prop === \"value\") {\n cells.forEach(function (cell) {\n cellIds.getValue(cell.getId());\n });\n }\n\n return cellIds;\n }\n }, {\n key: \"getOrignalCells\",\n value: function getOrignalCells(prop) {\n if (prop === \"id\" || prop === \"value\") return this.cells[prop]; //TODO: attributs\n\n return [];\n }\n }]);\n\n return MxGraph;\n}();\n\n\n\n//# sourceURL=webpack://graph_class/./src/graph_class.js?"); /***/ }) diff --git a/lws.config.js b/lws.config.js new file mode 100644 index 00000000..93dca279 --- /dev/null +++ b/lws.config.js @@ -0,0 +1,3 @@ +module.exports = { + port: 80 +} \ No newline at end of file diff --git a/src/graph_class.js b/src/graph_class.js index 4d4cac79..a05cde04 100644 --- a/src/graph_class.js +++ b/src/graph_class.js @@ -133,6 +133,10 @@ export default class MxGraph { this.center = true; this.zoom = false; this.zoomPercent = "1"; + this.cells = {}; + this.cells.id = []; + this.cells.value = []; + this.cells.attributs = {}; this.initGraph(); } @@ -157,6 +161,8 @@ export default class MxGraph { console.error(error); } finally { this.graph.getModel().endUpdate(); + this.cells["id"] = this.getCurrentCells("id"); + this.cells["value"] = this.getCurrentCells("value"); } } @@ -240,4 +246,28 @@ export default class MxGraph { }; + getCurrentCells(prop) { + cellIds = []; + let model = this.graph.getModel(); + let cells = model.cells; + if (prop === "id") { + cells.forEach(cell => { + cellIds.push(cell.getId()) + }); + + } + else if (prop === "value") { + cells.forEach(cell => { + cellIds.getValue(cell.getId()) + }); + } + return cellIds; + } + + getOrignalCells(prop) { + if (prop === "id" || prop === "value") return this.cells[prop]; + //TODO: attributs + return []; + } + } \ No newline at end of file