Добавил:
Upload Опубликованный материал нарушает ваши авторские права? Сообщите нам.
Вуз: Предмет: Файл:

imit_model / AnyLogic / UsersManual(AnyLogic)

.pdf
Скачиваний:
141
Добавлен:
06.06.2015
Размер:
4.28 Mб
Скачать

AnyLogic V User’s Manual

12.1.2.2 Animating structures not matching the model hierarchy

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

If those active objects have their own animations defined, and you wish to display them at some animation several objects up the model hierarchy, then you define animations for all intermediate active objects, which just contain necessary encapsulated animations and no other shapes.

In case you just wish to define animation for one (e.g. root) active object, you can draw all shapes on its animation diagram, and then associate them with the data of encapsulated active objects. Obviously, you should make sure those data are accessible.

12.1.3Interactive control of animation

In AnyLogic 2D animation can be made interactive by adding various types of controls to the animation diagram: buttons, edit boxes, check boxes, radio buttons, sliders, etc.

12.2 Animation diagram

Each active object class may have an animation diagram associated with it. An animation diagram is a collection of shapes. An animation diagram links shape properties to active object data and encapsulated objects, and also defines where the animation of this active object appears in the animation of a container, if the latter exists.

12.2.1Animation editor

An animation diagram is edited in the animation editor using the animation toolbar, see Figure 145.

© 1992-2004 XJ Technologies http://www.xjtek.com

287

Chapter 12. Animation

Figure 145. Animation editor and toolbar

To add an animation to an active object class

1.Click the New Animation toolbar button, or Choose Insert|New Animation… from the main menu. The New Animation dialog box is displayed.

Choose the active object class, which will contain the animation from the Choose active object drop-down list.

2.Alternatively, in the Project window, right-click the active object class, which will contain the animation, and choose New Animation… from the popup menu.

The New Animation dialog box is displayed.

3.Enter the name of the new animation in the Name of the new animation edit box.

4.If needed, select the Add encapsulated animations check box to add animations of the encapsulated objects to this animation.

Moreover, you can add links between encapsulated animations by setting the Add links between encapsulated animations check box.

5.Click OK.

288

© 1992-2004 XJ Technologies http://www.xjtek.com

AnyLogic V User’s Manual

To open the existing animation diagram of an active object class

1.Double-click the animation in the Project window, or

Right-click the animation in the Project window and choose Open Animation from the popup menu.

Animation editor shares a set of generic editing operations described in section 1.5.2, “Diagram editors. Generic operations”.

An animation diagram is always associated with an active object class and has the following properties:

Properties

Name – animation name.

X – [optional] dynamic expression of the x-coordinate of the animation on the container animation (pixels).

Y – [optional] dynamic expression of the y-coordinate of the animation on the container animation (pixels).

Rotation – [optional] dynamic expression of the rotation of the animation on the container animation (radians).

Scale – [optional] if defined, the positions and sizes of all shapes on this diagram are multiplied by this factor.

X Offset – [optional] if defined, the x-coordinates of all shapes on this diagram are increased by this value.

Y Offset – [optional] if defined, the y-coordinates of all shapes on this diagram are increased by this value.

Exclude from build – if set, the animation is excluded from the model.

Prevent frame selection – if set, the animation frame becomes non-selectable. This may be useful if your animation contains, e.g., a rectangle covering the entire animation and you want to select such a rectangle. The point is that in this case, the rectangle and the animation frame coincide. So, if this property is not set, you cannot know for sure what you select: the rectangle or the animation frame.

Flip Y-axis – changes the Y-axis direction.

© 1992-2004 XJ Technologies http://www.xjtek.com

289

Chapter 12. Animation

Properties specifying the location and rotation of the animation on the container animation (X, Y, Rotation) are suppressed by the dynamic expressions of the corresponding properties of the encapsulated animation shape in the container animation, if the latter is defined.

12.2.1.1 Animation origin, axis and frame

