AnyLogic
Expand
Font size

Text

Using Text presentation shape, you can put labels with some comments or descriptions on presentation diagram.

Texts can appear not only in 2D presentation, but also in 3D animation:

To add a text onto presentation

  1. Drag the  Text element from the  Presentation palette onto the graphical editor.
  2. After you drop the element onto the graphical editor, the text field appears. In the text field, type the text you want to be displayed by this text shape. To apply changes, click outside of the field or press Ctrl + Enter (macOS: Cmd + Return). To discard changes, press Esc.
    Alternatively, navigate to the Text section of the shape’s Properties view. In the box, type the text you want to be displayed by this text shape.
  3. By default text shapes do not appear in 3D animation, if you want the text to be shown also in 3D animation scene, open the Advanced section of the text Properties and choose In 2D and 3D in the option Show in. This will enable displaying the text in your 3D window.
  4. In the Position and size section of the Properties you can change the Z-coordinate of the text shape in the field Z.

Properties

General

Name — The name of the shape. It is used to identify and access the shape from code.

Ignore — If selected, the shape is excluded from the model.

Visible on upper agent — If selected, the shape is also visible on the upper agent where this agent lives.

Icon — If selected, the shape is considered as a part of the agent’s icon. Please note that icon shapes are not shown in 3D animation.

Lock — If selected, the shape is locked. Locked shapes do not react to mouse clicks — it is impossible to select them in the graphical editor until you unlock them. It is frequently needed when you use a shape as a background image for your animation and you want to prevent editing this shape while drawing other shapes over it.

Visible — Here you specify whether the shape is visible on the animation at the model runtime, or not. Choose yes or no using the control. If you expect visibility to change dynamically or to depend on some conditions, you may specify the expression defining the shape’s visibility here. This expression will be dynamically re-evaluated at the model runtime. It should return boolean value. The shape is visible when the specified expression evaluates to true, and not visible otherwise.

Text

Here you specify the content of the text shape: the text itself.

If necessary, you can specify the text directly in the graphical editor. To do this, double click the text shape and provide the required text in the text field. To apply changes, click outside of the field or press Ctrl + Enter (macOS: Cmd + Return). To discard changes, press Esc.

Appearance

Color — Static value or dynamic expression of the text color. Click inside the control and choose a color using the Colors dialog box. Otherwise, specify here the expression defining the text color. The expression should return an instance of Java class Color.

Alignment — Text alignment. Using the buttons to the right, choose, whether the text should be aligned to the left, center or right.

Font — Specifies the font family for the text. You can adjust the size of the text font using the control to the right.

Italic — If selected, the text is italicized.

Bold — If selected, the text is emphasized in bold.

Position and size

Level — Level to which this element belongs.

X — X-coordinate of the text’s upper left corner.

Y — Y-coordinate of the text’s upper left corner.

Z — Z-coordinate of the text shape.

Rotation — Shape’s rotation angle in XY plane.

Scale X — Here you can specify the expression returning the X-direction scale factor for the shape. *

Scale Y — Here you can specify the expression returning the Y-direction scale factor for the shape. *

* You can dynamically scale the shape at the model runtime by specifying expressions in the Scale X and Scale Y parameters.
Advanced

Show in — Here you can choose whether you want this shape to be shown both In 2D and 3D animation, or in 2D only, or in 3D only.

Replication — The replication factor of the shape. Here you specify how many copies of the shape will be created (the integer number). If you leave this field empty, only one shape will be created.

On click — Here you can type Java code that will be called each time a user clicks on the shape at the model runtime. If there are several shapes overlapping in the click point, the click will interact with the topmost shape only.
Local variables:
self — the element itself.
clickx — x-coordinate of the click relative to the shape coordinates.
clicky — y-coordinate of the click relative to the shape coordinates.

Show name — If selected, the shape’s name will be displayed on the presentation diagram.

Functions

You can dynamically modify shape properties at model runtime using the following API.

