GetColor() public method

Gets the color from the scale at position 'pos'.
If the position is outside the scale [0..1] only the fractional part is used (in other words the scale restarts for each integer-part).
public GetColor ( float pos ) : Color
pos float Position on scale between 0.0f and 1.0f
return System.Drawing.Color
示例#1
0
        /// <summary>
        /// Calculates the style for the gradient Theme. Use the constructor when all values are known because
        /// it will also update the symbol (bitmap).
        /// </summary>
        /// <param name="min"></param>
        /// <param name="max"></param>
        /// <param name="value"></param>
        /// <returns></returns>
        protected VectorStyle CalculateVectorStyle(VectorStyle min, VectorStyle max, double value)
        {
            //var style = new VectorStyle();
            double dFrac = Fraction(value);
            float  fFrac = Convert.ToSingle(dFrac);
            //bool enabled = (dFrac > 0.5 ? min.Enabled : max.Enabled);
            bool enableOutline = (dFrac > 0.5 ? min.EnableOutline : max.EnableOutline);

            Brush fillStyle = null;

            if (fillColorBlend != null)
            {
                fillStyle = new SolidBrush(fillColorBlend.GetColor(fFrac));
            }
            else if (min.Fill != null && max.Fill != null)
            {
                fillStyle = InterpolateBrush(min.Fill, max.Fill, value);
            }

            Pen lineStyle;

            if (lineColorBlend != null)
            {
                lineStyle = new Pen(lineColorBlend.GetColor(fFrac), InterpolateFloat(min.Line.Width, max.Line.Width, value));
            }
            else
            {
                lineStyle = InterpolatePen(min.Line, max.Line, value);
            }
            // assume line and outline same for gradient theme

            Pen outLineStyle = null;

            if (min.Outline != null && max.Outline != null)
            {
                outLineStyle = InterpolatePen(min.Outline, max.Outline, value);
            }

            ShapeType shapeType    = min.Shape;
            float     symbolScale  = InterpolateFloat(min.SymbolScale, max.SymbolScale, value);
            Type      geometryType = min.GeometryType;
            int       shapeSize    = InterpolateInt(min.ShapeSize, max.ShapeSize, value);
            var       style        = new VectorStyle(fillStyle, outLineStyle, enableOutline, lineStyle, symbolScale, geometryType, shapeType, shapeSize)
            {
                MinVisible = InterpolateDouble(min.MinVisible, max.MinVisible, value),
                MaxVisible = InterpolateDouble(min.MaxVisible, max.MaxVisible, value),
                Enabled    = (dFrac > 0.5 ? min.Enabled : max.Enabled)
            };

            return(style);
        }