The blue cross is the origin point (0, 0) of the animation diagram. Origin point also indicates the axis direction. AnyLogic enables you to change the Y-axis direction since some users got used to working with a frame with Y-axis directed down, while others, with the up-directed Y-axis frame.

To set up/down Y-axis direction

1.Click the animation item in the Project window.

2.In the Properties window, select/clear the Flip Y-axis check box. The blue rectangle, which you cannot delete, is the animation frame.

The animation frame has two meanings. In case this is a root animation, it denotes the window area. Otherwise, in case this animation is encapsulated in another animation, it is used for scaling the encapsulated animation: the scale is evaluated as the ratio of sizes of the animation frame and the encapsulated animation shape in the container animation. Note that no clipping occurs when animations are encapsulated.

The animation frame has properties generic for all animation shapes (see section 12.2.1.2, “Generic properties of animation shapes”).

You can specify a background image for the animation.

To set a background image for an animation

1.Click the animation frame in the animation window.

2.Click the Frame tab of the Properties window.

290

© 1992-2004 XJ Technologies http://www.xjtek.com

AnyLogic V User’s Manual

3.Click the Browse button.

The Open dialog box is displayed.

4.Browse for the image file you want to use.

Double-click the file or click the Open button to select the file.

5.Select Stretch|Tile|Center option to choose the manner the background image is displayed.

12.2.1.2 Generic properties of animation shapes

All shapes of an animation diagram have the following common properties that are displayed on the General page of the Properties window:

Properties

Name – name of the shape, which may be used to access it from code.

X – static value|[optional] dynamic expression of the x-coordinate (pixels).

Y – static value|[optional] dynamic expression of the y-coordinate (pixels).

Rotation – static value (degrees)|[optional] dynamic expression of the rotation angle (radians).

Width – static value|[optional] dynamic expression of the width (pixels).

Height – static value|[optional] dynamic expression of the height (pixels).

Fill color – static value|[optional] dynamic expression of the fill color (java.awt.Color). If the checkbox is not checked, the static color is transparent. If the expression evaluates to null, the dynamic color is transparent.

Line color – static value|[optional] dynamic expression of the line color (java.awt.Color). If the checkbox is not checked, the static color is transparent. If the expression evaluates to null, the dynamic color is transparent.

Line width – static value|[optional] dynamic expression of the line width (pixels).

Visible – [optional] dynamic boolean expression determining if the shape is visible.

Replication – replication factor of the shape.

© 1992-2004 XJ Technologies http://www.xjtek.com

291

Chapter 12. Animation

Lock aspect ratio – if set, the aspect ratio is locked for this shape.

Show name – if set, the name of the shape is shown on the animation diagram editor (but not in the animation).

Exclude from build – if set, the shape is excluded from the animation.

If a generic property is not applicable to a particular shape, it is disabled.

Names of animation shapes are used only for code generation and, correspondingly, to access shapes from code. Names do not appear in the animation window.

12.2.2Animation shapes

In this section the detailed description of the shapes that can be drawn on animation diagram is given.

12.2.2.1Rectangle

To draw a rectangle

1.Click the Rectangle toolbar button, or

Choose Draw|Animation|Rectangle from the main menu.

2.Click or drag the rectangle on the diagram.

The rectangle has no specific properties.

12.2.2.2 Rounded rectangle

To draw a rounded rectangle

1.Click the Rounded Rectangle toolbar button, or

Choose Draw|Animation|Rounded Rectangle from the main menu.

2.Click or drag the rounded rectangle on the diagram.

292

© 1992-2004 XJ Technologies http://www.xjtek.com

AnyLogic V User’s Manual

Properties

Radius – static value|[optional] dynamic expression of the corner radius of the rectangle (pixels).

12.2.2.3Line

To draw a line

1.Click the Line toolbar button, or

Choose Draw|Animation|Line from the main menu.

2.Drag the line on the diagram.

Properties

The following properties are set individually for line’s Begin point and End point.

