Rectangular Area

Rectangular area is one of two supported types of pedestrian areas in AnyLogic. Use Rectangular area if your area is rectangular, use Polygonal area if your area has complex form.

You can make the area sloped, e.g. to model stairs

This document describes only the specifics of the rectangular area, for the general information on pedestrian areas, please refer here.

 To draw a rectangular area

  1. Drag the  Rectangular Area element from the Space Markup section of the Pedestrian Library palette to the agent diagram.
  2. Resize the area as you need.

Properties

General

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

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

Visible on upper level – If selected, the area is also visible on the upper level where this agent lives.

Lock – If selected, the area 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. 

Visible – Here you specify whether the shape is visible on animation at model runtime, or not. Using the control, choose yes or no

Attractors... – Click this button to create attractors inside the area. Attractors are the places where the pedestrians will tend to get.

Appearance

Fill color – Shape's fill color. Choose No Fill, if you do not want shape to be filled.

Line color – Outline color. Choose No Line, if you do not want outline to be drawn.

Line width – Outline width.

Line style – [Enabled only if the Show in 3D checkbox is not selected] Outline style. Choose from the drop-down list, whether you want solid, dashed, or dotted outline to be drawn. 

Position and size

Ground – The ground this area belongs to. 

X – X-coordinate of the area's start point.

Y – Y-coordinate of the area's start point.

Width – Width of the area (in pixels).

Height – Height of the area (in pixels).

Z – [Enabled if Show in 3D option is selected] Z-coordinate of the area, in meters. The value is relative to the Z-coordinate of the area's ground. 

Rotation – Rotation angle of the area in the XY-plane. 

Sloped – If selected, this area lies on an inclining plane (e.g. it defines an escalator connecting two floors). To know more about defining inclining areas, please refer here.  

Advanced

Show in 3D - If selected, the area will be displayed both in 2D and 3D animation.

Show name – If selected, the shape's name is displayed on the graphical diagram.

Functions

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

Function

Description

List<Attractor> getAttractors()

Returns the unmodifiable list of attractors inside the area.

Position

Function

Description

double getX()

Returns the X-coordinate of the area.

double getY()

Returns the Y-coordinate of the area.

double getZ()

Returns the Z-coordinate of the area.

void setPos(double x, double y, double z)

Sets new coordinates for the area. 

Parameters:
x - the new value of the X-coordinate.
y - the new value of the Y-coordinate.
z - the new value of the Z-coordinate.

Point getCenter()

Returns the point with the coordinates of the area's rectangle center.


Size

Function

Description

double getWidth()

Returns the width of the area (in pixels).

double getHeight()

Returns the height of the area (in pixels).

void setSize
(double width, double height)

Sets the width and height of the area.

Parameters:
width - the new width of the area (in pixels).
height - the new height of the area (in pixels).


Rotation

Function

Description

double getRotation()

Returns the rotation of the area in radians (in the clockwise direction).

void setRotation(double rotation)

Sets the rotation of the area.

Parameter: rotation - the new value of rotation in radians (in the clockwise direction).


Visibility

Function

Description

boolean isVisible()

Returns true if the area is visible; returns false otherwise.

void setVisible(boolean v)

Sets the visibility of the area.

Parameter: v - visibility. If v is true - the area is set to be visible, if it is false - not visible.


Fill color / texture

Function

Description

Color getFillColor()

Returns the fill color of the area, or null if the area has no color or uses a texture (in this case use getFillTexture() to get the area's texture).

Texture getFillTexture()

Returns the fill texture of the area or null if the area has no texture but uses a color (in this case use getFillColor() to get the area's color).

void setFillColor(Color color)

Sets the fill color of the area.

Parameter: color - the new color.

void setFillColor(Paint color)

Sets the fill color (or texture) of the area.

Parameter: color - the new color or texture


Outline appearance

Function

Description

double getLineWidth()

Returns the width of the area outline. 

void setLineWidth(double width)

Sets the width of the area outline; 0 means the thinnest possible outline.

Parameter: width - the new width of the area outline.

Color getLineColor()

Returns the line color of the area, or null if the line has no color or uses a texture (in this case use getLineTexture() to get the line's texture).

Texture getLineTexture()

Returns the line texture of the area or null if the line has no texture but uses a color (in this case use getLineColor() to get the line's color).

void setLineColor(Color color)

Sets the fill color of the area.

Parameter: color - the new color.

void setLineColor(Paint color)

Sets the fill color (or texture) of the area.

Parameter: color - the new color or texture.

LineStyle getLineStyle()

Returns the line style of the area's outline. 

Possible values:
LINE_STYLE_SOLID - solid line.
LINE_STYLE_DOTTED - dotted line.
LINE_STYLE_DASHED - dashed line.

void setLineStyle(LineStyle lineStyle)

Sets the line style of the area's outline. 

Possible values:
LINE_STYLE_SOLID - solid line.
LINE_STYLE_DOTTED - dotted line.
LINE_STYLE_DASHED - dashed line.


Points

Function

Description

double getNearestPoint(double x, double y, Point out)

Calculates the point in this area nearest to the given (x, y) point and writes the result to the output Point object. Returns the square of the distance to the point. All calculations are performed in the horizontal XY-projection (i.e. z-coordinates are treated as zeros).

Parameters:
x - the X-coordinate of the point.
y
- the Y-coordinate of the point.
out - the output point to write result to.

double getNearestPoint(double x, double y, double z, Point out)

Calculates the point in this area nearest to the given (x, y, z) point and writes the result to the output Point object. Returns the square of the distance to the point.

Parameters:
x - the X-coordinate of the point.
y
- the Y-coordinate of the point.
z
- the Z-coordinate of the point.
out - the output point to write result to.

boolean contains(double px, double py)

Returns true if the point with the given coordinates (relative to the area's container) is located within the area; returns false otherwise.

Parameters:
px - the point's X-coordinate.
py - the point's Y-coordinate.

Point randomPointInside(Random rng, Point out)

Returns the randomly chosen point inside the area; utilises the given Random Number Generator.

Parameters:
rng - the random number generator.
out - the output Point object to write the result to. The object may be null.


Ground

Function

Description

Ground getGround()

Returns the ground where this area is located, or null if the area does not belong to any ground.



Related topics

Markup for pedestrian simulation

 Service with lines

 Service with area

 Service with a serpentine queue

 API reference: RectangularNode class