示例#2
0
        /// <summary>
        /// Creates a <see cref="GradientTheme"/>
        /// </summary>
        /// <param name="attribute">Name of the feature attribute</param>
        /// <param name="defaultStyle">Default <see cref="VectorStyle"/> to base this theme on</param>
        /// <param name="blend"><see cref="ColorBlend"/>
        ///   defining the min and max colors
        ///   Note: Silently assumes 2 Colors defined
        /// </param>
        /// <param name="minValue">Minimum value of the feature attribute values</param>
        /// <param name="maxValue">Maximum value of the feature attribute values</param>
        /// <param name="sizeMin">Minimum line/point size in pixels</param>
        /// <param name="sizeMax">Maximum line/point size in pixels</param>
        /// <param name="skipColors">Use the min and max colors (false) or the defaultStyle fill color (true)</param>
        /// <param name="skipSizes">Let the size of a point depend on the value (false) or use the defaultStyle size (true)</param>
        /// <param name="numberOfClasses">The number of classes (ThemeItems) to generate (default = 8)</param>
        /// <returns>A new <see cref="GradientTheme"/></returns>
        public static GradientTheme CreateGradientTheme(string attribute, VectorStyle defaultStyle, ColorBlend blend,
                                                        double minValue, double maxValue, int sizeMin, int sizeMax, bool skipColors, bool skipSizes, int numberOfClasses = 8)
        {
            if (defaultStyle == null)
            {
                defaultStyle = new VectorStyle {
                    GeometryType = typeof(IPolygon)
                };
            }

            Color minColor = (skipColors) ? ((SolidBrush)defaultStyle.Fill).Color : blend.GetColor(0);
            Color maxColor = (skipColors) ? ((SolidBrush)defaultStyle.Fill).Color : blend.GetColor(1);

            var deltaWidth = (defaultStyle.Outline.Width - defaultStyle.Line.Width);

            float minOutlineSize = deltaWidth + sizeMin;
            float maxOutlineSize = deltaWidth + sizeMax;

            // Use default styles if not working with VectorLayers (i.e. RegularGridCoverageLayers)
            var minStyle = (VectorStyle)defaultStyle.Clone();
            var maxStyle = (VectorStyle)defaultStyle.Clone();

            minStyle.GeometryType = defaultStyle.GeometryType;
            maxStyle.GeometryType = defaultStyle.GeometryType;

            if (defaultStyle.GeometryType == typeof(IPoint))
            {
                UpdateMinMaxForPoints(defaultStyle, sizeMin, sizeMax, minStyle, maxStyle, minColor, maxColor, skipSizes);
            }
            else if ((defaultStyle.GeometryType == typeof(IPolygon)) || (defaultStyle.GeometryType == typeof(IMultiPolygon)))
            {
                UpdateMinMaxForPolygons(defaultStyle, minStyle, maxStyle, minColor, maxColor, minOutlineSize, maxOutlineSize);
            }
            else if ((defaultStyle.GeometryType == typeof(ILineString)) || (defaultStyle.GeometryType == typeof(IMultiLineString)))
            {
                UpdateMinMaxForLineStrings(defaultStyle, sizeMin, sizeMax, minStyle, maxStyle, minColor, maxColor, minOutlineSize, maxOutlineSize, skipSizes);
            }
            else
            {
                //use for unknown geometry..
                minStyle.Fill    = new SolidBrush(minColor);
                maxStyle.Fill    = new SolidBrush(maxColor);
                minStyle.Outline = CreatePen(minColor, minOutlineSize, defaultStyle.Outline);
                maxStyle.Outline = CreatePen(maxColor, maxOutlineSize, defaultStyle.Outline);
            }

            return(new GradientTheme(attribute, minValue, maxValue, minStyle, maxStyle, blend, blend, null, numberOfClasses));
        }
