/* (non-Dotnetdoc) * see com.mxgraph.mxICell.Clone() */ public Object Clone() { mxCell cell = new mxCell(); cell.Collapsed = Collapsed; cell.Connectable = Connectable; cell.Edge = Edge; cell.Style = Style; cell.Vertex = Vertex; cell.Visible = Visible; mxGeometry geometry = Geometry; if (geometry != null) { cell.Geometry = geometry.Clone(); } Object value = Value; if (value is XmlNode) { cell.Value = ((XmlNode)value).CloneNode(true); } else { cell.Value = Value; } return(cell); }
/// <summary> /// Inner helper method to update the parent of the specified edge to the /// nearest-common-ancestor of its two terminals. /// </summary> /// <param name="edge">Specifies the edge to be updated.</param> /// <param name="root">Current root of the model.</param> public void UpdateEdgeParent(Object edge, Object root) { Object source = GetTerminal(edge, true); Object target = GetTerminal(edge, false); Object cell = null; // Uses the first non-relative descendants of the source terminal while (source != null && !IsEdge(source) && GetGeometry(source) != null && GetGeometry(source).Relative) { source = GetParent(source); } // Uses the first non-relative descendants of the target terminal while (target != null && !IsEdge(target) && GetGeometry(target) != null && GetGeometry(target).Relative) { target = GetParent(target); } if (IsAncestor(root, source) && IsAncestor(root, target)) { if (source == target) { cell = GetParent(source); } else { cell = GetNearestCommonAncestor(source, target); } if (cell != null && GetParent(cell) != root && GetParent(edge) != cell) { mxGeometry geo = GetGeometry(edge); if (geo != null) { mxPoint origin1 = GetOrigin(GetParent(edge)); mxPoint origin2 = GetOrigin(cell); double dx = origin2.X - origin1.X; double dy = origin2.Y - origin1.Y; geo = (mxGeometry)geo.Clone(); geo.Translate(-dx, -dy); SetGeometry(edge, geo); } Add(cell, edge, GetChildCount(cell)); } } }