Labels categories

Functions

LabelCategory Labels.AddCategory (string Name)
 Adds a visualization category for labels. More...
 
void Labels.ApplyCategories ()
 Maps labels to the visualization categories. More...
 
void Labels.ApplyColorScheme (tkColorSchemeType Type, ColorScheme ColorScheme)
 Applies color scheme to the visualization categories. More...
 
void Labels.ApplyColorScheme2 (tkColorSchemeType Type, ColorScheme ColorScheme, tkLabelElements Element)
 Applies color scheme to the visualization categories. More...
 
void Labels.ApplyColorScheme3 (tkColorSchemeType Type, ColorScheme ColorScheme, tkLabelElements Element, int CategoryStartIndex, int CategoryEndIndex)
 Applies color scheme to the visualization categories. More...
 
void Labels.ClearCategories ()
 Removes all the visualization categories. More...
 
bool Labels.GenerateCategories (int FieldIndex, tkClassificationType ClassificationType, int numClasses)
 Generates visualization categories for labels based on certain field from the attribute table of the parent shapefile. More...
 
LabelCategory Labels.get_Category (int Index)
 Gets the visualization category (LabelCategory) with the specified index. More...
 
LabelCategory Labels.InsertCategory (int Index, string Name)
 Inserts a new visualization category at the given position of the list. More...
 
bool Labels.MoveCategoryDown (int Index)
 Moves a specified label category down in the list. More...
 
bool Labels.MoveCategoryUp (int Index)
 Moves a specified label category up in the list. More...
 
bool Labels.RemoveCategory (int Index)
 Removes a visualization category with specified index. More...
 
void Labels.set_Category (int Index, LabelCategory pVal)
 Sets the visualization category at the given position in the list. More...
 

Properties

int Labels.NumCategories [get]
 Number of visualization categories associated with this instance of class. More...
 

Detailed Description

Here is a list of properties and methods to work with visualization categories for labels represented by LabelCategory class. This module is a part of the documentation of Labels class.

dot_inline_dotgraph_11.png

Graph description

A visualization category is designed to provide a common visualization options for a group of labels with similar attributes.

Visualization categories can be added in several ways.

1. Automatic generation. This example demonstrates how to create 6 categories with frame color ranging from orange to blue.