示例#3
0
        /// <summary>
        /// Creates a <see cref="GradientTheme"/>
        /// </summary>
        /// <param name="attribute">Name of the feature attribute</param>
        /// <param name="defaultStyle">Default <see cref="VectorStyle"/> to base this theme on</param>
        /// <param name="blend"><see cref="ColorBlend"/> 
        ///   defining the min and max colors
        ///   Note: Silently assumes 2 Colors defined
        /// </param>
        /// <param name="minValue">Minimum value of the feature attribute values</param>
        /// <param name="maxValue">Maximum value of the feature attribute values</param>
        /// <param name="sizeMin">Minimum line/point size in pixels</param>
        /// <param name="sizeMax">Maximum line/point size in pixels</param>
        /// <param name="skipColors">Use the min and max colors (false) or the defaultStyle fill color (true)</param>
        /// <param name="skipSizes">Let the size of a point depend on the value (false) or use the defaultStyle size (true)</param>
        /// <param name="numberOfClasses">The number of classes (ThemeItems) to generate (default = 8)</param>
        /// <returns>A new <see cref="GradientTheme"/></returns>
        public static GradientTheme CreateGradientTheme(string attribute, VectorStyle defaultStyle, ColorBlend blend,
            double minValue, double maxValue, int sizeMin, int sizeMax, bool skipColors, bool skipSizes, int numberOfClasses = 8)
        {
            if (defaultStyle == null)
            {
                defaultStyle = new VectorStyle { GeometryType = typeof(IPolygon) };
            }

            Color minColor = (skipColors) ? ((SolidBrush)defaultStyle.Fill).Color : blend.GetColor(0);
            Color maxColor = (skipColors) ? ((SolidBrush)defaultStyle.Fill).Color : blend.GetColor(1);

            var deltaWidth = (defaultStyle.Outline.Width - defaultStyle.Line.Width);

            float minOutlineSize = deltaWidth + sizeMin;
            float maxOutlineSize = deltaWidth + sizeMax;

            // Use default styles if not working with VectorLayers (i.e. RegularGridCoverageLayers)
            var minStyle = (VectorStyle)defaultStyle.Clone();
            var maxStyle = (VectorStyle)defaultStyle.Clone();

            minStyle.GeometryType = defaultStyle.GeometryType;
            maxStyle.GeometryType = defaultStyle.GeometryType;

            if (defaultStyle.GeometryType == typeof(IPoint))
            {
                UpdateMinMaxForPoints(defaultStyle, sizeMin, sizeMax, minStyle, maxStyle, minColor, maxColor, skipSizes);
            }
            else if ((defaultStyle.GeometryType == typeof(IPolygon)) || (defaultStyle.GeometryType == typeof(IMultiPolygon)))
            {
                UpdateMinMaxForPolygons(defaultStyle, minStyle, maxStyle, minColor, maxColor, minOutlineSize, maxOutlineSize);
            }
            else if ((defaultStyle.GeometryType == typeof(ILineString)) || (defaultStyle.GeometryType == typeof(IMultiLineString)))
            {
                UpdateMinMaxForLineStrings(defaultStyle, sizeMin, sizeMax, minStyle, maxStyle, minColor, maxColor, minOutlineSize, maxOutlineSize, skipSizes);
            }
            else
            {
                //use for unknown geometry..
                minStyle.Fill = new SolidBrush(minColor);
                maxStyle.Fill = new SolidBrush(maxColor);
                minStyle.Outline = CreatePen(minColor, minOutlineSize, defaultStyle.Outline);
                maxStyle.Outline = CreatePen(maxColor, maxOutlineSize, defaultStyle.Outline);
            }

            return new GradientTheme(attribute, minValue, maxValue, minStyle, maxStyle, blend, blend, null, numberOfClasses);
        }
示例#4
0
        public static CategorialTheme CreateCategorialTheme(string attribute, VectorStyle defaultStyle, ColorBlend blend,
                                                            int numberOfClasses, IList <IComparable> values, List <string> categories, int sizeMin, int sizeMax)
        {
            if (defaultStyle == null)
            {
                defaultStyle = new VectorStyle
                {
                    GeometryType = typeof(IPolygon)
                };
            }

            var categorialTheme = new CategorialTheme(attribute, defaultStyle);

            for (int i = 0; i < numberOfClasses; i++)
            {
                string label = (categories != null)
                                   ? categories[i]
                                   : values[i].ToString();

                Color color = (numberOfClasses > 1)
                                  ? blend.GetColor((float)i / (numberOfClasses - 1))
                                  : ((SolidBrush)defaultStyle.Fill).Color;

                var vectorStyle = (VectorStyle)defaultStyle.Clone();

                var size = sizeMin + (sizeMax - sizeMin) * i / (float)numberOfClasses;

                if (defaultStyle.GeometryType == typeof(IPoint))
                {
                    vectorStyle.Fill       = new SolidBrush(color);
                    vectorStyle.Line.Width = 16;
                    vectorStyle.Shape      = defaultStyle.Shape;
                }
                else if ((defaultStyle.GeometryType == typeof(IPolygon)) || (defaultStyle.GeometryType == typeof(IMultiPolygon)))
                {
                    vectorStyle.Fill = new SolidBrush(color);
                }
                else if ((defaultStyle.GeometryType == typeof(ILineString)) || (defaultStyle.GeometryType == typeof(IMultiLineString)))
                {
                    vectorStyle.Line = CreatePen(color, size, defaultStyle.Line);
                }
                else
                {
                    vectorStyle.Fill = new SolidBrush(color);
                }

                CategorialThemeItem categorialThemeItem = (values[i] != null)
                                                              ? new CategorialThemeItem(label, vectorStyle, vectorStyle.LegendSymbol, values[i])
                                                              : new CategorialThemeItem(label, vectorStyle, vectorStyle.LegendSymbol);


                categorialTheme.AddThemeItem(categorialThemeItem);
            }

            return(categorialTheme);
        }
