/// <summary> /// Returns the absolute, cummulated origin for the children inside the /// given parent. /// </summary> public mxPoint GetOrigin(Object cell) { mxPoint result = null; if (cell != null) { result = GetOrigin(GetParent(cell)); if (!IsEdge(cell)) { mxGeometry geo = GetGeometry(cell); if (geo != null) { result.X += geo.X; result.Y += geo.Y; } } } else { result = new mxPoint(); } return(result); }
/* (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)); } } }
/// <summary> /// see com.mxgraph.mxIGraphModel.SetGeometry(Object, mxGeometry) /// </summary> public mxGeometry SetGeometry(Object cell, mxGeometry geometry) { BeginUpdate(); try { ((mxICell)cell).Geometry = geometry; } finally { EndUpdate(); } return(geometry); }
/// <summary> /// Constructs a copy of the given geometry. /// </summary> /// <param name="geometry">Geometry to construct a copy of.</param> public mxGeometry(mxGeometry geometry) : base(geometry.X, geometry.Y, geometry.Width, geometry .Height) { if (geometry.points != null) { points = new List <mxPoint>(geometry.points.Count); foreach (mxPoint pt in geometry.points) { points.Add(pt.Clone()); } } if (geometry.sourcePoint != null) { sourcePoint = geometry.sourcePoint.Clone(); } if (geometry.targetPoint != null) { targetPoint = geometry.targetPoint.Clone(); } if (geometry.offset != null) { offset = geometry.offset.Clone(); } if (geometry.alternateBounds != null) { alternateBounds = geometry.alternateBounds.Clone(); } relative = geometry.relative; }
/// <summary> /// Constructs a new cell for the given value, geometry and style. /// </summary> /// <param name="value">Value that represents the user object.</param> /// <param name="geometry">Geometry of the cell to be created.</param> /// <param name="style">Style of the cell to be created.</param> public mxCell(Object value, mxGeometry geometry, string style) { Value = value; Geometry = geometry; Style = style; }