AnyLogic
Expand
Font size
All Implemented Interfaces:
IMarkupSegment, Serializable
Direct Known Subclasses:
MarkupSegmentArc, MarkupSegmentLine

public abstract class MarkupSegment
extends AbstractMarkupSegment
Basic implementation of IMarkupSegment for continuous space.
Author:
AnyLogic North America, LLC https://anylogic.com
See Also:
Serialized Form

Method Summary

Modifier and TypeMethodDescription
abstract List<Shape>convertToShapes()
Converts the markup segment into java.awt.geom primitives like Arc2D or Line2D
BoundingRectanglegetBoundingRectangle() 
abstract doublegetDistanceSq(double x, double y)
For horizontal segments, calculates and returns the square of distance to the point (in the XY-projection).
abstract doublegetDistanceSq(double x, double y, double z)
Calculates and returns the square of distance to the given (x, y, z) point.
doublegetDistanceSq(Point givenPoint)
Calculates and returns the square of distance to the given point.
final PointgetEnd(Point out)
Returns the location of the end point of the segment
final doublegetEndX()
Returns the x coordinate of the end point of the segment
final doublegetEndY()
Returns the y coordinate of the start point of the segment
final doublegetEndZ()
Returns the z coordinate of the start point of the segment
abstract doublegetNearestPoint(double x, double y, double z, Point out)
Calculates (using the output object) the point in this space markup element nearest to the given (x, y, z) point.
abstract doublegetNearestPoint(double x, double y, Point out)
For horizontal segments, calculates (using the output object) the point in this space markup element nearest to the given (x, y) point.
doublegetNearestPoint(Point givenPoint, Point out)
For horizontal segments, calculates (using the output object) the point in this space markup element nearest to the given (x, y) point.
doublegetOffsetFrom2D(double offset2D)
Converts offset from the beginning of this segment given in XY-projection, to true offset, which may be used in various methods which require offset
final PositiongetPositionAtOffset(double offset, Position out)
Returns the point located on the segment with the given offset distance calculated from start point.
final PointgetStart(Point out)
Returns the location of the start point of the segment
final doublegetStartX()
Returns the x coordinate of the start point of the segment
final doublegetStartY()
Returns the y coordinate of the start point of the segment
final doublegetStartZ()
Returns the z coordinate of the start point of the segment
final doublelength()
Returns the length of the path segment
final doublelength2D()
Returns the length of the path segment in XY-projection
final voidsetEnd(double x, double y, double z)
Sets the end point of the path segment.
This function may be called only for segments created using constructor without arguments.
Please call AbstractMarkupSegment.initialize() after segment setup is finished.
final voidsetEnd(Point p)
Sets the end point of the path segment.
This function may be called only for segments created using constructor without arguments.
Please call AbstractMarkupSegment.initialize() after segment setup is finished.
final voidsetStart(double x, double y, double z)
Sets the start point of the path segment.
This function may be called only for segments created using constructor without arguments.
Please call AbstractMarkupSegment.initialize() after segment setup is finished.
final voidsetStart(Point p)
Sets the start point of the path segment.
This function may be called only for segments created using constructor without arguments.
Please call AbstractMarkupSegment.initialize() after segment setup is finished.
final voidsetStartNextTo(IMarkupSegment previousSegment)
Sets the start point of the path segment to the coordinates of the end point of the given previousSegment.
This function may be called only for segments created using constructor without arguments.
Please call AbstractMarkupSegment.initialize() after segment setup is finished.

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

getEnd, getStart

Methods inherited from class java.lang.Object

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

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

addTo, getNearestPointOnRay2D, getOffsetOfPoint

Method Details

setStart

public final void setStart(double x,
 double y,
 double z)
Sets the start point of the path segment.
This function may be called only for segments created using constructor without arguments.
Please call AbstractMarkupSegment.initialize() after segment setup is finished.
Parameters:
x - the x coordinate
y - the y coordinate
z - the z coordinate

setStart

public final void setStart(Point p)
Sets the start point of the path segment.
This function may be called only for segments created using constructor without arguments.
Please call AbstractMarkupSegment.initialize() after segment setup is finished.
Specified by:
setStart in interface IMarkupSegment
Parameters:
p - the point

setStartNextTo

public final void setStartNextTo(IMarkupSegment previousSegment)
Sets the start point of the path segment to the coordinates of the end point of the given previousSegment.
This function may be called only for segments created using constructor without arguments.
Please call AbstractMarkupSegment.initialize() after segment setup is finished.
Specified by:
setStartNextTo in interface IMarkupSegment
Parameters:
previousSegment - the segment to get end-point, e.g. the previous segment in the path

getStart

public final Point getStart(Point out)
Returns the location of the start point of the segment
Specified by:
getStart in interface IMarkupSegment
Parameters:
out - output object to write to, may be null
Returns:
the Point object with coordinates of the segment start

setEnd

public final void setEnd(double x,
 double y,
 double z)
Sets the end point of the path segment.
This function may be called only for segments created using constructor without arguments.
Please call AbstractMarkupSegment.initialize() after segment setup is finished.
Parameters:
x - the x coordinate
y - the y coordinate
z - the z coordinate