X – static value|[optional] dynamic expression of the x-coordinate of the point (pixels).

Y – static value|[optional] dynamic expression of the y-coordinate of the point (pixels).

Style – point style. If Arrow is set, the arrow is drawn.

Size – the arrow size.

12.2.2.4Polyline

To draw a polyline

1.Click the Polyline toolbar button, or

Choose Draw|Animation|Polyline from the main menu.

2.Click at each polyline point on the diagram.

3.Double-click to finish.

© 1992-2004 XJ Technologies http://www.xjtek.com

293

Chapter 12. Animation

Properties

# points – [optional] dynamic expression of number of points of the polyline.

X[index] – [optional] dynamic expression of the x-coordinate of the polyline’s point (pixels).

Y[index] – [optional] dynamic expression of the y-coordinate of the polyline’s point (pixels).

Begin|End point style – the style of the begin|end point of the polyline. If Arrow is set, the arrow is drawn.

Begin|End point size – the size of the begin|end point’s arrow.

Closed polyline – if checked, the closing segment is created.

Each point of the polyline can be controlled during the model execution. You can specify dynamic expression, defining the number of points. The coordinates of the polyline’s points can also be defined by dynamic expressions. Use the predefined symbol “index” in X, Y expressions to refer to the current point index. The index value is zero based, i.e., the first point has index of 0.

To move a point of a polyline

1.Drag the point.

To add a salient point to a polyline

1.Select the polyline.

2.Click the Edit Points toolbar button, or Choose Draw|Edit Points from the main menu, or

Right-click the polyline and choose Edit Points from the popup menu. The points of the polyline should turn yellow.

3.Drag a segment of the polyline to create a salient point, or Right-click the segment and choose Add Point from the popup menu.

To remove a salient point from a polyline

1.Select the polyline.

294

© 1992-2004 XJ Technologies http://www.xjtek.com

AnyLogic V User’s Manual

2.Click the Edit Points toolbar button, or Choose Draw|Edit Points from the main menu, or

Right-click the polyline and choose Edit Points from the popup menu.

3.Right-click the point and choose Delete Point from the popup menu, or Drag the point to an adjacent point of the polyline.

The dragged point disappears.

12.2.2.5Oval

To draw an oval

1.Click the Oval toolbar button, or

Choose Draw|Animation|Oval from the main menu.

2.Click or drag the oval on the diagram.

Properties

Radius 1 – static value|[optional] dynamic expression of the first (horizontal) oval radius (pixels).

Radius 2 – static value|[optional] dynamic expression of the second (vertical) oval radius (pixels).

12.2.2.6Image

To draw an image

1.Click the Image toolbar button, or

Choose Draw|Animation|Image from the main menu.

2.Click or drag a rectangle area on the diagram.

Properties

Image index expression – [optional] dynamic expression defining the index of the image in the list to be displayed (integer, zero-based). If left blank, 0 is assumed.

© 1992-2004 XJ Technologies http://www.xjtek.com

295

Chapter 12. Animation

Images – list of file names containing images. Use Add and Remove buttons to edit the list. The Image index expression property defines which image is currently displayed.

Original size – if checked, the original image size is preserved.

If you intend to move your project file, first embed your images. Otherwise, you will need to update paths to all image files used. Embedded images are stored in the AnyLogic project file. If needed, they can be exported to a graphical file anew.

To embed an image

1.Select the image filename in the Images list.

2.Click the Embed button.

To export an embedded image

1.Select the image name in the Images list.

2.Click the Export button.

The Save As… dialog box is displayed.

3.Specify the name of the image file.

4.Browse for the folder where you want to store the file.

5.Click the Save button.

12.2.2.7Text

To draw a text

1.Click the Text toolbar button, or Choose Draw|Text from the main menu.

2.Click or drag a rectangle area on the diagram.

296

© 1992-2004 XJ Technologies http://www.xjtek.com

Соседние файлы в папке AnyLogic