Font size

Animating hierarchical models

AnyLogic presentations are associated with model components — agents — and are composed according to the model hierarchy. You develop presentations in a modular way, separately for each object. They can be incorporated into any higher-level presentation scene associated with a container object. When you create an embedded object, its presentation automatically appears on the presentation of a container object. This is called the embedded presentation shape and is drawn as a rectangle showing the content of the presentation of the embedded object. You can move and rotate an embedded presentation shape in the presentation editor, or you can assign expressions to necessary properties to allow a model to move, scale, and rotate an embedded presentation shape at runtime.

Motion of a shape in an embedded presentation is a composition of its motion defined in an embedded object and the motion of an embedded presentation shape defined in a container object.

The presentation of a container object can, in its turn, be embedded somewhere else, and so on to any desired level. This way, you can construct very complex presentations in a modular way, developing individual pictures independently one from another.

Position and size of an embedded presentation on a container presentation can be changed dynamically. This can be defined in two ways:

  • You can assign expressions to the properties of the presentation developed for the class of the embedded object, or
  • You can assign expressions to properties of the embedded presentation shape on the presentation diagram of the container.

If an embedded object itself knows its position with respect to a parent, then you use the first technique. In this case, you have to leave properties of the embedded presentation shape blank, because properties of an embedded presentation shape (if they are defined) override properties of an embedded presentation. If a container knows position of an embedded object, then you use the second technique.

In case an embedded object is created and destroyed dynamically, its presentation appears and disappears synchronously with the object.

In some cases, you have to draw an embedded presentation shape manually. For example, if you create an embedded object, and the embedded object class does not have presentation defined for it, than the embedded presentation shape is not created. If you define presentation for the embedded object class after that, you have to manually create an embedded presentation shape.

To create an embedded presentation shape manually

  1. Open the diagram of the container object.
  2. Select the embedded object by clicking on it.
  3. Go to the Properties and expand the Advanced section. Then click the Show Presentation button. Once this is done, you will see the presentation of the embedded object appeared on the diagram of the container object.
  4. If the button is disabled, the embedded presentation shape already exists. You can access it from the Projects view tree. Expand the container object branch and search for the embedded presentation ( icon) in its Presentation branch. Double clicking on the embedded object presentation in the tree you will select the shape in the graphical editor.

Animating structures not matching the model hierarchy

Although in the majority of cases the presentation structure naturally reproduces the model structure, sometimes they do not match. This means that sometimes you compose a presentation of shapes corresponding to agents lying in different levels of model hierarchy. There are two ways to do so:

  • If those agents have their own presentations defined, and you wish to display them at some presentation several objects up the model hierarchy, then you define presentations for all intermediate agents, which just contain necessary embedded presentations and no other shapes.
  • In case you just wish to define presentation for one (e.g. top-level) agent, you can draw all shapes on its presentation diagram, and then associate them with the data of embedded agents. Obviously, you should make sure those data are accessible.
How can we improve this article?