Class GeoStyle
- java.lang.Object
-
- com.supermap.data.GeoStyle
-
public class GeoStyle extends java.lang.Object
The GeoStyle Class
.The class is used to define the marker, line, and fill symbols and the related settings. The styles can be set using the GeoStyle, except for the GeoText object, whose style can only be set with the TextStyle.
This instance of this class only stores the ID of the specified style, the detailed information of the style is stored in the corresponding marker symbol library, line symbol library and fill symbol library. Only the compound dataset (CAD dataset) stores style, the other types of datasets will not store the information of style.
There are two kinds of fill mode, one is the common fill mode and the other is the gradient fill mode. In common fill mode, the shape can be filled with picture or vector symbols etc., while in gradient fill mode, there are four gradient fill types: linear gradient fill, radial gradient, conical gradient and foursquare gradient.
The ObjectDisposedException will be thrown if the object instance is called after being released with the
dispose()
method.- Example:
- The following example demonstrates how to set styles for GeoPoint, GeoLine and GeoRegion objects respectively and check the styles.
public void geoStyleTest(){ // Open a workspace object. // Creates an instantiation of a line object and set its style GeoStyle geoStyle_L = new GeoStyle(); geoStyle_L.setLineColor(new Color(255,255,255)); geoStyle_L.setLineSymbolID(15); geoStyle_L.setLineWidth(5.0); Point2Ds point2Ds = new Point2Ds(); Point2D[] point2DArray = {new Point2D(100, 100), new Point2D(200, 100), new Point2D(100, 200), new Point2D(200, 200)}; point2Ds.addRange(point2DArray); GeoLine geoLine = new GeoLine(point2Ds); geoLine.setStyle(geoStyle_L); // Creates an instantiation of a point object and set its style GeoStyle geoStyle_P = new GeoStyle(); geoStyle_P.setMarkerAngle(14.0); geoStyle_P.setMarkerSize(new Size2D(10, 10)); geoStyle_P.setMarkerSymbolID(10); GeoPoint geoPoint = new GeoPoint(); geoPoint.setX(100.0); geoPoint.setY(100.0); geoPoint.setStyle(geoStyle_P); // Creates an instantiation of a region object and set gradient styles for it GeoStyle geoStyle_R = new GeoStyle(); geoStyle_R.setFillBackColor(new Color(0,255,0)); geoStyle_R.setFillForeColor(new Color(255,0,0)); geoStyle_R.setFillBackOpaque(true); geoStyle_R.setFillOpaqueRate(50); geoStyle_R.setFillGradientAngle(30.0); //OpenGL does not support the color gradient geoStyle_R.setFillGradientMode(FillGradientMode.LINEAR); //OpenGL does not support the color gradient GeoRegion geoRegion = new GeoRegion(); Point2Ds point2Ds_R = new Point2Ds(); Point2D[] point2DArray_R = {new Point2D(10, 50), new Point2D(150, 50), new Point2D(100, 150), new Point2D(10, 150)}; point2Ds_R.addRange(point2DArray_R); geoRegion.addPart(point2Ds_R); geoRegion.setStyle(geoStyle_R); // Check the styles Map map = new Map(workspace); TrackingLayer layer = map.getTrackingLayer(); layer.add(geoLine, "Line"); layer.add(geoPoint, "Point"); layer.add(geoRegion, "Region"); map.setAntialias(true); map.setViewBounds(new Rectangle2D(0, 0, 250, 250)); }
-
-
Constructor Summary
Constructors Constructor and Description GeoStyle()
Constructs a new GeoStyle object.GeoStyle(GeoStyle style)
Initializes a new instance identical to the given GeoStyle object.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method and Description GeoStyle
clone()
Returns a copy of the current GeoStyle object.void
dispose()
Disposes the resources occupied by the object.boolean
fromJson(java.lang.String json)
Returns geostyle from json databoolean
fromXML(java.lang.String xml)
Creates a GeoStyle object with the specified XML string.Color
getFillBackColor()
Returns the background color of the fill symbol.boolean
getFillBackOpaque()
Determines whether the background of the fill symbol is opaque.Color
getFillForeColor()
Returns the foreground color of the fill symbol.double
getFillGradientAngle()
Gets or sets the rotation angle of the marker symbol.FillGradientMode
getFillGradientMode()
Returns the gradient type for the gradient fill style.double
getFillGradientOffsetRatioX()
Returns the horizontal offset percentage of the gradient fill center relative to the center of the fill extent.double
getFillGradientOffsetRatioY()
Returns the vertical offset percentage of the fill center relative to the center of the fill extent.int
getFillOpaqueRate()
Returns the fill opacity.int
getFillSymbolID()
Returns the ID of the fill symbol.java.lang.String
getFillSymbolStr()
Returns a padding symbol, which only supports MVTColor
getLineColor()
Returns the color of the line symbol or marker symbol.int
getLineSymbolID()
Return the ID of the line symbol.double
getLineWidth()
Returns the width of the line symbol, and the unit is millimeter and accurate to 0.1 millimeter.double
getMarkerAngle()
Returns he rotation angle of the marker symbol.Size2D
getMarkerSize()
Returns the size of the marker symbol.int
getMarkerSymbolID()
Return the ID of the point symbol.java.lang.String
getMarkerSymbolStr()
Fill symbol for return points, MVT is only supportedColor
getPointColor()
Return the color of point.void
setFillBackColor(Color value)
Sets the background color of the fill symbol.void
setFillBackOpaque(boolean value)
Sets whether the background of the fill symbol is opaque.void
setFillForeColor(Color value)
Sets the foreground color of the fill symbol.void
setFillGradientAngle(double value)
The rotation direction is anticlockwise and the unit is degree.The rotation angle is accurate to 0.1 degree.void
setFillGradientMode(FillGradientMode fillGradientMode)
Sets the gradient type for the gradient fill style.void
setFillGradientOffsetRatioX(double value)
Sets the horizontal offset percentage of the gradient fill center relative to the center of the fill extent.void
setFillGradientOffsetRatioY(double value)
Sets the vertical offset percentage of the fill center relative to the center of the fill extent.void
setFillOpaqueRate(int value)
Sets the fill opacity.void
setFillSymbolID(int value)
Sets the ID of the fill symbol.void
setFillSymbolStr(java.lang.String value)
Set the name of the fill symbol, currently only MVT is supportedvoid
setLineColor(Color value)
Sets the color of the line symbol or marker symbol.void
setLineSymbolID(int value)
Set the ID of the line symbol.void
setLineWidth(double value)
Sets the width of the line symbol, and the unit is millimeter and accurate to 0.1 millimeter.void
setMarkerAngle(double value)
Sets he rotation angle of the marker symbol.void
setMarkerSize(Size2D value)
Sets the size of the marker symbol.void
setMarkerSymbolID(int value)
Sets the symbol style of the point object.void
setMarkerSymbolStr(java.lang.String value)
Set the fill symbol of the point, only MVT is supportedvoid
setPointColor(Color value)
Sets the color of point.java.lang.String
toJson()
Converts data from geostyle into jsonjava.lang.String
toString()
Returns a String that represents the current GeoStyle object.java.lang.String
toXML()
Exports the XML string represents the GeoStyle object.
-
-
-
Constructor Detail
-
GeoStyle
public GeoStyle()
Constructs a new GeoStyle object.
-
GeoStyle
public GeoStyle(GeoStyle style)
Initializes a new instance identical to the given GeoStyle object.- Parameters:
style
- The specified GeoStyle3D object.- Throws:
ArgumentNullException
- If the introduced parameter is null or released.
-
-
Method Detail
-
getFillBackColor
public Color getFillBackColor()
Returns the background color of the fill symbol. When the fill mode is the gradient fill, the color is the end fill color.- Returns:
- Color The foreground color of the fill symbol. The default value is Color [A=255, R=255, G=255, B=255].
-
setFillBackColor
public void setFillBackColor(Color value)
Sets the background color of the fill symbol. When the fill mode is the gradient fill, the color is the gradient end fill color.- Parameters:
value
- The foreground color used to set the fill symbols.
-
getFillForeColor
public Color getFillForeColor()
Returns the foreground color of the fill symbol. When the fill mode is the gradient fill, the color is the start gradient fill color.- Returns:
- Color The foreground color of the fill symbol. The default value is Color [A=255, R=189, G=235, B=255].
-
setFillForeColor
public void setFillForeColor(Color value)
Sets the foreground color of the fill symbol. When the fill mode is the gradient fill, the color is the start gradient fill color.- Parameters:
value
- The foreground color used to set the fill symbols.
-
getFillGradientAngle
public double getFillGradientAngle()
Gets or sets the rotation angle of the marker symbol. The rotation direction is anticlockwise and the unit is degree.The rotation angle is accurate to 0.1 degree. About the definition of all gradient fill modes, please refer to the FillGradientMode.
The rotation of different gradient fills may have different representations,but are the center of the smallest external rectangle for the rotation center, counterclockwise rotation.
Linear gradient
When the angle is set to a value within the range between 0 and 360 degrees, the line defined by the starting point and ending point will rotate around the center of the minimum bounding box of the fill region from the original position, where the rotation angle is zero, by the specified rotation angle counterclockwise. Here the gradient fill effects at some rotation angles are given.
- When the gradient fill angle is set to 0 or 360 degrees, the color changes from left to right, from starting color to ending color. As the image shows, the starting color is yellow, and the ending color is pink.
- When the angle is set to 180 degree, the gradient fill style is exactly the opposite of the style described in 1 , that is, color changes from starting color on the right to the ending color on the left.
- When the rotation angle is set to 90 degree, the color changes from starting color at the bottom to the ending color at the top;
- When the angle is set to 270 degree, the gradient is opposite to the situation described in c) totally , that is, color changes from starting color at the top to the ending color at the bottom.
The radiation gradient
When the rotation angle is set to a value within the range from 0 to 360 degrees, the gradient rotates with the specified angle anticlockwise from the default state, as the circle is symmetrical with the center of the boundary rectangle, which is also the center of rotation, the rotation seems to have no effect on the gradient, and the gradient looks the same apparently, that is, the color changes from the center to the boundary of the rectangle and from the starting color to the ending color.
The cone gradient
When the gradient fill angle is set to a value within the range between 0 and 360 degrees, all the generatrices rotate around the center of the minimum bounding box of the fill region counterclockwise by the specified angle.
The foursquare gradient
When a value between 0 and 360 is given, the squares between which gradient occurs rotate with the given angle anticlockwise, the center of the boundary rectangle as the center of rotation. Similarly, all the squares rotate from the original positions, which is the default state of this gradient fill.
- Returns:
- The rotation angle of the gradient fill.
- Default:
- The default value is 0.
- When the gradient fill angle is set to 0 or 360 degrees, the color changes from left to right, from starting color to ending color. As the image shows, the starting color is yellow, and the ending color is pink.
-
setFillGradientAngle
public void setFillGradientAngle(double value)
The rotation direction is anticlockwise and the unit is degree.The rotation angle is accurate to 0.1 degree. About the definition of all gradient fill modes, please refer toFillGradientMode
.The rotation of different gradient fills may have different representations, but are the center of the smallest external rectangle for the rotation center, counterclockwise rotation. please refer to
getFillGradientAngle()
method.- Parameters:
value
- The rotation angle used to set the gradient fill.
-
getFillGradientOffsetRatioX
public double getFillGradientOffsetRatioX()
Returns the horizontal offset percentage of the gradient fill center relative to the center of the fill extent. Supposes the coordinate of the center point of boundary rectangle are (x0, y0), and the coordinate of the center point of the gradient fill is (x, y), and the width of the boundary rectangle is a, and the ratio of the horizontal offset is dx, then x=x0 + a*dx/100 The percentage can be negative. When it is negative, the fill center offsets to the negative direction of the x-axis relative to the center of the fill extent. This method is valid for radial gradient fill type, conical gradient fill type, square gradient fill type and linear fill gradient type.- Returns:
- The horizontal offset percentage of the gradient fill center relative to the center of the fill extent.
- Default:
- The default value is 0.
-
setFillGradientOffsetRatioX
public void setFillGradientOffsetRatioX(double value)
Sets the horizontal offset percentage of the gradient fill center relative to the center of the fill extent. The color gradient is not supported by OpenGL. Supposes the coordinate of the center point of boundary rectangle are (x0, y0), and the coordinate of the center point of the gradient fill is (x, y), and the width of the boundary rectangle is a, and the ratio of the horizontal offset is dx, then x=x0 + a*dx/100 The percentage can be negative. When it is negative, the fill center offsets to the negative direction of the x-axis relative to the center of the fill extent. This method is valid for radial gradient fill type, conical gradient fill type, square gradient fill type and linear fill gradient type.- Parameters:
value
- The value used to set the horizontal offset of the fill center.
-
getFillGradientOffsetRatioY
public double getFillGradientOffsetRatioY()
Returns the vertical offset percentage of the fill center relative to the center of the fill extent. Supposes the coordinate of the center point of boundary rectangle are (x0, y0), and the coordinate of the center point of the gradient fill is (x, y), and the height of the boundary rectangle is b, and the ratio of the vertical offset is dy, then y=y0 + b*dy/100 The percentage can be negative. When it is negative, the fill center offsets to the negative direction of the y-axis relative to the center of the fill extent. This method is valid for radial gradient fill type, conical gradient fill type, square gradient fill type and linear fill gradient type.- Returns:
- The vertical offset of the fill center.
- Default:
- The default value is 0.
-
setFillGradientOffsetRatioY
public void setFillGradientOffsetRatioY(double value)
Sets the vertical offset percentage of the fill center relative to the center of the fill extent. The color gradient is not supported by OpenGL. Supposes the coordinate of the center point of boundary rectangle are (x0, y0), and the coordinate of the center point of the gradient fill is (x, y), and the height of the boundary rectangle is b, and the ratio of the vertical offset is dy, then y=y0 + b*dy/100 The percentage can be negative. When it is negative, the fill center offsets to the negative direction of the y-axis relative to the center of the fill extent. This method is valid for radial gradient fill type, conical gradient fill type, square gradient fill type and linear fill gradient type. The color gradient is not supported by OpenGL.- Parameters:
value
- The value used to set the vertical offset of the fill center.
-
getFillGradientMode
public FillGradientMode getFillGradientMode()
Returns the gradient type for the gradient fill style. For definitions of each gradient fill type, please refer toFillGradientMode
.- Returns:
- fill gradient type.
- See Also:
FillGradientMode
- Default:
- default value is
NONE
type.
-
setFillGradientMode
public void setFillGradientMode(FillGradientMode fillGradientMode)
Sets the gradient type for the gradient fill style. The color gradient is not supported by OpenGL. For definitions of each gradient fill type, please refer toFillGradientMode
.- Parameters:
fillGradientMode
- Specifies the fill gradient mode.- See Also:
FillGradientMode
-
getFillOpaqueRate
public int getFillOpaqueRate()
Returns the fill opacity. The value ranges from 0 to 100, with 0 indicating fully transparent and 100 indicating fully opaque. Values less than 0 and greater than 100 will be taken as 0 and 100 respectively.- Returns:
- int iAn integer represents the fill opacity.
- Default:
- The default value is 100, indicating fully opaque.
-
setFillOpaqueRate
public void setFillOpaqueRate(int value)
Sets the fill opacity. The value ranges from 0 to 100, with 0 indicating null fill and 100 indicating fully opaque. Values less than 0 and greater than 100 will be taken as 0 and 100 respectively.- Parameters:
value
- The integral value used to set the fill opacity.
-
getFillSymbolID
public int getFillSymbolID()
Returns the ID of the fill symbol. It is used to uniquely identify the fill symbol.Fill symbols can be defined by users themselves. Also, users can use system symbols whose IDs are presented in the Resources section of the help doc of SuperMap Objects.
- Returns:
- An integer represents the code of fill symbol.
- Default:
- The default value is 0.
-
setFillSymbolID
public void setFillSymbolID(int value)
Sets the ID of the fill symbol. It is used to uniquely identify the fill symbol.Fill symbols can be defined by users themselves. Also, users can use system symbols whose IDs are presented in the Resources section of the help doc of SuperMap Objects.
- Parameters:
value
- An integer used to set the code of fill symbol.
-
getLineColor
public Color getLineColor()
Returns the color of the line symbol or marker symbol.- Returns:
- The color of the line symbol or marker symbol. The default value is Color [A=255, R=0, G=0, B=0].
-
setLineColor
public void setLineColor(Color value)
Sets the color of the line symbol or marker symbol.- Parameters:
value
- A Color used to set the color of the line symbol or marker symbol.- Example:
- Please refer to the example for the
Layer
class.
-
getLineSymbolID
public int getLineSymbolID()
Return the ID of the line symbol. It is used to uniquely identify the line symbol.Line symbols can be defined by users themselves. Also, users can use system symbols whose IDs are presented in the Resources section of the help doc of SuperMap Objects.
- Returns:
- The code of the line symbol.
- Default:
- The default value is 0.
-
setLineSymbolID
public void setLineSymbolID(int value)
Set the ID of the line symbol. It is used to uniquely identify the line symbol.Line symbols can be defined by users themselves. Also, users can use system symbols whose IDs are presented in the Resources section of the help doc of SuperMap Objects.
- Parameters:
value
- An integer used to set the code of line symbol.- Example:
- Please refer to the example for the
Layer
class.
-
getLineWidth
public double getLineWidth()
Returns the width of the line symbol, and the unit is millimeter and accurate to 0.1 millimeter.- Returns:
- The width of the line symbol.
- Default:
- The default value is 1.0.
-
setLineWidth
public void setLineWidth(double value)
Sets the width of the line symbol, and the unit is millimeter and accurate to 0.1 millimeter.- Parameters:
value
- The width used to set the line symbol.- Example:
- Please refer to the example for the
Layer
class.
-
getMarkerAngle
public double getMarkerAngle()
Returns he rotation angle of the marker symbol. The rotation direction is anticlockwise and the unit is degree.The rotation angle is accurate to 0.1 degrees. This angle can be used as fill symbol rotation in common fill style.- Returns:
- The rotation angle of the marker symbol.
- Default:
- The default value is 0.0.
-
setMarkerAngle
public void setMarkerAngle(double value)
Sets he rotation angle of the marker symbol. The rotation direction is anticlockwise and the unit is degree.The rotation angle is accurate to 0.1 degrees. This angle can be used as fill symbol rotation in common fill style.- Parameters:
value
- The rotation angle used to set the marker symbol.
-
getMarkerSize
public Size2D getMarkerSize()
Returns the size of the marker symbol. The unit is millimeters and the accuracy is 0.1 millimeters. The value must be greater than or equal to zero. If the value is equal to zero, this indicates that the symbol will not be displayed. If the value is less than zero, an exception will be thrown.- Returns:
- The size of the marker symbols.
- Default:
- The default value is {Width = 24,Height = 24}.
-
setMarkerSize
public void setMarkerSize(Size2D value)
Sets the size of the marker symbol. The unit is millimeters and the accuracy is 0.1 millimeters. The value must be greater than or equal to zero. If the value is equal to zero, this indicates that the symbol will not be displayed. If the value is less than zero, an exception will be thrown.- Parameters:
value
- The value used to set size of the marker symbol.
-
getMarkerSymbolID
public int getMarkerSymbolID()
Return the ID of the point symbol. It is used to uniquely identify the point symbol.Marker symbols can be defined by users themselves. Also, users can use system symbols whose IDs are presented in the Resources section of the help doc of SuperMap Objects.
- Returns:
- The code of the marker symbols.
- Default:
- The default value is 0.
-
setMarkerSymbolID
public void setMarkerSymbolID(int value)
Sets the symbol style of the point object. If both color and symbol exist, the symbol is preferred for rendering* @param value The code of the marker symbols.
-
getFillBackOpaque
public boolean getFillBackOpaque()
Determines whether the background of the fill symbol is opaque.- Returns:
- True, if the background of the fill symbol is opaque; otherwise, false.
- Default:
- The default is false, which represents transparent.
-
setFillBackOpaque
public void setFillBackOpaque(boolean value)
Sets whether the background of the fill symbol is opaque.- Parameters:
value
- Specified whether the the background of the fill symbol is opaque. true means opacity.
-
clone
public GeoStyle clone()
Returns a copy of the current GeoStyle object.- Overrides:
clone
in classjava.lang.Object
- Returns:
- The new GeoStyle object generated from the clone operation.
-
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()
Returns a String that represents the current GeoStyle object.- Overrides:
toString
in classjava.lang.Object
- Returns:
- A string that indicates the current GeoStyle.
-
fromXML
public boolean fromXML(java.lang.String xml)
Creates a GeoStyle object with the specified XML string.- Parameters:
xml
- The specified XML string.- Returns:
- Returns true, if successful; otherwise, false.
-
toXML
public java.lang.String toXML()
Exports the XML string represents the GeoStyle object.- Returns:
- the XML string represents the GeoStyle object.
-
getPointColor
public Color getPointColor()
Return the color of point.- Returns:
- Color
-
setPointColor
public void setPointColor(Color value)
Sets the color of point.- Parameters:
value
- Color
-
fromJson
public boolean fromJson(java.lang.String json)
Returns geostyle from json data- Parameters:
json
- json data- Returns:
- Returns geostyle from json data
-
toJson
public java.lang.String toJson()
Converts data from geostyle into json- Returns:
- Obtains data which is converted from geostyle into json
-
getFillSymbolStr
public java.lang.String getFillSymbolStr()
Returns a padding symbol, which only supports MVT- Returns:
-
setFillSymbolStr
public void setFillSymbolStr(java.lang.String value)
Set the name of the fill symbol, currently only MVT is supported- Parameters:
value
-
-
setMarkerSymbolStr
public void setMarkerSymbolStr(java.lang.String value)
Set the fill symbol of the point, only MVT is supported- Parameters:
value
-
-
getMarkerSymbolStr
public java.lang.String getMarkerSymbolStr()
Fill symbol for return points, MVT is only supported- Returns:
-
-