Class K2DText
java.lang.Object
com.kheops.jmap.client.graphics2D.K2DElement
com.kheops.jmap.client.graphics2D.K2DText
- All Implemented Interfaces:
- Shareable,- Serializable,- Cloneable
A class representing a scalable text element (map annotation).
- See Also:
- 
Field SummaryFieldsModifier and TypeFieldDescriptionstatic final StringAttribute name for specify the text value of K2DText.protected AnnotationTypeGeometryDefines the geometry of the current element.Fields inherited from class com.kheops.jmap.client.graphics2D.K2DElementattributes, DEFAULT_DC_BUFFER, id, selected
- 
Constructor SummaryConstructorsConstructorDescriptionK2DText()Defaults constructor with no geometry assigned.K2DText(AnnotationTypeGeometry geometry, int id) Constructs a new K2DText object with the specified annotation.K2DText(AnnotationTypeGeometry geometry, Object[] attribute, long id) Constructs a new K2DText object using the specified parameters.
- 
Method SummaryModifier and TypeMethodDescriptionclone()This will clone the current instance of K2DElement.voiddraw(GraphicsRef gr, K2DTransform t, Style s) Draws the element on the specified graphics object using the specified transformation and style.static voiddraw(GraphicsRef gr, Style style, float x, float y, TextLayout textLayout, AffineTransform transform) static voiddraw(GraphicsRef gr, Style style, float x, float y, AttributedString attribString, AffineTransform transform) Deprecated.voiddrawHandles(GraphicsRef gr, K2DTransform t, Style s) This method draws handles around the element.protected doublegetAdjustedFontSize(K2DTransform t, Graphics g, double textHeight, double presentSizeDC) Computes the size of the font based on the specified transform object.Determines the bounding box of the displayed element in DC.getDisplayBoundsWc(ViewState vs, Style s) Determines the bounding box including the style of element in WC (World Coordinates).Returns the geometry object associated with the element.intgetType()Return the current element type.voidsetGeometry(Geometry geometry) Sets the geometry object associated with the element.share()Creates a clone of the current element excluding the geometry which remains the same instance in both elements.
 Useclone()to create a real copy of the current element.intsizeOf()Returns the estimated memory used by this object in bytes.toString()This method overrides the toString methodbooleantouches(Point dcCoord, K2DTransform t, Style s) Determines if the specified device coordinate touches the displayed element.Methods inherited from class com.kheops.jmap.client.graphics2D.K2DElementcopyAttributes, draw, drawHandles, equals, fromByteArray, generateUniqueId, getAttributes, getDisplayBounds, getId, hashCode, isSelected, setAttributes, setId, setSelected, sizeOfAttributes, toByteArray, toByteArray, touches
- 
Field Details- 
ATTRIBUTE_TEXT_VALUEAttribute name for specify the text value of K2DText.- See Also:
 
- 
geometryDefines the geometry of the current element.
 
- 
- 
Constructor Details- 
K2DTextpublic K2DText()Defaults constructor with no geometry assigned.
- 
K2DTextConstructs a new K2DText object with the specified annotation.- Parameters:
- geometry- the annotation geometry that will contain the displayed text.
- id- the id of the element.
 
- 
K2DTextConstructs a new K2DText object using the specified parameters.- Parameters:
- geometry- the annotation geometry that will contain the displayed text.
- attribute- the attributes of the element.
- id- the id of the element.
 
 
- 
- 
Method Details- 
cloneThis will clone the current instance of K2DElement. The cloned element is always a deep copy of the source element.- Specified by:
- clonein class- K2DElement
- Returns:
- a new instance of K2DElement which is equal to the specified the current element.
 
- 
drawDraws the element on the specified graphics object using the specified transformation and style.- Specified by:
- drawin class- K2DElement
- Parameters:
- gr- a wrapper to the Graphics object to draw on
- t- the transformation to apply to the element
- s- the style that defines the appearance of the element
 
- 
draw@Deprecated public static void draw(GraphicsRef gr, Style style, float x, float y, AttributedString attribString, AffineTransform transform) Deprecated.Draws an AttributedString to the specified location.- Parameters:
- gr- the graphics wrapper to use.
- style- the style to use when drawing the annotation.
- x- the X coordinate.
- y- the Y coordinate.
- attribString- the attributed string to draw.
- transform- the view transformation matrix to use.
 
- 
drawpublic static void draw(GraphicsRef gr, Style style, float x, float y, TextLayout textLayout, AffineTransform transform) 
- 
getAdjustedFontSizeprotected double getAdjustedFontSize(K2DTransform t, Graphics g, double textHeight, double presentSizeDC) Computes the size of the font based on the specified transform object.- Parameters:
- t- the view transformation matrix.
- g- the current graphics object to use.
- presentSizeDC- the current DC size.
- Returns:
- the WC size that was computed.
 
- 
sizeOfpublic int sizeOf()Returns the estimated memory used by this object in bytes.- Overrides:
- sizeOfin class- K2DElement
- Returns:
- the estimated memory used by this object in bytes.
 
- 
toStringThis method overrides the toString method
- 
getGeometryReturns the geometry object associated with the element.
 The returned object is an instance of Annotation.- Specified by:
- getGeometryin class- K2DElement
- Returns:
- The geometry object associated with the element.
 
- 
setGeometrySets the geometry object associated with the element.- Specified by:
- setGeometryin class- K2DElement
- Parameters:
- geometry- the geometry
- Throws:
- IllegalArgumentException- if the specified geometry is not a valid Annotation instance.
 
- 
getDisplayBoundsDetermines the bounding box of the displayed element in DC. The bounding box is the smallest possible rectangle in which the displayed element fits entirely.- Specified by:
- getDisplayBoundsin class- K2DElement
- Parameters:
- t- the transformation used to calculate the display bounds of the element.
- s- the style used to calculate the display bounds of the element.
- Returns:
- the bounding box of the displayed element
 
- 
touchesDetermines if the specified device coordinate touches the displayed element. A point touches the element if it overlaps the graphical representation of the element. The style of the element influences the result.- Specified by:
- touchesin class- K2DElement
- Parameters:
- dcCoord- the device coordinate
- t- the transformation used to display the element
- s- the style used to display the element
- Returns:
- true if the element contains the point, false otherwise
- See Also:
 
- 
drawHandlesThis method draws handles around the element. The position of the handles is implementation dependent. These handles are typically used to modify the geometry of the element.- Specified by:
- drawHandlesin class- K2DElement
- Parameters:
- gr- the Graphics object to draw on.
- t- the transformation to apply to the element.
- s- the style of the element.
 
- 
getTypepublic int getType()Return the current element type.- Specified by:
- getTypein class- K2DElement
- Returns:
- the element type.
- See Also:
 
- 
getDisplayBoundsWcDetermines the bounding box including the style of element in WC (World Coordinates). The bounding box is the smallest possible rectangle in which the displayed element fits entirely. This method offers a basic implementation by transforming the DC getDisplayBounds method result in WC. To optimize performance, each K2DElement should override this method with its own implementation. See existing implementations (K2DPolygon, K2DPoint, K2DPolyline, etc.) for examples.- Overrides:
- getDisplayBoundsWcin class- K2DElement
- Parameters:
- vs- the view state that provides context information to calculate the display bounds of the element.
- s- the style used used to calculate the display bounds of the element.
- Returns:
- the bounding box of the displayed element in WC
 
 
- 
draw(GraphicsRef, Style, float, float, TextLayout, AffineTransform)instead