AnyLogic
Expand
Font size
All Implemented Interfaces:
AggregatableAnimationElement, HasLevel, LevelElement, LevelMarkup, SVGElement, UsdElement, Serializable

public class TargetLine
extends AbstractLevelMarkup
See Also:
Serialized Form

Field Summary

Fields inherited from interface com.anylogic.engine.presentation.UsdElement

ID_NOT_SET

Constructor Summary

ConstructorDescription
TargetLine() 
TargetLine(Agent owner, ShapeDrawMode drawMode, boolean isPublic, double x, double y, double[] dx, double[] dy, Color color)
Deprecated.
deprecated in version 8.4, will be removed in the future releases

Method Summary

Modifier and TypeMethodDescription
voidaddPoint(double x, double y)
Adds a point to the collection that will be used to build a polyline of this target line.
booleancontains(double px, double py)
Test if the shape contains the point with the given coordinates (relative to this shape's container, i.e.
booleancontains(double px, double py, double distance)
Test if the shape contains the point with the given coordinates (relative to this shape's container, i.e.
booleancontainsSq(double px, double py, double squareDistance)
Test if the shape contains the point with the given coordinates (relative to this shape's container, i.e.
BoundingRectanglegetBoundingRectangle() 
ColorgetColor()
Returns the color of the shape, or null if shape has no color
doublegetNearestPoint(double x, double y, Point out)
Returns a point on the target line that is closest to the specified point
intgetNPoints()
Returns the number of points in the shape.
final PointgetPointAtOffset(double offset, Point out)
Returns the point located on the path with the given offset distance calculated from start point.
doublegetPointDx(int i)
Returns the x coordinate of a particular point of the shape relative to the start point.
doublegetPointDy(int i)
Returns the y coordinate of a particular point of the shape relative to the start point.
doublegetX()
Returns the x coordinate of the shape.
doublegetY()
Returns the y coordinate of the shape.
final doublelength()
Returns the length of the path, calculated in 3D space.
PointrandomPointInside()
Returns a random point on this target line
final PointrandomPointInside(Random rng, Point out)
Returns a random point on this target line
voidsetColor(Color color)
Sets the color of the shape.
voidsetPos(double x, double y)
Sets coordinates of the shape
Path2DtoPath2D()
Returns the Path2D representation of this target line

Methods inherited from class com.anylogic.engine.markup.AbstractLevelMarkup

getDrawMode, getLevel, setLevel

Methods inherited from class com.anylogic.engine.markup.MarkupShape

error, getFullName, getOutsideLevelZ, getPresentable, getSpace, initialize, isClickHandled, isPublic, onClick, remove, setDrawMode, setOwner

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, onAggregatorVisibilityChanged, postInitialize

Constructor Details

TargetLine

public TargetLine()

TargetLine

@Deprecated
public TargetLine(Agent owner,
 ShapeDrawMode drawMode,
 boolean isPublic,
 double x,
 double y,
 double[] dx,
 double[] dy,
 Color color)
Deprecated.
deprecated in version 8.4, will be removed in the future releases
Parameters:
owner -
drawMode -
isPublic -
x -
y -
dx -
dy -
color -

Method Details

getX

public double getX()
Returns the x coordinate of the shape.
Returns:
the x coordinate of the shape

getY

public double getY()
Returns the y coordinate of the shape.
Returns:
the y coordinate of the shape

setPos

public void setPos(double x,
 double y)
Sets coordinates of the shape
Parameters:
x - the new value of x coordinate
y - the new value of y coordinate

addPoint

public void addPoint(double x,
 double y)
Adds a point to the collection that will be used to build a polyline of this target line. The element should be uninitialized
Parameters:
x - x coordinate of the point
y - y coordinate of the point

getNPoints

public int getNPoints()
Returns the number of points in the shape.
Returns:
the number of points in the shape

getPointDx

public double getPointDx(int i)
Returns the x coordinate of a particular point of the shape relative to the start point.
Parameters:
i - the index of the point (starting from 0)
Returns:
the x coordinate of the point relative to the start point

getPointDy

public double getPointDy(int i)
Returns the y coordinate of a particular point of the shape relative to the start point.
Parameters:
i - the index of the point (starting from 0)
Returns:
the y coordinate of the point relative to the start point

setColor

public void setColor(Color color)
Sets the color of the shape.
Parameters:
color - the new color, null = do not draw the shape

getColor

public Color getColor()
Returns the color of the shape, or null if shape has no color
Returns:
the color of the shape

length

public final double length()
Returns the length of the path, calculated in 3D space.
Returns:
the length of the path, a positive number

getPointAtOffset

public final Point getPointAtOffset(double offset,
 Point out)
Returns the point located on the path with the given offset distance calculated from start point.
Parameters:
offset - offset, non-negative value, should be less or equal to the length.
out - output object to write to, may be null
Returns:
the Point object with coordinates of the path point with the given offset and orientation along path at this point

contains

public boolean contains(double px,
 double py)
Description copied from class: MarkupShape
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)
Specified by:
contains in class MarkupShape
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

contains

public boolean contains(double px,
 double py,
 double distance)
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), using the given tolerance
Parameters:
px - the x coordinate relative to this shape's container
py - the y coordinate relative to this shape's container
squareDistance - the square of distance tolerance to determine whether the given point lies on the path line or not
Returns:
true if the shape contains the point with the given coordinates

containsSq

public boolean containsSq(double px,
 double py,
 double squareDistance)
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), using the given tolerance
Parameters:
px - the x coordinate relative to this shape's container
py - the y coordinate relative to this shape's container
squareDistance - the square of distance tolerance to determine whether the given point lies on the path line or not
Returns:
true if the shape contains the point with the given coordinates

randomPointInside

public Point randomPointInside()
Returns a random point on this target line
Returns:
a random point on this target line

randomPointInside

public final Point randomPointInside(Random rng,
 Point out)
Returns a random point on this target line
Parameters:
rng - specified random number generator
out - output object, may be null
Returns:
a random point on this target line

getNearestPoint

public double getNearestPoint(double x,
 double y,
 Point out)
Returns a point on the target line that is closest to the specified point
Parameters:
x - x coordinate of the point
y - y coordinate of the point
out - output object, may be null
Returns:
a point on the target line that is closest to the specified point

toPath2D

public Path2D toPath2D()
Returns the Path2D representation of this target line
Returns:
Path2D representation of this target line

getBoundingRectangle

@AnyLogicInternalAPI
public BoundingRectangle getBoundingRectangle()