internal static DNode CreateDNodeAndSetNodeBoundaryCurve(DrawingGraph drawingGraph, DGraph dGraph, GeometryNode geomNode, DrawingNode drawingNode) { double width = 0; double height = 0; DNode dNode = new DNode(drawingNode); dGraph.AddNode(dNode); Microsoft.Msagl.Drawing.Label label = drawingNode.Label; if (label != null) { CreateDLabel(dNode, label, out width, out height); width += 2 * dNode.DrawingNode.Attr.LabelMargin; height += 2 * dNode.DrawingNode.Attr.LabelMargin; } if (width < drawingGraph.Attr.MinNodeWidth) { width = drawingGraph.Attr.MinNodeWidth; } if (height < drawingGraph.Attr.MinNodeHeight) { height = drawingGraph.Attr.MinNodeHeight; } // Filippo Polo: I'm taking this out because I've modified the drawing of a double circle // so that it can be used with ellipses too. //if (drawingNode.Attr.Shape == Shape.DoubleCircle) //width = height = Math.Max(width, height) * Draw.DoubleCircleOffsetRatio; if (geomNode.BoundaryCurve == null) { geomNode.BoundaryCurve = Microsoft.Msagl.Drawing.NodeBoundaryCurves.GetNodeBoundaryCurve(dNode.DrawingNode, width, height); } return(dNode); }
internal static DNode CreateDNodeAndSetNodeBoundaryCurveForSubgraph(Graph drawingGraph, DGraph dGraph, GeometryNode geomNode, DrawingNode drawingNode, GViewer viewer) { double width = 0; double height = 0; var dNode = new DNode(drawingNode, viewer); dGraph.AddNode(dNode); Drawing.Label label = drawingNode.Label; if (label != null) { CreateDLabel(dNode, label, out width, out height, viewer); } if (width < drawingGraph.Attr.MinNodeWidth) { width = drawingGraph.Attr.MinNodeWidth; } if (height < drawingGraph.Attr.MinNodeHeight) { height = drawingGraph.Attr.MinNodeHeight; } var cluster = (Cluster)geomNode; var margin = dNode.DrawingNode.Attr.LabelMargin; if (label != null) { CreateDLabel(dNode, label, out width, out height, viewer); width += 2 * dNode.DrawingNode.Attr.LabelMargin + 2 * drawingNode.Attr.LineWidth; height += 2 * dNode.DrawingNode.Attr.LabelMargin + 2 * drawingNode.Attr.LineWidth; } cluster.RectangularBoundary = new RectangularClusterBoundary() { BottomMargin = margin, LeftMargin = margin, RightMargin = margin, TopMargin = height, MinWidth = width }; // Filippo Polo: I'm taking this out because I've modified the drawing of a double circle // so that it can be used with ellipses too. //if (drawingNode.Attr.Shape == Shape.DoubleCircle) //width = height = Math.Max(width, height) * Draw.DoubleCircleOffsetRatio; ICurve curve; if (drawingNode.NodeBoundaryDelegate != null && (curve = drawingNode.NodeBoundaryDelegate(drawingNode)) != null) { geomNode.BoundaryCurve = curve; } else if (geomNode.BoundaryCurve == null) { geomNode.BoundaryCurve = NodeBoundaryCurves.GetNodeBoundaryCurve(dNode.DrawingNode, width, height); } return(dNode); }
/// <summary> /// creates DGraph from a precalculated drawing graph /// </summary> /// <param name="drawingGraph"></param> /// <param name="viewer">the owning viewer</param> /// <returns></returns> internal static DGraph CreateDGraphFromPrecalculatedDrawingGraph(Graph drawingGraph, GViewer viewer) { var dGraph = new DGraph(drawingGraph, viewer); //create dnodes and node boundary curves if (drawingGraph.RootSubgraph != null) { foreach (DrawingNode drawingNode in drawingGraph.RootSubgraph.AllSubgraphsWidthFirstExcludingSelf()) { var dNode = new DNode(drawingNode, viewer); if (drawingNode.Label != null) { dNode.Label = new DLabel(dNode, drawingNode.Label, viewer); } dGraph.AddNode(dNode); } } foreach (DrawingNode drawingNode in drawingGraph.Nodes) { var dNode = new DNode(drawingNode, viewer); if (drawingNode.Label != null) { dNode.Label = new DLabel(dNode, drawingNode.Label, viewer); } dGraph.AddNode(dNode); } foreach (DrawingEdge drawingEdge in drawingGraph.Edges) { dGraph.AddEdge(new DEdge(dGraph.GetNode(drawingEdge.SourceNode), dGraph.GetNode(drawingEdge.TargetNode), drawingEdge, ConnectionToGraph.Connected, viewer)); } return(dGraph); }
/// <summary> /// creates DGraph from a precalculated drawing graph /// </summary> /// <param name="drawingGraph"></param> /// <returns></returns> internal static DGraph CreateDGraphFromPrecalculatedDrawingGraph(DrawingGraph drawingGraph) { DGraph ret = new DGraph(drawingGraph); //create dnodes and node boundary curves foreach (DrawingNode drawingNode in drawingGraph.NodeMap.Values) { DNode dNode = new DNode(drawingNode); if (drawingNode.Label != null) { dNode.Label = new DLabel(dNode, drawingNode.Label); } ret.AddNode(dNode); } foreach (DrawingEdge drawingEdge in drawingGraph.Edges) { ret.AddEdge(new DEdge(ret.GetNode(drawingEdge.SourceNode), ret.GetNode(drawingEdge.TargetNode), drawingEdge, Connection.Connected)); } return(ret); }
internal static DNode CreateDNodeAndSetNodeBoundaryCurve(Graph drawingGraph, DGraph dGraph, GeometryNode geomNode, DrawingNode drawingNode, GViewer viewer){ double width = 0; double height = 0; var dNode = new DNode(drawingNode, viewer); dGraph.AddNode(dNode); Drawing.Label label = drawingNode.Label; if (label != null){ CreateDLabel(dNode, label, out width, out height, viewer); width += 2*dNode.DrawingNode.Attr.LabelMargin; height += 2*dNode.DrawingNode.Attr.LabelMargin; } if (width < drawingGraph.Attr.MinNodeWidth) width = drawingGraph.Attr.MinNodeWidth; if (height < drawingGraph.Attr.MinNodeHeight) height = drawingGraph.Attr.MinNodeHeight; // Filippo Polo: I'm taking this out because I've modified the drawing of a double circle // so that it can be used with ellipses too. //if (drawingNode.Attr.Shape == Shape.DoubleCircle) //width = height = Math.Max(width, height) * Draw.DoubleCircleOffsetRatio; ICurve curve; if (drawingNode.NodeBoundaryDelegate != null && (curve = drawingNode.NodeBoundaryDelegate(drawingNode)) != null) geomNode.BoundaryCurve = curve; else if (geomNode.BoundaryCurve == null) geomNode.BoundaryCurve = NodeBoundaryCurves.GetNodeBoundaryCurve(dNode.DrawingNode, width, height); return dNode; }
/// <summary> /// creates DGraph from a precalculated drawing graph /// </summary> /// <param name="drawingGraph"></param> /// <param name="viewer">the owning viewer</param> /// <returns></returns> internal static DGraph CreateDGraphFromPrecalculatedDrawingGraph(Graph drawingGraph, GViewer viewer){ var dGraph = new DGraph(drawingGraph, viewer); //create dnodes and node boundary curves if (drawingGraph.RootSubgraph != null) foreach (DrawingNode drawingNode in drawingGraph.RootSubgraph.AllSubgraphsWidthFirstExcludingSelf()) { var dNode = new DNode(drawingNode, viewer); if (drawingNode.Label != null) dNode.Label = new DLabel(dNode, drawingNode.Label, viewer); dGraph.AddNode(dNode); } foreach (DrawingNode drawingNode in drawingGraph.Nodes){ var dNode = new DNode(drawingNode, viewer); if (drawingNode.Label != null) dNode.Label = new DLabel(dNode, drawingNode.Label, viewer); dGraph.AddNode(dNode); } foreach (DrawingEdge drawingEdge in drawingGraph.Edges) dGraph.AddEdge(new DEdge(dGraph.GetNode(drawingEdge.SourceNode), dGraph.GetNode(drawingEdge.TargetNode), drawingEdge, ConnectionToGraph.Connected, viewer)); return dGraph; }