AnyLogic
Expand
Font size
All Implemented Interfaces:
com.anylogic.engine.internal.Child, Locatable2D, Locatable3D, AggregatableAnimationElement, HasLevel, LevelElement, SVGElement, java.io.Serializable, java.lang.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

Constructors 
ShapeText()
Constructs a text shape with default attributes.
ShapeText​(boolean ispublic, double x, double y, double rotation, java.awt.Color color, java.lang.String text, java.awt.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, java.awt.Color color, java.lang.String text, java.awt.Font font, TextAlignment alignment)
Constructs a text shape with specific attributes.
Constructor Description

Method Summary

All Methods Instance Methods Concrete Methods Deprecated Methods 
ShapeText clone()
Creates and returns a copy of this shape (i.e.
boolean contains​(double px, double py)
Test if the shape contains the point with the given coordinates (relative to this shape's container, i.e.
TextAlignment getAlignment()
Returns the alignment of the text shape.
java.awt.Color getColor()
Returns the color of the text.
java.awt.Font getFont()
Returns the font of the text shape.
Presentable getPresentable()
Returns the Presentable object (Agent or Experiment) where this shape belongs to, or null.
java.lang.String getText()
Returns the text of the text shape.
void setAlignment​(TextAlignment alignment)
Sets the alignment of the text shape.
void setColor​(java.awt.Color color)
Sets the color of the text.
void setContextReference_xjal​(Presentable contextReference)
Deprecated.
void setFont​(java.awt.Font font)
Sets the font of the text shape.
void setText​(java.lang.Object text)
Sets the text of the text shape.
Modifier and Type Method Description

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 com.anylogic.engine.presentation.Shape

executeUserAction, findSVGElement, getGroup, getLevel, getName, getRotation, getScaleX, getScaleY, getSVGId, getX, getY, isJava2DSwingPresentation, isPublic_xjal, isSVGPresentation, isVisible, onAggregatorVisibilityChanged, onClick, postSVGShapeSpecificAttributes, randomPointInside, randomPointInside, removeSVGFromOwner, removeSVGImage, resetSVGState, restoreOwner, setLevel, setPublic_xjal, setScale, setScaleX, setScaleY, setVisible, setX, setY, updateDynamicProperties, updateDynamicPropertiesStructural, updateSVGProperties

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 Detail

ShapeText

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

ShapeText

@AnyLogicLegacyAPI
public ShapeText​(boolean ispublic,
                 double x,
                 double y,
                 double rotation,
                 java.awt.Color color,
                 java.lang.String text,
                 java.awt.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,
                 java.awt.Color color,
                 java.lang.String text,
                 java.awt.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 Detail

setColor

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

getColor

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

setText

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

getText

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

setFont

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

getFont

public java.awt.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.
How can we improve this article?