Curve is one of the of primitive presentation shapes that you can use to draw presentations for your models.
Curve is a freeform shape that is drawn in the same manner as a polyline - as a set of vertices that are sequentially connected. The difference is that the curve vertices are connected not to the straight lines, but to the curve segments, that make up a periodic spline.The picture below shows you a polyline and a curve, both drawn for the same set of vertices:
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.
Closed – If selected, the curve is closed, i.e. its begin and end point are connected with extra segment.
Line color
– Curve color. Click inside the control and choose the required color using the
Colors dialog box. Choose
No Line, if you do not want the curve to be drawn.
You can specify the expression that will be re-evaluated dynamically. It should return instance of
Color
Java class.
Fill color
– Curve's fill color. The curve is painted in the following way: the
line connecting curve's start and end points is drawn (if the curve is
not closed already) and the area inside the resulting shape is painted
over.
Click inside the control and choose the required color using the
Colors dialog box. Choose
No Fill, if you do not want area inside the curve to be filled.
Otherwise, specify here the expression defining the shape's fill color.
The expression should return an instance of Java class Color. If it returns
null, the shape is not filled.
Line width – The line width. Choose width from the drop-down list, or enter the value in pixels in the field to the right.
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.
Level – Level to which this element belongs.
X – X-coordinate of the curve (its start point).
Y – Y-coordinate of the curve (its start point).
Rotation, rad – The 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 ScaleY parameters.
Number of points – Here you can specify the expression that will return the number of points of the curve.
dX[indexPt] – Here you can specify the expression for the X-offset of the curve's point with the index indexPt regarding the start point of the curve. Use the predefined symbol indexPt to refer to the current point index. The index value is zero based, i.e., the first point has index of 0.
dY[indexPt] – Here you can specify the expression for the Y-offset of the curve's point with the index indexPt regarding the start point of the curve. Use the predefined symbol indexPt to refer to the current point index. The index value is zero based, i.e., the first point has index of 0.
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. By default the code returns false. If there are several shapes overlapping in the click point, AnyLogic iterates through these shapes in their Z-order, from top to bottom and sequentially executes shape's On click actions. Iteration stops when action code returns true.
Control points are set - here you can choose whether the control points of the curve are set automatically, or manually. Manually means that the "editing curve with the help of guiding lines" mode is switched on. It provides widely spread and convenient way of curve editing, that enables users to draw curves of any complexity and form.
Show name – If selected, the shape's name will be displayed on a presentation diagram.
You can change the appearance of the curve by editing its vertices.
AnyLogic supports editing curves using guiding lines - widely spread and convenient way of curve editing, that enables users to draw curves of any complexity and form.
To switch to "editing with the help of guiding lines" mode on
Let us explain how you can change a form of a curve using its guiding lines. We will illustrate results of operations by example of the curve drawn below:
To start editing a curve using its guiding lines
Using these markers you can change length and orientation of the corresponding guiding line.
Changing orientation of a guiding line, you change form of curve segments adjacent to the corresponding curve vertex.
To change form of curve segments adjacent to a vertex
Length of a guiding line defines a convexity of a curve segment in the corresponding vertex.
To change a convexity of a curve near a vertex
All the described operations change the appearance of both curve segments, adjacent to the curve vertex from both sides.
However, sometimes you may need to change the appearance of only one particular curve segment. In this case you should work with only one marker, corresponding to this segment, as described below:
To change the position of only one particular marker
To show a hidden guiding line for a vertex
Function |
Description |
double getX() double getY() |
Returns the X (Y) coordinate of the shape (curve's start point). |
void setX(double x) void setY(double y) |
Sets
the X (Y) coordinate of the shape (curve's start point). This function
not just changes the coordinate of the curve's start point, but moves
the curve to the new location.
x
- the new value of X coordinate |
void setPos(double x, double y) |
Sets new coordinates for the shape (curve's start point). Z-coordinate is left unchanged. This function not just changes the coordinate of the curve's start point, but moves the curve to the new location. Parameters:
x
- the new value of x coordinate |
Function |
Description |
int getNPoints() |
Returns the number of points of the curve. |
void setNPoints(int n) |
Sets the number of points in the shape. Does nothing if the number of points equals the current one. If it is different, the maximum possible set of points keep their coordinates in the new shape.
Parameter: |
double getPointDx(int i) double getPointDy(int i) |
Returns the X (Y) coordinate of a particular point of the shape relative to the start point.
Parameter:
|
void setPoint(int i, double ptdx, double ptdy) |
Sets the coordinates of a particular point of the shape relative to the start point.
Parameters: |
void setPointDx(int i, double ptdx) void setPointDy(int i, double ptdy) |
Sets the X (Y) coordinate of a particular point of the shape relative to the start point.
Parameters: |
boolean isClosed() |
Returns true, if the curve is closed, and false otherwise. |
void setClosed |
Sets the curve closed or not.
|
Function |
Description |
double getScaleX() double getScaleY() |
Returns the scale of the shape along X (Y) axis. |
void setScaleX(double sx) void setScaleY(double sy) |
Sets the scale of the shape along X (Y) 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.
|
void setScale(double s) |
Sets the same scale of the shape along both axes.
|
Function |
Description |
double getRotation() |
Returns the rotation of the shape in radians, clockwise. |
void setRotation(double r) |
Sets the rotation of the shape.
Parameter: |
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: |
Function |
Description |
boolean isManualControlPoints() |
Returns true if this curve uses manually specified control points (which are specified in the dx and dy arrays) |
void setManualControlPoints(boolean manualControlPoints) |
Sets control points mode: manual or automatic. |
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: |
void setColor |
Sets the color (or Texture) of the line.
Parameter: |
double getLineWidth() |
Returns the width of the line. |
void setLineWidth |
Sets the width of the line, 0 means thinnest possible.
|
int getLineStyle() |
Returns the style of the line, one of these three constants:
|
void setLineStyle(int style) |
Sets the style of the line, use one of these three constants:
Parameter: |