private IEnumerable <TRenderObject> drawPolygons(IEnumerable <IPolygon> polygons,
                                                         StyleBrush fill, StyleBrush highlightFill, StyleBrush selectFill,
                                                         StylePen outline, StylePen highlightOutline, StylePen selectOutline,
                                                         RenderState renderState)
        {
            if (fill == null)
            {
                throw new ArgumentNullException("fill");
            }
            if (outline == null)
            {
                throw new ArgumentNullException("outline");
            }

            IEnumerable <Path2D> paths = convertToPaths(polygons);

            if (highlightFill == null)
            {
                highlightFill = fill;
            }
            if (selectFill == null)
            {
                selectFill = fill;
            }
            if (highlightOutline == null)
            {
                highlightOutline = outline;
            }
            if (selectOutline == null)
            {
                selectOutline = outline;
            }

            IEnumerable <TRenderObject> renderedObjects = VectorRenderer.RenderPaths(
                paths, fill, highlightFill, selectFill, outline,
                highlightOutline, selectOutline, renderState);

            return(renderedObjects);
        }
        private IEnumerable <TRenderObject> drawLineStrings(IEnumerable <ILineString> lines,
                                                            StylePen fill, StylePen highlightFill, StylePen selectFill,
                                                            StylePen outline, StylePen highlightOutline, StylePen selectOutline,
                                                            RenderState renderState)
        {
            if (fill == null)
            {
                throw new ArgumentNullException("fill");
            }

            IEnumerable <Path2D> paths = convertToPaths(lines);

            if (highlightFill == null)
            {
                highlightFill = fill;
            }
            if (selectFill == null)
            {
                selectFill = fill;
            }
            if (highlightOutline == null)
            {
                highlightOutline = outline;
            }
            if (selectOutline == null)
            {
                selectOutline = outline;
            }

            IEnumerable <TRenderObject> renderedObjects = VectorRenderer.RenderPaths(paths,
                                                                                     fill, highlightFill, selectFill, outline, highlightOutline, selectOutline,
                                                                                     renderState);

            foreach (TRenderObject ro in renderedObjects)
            {
                yield return(ro);
            }
        }
        public virtual IEnumerable <TRenderObject> RenderLabel(Label2D label)
        {
            Size2D textSize = TextRenderer.MeasureString(label.Text, label.Font);
            //Size2D size = new Size2D(textSize.Width + 2*label.CollisionBuffer.Width, textSize.Height + 2*label.CollisionBuffer.Height);
            //Rectangle2D layoutRectangle =
            //    new Rectangle2D(new Point2D(label.Location.X-label.CollisionBuffer.Width, label.Location.Y-label.CollisionBuffer.Height), size);

            LabelStyle style = label.Style;
            Int32      x = 0, y = 0;

            if (style.HorizontalAlignment != HorizontalAlignment.Right || style.VerticalAlignment != VerticalAlignment.Bottom)
            {
                switch (style.HorizontalAlignment)
                {
                case HorizontalAlignment.Center:
                    x -= (Int32)(textSize.Width / 2.0f);
                    break;

                case HorizontalAlignment.Left:
                    x -= (Int32)textSize.Width;
                    break;

                default:
                    break;
                }

                switch (style.VerticalAlignment)
                {
                case VerticalAlignment.Middle:
                    y += (Int32)(textSize.Height / 2.0f);
                    break;

                case VerticalAlignment.Top:
                    y += (Int32)textSize.Height;
                    break;

                default:
                    break;
                }
            }

            Point2D     location        = RenderTransform.TransformVector(label.Location.X, label.Location.Y).Add(new Point2D(x, y));
            Rectangle2D layoutRectangle = new Rectangle2D(location, textSize);

            if (label.Style.Halo != null)
            {
                StylePen   halo       = label.Style.Halo;
                StyleBrush background = label.Style.Background;

                IEnumerable <TRenderObject> haloPath = VectorRenderer.RenderPaths(
                    generateHaloPath(layoutRectangle), background, background, background,
                    halo, halo, halo, RenderState.Normal);

                foreach (TRenderObject ro in haloPath)
                {
                    yield return(ro);
                }
            }

            IEnumerable <TRenderObject> renderedText = TextRenderer.RenderText(
                label.Text, label.Font, layoutRectangle, label.FlowPath, label.Style.Foreground, label.Transform);

            foreach (TRenderObject ro in renderedText)
            {
                yield return(ro);
            }
        }