setEnd

public final void setEnd(Point p)
Sets the end point of the path segment.
This function may be called only for segments created using constructor without arguments.
Please call AbstractMarkupSegment.initialize() after segment setup is finished.
Specified by:
setEnd in interface IMarkupSegment
Parameters:
p - the point

getEnd

public final Point getEnd(Point out)
Returns the location of the end point of the segment
Specified by:
getEnd in interface IMarkupSegment
Parameters:
out - output object to write to, may be null
Returns:
the Point object with coordinates of the segment end

getStartX

public final double getStartX()
Returns the x coordinate of the start point of the segment
Returns:
the x coordinate of the start point of the segment

getStartY

public final double getStartY()
Returns the y coordinate of the start point of the segment
Returns:
the y coordinate of the start point of the segment

getStartZ

public final double getStartZ()
Returns the z coordinate of the start point of the segment
Returns:
the z coordinate of the start point of the segment

getEndX

public final double getEndX()
Returns the x coordinate of the end point of the segment
Returns:
the x coordinate of the end point of the segment

getEndY

public final double getEndY()
Returns the y coordinate of the start point of the segment
Returns:
the y coordinate of the start point of the segment

getEndZ

public final double getEndZ()
Returns the z coordinate of the start point of the segment
Returns:
the z coordinate of the start point of the segment

getPositionAtOffset

public final Position getPositionAtOffset(double offset,
 Position out)
Returns the point located on the segment with the given offset distance calculated from start point.
Parameters:
offset - offset, non-negative value, should be less or equal to the segment length.
out - output object to write to, may be null
Returns:

getDistanceSq

public abstract double getDistanceSq(double x,
 double y)
For horizontal segments, calculates and returns the square of distance to the point (in the XY-projection). All the calculations are performed in the horizontal projection (z-coordinates aren't used, as if all of the z coordinates were zero).
Parameters:
x - x coordinate of the point
y - y coordinate of the point
Returns:
the square of distance to the given point in the horizontal (XY) projection

getNearestPoint

public abstract double getNearestPoint(double x,
 double y,
 double z,
 Point out)
Calculates (using the output object) the point in this space markup element nearest to the given (x, y, z) point. Returns the square of distance to the point.
Parameters:
x - x coordinate of the point
y - y coordinate of the point
z - z coordinate of the point
output - the output point to write result to.
Returns:
the square of distance to the nearest point

getNearestPoint

public abstract double getNearestPoint(double x,
 double y,
 Point out)
For horizontal segments, calculates (using the output object) the point in this space markup element nearest to the given (x, y) point. Returns the square of distance to the point (in the XY-projection). All the calculations are performed in the horizontal projection (z-coordinates aren't used, as if all of the z coordinates were zero).
Parameters:
x - x coordinate of the point
y - y coordinate of the point
out - the output point to write result to. Note that output.z is left unchanged.
Returns:
the square of distance to the nearest point in the horizontal (XY) projection

getNearestPoint

public double getNearestPoint(Point givenPoint,
 Point out)
Description copied from interface: IMarkupSegment
For horizontal segments, calculates (using the output object) the point in this space markup element nearest to the given (x, y) point. Returns the square of distance to the point (in the XY-projection). All the calculations are performed in the horizontal projection (z-coordinates aren't used, as if all of the z coordinates were zero).
Specified by:
getNearestPoint in interface IMarkupSegment
out - the output point to write result to. Note that output.z is left unchanged.
Returns:
the square of distance to the nearest point in the horizontal (XY) projection

getDistanceSq

public abstract double getDistanceSq(double x,
 double y,
 double z)
Calculates and returns the square of distance to the given (x, y, z) point.
Parameters:
x - x coordinate of the point
y - y coordinate of the point
z - z coordinate of the point
Returns:
the square of distance to the given point

getDistanceSq

public double getDistanceSq(Point givenPoint)
Description copied from interface: IMarkupSegment
Calculates and returns the square of distance to the given point.
Specified by:
getDistanceSq in interface IMarkupSegment
Returns:
the square of distance to the given point

length

public final double length()
Description copied from class: AbstractMarkupSegment
Returns the length of the path segment
Specified by:
length in interface IMarkupSegment
Overrides:
length in class AbstractMarkupSegment
Returns:
the length of the path segment, a positive number

length2D

public final double length2D()
Returns the length of the path segment in XY-projection
Returns:
the length of the path segment in XY-projection, a positive number

getOffsetFrom2D

@AnyLogicInternalAPI
public double getOffsetFrom2D(double offset2D)
Converts offset from the beginning of this segment given in XY-projection, to true offset, which may be used in various methods which require offset
Parameters:
offset2D - offset in XY-projection
Returns:
offset

convertToShapes

public abstract List<Shape> convertToShapes()
Converts the markup segment into java.awt.geom primitives like Arc2D or Line2D
Returns:
the list of primitives that comprise the markup segment

getBoundingRectangle

@AnyLogicInternalAPI
BoundingRectangle getBoundingRectangle()