Class ThemeLabel
- java.lang.Object
-
- com.supermap.mapping.Theme
-
- com.supermap.mapping.ThemeLabel
-
public class ThemeLabel extends Theme
Class label map.The label of the label map can be the numbers, letters, characters, such as the geographical name of river, lake, ocean, mountain, city, village, the DEM value, the isoline number, the velocity of flow, mileage of road, mileage of navigation route, etc.
You can set the style and location of the label in the label map. You can set the uniform style and use the range method to set the style of each item for displaying the label.
The legend description often occurs on the map, for example, name of map, scale. Which are the elements of drawing map and not belong to the label map.
- Example:
- The example below demonstrates how to link to an external table and create a label map with the linked data. Suppose we have already opened a Workspace object and we are going to label the name for each country and control the thematic map style according to the population.
public void themeLabelExample(DatasetVector datasetVector) { // Creates label thematic map ThemeLabel themeLabelMap = new ThemeLabel(); themeLabelMap.setLabelExpression("Country"); themeLabelMap.setRangeExpression("Pop_1994"); // Sets the range style for label thematic map. // Sets the labels of countries that population is more than 100 million ThemeLabelItem themeLabelItem1 = new ThemeLabelItem(); themeLabelItem1.setCaption(">100000000"); themeLabelItem1.setEnd(120000000); themeLabelItem1.setStart(100000000); themeLabelItem1.setVisible(true); TextStyle textStyle1 = new TextStyle(); textStyle1.setForeColor(java.awt.Color.getHSBColor(255, 190, 189)); textStyle1.setFontName("宋体"); themeLabelItem1.setStyle(textStyle1); // Sets the labels of countries that population is more than 10 million ThemeLabelItem themeLabelItem2 = new ThemeLabelItem(); themeLabelItem2.setCaption(">10000000"); themeLabelItem2.setEnd(100000000); themeLabelItem2.setStart(10000000); themeLabelItem2.setVisible(true); TextStyle textStyle2 = new TextStyle(); textStyle2.setForeColor(java.awt.Color.getHSBColor(255, 235, 189)); textStyle2.setFontName("宋体"); themeLabelItem2.setStyle(textStyle2); // Sets the labels of countries that population is more than 1 million ThemeLabelItem themeLabelItem3 = new ThemeLabelItem(); themeLabelItem3.setCaption(">1000000"); themeLabelItem3.setEnd(10000000); themeLabelItem3.setStart(1000000); themeLabelItem3.setVisible(true); TextStyle textStyle3 = new TextStyle(); textStyle3.setForeColor(java.awt.Color.getHSBColor(214, 255, 115)); textStyle3.setFontName("宋体"); themeLabelItem3.setStyle(textStyle3); // Sets the labels of countries that population is less than 1 million ThemeLabelItem themeLabelItem4 = new ThemeLabelItem(); themeLabelItem4.setCaption("<1000000"); themeLabelItem4.setEnd(1000000); themeLabelItem4.setStart(0); themeLabelItem4.setVisible(true); TextStyle textStyle4 = new TextStyle(); textStyle4.setForeColor(java.awt.Color.getHSBColor(214, 255, 189)); textStyle4.setFontName("宋体"); themeLabelItem4.setStyle(textStyle4); // Adds the items of label thematic map into the object of the label thematic map themeLabelMap.addToHead(themeLabelItem1); themeLabelMap.addToHead(themeLabelItem2); themeLabelMap.addToHead(themeLabelItem3); themeLabelMap.addToHead(themeLabelItem4); MapControl mapControl = new MapControl(); mapControl.getMap().setWorkspace(workspace); Layer layerTheme = mapControl.getMap().getLayers().add(datasetVector,themeLabelMap, true); mapControl.getMap().refresh(); }
, The following codes show you how to make a label map.ThemeLabel tl = new ThemeLabel(); tl.setLabelExpression("SmID"); TextStyle ts = new TextStyle(); ts.setFontName(mActivity.getResources().getString(R.string.font)); ts.setAlignment(TextAlignment.MIDDLECENTER); ts.setFontWidth(1.5); ts.setFontHeight(4.0); tl.setUniformStyle(ts); Dataset dataset = workspace.getDatasources().get(0).getDatasets().get(0); if (dataset != null) { m_UnifiedMapLayer = mapControl.getMap().getLayers().add(dataset,tl, true); }
-
-
Constructor Summary
Constructors Constructor and Description ThemeLabel()
The default constructor for constructing a new object.ThemeLabel(ThemeLabel themeLabel)
Copy constructor, initializes a new instance of the class which is identical with the specified ImportSettingGML object.
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method and Description boolean
addToHead(ThemeLabelItem item)
Adds an ThemeLabelItem object to the head of the range list.boolean
addToHead(ThemeLabelItem item, boolean normalize)
Adds an ThemeLabelItem object to the head of the range list.boolean
addToTail(ThemeLabelItem item)
Adds a ThemeLabelItem object to the tail of the range list.boolean
addToTail(ThemeLabelItem item, boolean normalize)
Adds a ThemeLabelItem object to the tail of the range list.void
clear()
Clears the ThemeLabelItem objects in label map.void
dispose()
Disposes the resources occupied by the object.AlongLineDirection
getAlongLineDirection()
Returns the along line direction of the label.double
getAlongLineSpaceRatio()
Returns the space ratio of the alongline text.LabelBackShape
getBackShape()
Returns the label background shape for the label map.GeoStyle
getBackStyle()
Returns the label background style for the label map.int
getCount()
Returns the count of the ranges for the label map.double
getCustomInterval()
Gets the custom range interval.ThemeLabelItem
getItem(int index)
Returns the label map item with the specified index in the label map.java.lang.String
getLabelExpression()
Returns the label field expression.double
getLabelRepeatInterval()
Returns the interval of the repeated labels along the line.GeoStyle
getLeaderLineStyle()
Returns the style of the leader line between the label and the object.int
getMaxLabelLength()
Returns the maximum label length displayed in each line.int
getMaxTextHeight()
Returns the maximum text height in the label.int
getMaxTextWidth()
Returns the maximum text width in the label.int
getMinTextHeight()
Returns the minimum text height in the label.int
getMinTextWidth()
Returns the minimum text width in the label.int
getNumericPrecision()
Returns the accuracy of numbers in labels.java.lang.String
getOffsetX()
Returns the false easting between the label text and the points in features in the label map.java.lang.String
getOffsetY()
Returns the vertical offset between the label text and the points in features in the label map.OverLengthLabelMode
getOverLengthMode()
Returns the overlength handling mode.ThemeLabel
getParent()
Returns the thematic map to which the current label map belongs.java.lang.String
getRangeExpression()
Returns the field expression for ranging.RangeMode
getRangeMode()
Returns the current range mode.Size2D
getTextExtentInflation()
Returns the extent inflation of the text in the label in the positive direction in X and Y axes.MixedTextStyle
getUniformMixedStyle()
Returns the uniform composite text style for the label map.TextStyle
getUniformStyle()
Returns the uniform text style.int
indexOf(double value)
Returns the index number of the themeLabel object in the themeLabel list with the specified value of the field.boolean
isAllDirectionsOverlappedAvoided()
Returns whether to avoid overlap at all directions.boolean
isAlongLine()
Returns whether to display labels along line, with true representing to label along line and false representing not to label along line.boolean
isAngleFixed()
Whether to fix the angle of text when the label is displaying along the line.boolean
isFlowEnabled()
Returns whether to allow labels for flow display.boolean
isLeaderLineDisplayed()
Returns whether to show the leader line that connects label and the feature.boolean
isOffsetFixed()
Returns whether the offset of the label is fixed when the map zooms in or zooms out.boolean
isOverlapAvoided()
Returns whether to prevent the label from overlapping with each other automatically.boolean
isRepeatedLabelAvoided()
Returns whether to avoid repeated labels.boolean
isRepeatIntervalFixed()
Returns whether the interval of the repeated label along the line is fixed.boolean
isSmallGeometryLabeled()
Returns whether to display a label if the label is longer than the object it labels.static ThemeLabel
makeDefault(DatasetVector dataset, java.lang.String rangeExpression, RangeMode rangeMode, double rangeParameter)
Makes the default label map with the given vector dataset, range expression, range mode and range parameter.static ThemeLabel
makeDefault(DatasetVector dataset, java.lang.String rangeExpression, RangeMode rangeMode, double rangeParameter, ColorGradientType colorGradientType)
Makes the default label map with the given dataset, rangeExpression, rangeMode, rangeParameter and colorGradientType.static ThemeLabel
makeDefault(DatasetVector dataset, java.lang.String rangeExpression, RangeMode rangeMode, double rangeParameter, ColorGradientType colorGradientType, JoinItems joinItems)
Makes the default label map with the given dataset, rangeExpression, rangeMode, rangeParameter, colorGradientType and joinItems.boolean
merge(int index, int count, TextStyle style, java.lang.String caption)
Merges the specified counts of Themelabel items from the specified index and assign the style and caption to the new item.void
reverseStyle()
Displays the ThemeLabel object with the reverse style in the label map.void
setAllDirectionsOverlappedAvoided(boolean value)
Sets whether to allow avoiding overlap from all directions.void
setAlongLine(boolean value)
Sets whether to display label along line, with true representing to label along line and false representing not to label along line.void
setAlongLineDirection(AlongLineDirection value)
Sets the along line direction of the label.void
setAlongLineSpaceRatio(double value)
Sets the space ratio of the alongline text.void
setAngleFixed(boolean value)
Whether to fix the angle of text when the label is displaying along the line.void
setBackShape(LabelBackShape value)
Sets the label background shape for the label map.void
setBackStyle(GeoStyle style)
Sets the label background style for the label map.void
setFlowEnabled(boolean value)
Sets whether to allow labels for flow display.void
setLabelExpression(java.lang.String value)
Sets label field expression.void
setLabelRepeatInterval(double value)
Sets the interval of the repeated labels along the line.void
setLeaderLineDisplayed(boolean value)
Sets whether to show the leader line that connects label and the labeled feature.void
setLeaderLineStyle(GeoStyle style)
Sets the style of the leader line between the label and the object.void
setMaxLabelLength(int value)
Sets the maximum length of the label.void
setMaxTextHeight(int value)
Sets the maximum text height in the label.void
setMaxTextWidth(int value)
Sets the maximum text width in the label.void
setMinTextHeight(int value)
Sets the minimum text height in the label.void
setMinTextWidth(int value)
Sets the minimum text width in the label.void
setNumericPrecision(int value)
Sets the accuracy of numbers in labels.void
setOffsetFixed(boolean value)
Sets whether the offset of the label is fixed when the map zooms in or zooms out.void
setOffsetX(java.lang.String value)
Sets the horizontal offset between the label text and the points in features in the label map.void
setOffsetY(java.lang.String value)
Sets the vertical offset between the label text and the points in features in the label map.void
setOverlapAvoided(boolean value)
Whether to prevent the label from overlapping with each other automatically.void
setOverLengthMode(OverLengthLabelMode value)
Sets the overlength handling mode.void
setRangeExpression(java.lang.String value)
Sets the field expression for ranging.void
setRepeatedLabelAvoided(boolean value)
Sets whether to avoid repeat labeling.void
setRepeatIntervalFixed(boolean value)
Sets whether the interval of the repeated label along the line is fixed.void
setSmallGeometryLabeled(boolean value)
Sets whether to display a label if the label is longer than the object it labels.void
setTextExtentInflation(Size2D size2D)
Sets the extent inflation of the text in the label in the positive direction in X and Y axes.void
setUniformMixedStyle(MixedTextStyle value)
Sets the uniform composite text style for the label map.void
setUniformStyle(TextStyle style)
Sets the uniform text style.boolean
split(int index, double splitValue, TextStyle style, java.lang.String caption1, TextStyle style2, java.lang.String caption2)
Splits a label map item with a specified index into items with separate styles and names.java.lang.String
toString()
Outputs the formatted string for the labels thematic map.-
Methods inherited from class com.supermap.mapping.Theme
fromXML, getMemoryData, getType, setMemoryData, toXML
-
-
-
-
Constructor Detail
-
ThemeLabel
public ThemeLabel()
The default constructor for constructing a new object.
-
ThemeLabel
public ThemeLabel(ThemeLabel themeLabel)
Copy constructor, initializes a new instance of the class which is identical with the specified ImportSettingGML object.- Parameters:
themeLabel
- the givenThemeLabel
object.
-
-
Method Detail
-
getItem
public ThemeLabelItem getItem(int index)
Returns the label map item with the specified index in the label map. For detailed information about the label map item, please refer to the class.- Parameters:
index
- The index of the specified label map item.- Returns:
- The label map item with the specified index.
- See Also:
ThemeLabelItem
-
getCount
public int getCount()
Returns the count of the ranges for the label map.- Returns:
- The count of the ranges in the label map.
- Default:
- The default value is 0.
-
getBackStyle
public GeoStyle getBackStyle()
Returns the label background style for the label map.- Returns:
- The label background style in the label map.
- Default:
- The default value is {FillBackColor=Color [A=255, R=255, G=255, B=255],FillForeColor=Color [A=255, R=255, G=255, B=204],FillGradientAngle=0,FillGradientMode=None,FillGradientOffsetRatioX=0,FillGradientOffsetRatioY=0,FillOpaqueRate=100,FillSymbolID=0,LineColor=Color [A=255, R=0, G=0, B=0],LineSymbolID=0,LineWidth=0.1,MarkerAngle=0,MarkerSize={Width=2.4,Height=-1},MarkerSymbolID=0}.
-
setBackStyle
public void setBackStyle(GeoStyle style)
Sets the label background style for the label map. OpenGL does not support label background transparency.- Parameters:
style
- The label background style for the label map.
-
getBackShape
public LabelBackShape getBackShape()
Returns the label background shape for the label map. The background shape of the label can be a rectangle, a rounded rectangle, an ellipse, a diamond, a triangle and a specified symbol. The default value is no background shape. For the details, please refer to .- Returns:
- The label background shape.
- See Also:
LabelBackShape
- Default:
- The default value is
LabelBackShape.NONE
, meaning there is none background.
-
setBackShape
public void setBackShape(LabelBackShape value)
Sets the label background shape for the label map. The background shape of the label can be a rectangle, a rounded rectangle, an ellipse, a diamond, a triangle and a specified symbol. The default value is no background shape. For the details, please refer to .- Parameters:
value
- The label background shape.- See Also:
LabelBackShape
-
getMaxLabelLength
public int getMaxLabelLength()
Returns the maximum label length displayed in each line.If the label length is greater than the maximum length, the label will display with two methods. One way is by wrapping the text. This method will adjust the word space to make each line has similar number of words and the length of each line is less than or equal to the maximum length allowed. The other way is by omitting the part that exceeds the maximum length. The part that exceeds the maximum length will be display with ellipsis.
- Returns:
- The maximum length for each line.
- Default:
- The default value is 256.
-
setMaxLabelLength
public void setMaxLabelLength(int value)
Sets the maximum length of the label. If the label length is more than the maximum length, the label will be display with two method, one is that displaying label with the suspension points, the other is that displaying label with the newline mode.- Parameters:
value
- The maximum for length for each line.
-
getOverLengthMode
public OverLengthLabelMode getOverLengthMode()
Returns the overlength handling mode. You can do nothing, omit the overlong part, or wrap the label.- Returns:
- The overlong label handling mode.
- Default:
- The default value is
OverLengthLabelMode.NONE
, which means that the long labels are not processed.
-
setOverLengthMode
public void setOverLengthMode(OverLengthLabelMode value)
Sets the overlength handling mode. You can do nothing, omit the overlong part, or wrap the label.- Parameters:
value
- The overlong label handling mode.
-
isFlowEnabled
public boolean isFlowEnabled()
Returns whether to allow labels for flow display. The default value is true.Note: Flow display only applies to labels for line and region features.
- Returns:
- Whether to flow display the labels.
- Default:
- The default value is true.
-
setFlowEnabled
public void setFlowEnabled(boolean value)
Sets whether to allow labels for flow display.Note: Flow display only applies to labels for line and region features.
- Parameters:
value
- Whether to allow labels for flow display.
-
isSmallGeometryLabeled
public boolean isSmallGeometryLabeled()
Returns whether to display a label if the label is longer than the object it labels.When the length of label is larger than that of the line or region object, the label texts will overlay with each other to be displayed if choosing to continue the label. In order to display the label clearly and completely, you can use the linefeed method to display the label, provided that the length of each line is smaller than that of the object.
- Returns:
- True or false indicating whether to show the label whose length is greater than that of the labeled object.
- Default:
- The default value is false.
-
setSmallGeometryLabeled
public void setSmallGeometryLabeled(boolean value)
Sets whether to display a label if the label is longer than the object it labels.When the length of label is larger than that of the line or region object, the label texts will overlay with each other to be displayed if choosing to continue the label. In order to display the label clearly and completely, you can use the linefeed method to display the label, provided that the length of each line is smaller than that of the object.
- Parameters:
value
- True or false indicating whether to show the label whose length is greater than that of the labeled object.
-
getAlongLineDirection
public AlongLineDirection getAlongLineDirection()
Returns the along line direction of the label.- Returns:
- The along line direction of the label.
- Default:
- The default value is
AlongLineDirection.LEFT_TOP_TO_RIGHT_BOTTOM
.
-
setAlongLineDirection
public void setAlongLineDirection(AlongLineDirection value)
Sets the along line direction of the label.- Parameters:
value
- The along line direction of the label.
-
isAlongLine
public boolean isAlongLine()
Returns whether to display labels along line, with true representing to label along line and false representing not to label along line.Note: this property applies to the line dataset thematic map.
- Returns:
- Whether to display the text along line.
- Default:
- The default value is true.
-
setAlongLine
public void setAlongLine(boolean value)
Sets whether to display label along line, with true representing to label along line and false representing not to label along line.Note: this property applies to the line dataset thematic map.
- Parameters:
value
- Whether to display the text along line.
-
isAngleFixed
public boolean isAngleFixed()
Whether to fix the angle of text when the label is displaying along the line. False indicates that displaying label along the line in the angle of the line. True indicates that displaying label in fixed angle.- Returns:
- Whether to fix the text angle when displaying the text along line.
- Default:
- The default value is false.
-
setAngleFixed
public void setAngleFixed(boolean value)
Whether to fix the angle of text when the label is displaying along the line. False indicates that displaying label along the line in the angle of the line. True indicates that displaying label in fixed angle.- Parameters:
value
- Whether to fix the text angle when displaying the text along line.
-
isOverlapAvoided
public boolean isOverlapAvoided()
Returns whether to prevent the label from overlapping with each other automatically. This is only available to text data in the label map.Note: The auto avoid overlap functionality can not completely avoid overlap if the overlap is severe.
If two objects employs the auto avoid overlap at the same time, the label with smaller ID will have the priority for being drawn.
- Returns:
- Whether to avoid text overlap automatically.
- Default:
- The default value is true, meaning auto avoid overlapping.
-
setOverlapAvoided
public void setOverlapAvoided(boolean value)
Whether to prevent the label from overlapping with each other automatically. This is only available to text data in the label map.Note: The auto avoid overlap functionality can not completely avoid overlap if the overlap is severe.
If two objects employs the auto avoid overlap at the same time, the label with smaller ID will have the priority for being drawn.
- Parameters:
value
- Whether to avoid text overlap automatically.
-
isRepeatIntervalFixed
public boolean isRepeatIntervalFixed()
Returns whether the interval of the repeated label along the line is fixed. True represents fixed and the interval of the repeated label uses the logical coordinates; false represents not fixed and the interval uses the geographic coordinate.- Returns:
- True or false indicating whether the interval of the repeated label is fixed.
- Default:
- The default value is false.
-
setRepeatIntervalFixed
public void setRepeatIntervalFixed(boolean value)
Sets whether the interval of the repeated label along the line is fixed. True represents fixed and the interval of the repeated label uses the logical coordinates; false represents not fixed and the interval uses the geographic coordinate.- Parameters:
value
- True or false indicating whether the interval of the repeated label is fixed.
-
getLabelRepeatInterval
public double getLabelRepeatInterval()
Returns the interval of the repeated labels along the line. The unit of distance of interval is the map unit.- Returns:
- The interval of repeated labels when labeling along line.
- Default:
- The default value is 0.
-
setLabelRepeatInterval
public void setLabelRepeatInterval(double value)
Sets the interval of the repeated labels along the line. The unit of distance of interval is the map unit.- Parameters:
value
- The interval of repeated labels when labeling along line.
-
getOffsetX
public java.lang.String getOffsetX()
Returns the false easting between the label text and the points in features in the label map.The value of offset is a constant value or the value of the field expression. If the field expression is SmID, where SmID=2, the value of offset is 2.
- Returns:
- The easting offset of label text relative to the points in the component in the label map.
- Default:
- The default is a null string.
-
setOffsetX
public void setOffsetX(java.lang.String value)
Sets the horizontal offset between the label text and the points in features in the label map.The value of offset is a constant value or the value of the field expression. If the field expression is SmID, where SmID=2, the value of offset is 2.
- Parameters:
value
- The horizontal offset of label text relative to the points in the component in the label map.
-
getOffsetY
public java.lang.String getOffsetY()
Returns the vertical offset between the label text and the points in features in the label map. The unit of the offset is map unit.The value of offset is a constant value or the value of the field expression. If the field expression is SmID, where SmID=2, the value of offset is 2.
- Returns:
- The vertical offset of label text relative to the points in the component in the label map.
- Default:
- The default is a null string.
-
setOffsetY
public void setOffsetY(java.lang.String value)
Sets the vertical offset between the label text and the points in features in the label map. The unit of the offset is map unit.The value of offset is a constant value or the value of the field expression. If the field expression is SmID, where SmID=2, the value of offset is 2.
- Parameters:
value
- The vertical offset of label text relative to the points in the component in the label map.
-
getLeaderLineStyle
public GeoStyle getLeaderLineStyle()
Returns the style of the leader line between the label and the object.- Returns:
- The style of the leader line between the label and the object.
- Default:
- ={FillBackColor=Color [A=255, R=255, G=255, B=255],FillForeColor=Color [A=255, R=189, G=235, B=255],FillGradientAngle=0,FillGradientMode=None,FillGradientOffsetRatioX=0,FillGradientOffsetRatioY=0,FillOpaqueRate=100,FillSymbolID=0,LineColor=Color [A=255, R=0, G=0, B=0],LineSymbolID=39,LineWidth=0.1,MarkerAngle=0,MarkerSize={Width=2.4,Height=-1},MarkerSymbolID=0}
-
setLeaderLineStyle
public void setLeaderLineStyle(GeoStyle style)
Sets the style of the leader line between the label and the object.- Parameters:
style
- The style of the leader line between the label and the object.
-
isLeaderLineDisplayed
public boolean isLeaderLineDisplayed()
Returns whether to show the leader line that connects label and the feature.- Returns:
- Whether to show the leader line that connects label and the labeled feature.
- Default:
- The default value is false, namely don't show the leader line that connects label and the labeled feature.
-
setLeaderLineDisplayed
public void setLeaderLineDisplayed(boolean value)
Sets whether to show the leader line that connects label and the labeled feature.- Parameters:
value
- Whether to show the leader line that connects label and the labeled feature.
-
getRangeExpression
public java.lang.String getRangeExpression()
Returns the field expression for ranging. The value of the range expression must be of the numeric type.Users compare the values returned by this method with the break values to determine how to display the labeling text corresponding to
getLabelExpression()
orgetLabelExpression()
.- Returns:
- The rangeExpression class.
- Default:
- The default is a null string.
-
setRangeExpression
public void setRangeExpression(java.lang.String value)
Sets the field expression for ranging. The value of the range expression must be of the numeric type.Users compare the values returned by this method with the break values to determine how to display the labeling text corresponding to
getLabelExpression()
orgetLabelExpression()
.- Parameters:
value
- The range field expression.
-
getLabelExpression
public java.lang.String getLabelExpression()
Returns the label field expression.- Returns:
- Label expression.
- Default:
- The default is a null string.
-
setLabelExpression
public void setLabelExpression(java.lang.String value)
Sets label field expression.- Parameters:
value
- The label field expression.
-
getUniformStyle
public TextStyle getUniformStyle()
Returns the uniform text style. Note: When the number of ThemeLabelItems are greater than 1, will not work.- Returns:
- The uniform text style.
- Default:
- The default value is . {Alignment=MiddleCenter,BackColor=Color [A=255, R=0, G=0, B=0],BackOpaque=False,Bold=False,FontHeight=4,FontWidth=0,ForeColor=Color [A=255, R=0, G=0, B=255],IsSizeFixed=True,Italic=False,Outline=False,Rotation=0,Shadow=False,Strikeout=False,Underline=False,Weight=0}
-
setUniformStyle
public void setUniformStyle(TextStyle style)
Sets the uniform text style. Note: When the number of ThemeLabelItems are greater than 1, will not work.- Parameters:
style
- The specified uniform style of the text.
-
addToHead
public boolean addToHead(ThemeLabelItem item)
Adds an ThemeLabelItem object to the head of the range list.- Parameters:
item
- The item to add.- Returns:
- True if it is added successfully; false otherwise.
-
addToTail
public boolean addToTail(ThemeLabelItem item)
Adds a ThemeLabelItem object to the tail of the range list.- Parameters:
item
- The label map item to be added.- Returns:
- True if it is added successfully; false otherwise.
-
addToHead
public boolean addToHead(ThemeLabelItem item, boolean normalize)
Adds an ThemeLabelItem object to the head of the range list.- Parameters:
item
- The item to add.normalize
- Whether to normalize or not. If true, normalize the value of item if it is invalid; otherwise, throw an exception if the value of item is invalid.- Returns:
- True if it is added successfully; false otherwise.
-
addToTail
public boolean addToTail(ThemeLabelItem item, boolean normalize)
Adds a ThemeLabelItem object to the tail of the range list.- Parameters:
item
- The label map item to be added.normalize
- Whether to normalize or not. If true, normalize the value of item if it is invalid; otherwise, throw an exception if the value of item is invalid.- Returns:
- True if it is added successfully; false otherwise.
-
split
public boolean split(int index, double splitValue, TextStyle style, java.lang.String caption1, TextStyle style2, java.lang.String caption2)
Splits a label map item with a specified index into items with separate styles and names. Note: The splitValue must be in the range for split, that is, greater than the start value and less than the end value of the label map item to split. If the condition is not satisfied, an exception will be thrown.- Parameters:
index
- The index of the specified label map item.splitValue
- The specified value for splitting ranges.style
- The style of one of the two split label map items.caption1
- The name of one of the two split label map items.style2
- The style of one of the two split label map items.caption2
- The name of one of the two split label map items.- Returns:
- True if it is split successfully; false otherwise.
-
merge
public boolean merge(int index, int count, TextStyle style, java.lang.String caption)
Merges the specified counts of Themelabel items from the specified index and assign the style and caption to the new item. Those merged items will be disposed after calling this method.- Parameters:
index
- The index of the specified label map item. This index serves as the start index.count
- The count of label map items to be merged, counting from the specified index.style
- The style of merged ThemeLabelItem.caption
- The caption of the merged ThemeLabelItem..- Returns:
- True if it is merged successfully; false otherwise.
-
clear
public void clear()
Clears the ThemeLabelItem objects in label map. All the ThemeLabelItem objects will be disposed after calling this method.
-
makeDefault
public static ThemeLabel makeDefault(DatasetVector dataset, java.lang.String rangeExpression, RangeMode rangeMode, double rangeParameter)
Makes the default label map with the given vector dataset, range expression, range mode and range parameter.- Parameters:
dataset
- The vector dataset.rangeExpression
- Range expressionrangeMode
- The range modes include the equidistant, square root, standard deviation, log, equal-counting, and the custom distance method.rangeParameter
- The range parameter. If the range mode is the equal interval mode, the square root mode, this parameter is for setting the range number and is required; if the range mode is the standard deviation mode, this parameter does not work; if the range mode is the custom interval mode, this parameter is used to set the custom interval.- Returns:
- Creates a new instance of the
ThemeLabel
class.
-
makeDefault
public static ThemeLabel makeDefault(DatasetVector dataset, java.lang.String rangeExpression, RangeMode rangeMode, double rangeParameter, ColorGradientType colorGradientType)
Makes the default label map with the given dataset, rangeExpression, rangeMode, rangeParameter and colorGradientType.- Parameters:
dataset
- The vector dataset.rangeExpression
- Range expressionrangeMode
- The range modes include the equidistant, square root, standard deviation, log, equal-counting, and the custom distance method.rangeParameter
- The range parameter. If the range mode is the equal interval mode, the square root mode, this parameter is for setting the range number and is required; if the range mode is the standard deviation mode, this parameter does not work; if the range mode is the custom interval mode, this parameter is used to set the custom interval.colorGradientType
- Color gradient type.- Returns:
- Creates a new instance of the
ThemeLabel
class.
-
makeDefault
public static ThemeLabel makeDefault(DatasetVector dataset, java.lang.String rangeExpression, RangeMode rangeMode, double rangeParameter, ColorGradientType colorGradientType, JoinItems joinItems)
Makes the default label map with the given dataset, rangeExpression, rangeMode, rangeParameter, colorGradientType and joinItems.- Parameters:
dataset
- The vector dataset.rangeExpression
- Range expressionrangeMode
- The range modes include the equidistant, square root, standard deviation, log, equal-counting, and the custom distance method.rangeParameter
- The range parameter. If the range mode is the equal interval mode, the square root mode, this parameter is for setting the range number and is required; if the range mode is the standard deviation mode, this parameter does not work; if the range mode is the custom interval mode, this parameter is used to set the custom interval.colorGradientType
- Color gradient type.joinItems
- external items.To add a thematic map to a map as a layer, you need to make the following settings for the thematic map layer through the setDisplayFilter method of the Layer object corresponding to the thematic map layer. The parameter queryParameter for the setDisplayFilter method of the Layer object corresponding to the layer is a QueryParameter object. Here we need to assign the joinItems parameter of the current method to the Layer object corresponding to the thematic map to display the thematic map properly.
- Returns:
- Creates a new instance of the
ThemeLabel
class.
-
indexOf
public int indexOf(double value)
Returns the index number of the themeLabel object in the themeLabel list with the specified value of the field.- Parameters:
value
- The given field values for segmentation.- Returns:
- The index number of the item of the ranges. If the item of the ranges does not exist, returns -1.
-
reverseStyle
public void reverseStyle()
Displays the ThemeLabel object with the reverse style in the label map.
-
getUniformMixedStyle
public MixedTextStyle getUniformMixedStyle()
Returns the uniform composite text style for the label map.The sequence for layer drawing is:
ThemeLabel.getUniformMixedStyle()
,ThemeLabelItem.getStyle()
,ThemeLabel.getUniformStyle()
, that is: whenThemeLabel.getUniformMixedStyle()
,{@link ThemeLabelItem#getStyle() ThemeLabelItem.getStyle()},orThemeLabel.getUniformStyle()
are not consistent, takeThemeLabel.getUniformMixedStyle()
.- Returns:
- The uniform composite text style for the label map.
- Default:
- The default value is null.
-
setUniformMixedStyle
public void setUniformMixedStyle(MixedTextStyle value)
Sets the uniform composite text style for the label map.The sequence for layer drawing is:
ThemeLabel.getUniformMixedStyle()
,ThemeLabelItem.getStyle()
,ThemeLabel.getUniformStyle()
, that is: whenThemeLabel.getUniformMixedStyle()
,{@link ThemeLabelItem#getStyle() ThemeLabelItem.getStyle()},orThemeLabel.getUniformStyle()
are not consistent, takeThemeLabel.getUniformMixedStyle()
.- Parameters:
value
- The uniform composite text style for the label map.
-
getParent
public ThemeLabel getParent()
Returns the thematic map to which the current label map belongs.- Returns:
ThemeLabel
object.- Default:
- The default value is null.
-
getNumericPrecision
public int getNumericPrecision()
Returns the accuracy of numbers in labels. For example, as to the label text 8071.64529347, 8071 will display if the accuracy is 18071.64529347. If the accuracy is 1, 8071.6 will display. If the accuracy is 3, 8071.645 will display.- Returns:
- The numeric precision in the label.
- Default:
- The default value is -1.
-
setNumericPrecision
public void setNumericPrecision(int value)
Sets the accuracy of numbers in labels. For example, as to the label text 8071.64529347, 8071 will display if the accuracy is 18071.64529347. If the accuracy is 1, 8071.6 will display. If the accuracy is 3, 8071.645 will display.- Parameters:
value
- The numeric precision in the label.
-
getMaxTextHeight
public int getMaxTextHeight()
Returns the maximum text height in the label.This method is available only when the size of the label is unfixed. The zooming of the label ended when the size exceeds the maximum text height. The unit of the height is 0.1 millimeter.
- Returns:
- The maximum text height in the label.
- Default:
- The default value is 0.
-
setMaxTextHeight
public void setMaxTextHeight(int value)
Sets the maximum text height in the label.This method is available only when the size of the label is unfixed. The zooming of the label ended when the size exceeds the maximum text height. The unit of the height is 0.1 millimeter.
- Parameters:
value
- The maximum text height in the label.
-
getMinTextHeight
public int getMinTextHeight()
Returns the minimum text height in the label.- Returns:
- The minimum text height in the label.
- Default:
- The default value is 0.
-
setMinTextHeight
public void setMinTextHeight(int value)
Sets the minimum text height in the label.- Parameters:
value
- The minimum text height in the label.
-
getMaxTextWidth
public int getMaxTextWidth()
Returns the maximum text width in the label.- Returns:
- The minimum text height in the label.
- Default:
- The default value is 0.
-
setMaxTextWidth
public void setMaxTextWidth(int value)
Sets the maximum text width in the label.- Parameters:
value
- The maximum text width in the label.
-
getMinTextWidth
public int getMinTextWidth()
Returns the minimum text width in the label.- Returns:
- The minimum text width in the label.
- Default:
- The default value is 0.
-
setMinTextWidth
public void setMinTextWidth(int value)
Sets the minimum text width in the label.- Parameters:
value
- The minimum text width in the label.
-
getTextExtentInflation
public Size2D getTextExtentInflation()
Returns the extent inflation of the text in the label in the positive direction in X and Y axes. You can modify the size of the text in the map by setting the extent inflation, and the value must not be negative.- Returns:
- The extent inflation of the text in the label in the positive direction in X and Y axes.
- Default:
- The default value is {Width=0,Height=0}.
-
setTextExtentInflation
public void setTextExtentInflation(Size2D size2D)
Sets the extent inflation of the text in the label in the positive direction in X and Y axes. You can modify the size of the text in the map by setting the extent inflation, and the value must not be negative.- Parameters:
size2D
- The extent inflation of the text in the label in the positive direction in X and Y axes.
-
isRepeatedLabelAvoided
public boolean isRepeatedLabelAvoided()
Returns whether to avoid repeated labels.Take the Subway Line 4 of Beijing as an example. Suppose it is composed of 4 sub-lines. If not allowing the repeated label existing, the result would be like the left illustration, and if allowing, SuperMap will regard the four sub-lines as one, and the result would be like the right illustration.
- Returns:
- True or false indicating whether to avoid repeat labeling.
- Default:
- The default value is false.
-
setRepeatedLabelAvoided
public void setRepeatedLabelAvoided(boolean value)
Sets whether to avoid repeat labeling.Take the Subway Line 4 of Beijing as an example. Suppose it is composed of 4 sub-lines. If not allowing the repeated label existing, the result would be like the left illustration, and if allowing, SuperMap will regard the four sub-lines as one, and the result would be like the right illustration.
- Parameters:
value
- True or false indicating whether to avoid repeat labeling.
-
isOffsetFixed
public boolean isOffsetFixed()
Returns whether the offset of the label is fixed when the map zooms in or zooms out. If the offset is fixed, the offset of the labels will not change with the map zooms in or zooms out.- Returns:
- True or false indicating whether the offset of the label is fixed.
- Default:
- The default value is false.
-
setOffsetFixed
public void setOffsetFixed(boolean value)
Sets whether the offset of the label is fixed when the map zooms in or zooms out. If the offset is fixed, the offset of the labels will not change with the map zooms in or zooms out.- Parameters:
value
- True or false indicating whether to fix the label offset.
-
dispose
public void dispose()
Disposes the resources occupied by the object. After calling this method, this object will not be usable.
-
toString
public java.lang.String toString()
Outputs the formatted string for the labels thematic map. The formatted string provides the information about the thematic map settings and it cannot be used for import and display of the thematic map like what the XML string can do.- For raster ranges map, the format is {Caption="china", Start=10 End=20, Visible=true?false, Style={linestyle=,markerstyle=,fillstyle=} };
- For raster unique map, the format is {Caption="china", Unique =20, Visible=true?false, Style={linestyle=,markerstyle=,fillstyle=} };
- For labels map, the format is {Caption="China", Start=10 End=20, Visible=true, Style={name=,width=,height=,color=()} };
- For ranges map, the format is {Caption="china", Start=10 End=20, Visible=true?false, Style={linestyle=,markerstyle=,fillstyle=} };
- For unqiue values map, the format is {Caption="china", Unique =20, Visible=true?false, Style={linestyle=,markerstyle=,fillstyle=} };
-
isAllDirectionsOverlappedAvoided
public boolean isAllDirectionsOverlappedAvoided()
Returns whether to avoid overlap at all directions.- Returns:
- Returns true or false indicating whether to avoid overlap at all directions.
-
setAllDirectionsOverlappedAvoided
public void setAllDirectionsOverlappedAvoided(boolean value)
Sets whether to allow avoiding overlap from all directions.- Parameters:
value
- Returns true or false indicating whether to avoid overlap at all directions.
-
getAlongLineSpaceRatio
public double getAlongLineSpaceRatio()
Returns the space ratio of the alongline text. This method only applies to alongline labels.This value is of multiple times of the font height.
Note:
1.If it is larger than 1, the text will be labeled by the specified space and with the center of the line.
2. If it is between 0 to 1, each character in the text is labeled with the angle of the line.
3. If it is less than or equals to 0, the default text along line label mode will be taken.
- Returns:
- The space ratio of the alongline text. This method only applies to alongline labels.
-
setAlongLineSpaceRatio
public void setAlongLineSpaceRatio(double value)
Sets the space ratio of the alongline text. This method only applies to alongline labels.This value is of multiple times of the font height.
Note:
1.If it is larger than 1, the text will be labeled by the specified space and with the center of the line.
2. If it is between 0 to 1, each character in the text is labeled with the angle of the line.
3. If it is less than or equals to 0, the default text along line label mode will be taken.
- Parameters:
value
- The space ratio for alongline text.
-
getRangeMode
public RangeMode getRangeMode()
Returns the current range mode.- Returns:
- The current range mode.
-
getCustomInterval
public double getCustomInterval()
Gets the custom range interval.- Returns:
- The custom range interval.
-
-