示例#5
0
        /// <summary>
        /// Function to compute a new <see cref="VectorStyle">style</see> for the given <paramref name="value"/>
        /// </summary>
        /// <param name="min">The minimum <see cref="VectorStyle">style</see></param>
        /// <param name="max">The maximum <see cref="VectorStyle">style</see></param>
        /// <param name="value">The value</param>
        /// <returns>A <see cref="VectorStyle">style</see></returns>
        protected VectorStyle CalculateVectorStyle(VectorStyle min, VectorStyle max, double value)
        {
            var    style = new VectorStyle();
            double dFrac = Fraction(value);
            float  fFrac = Convert.ToSingle(dFrac);

            style.Enabled         = (dFrac > 0.5 ? min.Enabled : max.Enabled);
            style.EnableOutline   = (dFrac > 0.5 ? min.EnableOutline : max.EnableOutline);
            style.VisibilityUnits = min.VisibilityUnits;
            if (_fillColorBlend != null)
            {
                style.Fill = new SolidBrush(_fillColorBlend.GetColor(fFrac));
            }
            else if (min.Fill != null && max.Fill != null)
            {
                style.Fill = InterpolateBrush(min.Fill, max.Fill, value);
            }

            if (min.Line != null && max.Line != null)
            {
                style.Line = InterpolatePen(min.Line, max.Line, value);
            }
            if (_lineColorBlend != null)
            {
                style.Line.Color = _lineColorBlend.GetColor(fFrac);
            }

            if (min.Outline != null && max.Outline != null)
            {
                style.Outline = InterpolatePen(min.Outline, max.Outline, value);
            }
            style.MinVisible   = InterpolateDouble(min.MinVisible, max.MinVisible, value);
            style.MaxVisible   = InterpolateDouble(min.MaxVisible, max.MaxVisible, value);
            style.Symbol       = (dFrac > 0.5 ? min.Symbol : max.Symbol);
            style.SymbolOffset = (dFrac > 0.5 ? min.SymbolOffset : max.SymbolOffset);
            //We don't interpolate the offset but let it follow the symbol instead
            style.SymbolScale = InterpolateFloat(min.SymbolScale, max.SymbolScale, value);
            return(style);
        }
示例#6
0
        public static QuantityTheme CreateQuantityTheme(string attribute, VectorStyle defaultStyle, ColorBlend blend,
                                                        int numberOfClasses, IList <Interval> intervals, float minSize, float maxSize, bool skipColors, bool skipSizes)
        {
            if (defaultStyle == null)
            {
                defaultStyle = new VectorStyle();
                defaultStyle.GeometryType = typeof(IPolygon);
            }

            var quantityTheme = new QuantityTheme(attribute, defaultStyle);

            var totalMinValue = (float)intervals[0].Min;
            var totalMaxValue = (float)intervals[intervals.Count - 1].Max;

            if (totalMinValue == totalMaxValue)
            {
                return(null);
            }

            for (int i = 0; i < numberOfClasses; i++)
            {
                Color color = numberOfClasses > 1
                                  ? blend.GetColor(1 - (float)i / (numberOfClasses - 1))
                                  : ((SolidBrush)defaultStyle.Fill).Color;

                float size = defaultStyle.Line.Width;

                if (!skipSizes)
                {
                    var minValue = (float)intervals[i].Min;
                    var maxValue = (float)intervals[i].Max;

                    float width = maxValue - minValue;
                    float mean  = minValue + 0.5f * width;

                    float fraction = (mean - totalMinValue) / (totalMaxValue - totalMinValue);

                    size = minSize + fraction * (maxSize - minSize);
                }

                var vectorStyle = new VectorStyle
                {
                    GeometryType = defaultStyle.GeometryType
                };

                if (defaultStyle.GeometryType == typeof(IPoint))
                {
                    if (skipColors)
                    {
                        color = ((SolidBrush)defaultStyle.Fill).Color;
                    }

                    vectorStyle.Fill  = new SolidBrush(color);
                    vectorStyle.Shape = defaultStyle.Shape;

                    if (!skipSizes)
                    {
                        vectorStyle.ShapeSize  = Convert.ToInt32(size);
                        vectorStyle.Line.Width = size;
                    }
                }
                else if ((defaultStyle.GeometryType == typeof(IPolygon)) || (defaultStyle.GeometryType == typeof(IMultiPolygon)))
                {
                    if (skipColors)
                    {
                        color = ((SolidBrush)defaultStyle.Fill).Color;
                    }
                    vectorStyle.Fill          = new SolidBrush(color);
                    vectorStyle.Line          = CreatePen(color, size, defaultStyle.Line);
                    vectorStyle.Outline.Width = (defaultStyle.Outline.Width - defaultStyle.Line.Width) + size;
                }
                else if ((defaultStyle.GeometryType == typeof(ILineString)) || (defaultStyle.GeometryType == typeof(IMultiLineString)))
                {
                    if (skipColors)
                    {
                        color = defaultStyle.Line.Color;
                    }
                    vectorStyle.Line          = CreatePen(color, size, defaultStyle.Line);
                    vectorStyle.Outline.Width = (defaultStyle.Outline.Width - defaultStyle.Line.Width) + size;
                }
                else
                {
                    vectorStyle.Fill = new SolidBrush(color);
                }

                quantityTheme.AddStyle(vectorStyle, intervals[i]);
            }

            return(quantityTheme);
        }
