private static ICurve CreateLabelAndBoundary(NavigationPoint navigationPoint, Microsoft.Msagl.Drawing.Node node)
        {
            node.Attr.LabelMargin *= 2;
            node.Label.IsVisible   = false;

            var y = (navigationPoint.Latitude - airfield.Latitude) * 200000;
            var x = (navigationPoint.Longitude - airfield.Longitude) * 200000;
            var positionalPoint = new Microsoft.Msagl.Core.Geometry.Point(x, y);

            switch (navigationPoint)
            {
            case Runway _:
                node.Attr.Color = Color.Green;
                return(CurveFactory.CreateCircle(50, positionalPoint));

            case Junction _:
                node.Attr.Shape = Shape.Hexagon;
                node.Attr.Color = Color.Blue;
                return(CurveFactory.CreateHexagon(100, 30, positionalPoint));

            case ParkingSpot _:
                node.Attr.Color = Color.Orange;
                return(CurveFactory.CreateOctagon(100, 30, positionalPoint));

            case WayPoint _:
                node.Attr.Color = Color.Purple;
                return(CurveFactory.CreateRectangle(100, 30, positionalPoint));
            }

            return(CurveFactory.CreateCircle(5, positionalPoint));
        }
Ejemplo n.º 2
0
        /// <summary>
        /// a helper function to creat a node boundary curve
        /// </summary>
        /// <param name="node">the node</param>
        /// <param name="width">the node width</param>
        /// <param name="height">the node height</param>
        /// <returns></returns>
        public static ICurve GetNodeBoundaryCurve(Node node, double width, double height)
        {
            if (node == null)
            {
                throw new InvalidOperationException();
            }
            NodeAttr nodeAttr = node.Attr;

            switch (nodeAttr.Shape)
            {
            case Shape.Ellipse:
            case Shape.DoubleCircle:
                return(CurveFactory.CreateEllipse(width, height, new P2(0, 0)));

            case Shape.Circle:
            {
                double r = Math.Max(width / 2, height / 2);
                return(CurveFactory.CreateEllipse(r, r, new P2(0, 0)));
            }

            case Shape.Box:
                if (nodeAttr.XRadius != 0 || nodeAttr.YRadius != 0)
                {
                    return(CurveFactory.CreateRectangleWithRoundedCorners(width, height, nodeAttr.XRadius,
                                                                          nodeAttr.YRadius, new P2(0, 0)));
                }
                return(CurveFactory.CreateRectangle(width, height, new P2(0, 0)));


            case Shape.Diamond:
                return(CurveFactory.CreateDiamond(
                           width, height, new P2(0, 0)));

            case Shape.House:
                return(CurveFactory.CreateHouse(width, height, new P2()));

            case Shape.InvHouse:
                return(CurveFactory.CreateInvertedHouse(width, height, new P2()));

            case Shape.Hexagon:
                return(CurveFactory.CreateHexagon(width, height, new P2()));

            case Shape.Octagon:
                return(CurveFactory.CreateOctagon(width, height, new P2()));

#if DEBUG
            case Shape.TestShape:
                return(CurveFactory.CreateTestShape(width, height));
#endif

            default:
            {
                //  Console.WriteLine("creating ellipse for shape {0}",nodeAttr.Shape);
                return(new Ellipse(
                           new P2(width / 2, 0), new P2(0, height / 2), new P2()));
            }
            }
        }
Ejemplo n.º 3
0
        /// <summary>
        /// Controlling the draw because a need to control the size.
        ///
        /// Supporting these shapes :
        /// Box
        /// Ellipse
        /// Circle
        /// Plaintext
        /// Point
        /// </summary>
        /// <param name="node"></param>
        /// <param name="centerLocation"></param>
        /// <param name="width"></param>
        /// <param name="hight"></param>
        /// <returns></returns>
        ICurve DrawCurve(Microsoft.Msagl.Drawing.Node node)
        {
            ICurve shape = null;

            switch (node.Attr.Shape)
            {
            case Shape.Box:
                shape = CurveFactory.CreateRectangle(NodeWidth, NodeHeight, NodeCenter);
                break;

            case Shape.Ellipse:
                shape = CurveFactory.CreateEllipse(NodeWidth, NodeHeight, NodeCenter);
                break;

            case Shape.Circle:
                shape = CurveFactory.CreateCircle(NodeWidth, NodeCenter);
                break;

            case Shape.Point:
                shape = CurveFactory.CreateCircle(0.5, NodeCenter);
                break;

            case Shape.Diamond:
                shape = CurveFactory.CreateDiamond(NodeWidth, NodeHeight, NodeCenter);
                break;

            case Shape.Hexagon:
                shape = CurveFactory.CreateHexagon(NodeWidth, NodeHeight, NodeCenter);
                break;

            case Shape.Octagon:
                shape = CurveFactory.CreateOctagon(NodeWidth, NodeHeight, NodeCenter);
                break;
            }
            return(shape);
        }