diff --git a/js/ui/mxgraph/src/js/model/mxCell.js b/js/ui/mxgraph/src/js/model/mxCell.js new file mode 100644 index 0000000..99db3ea --- /dev/null +++ b/js/ui/mxgraph/src/js/model/mxCell.js @@ -0,0 +1,855 @@ +/** + * Copyright (c) 2006-2015, JGraph Ltd + * Copyright (c) 2006-2015, Gaudenz Alder + */ +/** + * Class: mxCell + * + * Cells are the elements of the graph model. They represent the state + * of the groups, vertices and edges in a graph. + * + * Custom attributes: + * + * For custom attributes we recommend using an XML node as the value of a cell. + * The following code can be used to create a cell with an XML node as the + * value: + * + * (code) + * var doc = mxUtils.createXmlDocument(); + * var node = doc.createElement('MyNode') + * node.setAttribute('label', 'MyLabel'); + * node.setAttribute('attribute1', 'value1'); + * graph.insertVertex(graph.getDefaultParent(), null, node, 40, 40, 80, 30); + * (end) + * + * For the label to work, and + * should be overridden as follows: + * + * (code) + * graph.convertValueToString = function(cell) + * { + * if (mxUtils.isNode(cell.value)) + * { + * return cell.getAttribute('label', '') + * } + * }; + * + * var cellLabelChanged = graph.cellLabelChanged; + * graph.cellLabelChanged = function(cell, newValue, autoSize) + * { + * if (mxUtils.isNode(cell.value)) + * { + * // Clones the value for correct undo/redo + * var elt = cell.value.cloneNode(true); + * elt.setAttribute('label', newValue); + * newValue = elt; + * } + * + * cellLabelChanged.apply(this, arguments); + * }; + * (end) + * + * Callback: onInit + * + * Called from within the constructor. + * + * Constructor: mxCell + * + * Constructs a new cell to be used in a graph model. + * This method invokes upon completion. + * + * Parameters: + * + * value - Optional object that represents the cell value. + * geometry - Optional that specifies the geometry. + * style - Optional formatted string that defines the style. + */ +function mxCell(value, geometry, style) +{ + this.value = value; + this.setGeometry(geometry); + this.setStyle(style); + +/* +** Custom native JS object link and +** optional object property callback handler +** returning a property object with actual values or when provding a property object +** updating the custum JS object. +*/ + this.obj = undefined; + this.callback = undefined; + + if (this.onInit != null) + { + this.onInit(); + } +}; + +/** + * Variable: id + * + * Holds the Id. Default is null. + */ +mxCell.prototype.id = null; + +/** + * Variable: value + * + * Holds the user object. Default is null. + */ +mxCell.prototype.value = null; + +/** + * Variable: geometry + * + * Holds the . Default is null. + */ +mxCell.prototype.geometry = null; + +/** + * Variable: style + * + * Holds the style as a string of the form [(stylename|key=value);]. Default is + * null. + */ +mxCell.prototype.style = null; + +/** + * Variable: vertex + * + * Specifies whether the cell is a vertex. Default is false. + */ +mxCell.prototype.vertex = false; + +/** + * Variable: edge + * + * Specifies whether the cell is an edge. Default is false. + */ +mxCell.prototype.edge = false; + +/** + * Variable: connectable + * + * Specifies whether the cell is connectable. Default is true. + */ +mxCell.prototype.connectable = true; + +/** + * Variable: visible + * + * Specifies whether the cell is visible. Default is true. + */ +mxCell.prototype.visible = true; + +/** + * Variable: collapsed + * + * Specifies whether the cell is collapsed. Default is false. + */ +mxCell.prototype.collapsed = false; + +/** + * Variable: parent + * + * Reference to the parent cell. + */ +mxCell.prototype.parent = null; + +/** + * Variable: source + * + * Reference to the source terminal. + */ +mxCell.prototype.source = null; + +/** + * Variable: target + * + * Reference to the target terminal. + */ +mxCell.prototype.target = null; + +/** + * Variable: children + * + * Holds the child cells. + */ +mxCell.prototype.children = null; + +/** + * Variable: edges + * + * Holds the edges. + */ +mxCell.prototype.edges = null; + +/** + * Variable: mxTransient + * + * List of members that should not be cloned inside . This field is + * passed to and is not made persistent in . + * This is not a convention for all classes, it is only used in this class + * to mark transient fields since transient modifiers are not supported by + * the language. + */ +mxCell.prototype.mxTransient = ['id', 'value', 'parent', 'source', + 'target', 'children', 'edges']; + +/** + * Function: getId + * + * Returns the Id of the cell as a string. + */ +mxCell.prototype.getId = function() +{ + return this.id; +}; + +/** + * Function: setId + * + * Sets the Id of the cell to the given string. + */ +mxCell.prototype.setId = function(id) +{ + this.id = id; +}; + +/** + * Function: getValue + * + * Returns the user object of the cell. The user + * object is stored in . + */ +mxCell.prototype.getValue = function() +{ + return this.value; +}; + +/** + * Function: setValue + * + * Sets the user object of the cell. The user object + * is stored in . + */ +mxCell.prototype.setValue = function(value) +{ + this.value = value; +}; + +/** + * Function: getObject + * + * Returns the user object of the cell. The user + * object is stored in . + */ +mxCell.prototype.getObject = function() +{ + return this.obj; +}; + +/** + * Function: setObject + * + * Sets the native JS object of the cell. The object + * is stored in . + */ +mxCell.prototype.setObject = function(obj) +{ + this.obj = obj; +}; + +/** + * Function: setCallback + * + * Sets an native object callback handler of the cell. The callback + * is stored in . + * If the callback handler is called w/o an argument, it returns + * an property object with actual values. Modifications of the native + * object can be performed by passing an update object to the handler. + * + * Ex. + * cb() -> {a:1,b:2} (obj) + * cb({b:3} => obj.b==3 + */ +mxCell.prototype.setCallback = function(cb) +{ + this.callback = cb; +}; + +/** + * Function: valueChanged + * + * Changes the user object after an in-place edit + * and returns the previous value. This implementation + * replaces the user object with the given value and + * returns the old user object. + */ +mxCell.prototype.valueChanged = function(newValue) +{ + var previous = this.getValue(); + this.setValue(newValue); + + return previous; +}; + +/** + * Function: getGeometry + * + * Returns the that describes the . + */ +mxCell.prototype.getGeometry = function() +{ + return this.geometry; +}; + +/** + * Function: setGeometry + * + * Sets the to be used as the . + */ +mxCell.prototype.setGeometry = function(geometry) +{ + this.geometry = geometry; +}; + +/** + * Function: getStyle + * + * Returns a string that describes the