예제 #1
0
        void CreateTargetNode(Microsoft.Msagl.Drawing.Node a)
        {
            a.Attr.Shape     = Shape.DoubleCircle;
            a.Attr.FillColor = Color.LightGray;

            a.Attr.LabelMargin = -4;
        }
        private Microsoft.Msagl.Drawing.Node AddNodeToCircle(Point center, Graph graph, double angle)
        {
            var nodeCenter = center + _circleRadius * (new Point(Math.Cos(angle), Math.Sin(angle)));

            Microsoft.Msagl.Drawing.Node node = CreateNodeOnCenter(graph, nodeCenter);
            return(node);
        }
예제 #3
0
        private ICurve GetNodeBoundaryCurve(Microsoft.Msagl.Drawing.Node node)
        {
            double width, height;

            FrameworkElement frameworkElement;

            if (this.drawingObjectsToFrameworkElements.TryGetValue(node, out frameworkElement))
            {
                Debug.Assert(frameworkElement.CheckAccess());

                // a Frameworkelement was prerpared beforehand.
                width  = frameworkElement.Width + 2 * node.Attr.LabelMargin;
                height = frameworkElement.Height + 2 * node.Attr.LabelMargin;
            }
            else
            {
                return(GetNodeBoundaryCurveByMeasuringText(node));
            }

            // the calculated width must not be smaller the minimal size.

            if (width < drawingGraph.Attr.MinNodeWidth)
            {
                width = drawingGraph.Attr.MinNodeWidth;
            }
            if (height < drawingGraph.Attr.MinNodeHeight)
            {
                height = drawingGraph.Attr.MinNodeHeight;
            }

            return(NodeBoundaryCurves.GetNodeBoundaryCurve(node, width, height));
        }
예제 #4
0
        private ICurve GetNodeBoundaryCurveByMeasuringText(Microsoft.Msagl.Drawing.Node node)
        {
            double width, height;

            if (String.IsNullOrEmpty(node.LabelText))
            {
                width  = 10;
                height = 10;
            }
            else
            {
                var size = MeasureText(node.LabelText, new FontFamily(node.Label.FontName), node.Label.FontSize);
                width  = size.Width;
                height = size.Height;
            }

            width  += 2 * node.Attr.LabelMargin;
            height += 2 * node.Attr.LabelMargin;

            if (width < drawingGraph.Attr.MinNodeWidth)
            {
                width = drawingGraph.Attr.MinNodeWidth;
            }
            if (height < drawingGraph.Attr.MinNodeHeight)
            {
                height = drawingGraph.Attr.MinNodeHeight;
            }

            return(NodeBoundaryCurves.GetNodeBoundaryCurve(node, width, height));
        }
예제 #5
0
 public void NodeToCenter(Microsoft.Msagl.Drawing.Node node)
 {
     if (node.GeometryNode == null)
     {
         return;
     }
     PointToCenter(node.GeometryNode.Center);
 }
예제 #6
0
        public IViewerObject AddNode(Microsoft.Msagl.Drawing.Node drawingNode)
        {
            Graph.AddNode(drawingNode);
            var vNode = GetOrCreateViewerNode(drawingNode);

            LayoutEditor.AttachLayoutChangeEvent(vNode);
            LayoutEditor.CleanObstacles();
            return(vNode);
        }
예제 #7
0
 static void CreateSourceNode(Microsoft.Msagl.Drawing.Node a)
 {
     a.Attr.Shape           = Shape.Box;
     a.Attr.XRadius         = 3;
     a.Attr.YRadius         = 3;
     a.Attr.FillColor       = Color.Green;
     a.Attr.LineWidth       = 10;
     a.NodeBoundaryDelegate = new DelegateToSetNodeBoundary(StarCurve);
     a.Attr.Shape           = Shape.DrawFromGeometry;
 }
예제 #8
0
        public void NodeToCenterWithScale(Microsoft.Msagl.Drawing.Node node, double scale)
        {
            if (node.GeometryNode == null)
            {
                return;
            }
            var screenPoint = new WpfPoint(GraphCanvas.RenderSize.Width / 2, GraphCanvas.RenderSize.Height / 2);
            var sourcePoint = node.BoundingBox.Center;

            SetTransform(scale, screenPoint.X - scale * sourcePoint.X, screenPoint.Y + scale * sourcePoint.Y);
        }
        private Microsoft.Msagl.Drawing.Node CreateNodeOnCenter(Graph graph, Point nodeCenter)
        {
            var node = new Microsoft.Msagl.Drawing.Node(graph.NodeCount.ToString());

            node.Attr.Shape     = Microsoft.Msagl.Drawing.Shape.Circle;
            node.Attr.Color     = new Color(0, 100, 100, 100);
            node.Attr.FillColor = new Color(100, 100, 100, 100);
            var geomNode = new Node(CurveFactory.CreateCircle(_nodeWidth / 2, nodeCenter));

            node.GeometryNode = geomNode;
            geomNode.UserData = node;
            graph.AddNode(node);
            graph.GeometryGraph.Nodes.Add(geomNode);
            return(node);
        }
        private static void AddEdge(Microsoft.Msagl.Drawing.Node a, Microsoft.Msagl.Drawing.Node b, Graph graph)
        {
            var de = new Microsoft.Msagl.Drawing.Edge(a, b, ConnectionToGraph.Connected);

            de.Attr.LineWidth = Math.Max(1, (int)(a.Width / 10));
            de.Attr.Color     = new Microsoft.Msagl.Drawing.Color(200, 100, 100, 100);
            var   ge    = new Edge(a.GeometryNode, b.GeometryNode);
            Point start = a.GeometryNode.Center;
            Point end   = b.GeometryNode.Center;
            Point d     = (end - start) / 4;
            Point b1    = start + d;
            Point b2    = b1 + d;
            Point b3    = b2 + d;

            ge.EdgeGeometry.Curve           = new CubicBezierSegment(start, b1, b2, b3);
            ge.EdgeGeometry.TargetArrowhead = new Arrowhead()
            {
                TipPosition = end
            };
            de.GeometryEdge = ge;
            ge.UserData     = de;
        }
예제 #11
0
 static ICurve StarCurve(Microsoft.Msagl.Drawing.Node node)
 {
     return(CurveFactory.CreateStar(60, new Point()));
 }
예제 #12
0
        void AddRandomNode(Graph graph)
        {
            var nodeCenter = RandomCenter();

            Microsoft.Msagl.Drawing.Node node = CreateNodeOnCenter(graph, nodeCenter);
        }