SharpMap.Rendering.Thematics.GradientTheme.GradientTheme C# (CSharp) Method

GradientTheme() public method

Initializes a new instance of the GradientTheme class

The gradient theme interpolates linearly between two styles based on a numerical attribute in the datasource. This is useful for scaling symbols, line widths, line and fill colors from numerical attributes.

Colors are interpolated between two colors, but if you want to interpolate through more colors (fx. a rainbow), set the TextColorBlend, LineColorBlend and FillColorBlend properties to a custom ColorBlend.

The following properties are scaled (properties not mentioned here are not interpolated): PropertyRemarks System.Drawing.ColorRed, Green, Blue and Alpha values are linearly interpolated. System.Drawing.PenThe color, width, color of pens are interpolated. MiterLimit,StartCap,EndCap,LineJoin,DashStyle,DashPattern,DashOffset,DashCap,CompoundArray, and Alignment are switched in the middle of the min/max values. System.Drawing.SolidBrushSolidBrush color are interpolated. Other brushes are not supported. SharpMap.Styles.VectorStyleMaxVisible, MinVisible, Line, Outline, Fill and SymbolScale are scaled linearly. Symbol, EnableOutline and Enabled switch in the middle of the min/max values. SharpMap.Styles.LabelStyleFontSize, BackColor, ForeColor, MaxVisible, MinVisible, Offset are scaled linearly. All other properties use min-style.

Creating a rainbow colorblend showing colors from red, through yellow, green and blue depicting the population density of a country. //Create two vector styles to interpolate between SharpMap.Styles.VectorStyle min = new SharpMap.Styles.VectorStyle(); SharpMap.Styles.VectorStyle max = new SharpMap.Styles.VectorStyle(); min.Outline.Width = 1f; //Outline width of the minimum value max.Outline.Width = 3f; //Outline width of the maximum value //Create a theme interpolating population density between 0 and 400 SharpMap.Rendering.Thematics.GradientTheme popdens = new SharpMap.Rendering.Thematics.GradientTheme("PopDens", 0, 400, min, max); //Set the fill-style colors to be a rainbow blend from red to blue. popdens.FillColorBlend = SharpMap.Rendering.Thematics.ColorBlend.Rainbow5; myVectorLayer.Theme = popdens;
public GradientTheme ( string columnName, double minValue, double maxValue, SharpMap minStyle, SharpMap maxStyle ) : System
columnName string Name of column to extract the attribute
minValue double Minimum value
maxValue double Maximum value
minStyle SharpMap Color for minimum value
maxStyle SharpMap Color for maximum value
return System
        public GradientTheme(string columnName, double minValue, double maxValue, SharpMap.Styles.IStyle minStyle, SharpMap.Styles.IStyle maxStyle)
        {
            _ColumnName = columnName;
            _min = minValue;
            _max = maxValue;
            _maxStyle = maxStyle;
            _minStyle = minStyle;
        }