AnyLogic
Expand
Font size
All Implemented Interfaces:
com.anylogic.engine.internal.Child, Locatable2D, Locatable3D, AggregatableAnimationElement, HasLevel, LevelElement, SVGElement, Serializable, Cloneable

public class ShapeText
extends Shape3D
Persistent text shape.
Author:
AnyLogic North America, LLC https://anylogic.com
See Also:
Serialized Form

Field Summary

Fields inherited from class com.anylogic.engine.presentation.Shape3D

UNKNOWN_NAME

Constructor Summary

ConstructorDescription
ShapeText()
Constructs a text shape with default attributes.
ShapeText(boolean ispublic, double x, double y, double rotation, Color color, String text, Font font, TextAlignment alignment)
Constructs a 2D-only text shape with specific attributes.
ShapeText(ShapeDrawMode drawMode, boolean ispublic, double x, double y, double z, double rotation, Color color, String text, Font font, TextAlignment alignment)
Constructs a text shape with specific attributes.

Method Summary

Modifier and TypeMethodDescription
ShapeTextclone()
Creates and returns a copy of this shape (i.e.
booleancontains(double px, double py)
Test if the shape contains the point with the given coordinates (relative to this shape's container, i.e.
TextAlignmentgetAlignment()
Returns the alignment of the text shape.
ColorgetColor()
Returns the color of the text.
FontgetFont()
Returns the font of the text shape.
PresentablegetPresentable()
Returns the Presentable object (Agent or Experiment) where this shape belongs to, or null.
StringgetText()
Returns the text of the text shape.
voidsetAlignment(TextAlignment alignment)
Sets the alignment of the text shape.
voidsetColor(Color color)
Sets the color of the text.
voidsetContextReference_xjal(Presentable contextReference)
Deprecated.
voidsetFont(Font font)
Sets the font of the text shape.
voidsetText(Object text)
Sets the text of the text shape.

Methods inherited from class com.anylogic.engine.presentation.Shape3D

canHandleClick, getDrawMode, getScaleZ, getZ, getZOffset, setDrawMode, setPos, setPos, setPos, setRotation, setScale, setScale, setScaleZ, setZ

Methods inherited from class java.lang.Object

equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait

Methods inherited from interface com.anylogic.engine.markup.AggregatableAnimationElement

initializeInternal, postInitialize

Methods inherited from interface com.anylogic.engine.Locatable2D

getX, getY

Constructor Details

ShapeText

public ShapeText()
Constructs a text shape with default attributes.

ShapeText

@AnyLogicLegacyAPI
public ShapeText(boolean ispublic,
 double x,
 double y,
 double rotation,
 Color color,
 String text,
 Font font,
 TextAlignment alignment)
Constructs a 2D-only text shape with specific attributes.
Parameters:
ispublic - if true, the shape is visible on container's presentation
x - the x coordinate of the beginning of the first line of the text
y - the y coordinate of the beginning of the first line of the text
rotation - the rotation of the text in radians
color - color of the text
text - the text displayed by the text shape
font - the font used by the text shape
alignment - the alignment of the text shape

ShapeText

public ShapeText(ShapeDrawMode drawMode,
 boolean ispublic,
 double x,
 double y,
 double z,
 double rotation,
 Color color,
 String text,
 Font font,
 TextAlignment alignment)
Constructs a text shape with specific attributes.
Parameters:
drawMode - where to draw this shape: 2D, 3D or 2D+3D
ispublic - if true, the shape is visible on container's presentation
x - the x coordinate of the beginning of the first line of the text
y - the y coordinate of the beginning of the first line of the text
z - the z coordinate of the text
rotation - the rotation of the text in radians
color - color of the text
text - the text displayed by the text shape
font - the font used by the text shape
alignment - the alignment of the text shape

Method Details

setColor

public void setColor(Color color)
Sets the color of the text.
Parameters:
color - the new color, null = do not draw the text

getColor

public Color getColor()
Returns the color of the text.
Returns:
the color of the text

setText

public void setText(Object text)
Sets the text of the text shape.
Parameters:
text - the new text of the text shape

getText

public String getText()
Returns the text of the text shape.
Returns:
the text of the text shape

setFont

public void setFont(Font font)
Sets the font of the text shape.
Parameters:
font - the new font of the text shape

getFont

public Font getFont()
Returns the font of the text shape.
Returns:
the font of the text shape

setAlignment

public void setAlignment(TextAlignment alignment)
Sets the alignment of the text shape.
Parameters:
alignment - the new alignment of the text shape, one of:

getAlignment

public TextAlignment getAlignment()
Returns the alignment of the text shape. Possible values are:
Returns:
the alignment of the text shape

contains

public boolean contains(double px,
 double py)
Description copied from class: Shape
Test if the shape contains the point with the given coordinates (relative to this shape's container, i.e. in the same system with the coordinates of this shape, x and y)
Specified by:
contains in class Shape
Parameters:
px - the x coordinate relative to this shape's container
py - the y coordinate relative to this shape's container
Returns:
true if the shape contains the point with the given coordinates

clone

public ShapeText clone()
Description copied from class: Shape
Creates and returns a copy of this shape (i.e. new shape instance).
The returned shape is the object of the same class
The returned copy isn't automatically added to the group this shape belongs to.
The clone is created in the context of the same experiment or agent

Note that cloning of GIS shape, controls and charts is not supported
Overrides:
clone in class Shape

getPresentable

public Presentable getPresentable()
Description copied from class: Shape
Returns the Presentable object (Agent or Experiment) where this shape belongs to, or null.
Overrides:
getPresentable in class Shape
Returns:
the Presentable that owns this shape, or null

setContextReference_xjal

@AnyLogicInternalAPI
@Deprecated
public void setContextReference_xjal(Presentable contextReference)
Deprecated.