示例#7
0
        public static QuantityTheme CreateQuantityTheme(string attribute, VectorStyle defaultStyle, ColorBlend blend, 
            int numberOfClasses, IList<Interval> intervals, float minSize, float maxSize, bool skipColors, bool skipSizes)
        {
            if (defaultStyle == null)
            {
                defaultStyle = new VectorStyle();
                defaultStyle.GeometryType = typeof(IPolygon);
            }

            var quantityTheme = new QuantityTheme(attribute, defaultStyle);
            
            var totalMinValue = (float) intervals[0].Min;
            var totalMaxValue = (float) intervals[intervals.Count - 1].Max;
            
            if (totalMinValue == totalMaxValue)
            {
                return null;
            }

            for (int i = 0; i < numberOfClasses; i++)
            {
                Color color = numberOfClasses > 1
                                  ? blend.GetColor(1 - (float) i/(numberOfClasses - 1))
                                  : ((SolidBrush) defaultStyle.Fill).Color;

                float size = defaultStyle.Line.Width;

                if (!skipSizes)
                {
                    var minValue = (float) intervals[i].Min;
                    var maxValue = (float) intervals[i].Max;
                    
                    float width = maxValue - minValue;
                    float mean = minValue + 0.5f * width;

                    float fraction = (mean - totalMinValue) / (totalMaxValue - totalMinValue);

                    size = minSize + fraction * (maxSize - minSize);
                }

                var vectorStyle = new VectorStyle
                                      {
                                          GeometryType = defaultStyle.GeometryType
                                      };

                if (defaultStyle.GeometryType == typeof(IPoint))
                {
                    if (skipColors)
                    {
                        color = ((SolidBrush)defaultStyle.Fill).Color;
                    }

                    vectorStyle.Fill = new SolidBrush(color);
                    vectorStyle.Shape = defaultStyle.Shape;

                    if (!skipSizes)
                    {
                        vectorStyle.ShapeSize = Convert.ToInt32(size);
                        vectorStyle.Line.Width = size;
                    }

                }
                else if ((defaultStyle.GeometryType == typeof(IPolygon)) || (defaultStyle.GeometryType == typeof(IMultiPolygon)))
                {
                    if (skipColors)
                    {
                        color = ((SolidBrush)defaultStyle.Fill).Color;
                    }
                    vectorStyle.Fill = new SolidBrush(color);
                    vectorStyle.Line = CreatePen(color, size, defaultStyle.Line);
                    vectorStyle.Outline.Width = (defaultStyle.Outline.Width - defaultStyle.Line.Width) + size;
                }
                else if ((defaultStyle.GeometryType == typeof(ILineString)) || (defaultStyle.GeometryType == typeof(IMultiLineString)))
                {
                    if (skipColors)
                    {
                        color = defaultStyle.Line.Color;
                    }
                    vectorStyle.Line = CreatePen(color, size, defaultStyle.Line);
                    vectorStyle.Outline.Width = (defaultStyle.Outline.Width - defaultStyle.Line.Width) + size;
                }
                else
                {
                    vectorStyle.Fill = new SolidBrush(color);
                }
              
                quantityTheme.AddStyle(vectorStyle, intervals[i]);
            }

            return quantityTheme;
        }
