AnyLogic
Expand
Font size
All Implemented Interfaces:
com.anylogic.engine.internal.Child, Locatable2D, Locatable3D, AggregatableAnimationElement, HasLevel, LevelElement, Path2D, Path3D, SVGElement, Serializable, Cloneable
Direct Known Subclasses:
ShapeCurve

public class ShapePolyLine
extends ShapeMultiplePoints
Persistent polyline shape.
Author:
AnyLogic North America, LLC https://anylogic.com
See Also:
Serialized Form

Field Summary

Fields inherited from class com.anylogic.engine.presentation.Shape3D

UNKNOWN_NAME

Constructor Summary

ConstructorDescription
ShapePolyLine()
Constructs a polyline with default attributes.
ShapePolyLine(boolean ispublic, double x, double y, Paint lineColor, Paint fillColor, int npoints, double[] dx, double[] dy, boolean closed, double lineWidth, LineStyle lineStyle)
Constructs a 2D-only polyline with specific attributes.
ShapePolyLine(ShapeDrawMode drawMode, boolean ispublic, double x, double y, double z, Paint lineColor, Paint fillColor, int npoints, double[] dx, double[] dy, double[] dz, boolean closed, double zHeight, double lineWidth, LineStyle lineStyle)
Constructs a polyline with specific attributes.

Method Summary

