Table of Contents

Class ValueStyle

Namespace
ThinkGeo.Core
Assembly
ThinkGeo.Core.dll

This class allows you to match a value with data in the feature to determine how to draw that feature.

public class ValueStyle : Style
Inheritance
ValueStyle
Derived
Inherited Members

Remarks

Value Style:

The ValueStyle allows you to match data in the FeatureSource against a value string. If the value matches, then we will use the style defined in that item to do the drawing. For example, let's say you have some data that contains states, and each state is categorized as either a high, medium or low pollution state. Based on the string values of "High", Medium" and "Low", we can match on these. If a feature's data for the column matched the string "High", then we would use the high ValueItem's styles to draw that feature. This can be applied to all kinds of things, such as road classifications, etc.

This can be somewhat slow because we have to match data from the FeatureSource. If performance is key, then instead of using the ValueStyle, we recommend that you create a set custom index for your layer, one index with only "High" elements, one for "Medium" and so on. Then load each as a separate layer. In this way, you would only have one data set, but multiple indexes. This is the fastest way if you are working with Shape Files. If you are working with spatial databases, then we suggest creating a view to segment out each category.

Constructors

ValueStyle()

This is a constructor for the class.

public ValueStyle()

Remarks

If you use this constructor, you need to set the required properties manually.

ValueStyle(string, Collection<ValueItem>)

This is a constructor for this class.

public ValueStyle(string columnName, Collection<ValueItem> valueItems)

Parameters

columnName string

The columnName used to match with the value specified in the items.

valueItems Collection<ValueItem>

The collection of ValueItems. Each item can have its own value to match.

Properties

ColumnName

This property gets and sets the column name used to match with the value specified in the items.

public string ColumnName { get; set; }

Property Value

string

This property gets the column name used to match with the value specified in the items.

Remarks

This is the column we use for matching.

DrawingOrder

public ValueDrawingOrder DrawingOrder { get; set; }

Property Value

ValueDrawingOrder

ValueItems

This property gets the collection of ValueItems. Each item can have its own value to match.

public Collection<ValueItem> ValueItems { get; }

Property Value

Collection<ValueItem>

This property gets the collection of ValueItems.

Remarks

You will want to add ValueItems to this collection. Each item can have its own style and matching string.

Methods

DrawCore(IEnumerable<Feature>, GeoCanvas, Collection<SimpleCandidate>, Collection<SimpleCandidate>)

This method draws the features on the view you provided.

protected override void DrawCore(IEnumerable<Feature> features, GeoCanvas canvas, Collection<SimpleCandidate> labelsInThisLayer, Collection<SimpleCandidate> labelsInAllLayers)

Parameters

features IEnumerable<Feature>

This parameter represents the features you want to draw on the view.

canvas GeoCanvas

This parameter represents the view you want to draw the features on.

labelsInThisLayer Collection<SimpleCandidate>

The labels will be drawn in the current layer only.

labelsInAllLayers Collection<SimpleCandidate>

The labels will be drawn in all layers.

Remarks

This overridden method is called from the concrete public method Draw. In this method, we take the features you passed in and draw them on the view you provided. Each style (based on its properties) may draw each feature differently.


When overriding this method, consider each feature and its column data values. You can use the full power of the GeoCanvas to do the drawing. If you need column data for a feature, be sure to override the GetRequiredColumnNamesCore and add the columns you need to the collection. In many of the styles, we add properties to allow the user to specify which field they need; then, in the GetRequiredColumnNamesCore, we read that property and add it to the collection.

Exceptions

InvalidOperationException

In the event you attempt to call this method when the GeoCanvas's IsDrawing mode is false, it will throw an InvalidOperationException.

ArgumentNullException

If you pass a null as the view, we will throw an ArgumentNullException.

ArgumentNullException

If you pass a null as the features, we will throw an ArgumentNullException.

ArgumentNullException

If columnName is null, we will throw an ArgumentNullException.

DrawSampleCore(GeoCanvas, DrawingRectangleF)

protected override void DrawSampleCore(GeoCanvas canvas, DrawingRectangleF drawingExtent)

Parameters

canvas GeoCanvas
drawingExtent DrawingRectangleF

GetRequiredColumnNamesCore()

This method returns the column data for each feature that is required for the style to properly draw.

protected override Collection<string> GetRequiredColumnNamesCore()

Returns

Collection<string>

This method returns a collection of the column names that it needs.

Remarks

This abstract method is called from the concrete public method GetRequiredFieldNames. In this method, we return the column names that are required for the style to draw the feature properly. For example, if you have a style that colors areas blue when a certain column value is over 100, then you need to be sure you include that column name. This will ensure that the column data is returned to you in the feature when it is ready to draw.

In many of the styles, we add properties to allow the user to specify which field they need; then, in the GetRequiredColumnNamesCore, we read that property and add it to the collection.

Exceptions

ArgumentNullException

If columnName is null, we will throw an ArgumentNullException.