Class ClassBreakStyle
This class represents a style based on class break values.
public class ClassBreakStyle : Style
- Inheritance
-
ClassBreakStyle
- Inherited Members
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.
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
stringThis 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
stringThis parameter is the column name of the column that will be used for the break values.
breakValueInclusion
BreakValueInclusionThis 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
stringThis parameter is the column name of the column that will be used for the break values.
breakValueInclusion
BreakValueInclusionThis 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.
Properties
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.
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.
DrawingOrder
public ClassBreakDrawingOrder DrawingOrder { get; set; }
Property Value
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
GeoCanvasThis 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 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.
DrawSampleCore(GeoCanvas, DrawingRectangleF)
protected override void DrawSampleCore(GeoCanvas canvas, DrawingRectangleF drawingExtent)
Parameters
canvas
GeoCanvasdrawingExtent
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.
OnGottenFeatureValue(GottenFeatureValueClassBreakStyleEventArgs)
protected virtual void OnGottenFeatureValue(GottenFeatureValueClassBreakStyleEventArgs e)
Parameters
Events
GottenFeatureValue
public event EventHandler<GottenFeatureValueClassBreakStyleEventArgs> GottenFeatureValue