Skip to content

ClassBreakStyle

Namespace: ThinkGeo.Core

This class represents a style based on class break values.

public class ClassBreakStyle : Style

Inheritance ObjectStyleClassBreakStyle

Remarks:

The ClassBreakStyle allows you to change the way features are drawn based on their data values. It is often useful for you to display features differently based on ranges of numeric values. For example, you may have a states ShapeFile that has the populations of each state as part of its data. You may then want to color states differently based on their population. The ClassBreakStyle allows you to do this.

How class breaks work:

You add a number of ClassBreak classes to the ClassBreak collection. The numeric values of the breaks are important and you must place the breaks in numerical order. For example, break 0 must be added before break 100. In each ClassBreak, you specify the style you want to represent that break. Additionally, in the ColumnName property, you specify the name of the column where we will find the data used to compare the breaks. The column name must point to a column that is numeric.

When we proceed to draw the style, we look through the ClassBreaks and select the ClassBreak that is where the features column data is greater than and closest to the break value.

Example:

Feature Value = 42

ClassBreak1.Value = 0
ClassBreak2.Value = 20
ClassBreak3.Value = 40
ClassBreak4.Value = 60

In this case, the break closest to the feature value without exceeding it is ClassBreak3(40). If the feature value had been less than zero, nothing would have been drawn. If the feature value were 1000, then ClassBreak4 would draw.

If you wanted to represent a value that is less then zero, you could do that as shown in the sample below.

Feature Value = -1

ClassBreak1.Value = Double.Min
ClassBreak2.Value = 0
ClassBreak3.Value = 20
ClassBreak4.Value = 40

In this example, the first class break would be used.

Properties

ColumnName

This property gets and sets the column name in the FeatureSource where the data will be found for each feature.

public string ColumnName { get; set; }

Property Value

String

        This property gets the column name in the FeatureSource where the data will be found
        for each feature.
        Please see the ClassBreakStyle class remarks for a full description of how the
        ClassBreakStyle works.

Remarks:

You use this property to set the name of the column where the numeric data is stored for your features.

BreakValueInclusion

This property gets and sets the value of if the break values are included in the break calculation.

public BreakValueInclusion BreakValueInclusion { get; set; }

Property Value

BreakValueInclusion

        This property gets the value of if the break values are included in the break
        calculation.

Remarks:

Example: If you have a class break value set to 100 and the break value is included, then 100 is included for this break. If you set the value to excluded, then 100 would match with the break below 100 instead.

Please see the ClassBreakStyle class remarks for a full description of how the ClassBreakStyle works.

ClassBreaks

This property gets the collection of class breaks.

public Collection<ClassBreak> ClassBreaks { get; }

Property Value

Collection<ClassBreak>
This property gets the collection of class breaks.

Remarks:

The class breaks determine which style to use, based on the break values.

Please see the ClassBreakStyle class remarks for a full description of how the ClassBreakStyle works.

DrawingOrder

public ClassBreakDrawingOrder DrawingOrder { get; set; }

Property Value

ClassBreakDrawingOrder

Name

This property gets and set the name of the style.

public string Name { get; set; }

Property Value

String
This property gets the name of the style.

Remarks:

This name is not used by the system; it is only for the developer. However, it can be used if you generate your own legend.

IsActive

This property gets and sets the active status of the style.

public bool IsActive { get; set; }

Property Value

Boolean
This property gets the active status of the style.

Remarks:

If the style is not active then it will not draw.

RequiredColumnNames

This property gets the collection of fields that are required for the style.

public Collection<string> RequiredColumnNames { get; }

Property Value

Collection<String>

        This property gets the collection of fields that are required for the
        style.

Remarks:

This property gets the collection of fields that are required for the style. These are in addition to any other columns you specify in styles that inherit from this one. For example, if you have use a ValueStyle and it requires a column name for the value comparison, then that column does not need to be in this collection. You only use the RequiredColumnNames for columns you need beyond those required by specific inherited styles.

Filters

public Collection<string> Filters { get; }

Property Value

Collection<String>

Constructors

ClassBreakStyle()

This is the constructor for this class.

public ClassBreakStyle()

ClassBreakStyle(String)

This is the constructor for this class.

public ClassBreakStyle(string columnName)

Parameters

columnName String

        This parameter is the column name of the column that will be used for the break
        values.

ClassBreakStyle(String, BreakValueInclusion)

This is the constructor for this class.

public ClassBreakStyle(string columnName, BreakValueInclusion breakValueInclusion)

Parameters

columnName String

        This parameter is the column name of the column that will be used for the break
        values.

breakValueInclusion BreakValueInclusion

        This parameter lets you specify whether the break value is included in the class break
        calculation.

ClassBreakStyle(String, BreakValueInclusion, Collection<ClassBreak>)

This is the constructor for this class.

public ClassBreakStyle(string columnName, BreakValueInclusion breakValueInclusion, Collection<ClassBreak> classBreaks)

Parameters

columnName String

        This parameter is the column name of the column that will be used for the break
        values.

breakValueInclusion BreakValueInclusion

        This parameter lets you specify whether the break value is included in the class break
        calculation.

classBreaks Collection<ClassBreak>
The parameter represents the class break that will determine which style to be used on the break values. Please see the ClassBreakStyle class remarks for a full description of how the ClassBreakStyle works.

Methods

OnGottenFeatureValue(GottenFeatureValueClassBreakStyleEventArgs)

protected void OnGottenFeatureValue(GottenFeatureValueClassBreakStyleEventArgs e)

Parameters

e GottenFeatureValueClassBreakStyleEventArgs

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

This method draws the features on the view you provided.

protected 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.

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 OutlinePen is null, we will throw an ArgumentNullException.

ArgumentNullException
If FillSolidBrush is null, we will throw an ArgumentNullException.

ArgumentException
If the ClassBreaks are invalid, we will throw an ArgumentException.

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.

DrawSampleCore(GeoCanvas, DrawingRectangleF)

protected 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 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.

Events

GottenFeatureValue

public event EventHandler<GottenFeatureValueClassBreakStyleEventArgs> GottenFeatureValue;