Shapefile sf = some_shapefile;
sf.Labels.FrameVisible = true; // this option will be used inherited by newly generated categories
if (sf.Labels.GenerateCategories(0, tkClassificationType.ctNaturalBreaks, 6)) // 0 - index of field
{
ColorScheme scheme = new ColorScheme();
scheme.SetColors2(tkMapColor.Orange, tkMapColor.Blue);
sf.Labels.ApplyColorScheme2(tkColorSchemeType.ctSchemeGraduated, scheme, tkLabelElements.leFrameBackground);
}
tkClassificationType
The type of the classification available for ShapefileCategories.Generate and Labels....
Definition: Enumerations.cs:227
tkLabelElements
Lists the parts of the label. Can be used to specify particular parts to apply color scheme to.
Definition: Enumerations.cs:803
tkMapColor
A list of named constants for some of the well-known colors.
Definition: Enumerations.cs:951
tkColorSchemeType
The type of color scheme. Determines how colors will be extracted from the color scheme (see Shapefil...
Definition: Enumerations.cs:305
Provides methods for random colour generation and colour interpolation based on the specific set of c...
Definition: ColorScheme.cs:65
void SetColors2(tkMapColor Color1, tkMapColor Color2)
Clears all the existing breaks and creates 2 breaks with the specified colours.
Definition: ColorScheme.cs:156
Provides a functionality for accessing and editing ESRI shapefiles.
Definition: Shapefile.cs:72
Labels Labels
Gets or sets the instance of the Labels class associated with the shapefile.
Definition: Shapefile.cs:184
bool GenerateCategories(int FieldIndex, tkClassificationType ClassificationType, int numClasses)
Generates visualization categories for labels based on certain field from the attribute table of the ...
Definition: Labels.cs:323
void ApplyColorScheme2(tkColorSchemeType Type, ColorScheme ColorScheme, tkLabelElements Element)
Applies color scheme to the visualization categories.
Definition: Labels.cs:385
bool FrameVisible
Gets or sets the values which indicates whether label's frame is visible.
Definition: Labels.cs:1357

2. Manual creation. In this scenario particular labels can be attributed to the category by:

In this example a new category with yellow background will be created and objects with area greater than 100 units will be mapped to it.

LabelCategory ct2 = sf.Labels.AddCategory("yellow");
if (ct2 != null)
{
ct2.FrameBackColor = Convert.ToUInt32(tkMapColor.Yellow);
ct2.Expression = "[Area] > 100";
sf.Labels.ApplyCategories(); // this will set Label.Category property
}
Represents visualization options for labels displayed on the map.
Definition: LabelCategory.cs:115
string Expression
Gets or sets expression which defines shapes that belong to this category.
Definition: LabelCategory.cs:148
uint FrameBackColor
Gets or sets the back color of the frame.
Definition: LabelCategory.cs:278
void ApplyCategories()
Maps labels to the visualization categories.
Definition: Labels.cs:300
LabelCategory AddCategory(string Name)
Adds a visualization category for labels.
Definition: Labels.cs:290

This time a category with gray background will be added and then all the labels with even index will be attributed to it.

if (ct != null)
{
ct.FrameBackColor = Convert.ToUInt32(tkMapColor.Gray);
int index = sf.Labels.NumCategories - 1; // it was added as the last one
for (int i = 0; i < sf.Labels.Count; i = i + 2)
{
sf.Labels.get_Label(i, 0).Category = index; // 0 is the index of part
}
}
int Category
The index of visualization category the label belongs to.
Definition: LabelClass.cs:73
int NumCategories
Number of visualization categories associated with this instance of class.
Definition: Labels.cs:364
Label get_Label(int Index, int Part)
Gets label with the specified index.
Definition: Labels.cs:574
int Count
Gets the number of labels.
Definition: Labels.cs:476

Don't forget to redraw the map in the end (AxMap.Redraw).

Function Documentation

◆ AddCategory()

LabelCategory Labels.AddCategory ( string  Name)

Adds a visualization category for labels.

Use LabelCategory.Expression or Label.Category to map specific labels to the newly created category.

Parameters
NameThe name of the new category
Returns
The reference to the new category.
Examples
ImageLabels.cs, and LabelSelection.cs.

◆ ApplyCategories()

void Labels.ApplyCategories ( )

Maps labels to the visualization categories.

LabelCategory.Expression property is analysed. Afterwards Label.Category property is changed for all labels whose attributes comply with the expression.

◆ ApplyColorScheme()

void Labels.ApplyColorScheme ( tkColorSchemeType  Type,
ColorScheme  ColorScheme 
)

Applies color scheme to the visualization categories.

Parameters
TypeThe method of interpolation.
ColorSchemeColor scheme to take colors from.

◆ ApplyColorScheme2()

void Labels.ApplyColorScheme2 ( tkColorSchemeType  Type,
ColorScheme  ColorScheme,
tkLabelElements  Element 
)

Applies color scheme to the visualization categories.

Allows to choose the part of label to apply colors to.

Parameters
TypeThe method of interpolation.
ColorSchemeColor scheme object to borrow colors from.
ElementThe element of the label to apply colors to. Labels.ApplyColorScheme is shortcut for using leDefault option.

◆ ApplyColorScheme3()

void Labels.ApplyColorScheme3 ( tkColorSchemeType  Type,
ColorScheme  ColorScheme,
tkLabelElements  Element,
int  CategoryStartIndex,
int  CategoryEndIndex 
)

Applies color scheme to the visualization categories.

Parameters
TypeThe method of interpolation.
ColorSchemeColor scheme object to borrow colors from.
ElementThe element of the label to apply colors to. Labels.ApplyColorScheme is shortcut for using leDefault option.
CategoryStartIndexThe index of the first visualization category to apply colors to.
CategoryEndIndexThe index of the last visualization category to apply colors to.

◆ ClearCategories()

void Labels.ClearCategories ( )

Removes all the visualization categories.

◆ GenerateCategories()

bool Labels.GenerateCategories ( int  FieldIndex,
tkClassificationType  ClassificationType,
int  numClasses 
)

Generates visualization categories for labels based on certain field from the attribute table of the parent shapefile.

Use Labels.ApplyCategories to map particular labels to the generated categories based on the LabelCategory.Expression property.

Parameters
FieldIndexThe index of field from the attribute table.
ClassificationTypeThe type of classification.
numClassesNumber of categories to be generated. It will be ignored for ctUniqueValues.
Returns
True on successful generation and false otherwise.

◆ get_Category()

LabelCategory Labels.get_Category ( int  Index)

Gets the visualization category (LabelCategory) with the specified index.

Parameters
IndexThe index of the category to get.
Returns
The reference to the category or null in case of the incorrect index.

◆ InsertCategory()

LabelCategory Labels.InsertCategory ( int  Index,
string  Name 
)

Inserts a new visualization category at the given position of the list.

Parameters
IndexThe index to insert the new category at. Should be greater or equal to 0 and less then Labels.numCategories.
NameThe name of the new category.
Returns
The reference to the newly created category.

◆ MoveCategoryDown()

bool Labels.MoveCategoryDown ( int  Index)

Moves a specified label category down in the list.

Parameters
IndexThe index of the category to move.
Returns
True on successful operation and false otherwise.

◆ MoveCategoryUp()

bool Labels.MoveCategoryUp ( int  Index)

Moves a specified label category up in the list.

Parameters
IndexThe index of the category to move.
Returns
True on successful operation and false otherwise.

◆ RemoveCategory()

bool Labels.RemoveCategory ( int  Index)

Removes a visualization category with specified index.

Parameters
IndexThe index of category to be removed.
Returns
True on successful removal and false otherwise.

◆ set_Category()

void Labels.set_Category ( int  Index,
LabelCategory  pVal 
)

Sets the visualization category at the given position in the list.

In fact the method replaces the category at the given index with the new one.

Parameters
IndexThe index to set the category at. It should be less then Labels.NumCategories.
pValThe reference to the category to set.

Properties

◆ NumCategories

int Labels.NumCategories
get

Number of visualization categories associated with this instance of class.