示例#8
0
        public static CategorialTheme CreateCategorialTheme(string attribute, VectorStyle defaultStyle, ColorBlend blend, 
            int numberOfClasses, IList<IComparable> values, List<string> categories, int sizeMin, int sizeMax)
        {
            if (defaultStyle == null)
            {
                defaultStyle = new VectorStyle
                                   {
                                       GeometryType = typeof (IPolygon)
                                   };
            }

            var categorialTheme = new CategorialTheme(attribute, defaultStyle);

            for (int i = 0; i < numberOfClasses; i++)
            {
                string label = (categories != null)
                                   ? categories[i]
                                   : values[i].ToString();

                Color color = (numberOfClasses > 1)
                                  ? blend.GetColor((float) i/(numberOfClasses - 1))
                                  : ((SolidBrush) defaultStyle.Fill).Color;
                
                var vectorStyle = (VectorStyle) defaultStyle.Clone();

                var size = sizeMin + (sizeMax - sizeMin)*i/(float) numberOfClasses;

                if (defaultStyle.GeometryType == typeof(IPoint))
                {
                    vectorStyle.Fill = new SolidBrush(color);
                    vectorStyle.Line.Width = 16;
                    vectorStyle.Shape = defaultStyle.Shape;
                }
                else if ((defaultStyle.GeometryType == typeof(IPolygon)) || (defaultStyle.GeometryType == typeof(IMultiPolygon)))
                {
                    vectorStyle.Fill = new SolidBrush(color);
                }
                else if ((defaultStyle.GeometryType == typeof(ILineString)) || (defaultStyle.GeometryType == typeof(IMultiLineString)))
                {
                    vectorStyle.Line = CreatePen(color, size, defaultStyle.Line);
                }
                else
                {
                    vectorStyle.Fill = new SolidBrush(color);
                }

                CategorialThemeItem categorialThemeItem = (values[i] != null)
                                                              ? new CategorialThemeItem(label, vectorStyle, vectorStyle.LegendSymbol, values[i])
                                                              : new CategorialThemeItem(label, vectorStyle, vectorStyle.LegendSymbol);

                
                categorialTheme.AddThemeItem(categorialThemeItem);
            }

            return categorialTheme;
        }
