C# Class Mapsui.Styles.Thematics.GradientTheme

The GradientTheme class defines a gradient color thematic rendering of features based by a numeric attribute.
Inheritance: Style, IThemeStyle
ファイルを表示 Open project: pauldendulk/Mapsui Class Usage Examples

Public Methods

Method Description
GetStyle ( IFeature row ) : IStyle

Returns the style based on a numeric DataColumn, where style properties are linearly interpolated between max and min values.

GradientTheme ( string columnName, double minValue, double maxValue, IStyle minStyle, IStyle maxStyle ) : System

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 ColorRed, Green, Blue and Alpha values are linearly interpolated. 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. BrushBrush color are interpolated. Other brushes are not supported. Mapsui.Styles.VectorStyleMaxVisible, MinVisible, Line, Outline, Fill and SymbolScale are scaled linearly. Symbol, EnableOutline and Enabled switch in the middle of the min/max values. Mapsui.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 Mapsui.Styles.VectorStyle min = new Mapsui.Styles.VectorStyle(); Mapsui.Styles.VectorStyle max = new Mapsui.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 Mapsui.Rendering.Thematics.GradientTheme popdens = new Mapsui.Rendering.Thematics.GradientTheme("PopDens", 0, 400, min, max); //Set the fill-style colors to be a rainbow blend from red to blue. popdens.FillColorBlend = Mapsui.Rendering.Thematics.ColorBlend.Rainbow5; myVectorLayer.Styles.Add(popdens);

Private Methods

Method Description
CalculateLabelStyle ( LabelStyle style, LabelStyle min, LabelStyle max, double value ) : void
CalculateSymbolStyle ( SymbolStyle style, SymbolStyle min, SymbolStyle max, double value ) : void
CalculateVectorStyle ( VectorStyle style, VectorStyle min, VectorStyle max, double value ) : void
Fraction ( double attr ) : double
InterpolateBool ( bool min, bool max, double attr ) : bool
InterpolateBrush ( Brush min, Brush max, double attr ) : Brush
InterpolateColor ( System.Color minCol, System.Color maxCol, double attr ) : System.Color
InterpolateDouble ( double min, double max, double attr ) : double
InterpolatePen ( Pen min, Pen max, double attr ) : Pen
InterpolateString ( string min, string max, double attr ) : string

Method Details

GetStyle() public method

Returns the style based on a numeric DataColumn, where style properties are linearly interpolated between max and min values.
public GetStyle ( IFeature row ) : IStyle
row IFeature Feature
return IStyle

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 ColorRed, Green, Blue and Alpha values are linearly interpolated. 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. BrushBrush color are interpolated. Other brushes are not supported. Mapsui.Styles.VectorStyleMaxVisible, MinVisible, Line, Outline, Fill and SymbolScale are scaled linearly. Symbol, EnableOutline and Enabled switch in the middle of the min/max values. Mapsui.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 Mapsui.Styles.VectorStyle min = new Mapsui.Styles.VectorStyle(); Mapsui.Styles.VectorStyle max = new Mapsui.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 Mapsui.Rendering.Thematics.GradientTheme popdens = new Mapsui.Rendering.Thematics.GradientTheme("PopDens", 0, 400, min, max); //Set the fill-style colors to be a rainbow blend from red to blue. popdens.FillColorBlend = Mapsui.Rendering.Thematics.ColorBlend.Rainbow5; myVectorLayer.Styles.Add(popdens);
public GradientTheme ( string columnName, double minValue, double maxValue, IStyle minStyle, IStyle maxStyle ) : System
columnName string Name of column to extract the attribute
minValue double Minimum value
maxValue double Maximum value
minStyle IStyle Color for minimum value
maxStyle IStyle Color for maximum value
return System