DotDensityStyle¶
Namespace: ThinkGeo.Core
This class allows you to display information by drawing points on an area based on a value from the features data.
public class DotDensityStyle : Style
Inheritance Object → Style → DotDensityStyle
Remarks:
This class allows you to display information by drawing points on an area based on a value from the features data. The higher the value is in the data, the greater the number of points that are drawn. The points themselves are distributed randomly inside of the polygon.
You would use this style if you have areas (such as counties) and numeric data (such as the number of births in those counties). In this example, you could plot a point in each county to represent each birth. A county will show a higher density of points if it is smaller or if there are more births there.
When you have data values that are too large to represent by plotting an individual point for each, or data that is too sparse, you can set the PointToValueRatio. Setting this will control the ratio of points drawn to the value in the data. For example, if you have a value of 100 in the data and you have the ratio set to 1, then you will get 100 points drawn. A ratio of higher than 1 will draw more points than the data value; in our example, a ratio of 2 will draw 200 points. Conversely, a ratio of less than 1 will draw fewer points than the data value; in our example, a ratio of 0.5 would draw 50 points.
Properties¶
CustomPointStyle¶
This property gets and sets a custom point style.
public PointStyle CustomPointStyle { get; set; }
Property Value¶
PointStyle
This property gets a custom point style.
Remarks:
You will use this property when you want to specify a point style that is not just a simple colored dot. You may want to use a bitmap or take advantage of a custom fill brush.
ColumnName¶
This property gets and sets the column name that will be used for the density value.
public string ColumnName { get; set; }
Property Value¶
This property gets the column name that will be used for the density
value.
Remarks:
This value should represent a value in the FeatureSource that is numeric. It will be used in conjunction with the PointToValueRatio property to deterime how many points are drawn in the area.
PointSize¶
This property gets and sets the point size of the density points.
public int PointSize { get; set; }
Property Value¶
Int32
This property gets the point size of the density points.
Remarks:
If you have sparse data, one way to better fill the area is to use larger point sizes. The opposite is also true; if you have lots of data, smaller point sizes look better.
PointColor¶
This property gets and sets the color of the density points.
public GeoColor PointColor { get; set; }
Property Value¶
GeoColor
This property gets the color of the density points.
Remarks:
None
PointToValueRatio¶
This property gets and sets the ratio of points to value in the data.
public double PointToValueRatio { get; set; }
Property Value¶
Double
This property gets the ratio of points to value in the data.
Remarks:
This property controls the ratio of points on the screen to numeric value in the data. For example, if you have a value of 100 in the data and you have the ratio set to 1, then you will get 100 points drawn. A ratio of higher than 1 will draw more points than the data value; in our example, a ratio of 2 will draw 200 points. Conversely, a ratio of less than 1 will draw fewer points than the data value; in our example, a ratio of 0.5 would draw 50 points.
CachedPoints¶
The cachedPoints for the dotdensity style to speed it up.
public Dictionary<string, Collection<Vertex>> CachedPoints { get; }
Property Value¶
Dictionary<String, Collection<Vertex>>
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¶
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¶
Constructors¶
DotDensityStyle()¶
This is the constructor for the class.
public DotDensityStyle()
Remarks:
This is the default constructor. If you use this constructor, you should set the values by the properties.
DotDensityStyle(String, Double, Int32, GeoColor)¶
This is the constructor for the class.
public DotDensityStyle(string columnName, double pointToValueRatio, int pointSize, GeoColor pointColor)
Parameters¶
columnName
String
This parameter is the name of the column in the FeatureSource that will supply
the data.
pointToValueRatio
Double
This parameter controls the point-to-value ratio for the random dots.
pointSize
Int32
This parameter controls the size of each randomly placed point in the
area.
pointColor
GeoColor
This parameter controls the color of each randomly placed point in the
area.
Remarks:
This constructor allows you to set everything you need to a standard scenario.
DotDensityStyle(String, Double, PointStyle)¶
This is the constructor for the class.
public DotDensityStyle(string columnName, double pointToValueRatio, PointStyle customPointStyle)
Parameters¶
columnName
String
This parameter is the name of the column in the FeatureSource that will supply
the data.
pointToValueRatio
Double
This parameter controls the point-to-value ratio for the random dots.
customPointStyle
PointStyle
This parameter represents a custom point you want to draw.
Remarks:
If you require a custom point symbol, this constructor allows you to set everything you need. Custom points can include bitmaps and points that require custom fill brushes.
Methods¶
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 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.
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.
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.