示例#9
0
        /// <summary>
        /// Calculates the style for the gradient Theme. Use the constructor when all values are known because
        /// it will also update the symbol (bitmap).
        /// </summary>
        /// <param name="value"></param>
        /// <returns></returns>
        protected VectorStyle CalculateVectorStyle(double value)
        {
            var min = (VectorStyle)MinStyle;
            var max = (VectorStyle)MaxStyle;

            double dFrac = Fraction(value);

            //There are some theoretical issues with this caching if the number of color transitions is high
            //(and non-smooth). However, for all intents and purposes this approach will be visually equal
            //to non-cached styling.
            const int numberOfCachedStyles = 512;
            int       cacheIndex           = (int)(dFrac * numberOfCachedStyles);

            if (vectorStyleCache.ContainsKey(cacheIndex))
            {
                return(vectorStyleCache[cacheIndex]);
            }

            float fFrac = Convert.ToSingle(dFrac);
            //bool enabled = (dFrac > 0.5 ? min.Enabled : max.Enabled);
            bool enableOutline = (dFrac > 0.5 ? min.EnableOutline : max.EnableOutline);

            Brush fillStyle = null;

            if (fillColorBlend != null)
            {
                fillStyle = new SolidBrush(fillColorBlend.GetColor(fFrac));
            }
            else if (min.Fill != null && max.Fill != null)
            {
                fillStyle = InterpolateBrush(min.Fill, max.Fill, value);
            }

            Pen lineStyle;

            if (lineColorBlend != null)
            {
                lineStyle = new Pen(lineColorBlend.GetColor(fFrac), InterpolateFloat(min.Line.Width, max.Line.Width, value));
            }
            else
            {
                lineStyle = InterpolatePen(min.Line, max.Line, value);
            }
            // assume line and outline same for gradient theme

            Pen outLineStyle = null;

            if (min.Outline != null && max.Outline != null)
            {
                outLineStyle = InterpolatePen(min.Outline, max.Outline, value);
            }

            ShapeType shapeType    = min.Shape;
            float     symbolScale  = InterpolateFloat(min.SymbolScale, max.SymbolScale, value);
            Type      geometryType = min.GeometryType;
            int       shapeSize    = InterpolateInt(min.ShapeSize, max.ShapeSize, value);
            var       style        = new VectorStyle(fillStyle, outLineStyle, enableOutline, lineStyle, symbolScale, geometryType, shapeType, shapeSize)
            {
                MinVisible = InterpolateDouble(min.MinVisible, max.MinVisible, value),
                MaxVisible = InterpolateDouble(min.MaxVisible, max.MaxVisible, value),
                Enabled    = (dFrac > 0.5 ? min.Enabled : max.Enabled),
                Line       =
                {
                    StartCap = min.Line.StartCap,
                    EndCap   = min.Line.EndCap
                }
            };

            vectorStyleCache[cacheIndex] = style;

            return(style);
        }
示例#10
0
        public static GradientTheme CreateGradientTheme(string attribute, VectorStyle defaultStyle, ColorBlend blend,
                                                        float minValue, float maxValue, int sizeMin, int sizeMax, bool skipColors, bool skipSizes, int numberOfClasses)
        {
            if (defaultStyle == null)
            {
                defaultStyle = new VectorStyle();
                defaultStyle.GeometryType = typeof(IPolygon);
            }

            Color minColor = (skipColors)? ((SolidBrush)defaultStyle.Fill).Color : blend.GetColor(0);
            Color maxColor = (skipColors) ? ((SolidBrush)defaultStyle.Fill).Color : blend.GetColor(1);

            var deltaWith = (defaultStyle.Outline.Width - defaultStyle.Line.Width);

            float minOutlineSize = deltaWith + sizeMin;
            float maxOutlineSize = deltaWith + sizeMax;

            // Use default styles if not working with VectorLayers (i.e. RegularGridCoverageLayers)
            var minStyle = (VectorStyle)defaultStyle.Clone();
            var maxStyle = (VectorStyle)defaultStyle.Clone();

            minStyle.GeometryType = defaultStyle.GeometryType;
            maxStyle.GeometryType = defaultStyle.GeometryType;

            if (defaultStyle.GeometryType == typeof(IPoint))
            {
                minStyle.Fill  = new SolidBrush(minColor);
                maxStyle.Fill  = new SolidBrush(maxColor);
                minStyle.Shape = defaultStyle.Shape;
                maxStyle.Shape = defaultStyle.Shape;
                if (!skipSizes)
                {
                    minStyle.Line.Width = sizeMin;
                    maxStyle.Line.Width = sizeMax;
                    minStyle.ShapeSize  = sizeMin;
                    maxStyle.ShapeSize  = sizeMax;
                }
            }
            else if ((defaultStyle.GeometryType == typeof(IPolygon)) || (defaultStyle.GeometryType == typeof(IMultiPolygon)))
            {
                minStyle.Fill    = new SolidBrush(minColor);
                maxStyle.Fill    = new SolidBrush(maxColor);
                minStyle.Outline = new Pen(defaultStyle.Outline.Color, minOutlineSize);
                maxStyle.Outline = new Pen(defaultStyle.Outline.Color, maxOutlineSize);
            }
            else if ((defaultStyle.GeometryType == typeof(ILineString)) || (defaultStyle.GeometryType == typeof(IMultiLineString)))
            {
                minStyle.Line    = new Pen(minColor, sizeMin);
                maxStyle.Line    = new Pen(maxColor, sizeMax);
                minStyle.Outline = new Pen(defaultStyle.Outline.Color, minOutlineSize);
                maxStyle.Outline = new Pen(defaultStyle.Outline.Color, maxOutlineSize);
            }
            else
            {
                minStyle.Fill    = new SolidBrush(minColor);
                maxStyle.Fill    = new SolidBrush(maxColor);
                minStyle.Outline = new Pen(minColor, minOutlineSize);
                maxStyle.Outline = new Pen(maxColor, maxOutlineSize);
            }

            var gradientTheme = new GradientTheme(attribute, minValue, maxValue, minStyle, maxStyle, blend, blend, null, numberOfClasses);

            return(gradientTheme);
        }
