com.supermap.data
Class TextPart
- java.lang.Object
-
- com.supermap.data.TextPart
-
public class TextPart extends java.lang.Object
The TextPart class.This class represents the part of the text object, and mainly used to store the information of the text, rotation angle and anchor point etc. of the part of the GeoText.
The ObjectDisposedException exception will be thrown while invoking the member of this class after being released by thedispose()
method.- Example:
- The following codes demonstrate how to add text child object to text object and display in the map tracking layer.
public void textPartTest(){ // Supposes that you open a workspace object workspace // Set the text sub object TextPart textPart = new TextPart(); textPart.setAnchorPoint(new Point2D(500, 500)); textPart.setRotation(30); textPart.setText("Example"); // Adds the sub object into the text object GeoText geotext = new GeoText(); geotext.addPart(textPart); // Initialize the Map object Map map = new Map(workspace); // Adds the text object into the tracking layer of map and displays it. map.getTrackingLayer().add(geotext, ""); map.setViewBounds(new Rectangle2D(new Point2D(0, 0),new Point2D(300, 300))); // Releases the resources textPart.dispose(); geotext.dispose(); workspace.dispose(); }
-
-
Constructor Summary
Constructors Constructor and Description TextPart()
Constructs a new TextPart object.TextPart(java.lang.String text, double x, double y, double rotation)
Creates a new TextPart object according to the specified arguments.TextPart(java.lang.String text, Point2D anchorPoint)
Creates a new TextPart object according to the specified arguments.TextPart(java.lang.String text, Point2D anchorPoint, double rotation)
Creates a new TextPart object according to the specified arguments.TextPart(TextPart textpart)
Constructs a new object identical to the given TextPart object.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method and Description void
dispose()
Release the resource occupy by this object.Point2D
getAnchorPoint()
Returns the anchor point of the TextPart object, the type is {Point2D
}.double
getRotation()
Returns the angle of rotation of the text, in degrees, and anticlockwise as the positive direction.java.lang.String
getText()
Returns the text content of the instance of this TextPart object.double
getX()
Sets the x-coordinate of the anchor point of the TextPart object.double
getY()
Sets the y-coordinate of the anchor point of the TextPart object.void
setAnchorPoint(Point2D anchorPoint)
Sets the anchor point of the TextPart object, the type is {Point2D
}.void
setRotation(double rotation)
Sets the rotation angle of the instance of the TextPart class, in degrees.void
setText(java.lang.String text)
Sets the text content of the instance of this TextPart object.
-
-
-
Constructor Detail
-
TextPart
public TextPart()
Constructs a new TextPart object.The angle of rotation is 0.0 degree, the text content is null, the isEmpty() of the anchor point is true (that is the X coordinate and the Y coordinate are all 0.0).
-
TextPart
public TextPart(TextPart textpart)
Constructs a new object identical to the given TextPart object.
-
TextPart
public TextPart(java.lang.String text, Point2D anchorPoint)
Creates a new TextPart object according to the specified arguments.- Parameters:
text
- the text of the specified TextPart instance.anchorPoint
- the anchor point of the TextPart instance.
-
TextPart
public TextPart(java.lang.String text, Point2D anchorPoint, double rotation)
Creates a new TextPart object according to the specified arguments.- Parameters:
text
- The specified text of the TextPart object.anchorPoint
- The anchor point of the specified TextPart object.rotation
- Specifies the angle of rotation of the text, in degrees, and anticlockwise as the positive direction.- Example:
- Please see the sample of
TextStyle
.
-
TextPart
public TextPart(java.lang.String text, double x, double y, double rotation)
Creates a new TextPart object according to the specified arguments.- Parameters:
text
- The specified text of the TextPart object.x
- Specifies the x-coordinate of anchor point of the TextPart object.y
- Specifies the y-coordinate of anchor point of the TextPart object.rotation
- Specifies the angle of rotation of the text, in degrees, and anticlockwise as the positive direction.
-
-
Method Detail
-
dispose
public void dispose()
Release the resource occupy by this object.
-
getRotation
public double getRotation()
Returns the angle of rotation of the text, in degrees, and anticlockwise as the positive direction.The rotation angle of the TextPart object after being stored with the data engine. The accuracy is 0.1 degrees. The rotation angle accuracy doesn't change for the TextPart constructed by the constructor.
- Returns:
- the rotation angle of the TextPart object.
- Default:
- The default value is 0.0.
-
setRotation
public void setRotation(double rotation)
Sets the rotation angle of the instance of the TextPart class, in degrees. The positive direction is anticlockwise.- Parameters:
rotation
- the rotation angle of the TextPart object.
-
getText
public java.lang.String getText()
Returns the text content of the instance of this TextPart object.- Returns:
- String the text content of the instance of this TextPart object.
- Default:
- The default is a null string.
-
setText
public void setText(java.lang.String text)
Sets the text content of the instance of this TextPart object.- Parameters:
text
- String the text content of the instance of this TextPart object.
-
getAnchorPoint
public Point2D getAnchorPoint()
Returns the anchor point of the TextPart object, the type is {Point2D
}. This anchor point and the alignment of the text determine the location of the TextPart object, please refer to the {Point2D
} class.- Returns:
- The anchor point of the TextPart object.
- Default:
- The default value is Point2D(0.0,0.0).
-
setAnchorPoint
public void setAnchorPoint(Point2D anchorPoint)
Sets the anchor point of the TextPart object, the type is {Point2D
}. This anchor point and the alignment of the text determine the location of the TextPart object, please refer to the {Point2D
} class.- Parameters:
anchorPoint
- The anchor point of the specified TextPart object.
-
getX
public double getX()
Sets the x-coordinate of the anchor point of the TextPart object.- Returns:
- the x-coordinate of the anchor point of the TextPart object.
- Default:
- The default value is 0.
-
getY
public double getY()
Sets the y-coordinate of the anchor point of the TextPart object.- Returns:
- the y-coordinate of the anchor point of the TextPart object.
- Default:
- The default value is 0.
-
-