Пример #1
0
        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);
        }
Пример #2
0
        internal static void SetNodeBoundaryCurve(DrawingGraph drawingGraph, DrawingNode drawingNode, DLabel existingLabel)
        {
            // Create the boundary curve. Note that a delegate may be allowed to create the curve (or replace it, if it already exists).
            GeometryNode geomNode = drawingNode.GeometryNode;
            if (geomNode == null)
                return;
            ICurve curve;
            if (drawingNode.NodeBoundaryDelegate == null || (curve = drawingNode.NodeBoundaryDelegate(drawingNode)) == null)
            {
                // I need to know the node size, which may depend on a label.
                double width = 0.0;
                double height = 0.0;
                if (existingLabel != null)
                {
                    //existingLabel.MakeVisual();
                    width = existingLabel.Label.Width;
                    height = existingLabel.Label.Height;
                    width += 2 * drawingNode.Attr.LabelMargin;
                    height += 2 * drawingNode.Attr.LabelMargin;
                }
                else if (drawingNode.Label != null && drawingNode.Label.GeometryLabel != null)
                {
                    // Measure the label's size (the only safe way is to instantiate it).
                    var dLabel = new DTextLabel(null, drawingNode.Label);
                    dLabel.MakeVisual();
                    width = dLabel.Label.Width;
                    height = dLabel.Label.Height;

                    // Add node label margin.
                    width += 2 * drawingNode.Attr.LabelMargin;
                    height += 2 * drawingNode.Attr.LabelMargin;
                }
                // Apply lower cap to node size
                if (width < drawingGraph.Attr.MinNodeWidth)
                    width = drawingGraph.Attr.MinNodeWidth;
                if (height < drawingGraph.Attr.MinNodeHeight)
                    height = drawingGraph.Attr.MinNodeHeight;

                curve = NodeBoundaryCurves.GetNodeBoundaryCurve(drawingNode, width, height);
            }
            if (geomNode.BoundaryCurve != null)
                curve.Translate(geomNode.BoundingBox.Center);
            geomNode.BoundaryCurve = curve;
        }
Пример #3
0
        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;
        }