Modifier and TypeMethodDescription
ShapePolyLineclone()
Creates and returns a copy of this shape (i.e.
booleancontains(double px, double py)
Tests if the polygon (based on this polyline points) contains the point with coordinates (x,y).
PositiongetPosition(double value, double maxValue, boolean reverseOffset, Position out) 
PositiongetPosition(int index, int totalNumber, Position out) 
doublegetXMax()
Returns the x coordinate of the bottom-right corner of bounding rectangle for this polyline.
doublegetXMin()
Returns the x coordinate of the top-left corner of bounding rectangle for this polyline.
doublegetYMax()
Returns the y coordinate of the bottom-right corner of bounding rectangle for this polyline.
doublegetYMin()
Returns the y coordinate of the top-left corner of bounding rectangle for this polyline.
doublelength()
Calculates and returns the length of the polyline (not scaled), respecting its closeness.
For 3D polylines this method also respects z coordinates of points.
This method doesn't work for Curve.
voidpostSVGShapeSpecificAttributes(List<String> att, List<String> val, boolean publicOnly)
Posts general properties specific to a particular shape class.
PointrandomPointInside()
Returns the randomly chosen point inside the fill-area of the polyline (like if it was closed).
PointrandomPointInside(Random rng)
Returns the randomly chosen point inside the fill-area of the polyline (like if it was closed).
voidsetRotation(double r)
Sets the rotation of the shape.
voidsetScale(double s)
Sets the same scale of the shape along all the axes
voidsetScale(double sx, double sy)
Sets the scales of the shape along both axes
voidsetScaleX(double sx)
Sets the scale of the shape along x axis
voidsetScaleY(double sy)
Sets the scale of the shape along y axis

Methods inherited from class com.anylogic.engine.presentation.ShapeMultiplePoints

getNPoints, getPointDx, getPointDy, getPointDz, isClosed, setClosed, setNPoints, setPoint, setPoint, setPointDx, setPointDy, setPointDz

Methods inherited from class com.anylogic.engine.presentation.Shape3D

canHandleClick, getDrawMode, getScaleZ, getZ, setDrawMode, setPos, setPos, setPos, setScale, setScaleZ, setZ

Methods inherited from class java.lang.Object

equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait

Methods inherited from interface com.anylogic.engine.markup.AggregatableAnimationElement

initializeInternal, postInitialize

Methods inherited from interface com.anylogic.engine.Locatable3D

getZOffset

Methods inherited from interface com.anylogic.engine.Path2D

getX, getY

Methods inherited from interface com.anylogic.engine.Path3D

getZ

Constructor Details

ShapePolyLine

public ShapePolyLine()
Constructs a polyline with default attributes.

ShapePolyLine

public ShapePolyLine(boolean ispublic,
 double x,
 double y,
 Paint lineColor,
 Paint fillColor,
 int npoints,
 double[] dx,
 double[] dy,
 boolean closed,
 double lineWidth,
 LineStyle lineStyle)
Constructs a 2D-only polyline with specific attributes.
Parameters:
ispublic - if true, the polyline is visible on container's presentation
x - the x coordinate of the polyline start point
y - the y coordinate of the polyline start point
lineColor - line color (or Texture) of the polyline
fillColor - fill color (or Texture) of the polyline
npoints - the number of points in the polyline
dx - the array of (at least npoints) polyline points x coordinates relative to the start point
dy - the array of (at least npoints) polyline points y coordinates relative to the start point
closed - if true, the polyline is drawn as closed
lineWidth - the polyline width
lineStyle - the polyline stroke style (solid, dotted, dashed)

ShapePolyLine

public ShapePolyLine(ShapeDrawMode drawMode,
 boolean ispublic,
 double x,
 double y,
 double z,
 Paint lineColor,
 Paint fillColor,
 int npoints,
 double[] dx,
 double[] dy,
 double[] dz,
 boolean closed,
 double zHeight,
 double lineWidth,
 LineStyle lineStyle)
Constructs a polyline with specific attributes.
Parameters:
drawMode - where to draw this shape: 2D, 3D or 2D+3D
ispublic - if true, the polyline is visible on container's presentation
x - the x coordinate of the polyline start point
y - the y coordinate of the polyline start point
z - the z coordinate of the polyline start point
lineColor - line color (or Texture) of the polyline
fillColor - fill color (or Texture) of the polyline
npoints - the number of points in the polyline
dx - the array of (at least npoints) polyline points x coordinates relative to the start point
dy - the array of (at least npoints) polyline points y coordinates relative to the start point
dz - the array of (at least npoints) polyline points z coordinates relative to the start point
closed - if true, the polyline is drawn as closed
zHeight - the height of a polyline along Z-axis
lineWidth - the polyline width
lineStyle - the polyline stroke style (only solid is supported)

Method Details

contains

public boolean contains(double px,
 double py)
Tests if the polygon (based on this polyline points) contains the point with coordinates (x,y). (relative to this shape's container, i.e. in the same system with the coordinates of this shape, x and y)
Specified by:
contains in class Shape
Parameters:
px - the x coordinate relative to this shape's container
py - the y coordinate relative to this shape's container
Returns:
true if the shape contains the point with the given coordinates

randomPointInside

public Point randomPointInside()
Returns the randomly chosen point inside the fill-area of the polyline (like if it was closed). This method utilises Random Number Generator of the Presentable object containing this polyline. (Will throw an exception if the polyline has been created from code and hasn't been added to any group, - in such case please use randomPointInside(Random)).
Returned point is set to the z coordinate of the polyline (zero in case of 2D)
Overrides:
randomPointInside in class Shape
Returns:
the randomly chosen point inside the polyline

randomPointInside

public Point randomPointInside(Random rng)
Returns the randomly chosen point inside the fill-area of the polyline (like if it was closed). This method utilises the given Random Number Generator.
Returned point is set to the z coordinate of the polyline (zero in case of 2D)
Overrides:
randomPointInside in class Shape
Parameters:
rng - the random number generator.
Returns:
the randomly chosen point inside the polyline

setRotation

public void setRotation(double r)
Description copied from class: Shape
Sets the rotation of the shape.
Overrides:
setRotation in class Shape3D
Parameters:
r - the new value of rotation in radians

setScaleX

public void setScaleX(double sx)
Description copied from class: Shape
Sets the scale of the shape along x axis
Overrides:
setScaleX in class Shape
Parameters:
sx - the new value of scale along x axis, 1 = keep original size

setScaleY

public void setScaleY(double sy)
Description copied from class: Shape
Sets the scale of the shape along y axis
Overrides:
setScaleY in class Shape
Parameters:
sy - the new value of scale along y axis, 1 = keep original size

setScale

public void setScale(double s)
Description copied from class: Shape
Sets the same scale of the shape along all the axes
Overrides:
setScale in class Shape3D
Parameters:
s - the new value of scale along all the axes, 1 = keep original size

setScale

public void setScale(double sx,
 double sy)
Description copied from class: Shape
Sets the scales of the shape along both axes
Overrides:
setScale in class Shape
Parameters:
sx - the new value of scale along x axis, 1 = keep original size
sy - the new value of scale along y axis, 1 = keep original size

getXMin

public double getXMin()
Returns the x coordinate of the top-left corner of bounding rectangle for this polyline. (Shape.getX() is included)
Returns:
the minimum x coordinate of the polyline

getXMax

public double getXMax()
Returns the x coordinate of the bottom-right corner of bounding rectangle for this polyline. (Shape.getX() is included)
Returns:
the maximum x coordinate of the polyline
Since:
6.8

getYMin

public double getYMin()
Returns the y coordinate of the top-left corner of bounding rectangle for this polyline. (Shape.getY() is included)
Returns:
the minimum y coordinate of the polyline
Since:
6.8

getYMax

public double getYMax()
Returns the y coordinate of the bottom-right corner of bounding rectangle for this polyline. (Shape.getY() is included)
Returns:
the maximum y coordinate of the polyline
Since:
6.8

length

public double length()
Calculates and returns the length of the polyline (not scaled), respecting its closeness.
For 3D polylines this method also respects z coordinates of points.
This method doesn't work for Curve.
Returns:
the length of the polyline, respecting its closeness

clone

public ShapePolyLine clone()
Description copied from class: Shape
Creates and returns a copy of this shape (i.e. new shape instance).
The returned shape is the object of the same class
The returned copy isn't automatically added to the group this shape belongs to.
The clone is created in the context of the same experiment or agent

Note that cloning of GIS shape, controls and charts is not supported
Overrides:
clone in class Shape

getPosition

public Position getPosition(int index,
 int totalNumber,
 Position out)

getPosition

public Position getPosition(double value,
 double maxValue,
 boolean reverseOffset,
 Position out)

postSVGShapeSpecificAttributes

public void postSVGShapeSpecificAttributes(List<String> att,
 List<String> val,
 boolean publicOnly)
Description copied from class: Shape
Posts general properties specific to a particular shape class. Is triggered by SVG_DIRTY_SHAPE flag. Made public for occasional posting of additional SVG properties from outside engine (e.g. from libraries)
Overrides:
postSVGShapeSpecificAttributes in class ShapeLineFill
Parameters:
att - attribute names
val - attribute values
publicOnly - TODO