Location
Function Description
double getX()
double getY()
double getZ()
Returns the X (Y, Z) coordinate of the shape (namely, the X coordinate of its upper left corner).
void setX(double x)
void setY(double y)
void setZ(double z)
Sets the X (Y, Z) coordinate of the shape.

x — the new value of X coordinate.
y — the new value of Y coordinate.
z — the new value of Z coordinate.
void setPos(double x, double y) Sets new X, Y coordinates for the shape. Z coordinate stays unchanged.
x — the new value of X coordinate.
y — the new value of Y coordinate.
void setPos(double x, double y, double z) Sets new X, Y, Z coordinates for the shape.

x — the new value of X coordinate.
y — the new value of Y coordinate.
z — the new value of Z coordinate.
Scaling
Function Description
double getScaleX()
double getScaleY()
double getScaleZ()
Returns the scale of the shape along X (Y, Z) axis.
void setScaleX(double sx)
void setScaleY(double sy)
void setScaleZ(double sz)
Sets the scale of the shape along X (Y, Z) axis.

sx — the new value of scale along X axis. *
sy — the new value of scale along Y axis. *
sz — the new value of scale along Z axis. *
void setScale(double sx, double sy) Sets the scales of the shape along X and Y axes.

sx — the new value of scale along X axis. *
sy — the new value of scale along Y axis. *
void setScale(double sx, double sy, double sz) Sets the scale of the shape.

sx — the new value of scale along X axis. *
sy — the new value of scale along Y axis. *
sz — the new value of scale along Z axis. *
void setScale(double s) Sets the same scale of the shape along all axes.

s — the new value of scale along all axis. *
* Set to 1 to keep the original size.
Rotation
Function Description
double getRotation() Returns the rotation of the shape in radians, clockwise.
void setRotation(double r) Sets the rotation of the shape.

r — the new value of rotation in radians.
Visibility
Function Description
boolean isVisible() Checks the visibility of the shape. If the shape is visible, returns true, otherwise returns false.
void setVisible(boolean v) Sets the visibility of the shape.

v — visibility: if true — the shape is set to be visible, if false — not visible.
Text contents
Function Description
String getText() Returns the text of the text shape.
void setText(Object text) Sets the text of the text shape.

text — the new text of the text shape.
Text font, color, alignment
Function Description
Font getFont() Returns the font of the text shape.
void setFont(Font font) Sets the font of the text shape.

font — the new font of the text shape.
Color getColor() Returns the color of the text.
void setColor(Color color) Sets the color of the text.

color — the new color, if null, the text is not drawn.
int getAlignment() Returns the alignment of the text shape.

Valid values:
ALIGNMENT_LEFT
ALIGNMENT_CENTER
ALIGNMENT_RIGHT
void setAlignment(int alignment) Sets the alignment of the text shape.

alignment — the new alignment of the text shape.
Valid values:
ALIGNMENT_LEFT
ALIGNMENT_CENTER
ALIGNMENT_RIGHT
Draw mode (2D / 3D)
Function Description
ShapeDrawMode getDrawMode() Returns the drawing mode of the shape (it defines where this shape is drawn: in 2D, 3D or 2D+3D animation).

Valid values:
SHAPE_DRAW_2D3D — show in 2D and 3D animation
SHAPE_DRAW_2D — show only in 2D animation
SHAPE_DRAW_3D — show only in 3D animation
void setDrawMode(ShapeDrawMode drawMode) Sets the drawing mode of the shape (where to draw this shape: 2D, 3D or 2D+3D animation).
This method may be called only once and only for the shapes created using the constructor without arguments. The call, which changes the set draw mode, will throw the error.
drawMode — the new draw mode of the shape.
Valid values:
SHAPE_DRAW_2D3D — show in 2D and 3D animation
SHAPE_DRAW_2D — show only in 2D animation
SHAPE_DRAW_3D — show only in 3D animation
Group
Function Description
ShapeGroup getGroup() Returns the group containing this shape.
Level
Function Description
Level getLevel() Returns the level, where this shape is located.
How can we improve this article?