Line

Line is a shape that you can use to draw presentations for your models.

Line may appear in 3D animation with a specified height. In this case the shape will be displayed at model runtime in the regular presentation, and also in 3D window (see the figure below). The base of the shape is drawn in the graphical editor, while its height is specified in the Z-Height property of the shape.

 To draw a line

  1. Drag the  Line element from the  Presentation palette to the graphical editor. Now you can modify the appearance of the drawn line by dragging its end points.
  1. It might probably be more convenient to use drawing mode. To activate it, double-click the  Line element in the palette, its icon should turn into . Then click in the graphical editor where the first point of the line should be placed, hold the mouse button pressed and drag the mouse to the second point of the line. As the result, the line of the required form will be drawn at once.
  2. In the Position and size section of the Properties view you can change the Z-coordinate of the line's start and end points (in the field Z and dZ correspondingly) as well as the height of the line in the field Z-Height (by default it is set to 10).
By default the shape is shown both in 2D animation and in your  3D window. You can set the shape to be shown only in 2D, or in 3D in the Show in advanced properties of the shape.

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 level – If selected, the shape is also visible on the upper level 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 reevaluated at the model runtime. It should return boolean value. The shape is visible when the specified expression evaluates to true, and not visible otherwise.

Appearance

Line color – Line color.
Click inside the control and choose the required color using the Colors dialog box. Choose No Line, if you do not want the line to be drawn.
You can specify the expression that will be reevaluated dynamically. It should return instance of Color Java class. 

Line width – The line width. Choose the width from the drop-down list, or enter the value in pixels in the field to the right. You can specify the dynamic expression, it should return int value.

Line style – [Enabled only if the 2D only option is selected in the Show in advanced property] The line style. Choose from the drop-down list, whether you want solid, dashed, or dotted line to be drawn. 

Position and size

X – X-coordinate of the line (its start point).

Y – Y-coordinate of the line (its start point).

Z – Z-coordinate of the line (its start point).

dX – X-offset of the end point regarding the start point of the line.

dY – Y-offset of the end point regarding the start point of the line.

dZ – Z-offset of the end point regarding the start point of the line.

Z-Height – The z-height (height along the Z axis) of the line. 

Rotation (Z) – 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.*

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

* You can dynamically scale the shape at the model runtime by specifying expressions in the Scale X, ScaleY,and optionally Scale Z 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 – Code that will be called each time a user clicks on the shape at the model runtime.

Show name – If selected, the shape's name will be displayed on the presentation diagram.

Functions

Location

Function

Description

double getX()

double getY()

double getZ()

Returns the X (Y, Z) coordinate of the shape (line's start point).

void setX(double x)

void setY(double y)

void setZ(double z)

Sets the X (Y, Z) coordinate of the shape (line's start point). This function not just changes the coordinate of the line's start point, but moves the line to the new location.

Parameters:  

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 coordinates for the shape (line's start point). Z-coordinate is left unchanged. This function not just changes the coordinate of the line's start point, but moves the line to the new location.

Parameters:

x - the new value of x coordinate
y - the new value of y coordinate

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

Sets new coordinates for the shape (line's start point). This function not just changes the coordinate of the line's start point, but moves the line to the new location.

Parameters:
x - the new value of x coordinate
y - the new value of y coordinate
z - the new value of z coordinate

End point coordinates, length

Function

Description

double getEndX()

double getEndY()

double getEndZ()

Returns the X (Y, Z) coordinate of the line's end point.

void setEndX(double endx)

void setEndY(double endy)

void setEndZ(double endz)

Sets the X  (Y, Z) coordinate of line's end point.

Parameters:    
endx
- the new value of X coordinate
endy - the new value of Y coordinate
endz
- the new value of Z coordinate

double getDx()

double getDy()

double getDz()

Returns the difference of X (Y, Z) coordinates of the line end and start points.

void setDx(double dx)

void setDy(double dy)

void setDz(double dz)

Sets the difference of X (Y, Z) coordinates of the line end and start points.

Parameters:
dx - the new difference of X coordinates of the line end and start points
dy - the new difference of Y coordinates of the line end and start points
dz - the new difference of Z coordinates of the line end and start points

double length()

Returns the length of the line.

Z-height

Function

Description

double getZHeight()

Returns the height of the shape along Z-axis

void setZHeight(double zHeight)

Sets the height of the shape along Z-axis

Parameter:
zHeight - the new value of z-height

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.

Parameters:
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 *

* The value 1 means that the original size should be kept

void setScale(double sx, double sy)

Sets the scales of the shape along both axes.

Parameters:
sx - the new value of scale along X axis *
sy - the new value of scale along Y axis *

void setScale(double s)

Sets the same scale of the shape along both axes.

Parameter:
s - the new value of scale along both axis *


Rotation

Function

Description

double getRotation()

Returns the rotation of the shape in radians, clockwise.

void setRotation(double r)

Sets the rotation of the shape.

Parameter:
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.

Parameter:
v - visibility: if true - the shape is set to be visible, if false - not visible

Line appearance

Function

Description

Color getColor()

Returns the color of the line, or null if the line has no color or has texture (in this case getTexture() should be used instead) 

Texture getTexture()

Returns the line texture, if the line has texture.

void setColor(Color color)

Sets the line color.

Parameter:
color - the new line color, if null, the line is not drawn

void setColor
(Object color)

Sets the color (or Texture) of the line.

Parameter:
color - the new color, null = do not draw the line

double getLineWidth()

Returns the width of the line. 

void setLineWidth
(double width)

Sets the width of the line, 0 means thinnest possible.

Parameter:
width - the new width of the line

int getLineStyle()

Returns the style of the line: 

LineStyle.SOLIDLineStyle.DOTTED or LineStyle.DASHED 

void setLineStyle(int style)

Sets the style of the line: LineStyle.SOLIDLineStyle.DOTTED or LineStyle.DASHED 

Parameter:
style - the new style of the line

Points on the line

Function

Description

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. in the same system with the coordinates of this shape, x and y) . Returns true if the shape contains the point with the given coordinates.

Parameters:
px - the x coordinate relative to this shape's container
py - the y coordinate relative to this shape's container

Point randomPointInside()

Returns the randomly chosen point inside the shape area.

This function utilizes Random Number Generator of the Presentable object containing this shape. (Will throw an exception if the shape has been created from code and hasn't been added to any group, - in this case use randomPointInside(Random rng)).

Returns null if the shape has no points (e.g. polyline with no points).

Point randomPointInside
(java.util.Random rng)

Returns the randomly chosen point inside the shape area. This function utilizes the given Random Number Generator. 

Parameter:
rng - the random number generator.


Related topics

Moving presentation shapes

Resizing presentation shapes

Rotating presentation shapes

Changing shape color

Changing shape's line appearance

Changing shape's position in stacking order

 Aligning shapes