AnyLogic AnyLogic
Expand
Font size
All Implemented Interfaces:
AggregatableAnimationElement, HasLevel, LevelElement, LevelMarkup, SVGElement, java.io.Serializable

public class TargetLine
extends AbstractLevelMarkup
See Also:
Serialized Form

Constructor Summary

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

Method Summary

All Methods Instance Methods Concrete Methods 
void addPoint​(double x, double y)
Adds a point to the collection that will be used to build a polyline of this target line.
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)
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
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
BoundingRectangle getBoundingRectangle()  
java.awt.Color getColor()
Returns the color of the shape, or null if shape has no color
double getNearestPoint​(double x, double y, Point out)
Returns a point on the target line that is closest to the specified point
int getNPoints()
Returns the number of points in the shape.
Point getPointAtOffset​(double offset, Point out)
Returns the point located on the path with the given offset distance calculated from start point.
double getPointDx​(int i)
Returns the x coordinate of a particular point of the shape relative to the start point.
double getPointDy​(int i)
Returns the y coordinate of a particular point of the shape relative to the start point.
double getX()
Returns the x coordinate of the shape.
double getY()
Returns the y coordinate of the shape.
double length()
Returns the length of the path, calculated in 3D space.
Point randomPointInside()
Returns a random point on this target line
Point randomPointInside​(java.util.Random rng, Point out)
Returns a random point on this target line
void setColor​(java.awt.Color color)
Sets the color of the shape.
void setPos​(double x, double y)
Sets coordinates of the shape
Path2D toPath2D()
Returns the Path2D representation of this target line
Modifier and Type Method Description

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 com.anylogic.engine.markup.AbstractMarkup

discardOwner, executeUserAction, findSVGElement, getName, getSVGId, initializeInternal, isVisible, onAggregatorInitialized, onAggregatorVisibilityChanged, removeSVGFromOwner, resetSVGState, setVisible, updateDynamicProperties, updateDynamicPropertiesStructural, updateSVGProperties

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 Detail

TargetLine

public TargetLine()

TargetLine

@Deprecated
public TargetLine​(Agent owner,
                  ShapeDrawMode drawMode,
                  boolean isPublic,
                  double x,
                  double y,
                  double[] dx,
                  double[] dy,
                  java.awt.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 Detail

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​(java.awt.Color color)
Sets the color of the shape.
Parameters:
color - the new color, null = do not draw the shape

getColor

public java.awt.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​(java.util.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()
How can we improve this article?