示例#11
0
        public static GradientTheme CreateGradientTheme(string attribute, VectorStyle defaultStyle, ColorBlend blend, 
            float minValue, float maxValue, int sizeMin, int sizeMax, bool skipColors, bool skipSizes, int numberOfClasses)
        {
            if(defaultStyle == null)
            {
                defaultStyle = new VectorStyle();
                defaultStyle.GeometryType = typeof(IPolygon);
            }

            Color minColor = (skipColors)? ((SolidBrush) defaultStyle.Fill).Color : blend.GetColor(0);
            Color maxColor = (skipColors) ? ((SolidBrush)defaultStyle.Fill).Color : blend.GetColor(1);

            var deltaWith = (defaultStyle.Outline.Width - defaultStyle.Line.Width);

            float minOutlineSize = deltaWith + sizeMin;
            float maxOutlineSize = deltaWith + sizeMax;

            // Use default styles if not working with VectorLayers (i.e. RegularGridCoverageLayers)
            var minStyle = (VectorStyle) defaultStyle.Clone();
            var maxStyle = (VectorStyle) defaultStyle.Clone();

            minStyle.GeometryType = defaultStyle.GeometryType;
            maxStyle.GeometryType = defaultStyle.GeometryType;

            if (defaultStyle.GeometryType == typeof(IPoint))
            {
                minStyle.Fill = new SolidBrush(minColor);
                maxStyle.Fill = new SolidBrush(maxColor);
                minStyle.Shape = defaultStyle.Shape;
                maxStyle.Shape = defaultStyle.Shape;
                if (!skipSizes)
                {
                    minStyle.Line.Width = sizeMin;
                    maxStyle.Line.Width = sizeMax;
                    minStyle.ShapeSize = sizeMin;
                    maxStyle.ShapeSize = sizeMax;
                }
            }
            else if ((defaultStyle.GeometryType == typeof(IPolygon)) || (defaultStyle.GeometryType == typeof(IMultiPolygon)))
            {
                minStyle.Fill = new SolidBrush(minColor);
                maxStyle.Fill = new SolidBrush(maxColor);
                minStyle.Outline = new Pen(defaultStyle.Outline.Color, minOutlineSize);
                maxStyle.Outline = new Pen(defaultStyle.Outline.Color, maxOutlineSize);
            }
            else if ((defaultStyle.GeometryType == typeof(ILineString)) || (defaultStyle.GeometryType == typeof(IMultiLineString)))
            {
                minStyle.Line = new Pen(minColor, sizeMin);
                maxStyle.Line = new Pen(maxColor, sizeMax);
                minStyle.Outline = new Pen(defaultStyle.Outline.Color, minOutlineSize);
                maxStyle.Outline = new Pen(defaultStyle.Outline.Color, maxOutlineSize);
            }
            else
            {
                minStyle.Fill = new SolidBrush(minColor);
                maxStyle.Fill = new SolidBrush(maxColor);
                minStyle.Outline = new Pen(minColor, minOutlineSize);
                maxStyle.Outline = new Pen(maxColor, maxOutlineSize);
            }

            var gradientTheme = new GradientTheme(attribute, minValue, maxValue, minStyle, maxStyle, blend, blend, null, numberOfClasses);
            return gradientTheme;
       }