Class DotDensityStyle
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
-
DotDensityStyle
- Inherited Members
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.
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, int, GeoColor)
This is the constructor for the class.
public DotDensityStyle(string columnName, double pointToValueRatio, int pointSize, GeoColor pointColor)
Parameters
columnName
stringThis parameter is the name of the column in the FeatureSource that will supply the data.
pointToValueRatio
doubleThis parameter controls the point-to-value ratio for the random dots.
pointSize
intThis parameter controls the size of each randomly placed point in the area.
pointColor
GeoColorThis 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
stringThis parameter is the name of the column in the FeatureSource that will supply the data.
pointToValueRatio
doubleThis parameter controls the point-to-value ratio for the random dots.
customPointStyle
PointStyleThis 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.
Properties
CachedPoints
The cachedPoints for the dotdensity style to speed it up.
public Dictionary<string, Collection<Vertex>> CachedPoints { get; }
Property Value
ColumnName
This property gets and sets the column name that will be used for the density value.
public string ColumnName { get; set; }
Property Value
- string
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.
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.
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
PointSize
This property gets and sets the point size of the density points.
public int PointSize { get; set; }
Property Value
- int
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.
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.
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.
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 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.