Class ThemeUnique
- java.lang.Object
-
- com.supermap.mapping.Theme
-
- com.supermap.mapping.ThemeUnique
-
public class ThemeUnique extends Theme
The ThemUnique class.Features whose thematic values are the same are classified into one class. Different classes are rendered with different styles. For example, in a land use map, grasslands, woodlands, and residential areas are assigned different colors. The unique values map is applicable to geology maps, topography maps, vegetation maps, land use maps, political administrative division maps, natural zoning maps, economic zoning maps and so on.
- Example:
- The following example demonstrates how to create a unique values map.
public void themeUniqueTest() { // Opens the datasource and gets the dataset named "World" Workspace workspace = new Workspace(); String rootPath = android.os.Environment.getExternalStorageDirectory().getAbsolutePath(); String path = rootPath + "/SampleData/GeometryInfo/World.udb"; DatasourceConnectionInfo datasourceConnectionInfo = new DatasourceConnectionInfo(path, "World", ""); Datasource datasource = workspace.getDatasources().open(datasourceConnectionInfo); DatasetVector datasetVector = (DatasetVector) datasource.getDatasets().get("World"); // Constructs a unique value thematic map and does related setting. ThemeUnique theme = new ThemeUnique(); theme.setUniqueExpression("SmID"); GeoStyle style = new GeoStyle(); style.setFillForeColor(java.awt.Color.yellow); style.setFillBackColor(java.awt.Color.green); style.setFillGradientMode(FillGradientMode.RADIAL); theme.setDefaultStyle(style); // Adds the got thematic map into the map MapControl mapControl = new MapControl(workspace); Layer layer = mapControl.getMap().getLayers().add(datasetVector, true); Layer layerTheme = mapControl.getMap().getLayers().add(datasetVector, theme, true); // Outputs the map in JPG mapControl.getMap().setImageSize(new java.awt.Dimension(512, 512)); String outFile = "c:/temp/themeUnique.jpg"; mapControl.getMap().outputMapToJPG(outFile); // Releases resources mapControl.dispose(); workspace.dispose(); }
-
-
Constructor Summary
Constructors Constructor and Description ThemeUnique()
The default constructor for constructing a new object.ThemeUnique(ThemeUnique themeUnique)
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 int
add(ThemeUniqueItem item)
Adds a unique values map item to the list of the items.void
clear()
Clears all the items of the unique values map.void
dispose()
Disposes the resources occupied by the object.boolean
fromXML(java.lang.String xml)
Reconstructs the object according to the XML string passed in.int
getCount()
Returns the count of the items in the unique values map.GeoStyle
getDefaultStyle()
Returns the default style of unique values map.ThemeUniqueItem
getItem(int index)
Returns the ThemeUniqueItem object with the specified index.java.lang.String
getOffsetX()
Returns the False Easting that the objects in the ThemeUnique crested by point, line and region layers, is relative to original location The unit of the offset is depended on the isOffsetFixed() settings.java.lang.String
getOffsetY()
Returns the False Northing that the objects in the ThemeUnique crested by point, line and region layers, is relative to original location The unit of the offset is depended on the isOffsetFixed() settings.java.lang.String
getUniqueExpression()
Returns the field expression of the unique value map, which is used to set the field or field expression used to create unique values map.int
indexOf(java.lang.String unique)
Returns the index number of the Theme3DUniqueItem object in the Theme3DUniqueItem list with the specified unique value.boolean
insert(int index, ThemeUniqueItem item)
Inserts the given item into the position at which is the specified index.boolean
isDefaultStyleVisible()
Returns whether the style of the unique values map item is visible.boolean
isOffsetFixed()
Returns true or false.static ThemeUnique
makeDefault(DatasetVector dataset, java.lang.String uniqueExpression)
Makes the default unique values map with the given dataset and the UniqueExpression.static ThemeUnique
makeDefault(DatasetVector dataset, java.lang.String uniqueExpression, ColorGradientType colorGradientType)
Makes the default unique values map with the given dataset, UniqueExpression and colorGradientType.Tstatic ThemeUnique
makeDefault(DatasetVector dataset, java.lang.String uniqueExpression, ColorGradientType colorGradientType, JoinItems joinItems)
Makes the default unique values map with the given dataset, UniqueExpression, colorGradientType and joinItems.static ThemeUnique
makeDefault(DatasetVector dataset, java.lang.String colorField, Colors colors)
Makes a default four-color unique values map with the specified region dataset, color fields, and colors.boolean
remove(int index)
Removes the item of the unique values map with the specified index.void
reverseStyle()
Displays the itemin the ThemeUnique object with the reverse style in unique values map.void
setDefaultStyle(GeoStyle style)
Sets the default style of unique values map.void
setDefaultStyleVisible(boolean value)
Sets whether the default style of the unique values map is visible.void
setOffsetFixed(boolean value)
True indicates to employ the device unit; while false indicates to employ the geographic coordinate unit.void
setOffsetX(java.lang.String value)
Sets the False Easting that the objects in the ThemeUnique crested by point, line and region layers, is relative to original location The unit of the offset is depended on the isOffsetFixed() settings.void
setOffsetY(java.lang.String value)
Sets the False Northing that the objects in the ThemeUnique crested by point, line and region layers, is relative to original location The unit of the offset is depended on the isOffsetFixed() settings.void
setUniqueExpression(java.lang.String value)
Sets the field expression of the unique value map, which is used to set the field or field expression used to create unique values map.java.lang.String
toString()
Outputs the formatted string for the unique values thematic map.-
Methods inherited from class com.supermap.mapping.Theme
getMemoryData, getType, setMemoryData, toXML
-
-
-
-
Constructor Detail
-
ThemeUnique
public ThemeUnique()
The default constructor for constructing a new object.
-
ThemeUnique
public ThemeUnique(ThemeUnique themeUnique)
Copy constructor, initializes a new instance of the class which is identical with the specified ImportSettingGML object.- Parameters:
themeUnique
- The specified object of the ThemeUnique.
-
-
Method Detail
-
getItem
public ThemeUniqueItem getItem(int index)
Returns the ThemeUniqueItem object with the specified index.- Parameters:
index
- The specified index of the ThemeUniqueItem object.- Returns:
- The ThemeUniqueItem object with the specified index.
-
getCount
public int getCount()
Returns the count of the items in the unique values map.- Returns:
- The count of the items in the unique values map.
- Default:
- The default value is 0.
-
getUniqueExpression
public java.lang.String getUniqueExpression()
Returns the field expression of the unique value map, which is used to set the field or field expression used to create unique values map. It can be a certain property of features, such as the age or component in a geologic map. The value type can be numeric or string.- Returns:
- The field expression for the unique values map.
- Default:
- The default is a null string.
-
setUniqueExpression
public void setUniqueExpression(java.lang.String value)
Sets the field expression of the unique value map, which is used to set the field or field expression used to create unique values map. It can be a certain property of features, such as the age or component in a geologic map. The value type can be numeric or string .- Parameters:
value
- The field expression for the unique value map.
-
getDefaultStyle
public GeoStyle getDefaultStyle()
Returns the default style of unique values map. Those features that are not included in the items of the thematic map will use this style to display. If no specification, use the default layer style to display.- Returns:
- The default style of the unique values map.
- Default:
- The default value is {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=0,LineWidth=0.1,MarkerAngle=0,MarkerSize={Width=2.4,Height=-1},MarkerSymbolID=0}.
-
setDefaultStyle
public void setDefaultStyle(GeoStyle style)
Sets the default style of unique values map. Those features that are not included in the items of the thematic map will use this style to display. If no specification, use the default layer style to display.- Parameters:
style
- The default style of the specified unique values map.
-
add
public int add(ThemeUniqueItem item)
Adds a unique values map item to the list of the items.- Parameters:
item
- The themeUniqueItem object to be added.- Returns:
- If successful, returns index of the item which has been added; Otherwise, returns -1 .
-
insert
public boolean insert(int index, ThemeUniqueItem item)
Inserts the given item into the position at which is the specified index.- Parameters:
index
- The specified index of the ThemeUnique serial number.item
- The themeUniqueItem object to be inserted.- Returns:
- Returns true If successful; otherwise false.
-
remove
public boolean remove(int index)
Removes the item of the unique values map with the specified index.- Parameters:
index
- The specified index number of the ThemeGridUniqueItem object to be deleted.- Returns:
- Returns true If successful; otherwise false.
-
clear
public void clear()
Clears all the items of the unique values map. All the ThemeUniqueItem objects will be disposed after calling this method.
-
makeDefault
public static ThemeUnique makeDefault(DatasetVector dataset, java.lang.String uniqueExpression)
Makes the default unique values map with the given dataset and the UniqueExpression.- Parameters:
dataset
- The specified vector dataset.uniqueExpression
- The field expression for the unique values map.- Returns:
- Creates a new instance of the ThemeUnique with the given parameters.
-
makeDefault
public static ThemeUnique makeDefault(DatasetVector dataset, java.lang.String uniqueExpression, ColorGradientType colorGradientType)
Makes the default unique values map with the given dataset, UniqueExpression and colorGradientType.T- Parameters:
dataset
- The specified vector dataset.uniqueExpression
- The field expression for the unique values map.colorGradientType
- Color gradient type.- Returns:
- Creates a new instance of the ThemeUnique with the given parameters.
-
makeDefault
public static ThemeUnique makeDefault(DatasetVector dataset, java.lang.String uniqueExpression, ColorGradientType colorGradientType, JoinItems joinItems)
Makes the default unique values map with the given dataset, UniqueExpression, colorGradientType and joinItems.- Parameters:
dataset
- The specified vector dataset.uniqueExpression
- The field expression for the unique values map.colorGradientType
- Color gradient type.joinItems
- External join items- Returns:
- Creates a new instance of the ThemeUnique with the given parameters.
-
makeDefault
public static ThemeUnique makeDefault(DatasetVector dataset, java.lang.String colorField, Colors colors)
Makes a default four-color unique values map with the specified region dataset, color fields, and colors.A four-color 3D unique values map is a map on which only four colors are needed to differentiate adjacent region objects.
Note: The result thematic map has four colors if the specified region dataset is simple; while five colors may present if the dataset is complicated.
- Parameters:
dataset
- The specified region dataset. Because this constructor modifies the attribution information for the region dataset, dataset must not be "read-only".colorField
- The field name of the color. The field for coloring must be of the integer type. It can be an existing attribute field in the region dataset, or some other custom field. If it is an existing field, it must be of the integer type. The system will modify the attribute values in this field, and assign 1, 2, 3, and 4 to the field values. If it is a custom field, the field name must be valid. In this case the system will first create this field in the region dataset and then assign 1, 2, 3, and 4 to the field values. Therefore the values in the coloring field include 1, 2, 3, and 4, representing 4 different colors. A four-color map can be generated based on this field.colors
- The colors passed by the user for making a thematic map. There are no rules about the number of passed colors. For example, if the user only passes one color, the system will automatically fill the map with other needed colors automatically when generating the thematic map.- Returns:
- The four-color unique values map generated.
-
indexOf
public int indexOf(java.lang.String unique)
Returns the index number of the Theme3DUniqueItem object in the Theme3DUniqueItem list with the specified unique value.- Parameters:
unique
- The Single Value of the specified ThemeUniqueItem object .- Returns:
- The index number of the item. If the index value does not exist, returns -1.
-
reverseStyle
public void reverseStyle()
Displays the itemin the ThemeUnique object with the reverse style in unique values map.
-
toString
public java.lang.String toString()
Outputs the formatted string for the unique values 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=} };
-
dispose
public void dispose()
Disposes the resources occupied by the object. After calling this method, this object will not be usable.
-
fromXML
public boolean fromXML(java.lang.String xml)
Reconstructs the object according to the XML string passed in.
-
setDefaultStyleVisible
public void setDefaultStyleVisible(boolean value)
Sets whether the default style of the unique values map is visible.- Parameters:
value
- whether the default style of the unique values map is visible.
-
isDefaultStyleVisible
public boolean isDefaultStyleVisible()
Returns whether the style of the unique values map item is visible.- Returns:
- Whether the style of the unique values map item is visible.
-
getOffsetX
public java.lang.String getOffsetX()
Returns the False Easting that the objects in the ThemeUnique crested by point, line and region layers, is relative to original locationThe unit of the offset is depended on the isOffsetFixed() settings. If the parameter is True, representing use the device unit; Otherwise, the geographic coordinates.
- Returns:
- The False Easting that the objects in the ThemeUnique crested by point, line and region layers, is relative to original location
-
setOffsetX
public void setOffsetX(java.lang.String value)
Sets the False Easting that the objects in the ThemeUnique crested by point, line and region layers, is relative to original locationThe unit of the offset is depended on the isOffsetFixed() settings. If the parameter is True, representing use the device unit; Otherwise, the geographic coordinates.
- Parameters:
value
- The False Easting that the objects in the ThemeUnique crested by point, line and region layers, is relative to original location
-
getOffsetY
public java.lang.String getOffsetY()
Returns the False Northing that the objects in the ThemeUnique crested by point, line and region layers, is relative to original locationThe unit of the offset is depended on the isOffsetFixed() settings. If the parameter is True, representing use the device unit; Otherwise, the geographic coordinates.
- Returns:
- The False Northing that the objects in the ThemeUnique crested by point, line and region layers, is relative to original location
-
setOffsetY
public void setOffsetY(java.lang.String value)
Sets the False Northing that the objects in the ThemeUnique crested by point, line and region layers, is relative to original locationThe unit of the offset is depended on the isOffsetFixed() settings. If the parameter is True, representing use the device unit; Otherwise, the geographic coordinates.
- Parameters:
value
- The False Northing that the objects in the ThemeUnique crested by point, line and region layers, is relative to original location
-
isOffsetFixed
public boolean isOffsetFixed()
Returns true or false. True indicates to employ the device unit; while false indicates to employ the geographic coordinate unit.- Returns:
- Whether to fix the offsets.
-
setOffsetFixed
public void setOffsetFixed(boolean value)
True indicates to employ the device unit; while false indicates to employ the geographic coordinate unit.- Parameters:
value
- Whether to employ the device unit.
-
-