Exemplo n.º 1
0
        /// <summary>
        /// Given a size, this will return the native symbolizer that has been adjusted to the specified size.
        /// </summary>
        /// <param name="size">The size of the symbol</param>
        /// <param name="color">The color of the symbol</param>
        /// <returns>The adjusted symbolizer.</returns>
        public IFeatureSymbolizer GetSymbolizer(double size, Color color)
        {
            IFeatureSymbolizer copy = Symbolizer.Copy();

            // preserve aspect ratio, larger dimension specified
            IPointSymbolizer ps = copy as IPointSymbolizer;

            if (ps != null)
            {
                Size2D s     = ps.GetSize();
                double ratio = size / Math.Max(s.Width, s.Height);
                s.Width  *= ratio;
                s.Height *= ratio;
                ps.SetSize(s);
                ps.SetFillColor(color);
            }

            ILineSymbolizer ls = copy as ILineSymbolizer;

            if (ls != null)
            {
                ls.SetWidth(size);
                ls.SetFillColor(color);
            }

            return(copy);
        }
Exemplo n.º 2
0
        /// <summary>
        /// Creates the category using a random fill color.
        /// </summary>
        /// <param name="fillColor">The base color to use for creating the category.</param>
        /// <param name="size">The double size of the larger dimension of the point.</param>
        /// <returns>A new polygon category.</returns>
        public override ICategory CreateNewCategory(Color fillColor, double size)
        {
            IPointSymbolizer ps = EditorSettings.TemplateSymbolizer.Copy() as IPointSymbolizer ?? new PointSymbolizer(fillColor, PointShape.Ellipse, size);

            ps.SetFillColor(fillColor);
            Size2D oSize = ps.GetSize();
            double rat   = size / Math.Max(oSize.Width, oSize.Height);

            ps.SetSize(new Size2D(rat * oSize.Width, rat * oSize.Height));
            return(new PointCategory(ps));
        }