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

public class ShapeLine
extends Shape3D
implements Segment3D
A basic line. For line with arrows see ShapeArrowLine
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
ShapeLine()
Constructs a line with default attributes.
ShapeLine(boolean ispublic, double x, double y, Paint color, double dx, double dy, double width, LineStyle style)
Constructs a 2D-only line with specific attributes.
ShapeLine(ShapeDrawMode drawMode, boolean ispublic, double x, double y, double z, Paint color, double dx, double dy, double dz, double width, double zHeight, LineStyle style)
Constructs a line with specific attributes.
ShapeLine(ShapeDrawMode drawMode, boolean ispublic, double x, double y, double z, Paint color, double dx, double dy, double dz, double width, double zHeight, LineStyle style, LineArrowStyle beginArrowStyle, double beginArrowOffset, double beginArrowLength, double beginArrowWidth, LineArrowStyle endArrowStyle, double endArrowOffset, double endArrowLength, double endArrowWidth)
Deprecated.
this constructor is deprecated since version 8.4 and will be removed in the future.

Method Summary

Modifier and TypeMethodDescription
ShapeLineclone()
Creates and returns a copy of this shape (i.e.
booleancontains(double px, double py)
Always returns false as line has no area and does not contain any point.
floatgetBeginArrowLength()
Deprecated.
this method is deprecated since version 8.4 and will be removed in the future.
floatgetBeginArrowOffset()
Deprecated.
this method is deprecated since version 8.4 and will be removed in the future.
LineArrowStylegetBeginArrowStyle()
Deprecated.
this method is deprecated since version 8.4 and will be removed in the future.
floatgetBeginArrowWidth()
Deprecated.
this method is deprecated since version 8.4 and will be removed in the future.
ColorgetColor()
Returns the color of the line, or null if line has no color or has texture (in this case getTexture() should be used instead)
doublegetDx()
Returns the difference of x coordinates of the line end and start points.
doublegetDy()
Returns the difference of y coordinates of the line end and start points.
doublegetDz()
Returns the difference of z coordinates of the line end and start points.
floatgetEndArrowLength()
Deprecated.
this method is deprecated since version 8.4 and will be removed in the future.
floatgetEndArrowOffset()
Deprecated.
this method is deprecated since version 8.4 and will be removed in the future.
LineArrowStylegetEndArrowStyle()
Deprecated.
this method is deprecated since version 8.4 and will be removed in the future.
floatgetEndArrowWidth()
Deprecated.
this method is deprecated since version 8.4 and will be removed in the future.
doublegetEndX()
Returns the x coordinate of the line end point.
doublegetEndY()
Returns the y coordinate of the line end point.
doublegetEndZ()
Returns the z coordinate of the line end point.
doublegetLength()
This function is obsolete.
LineStylegetLineStyle()
Returns the style of the line: LINE_STYLE_SOLID, LINE_STYLE_DOTTED or LINE_STYLE_DASHED
doublegetLineWidth()
Returns the width of the line.
PresentablegetPresentable()
Returns the Presentable object (Agent or Experiment) where this shape belongs to, or null.
TexturegetTexture()
Returns the texture of the line, if the line has it
doublegetZHeight()
Returns the height of the shape along Z-axis
doublegetZOffset()
Returns the offset from z coordinate of the location base.
This e.g.
doublelength()
Returns the length of the line.
voidpostSVGShapeSpecificAttributes(List<String> att, List<String> val, boolean publicOnly)
Posts general properties specific to a particular shape class.
PointrandomPointInside(Random rng)
Returns the randomly chosen point inside the shape area.
This method utilises the given Random Number Generator.
Throws error if this shape type doesn't support returning random point inside.
voidsetBeginArrowLength(double beginArrowLength)
Deprecated.
this method is deprecated since version 8.4 and will be removed in the future.
voidsetBeginArrowOffset(double beginArrowOffset)
Deprecated.
this method is deprecated since version 8.4 and will be removed in the future.
voidsetBeginArrowStyle(LineArrowStyle beginArrowStyle)
Deprecated.
this method is deprecated since version 8.4 and will be removed in the future.
voidsetBeginArrowWidth(double beginArrowWidth)
Deprecated.
this method is deprecated since version 8.4 and will be removed in the future.
voidsetColor(Color color)
Sets the color of the line.
voidsetColor(Paint color)
Sets the color (or Texture) of the line.
voidsetContextReference_xjal(Presentable contextReference)
Deprecated.
voidsetDx(double dx)
Sets the difference of x coordinates of the line end and start points.
voidsetDy(double dy)
Sets the difference of y coordinates of the line end and start points.
voidsetDz(double dz)
Sets the difference of z coordinates of the line end and start points.
voidsetEndArrowLength(double endArrowLength)
Deprecated.
this method is deprecated since version 8.4 and will be removed in the future.
voidsetEndArrowOffset(double endArrowOffset)
Deprecated.
this method is deprecated since version 8.4 and will be removed in the future.
voidsetEndArrowStyle(LineArrowStyle endArrowStyle)
Deprecated.
this method is deprecated since version 8.4 and will be removed in the future.
voidsetEndArrowWidth(double endArrowWidth)
Deprecated.
this method is deprecated since version 8.4 and will be removed in the future.
voidsetEndX(double endx)
Sets the x coordinate of the line end point.
voidsetEndY(double endy)
Sets the y coordinate of the line end point.
voidsetEndZ(double endz)
Sets the z coordinate of the line end point.
voidsetLineStyle(LineStyle lineStyle)
Sets the style of the line: LINE_STYLE_SOLID, LINE_STYLE_DOTTED or LINE_STYLE_DASHED
voidsetLineWidth(double width)
Sets the width of the line
voidsetZHeight(double zHeight)
Sets the height of the shape along Z-axis

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

canHandleClick, getDrawMode, getScaleZ, getZ, setDrawMode, setPos, setPos, setPos, setRotation, setScale, 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.Segment2D

getX, getY

Methods inherited from interface com.anylogic.engine.Segment3D

getZ

Constructor Details

ShapeLine

public ShapeLine()
Constructs a line with default attributes.

ShapeLine

public ShapeLine(boolean ispublic,
 double x,
 double y,
 Paint color,
 double dx,
 double dy,
 double width,
 LineStyle style)
Constructs a 2D-only line with specific attributes.
Parameters:
ispublic - if true, the shape is visible on container's presentation
x - the x coordinate of the line start point
y - the y coordinate of the line start point
color - color (or Texture) of the line
dx - the difference of x coordinates of the line end and start points
dy - the difference of y coordinates of the line end and start points
width - the line width
style - the line stroke style (solid, dotted, dashed)

ShapeLine

public ShapeLine(ShapeDrawMode drawMode,
 boolean ispublic,
 double x,
 double y,
 double z,
 Paint color,
 double dx,
 double dy,
 double dz,
 double width,
 double zHeight,
 LineStyle style)
Constructs a line with specific attributes.
Parameters:
drawMode - where to draw this shape: 2D, 3D or 2D+3D
ispublic - if true, the shape is visible on container's presentation
x - the x coordinate of the line start point
y - the y coordinate of the line start point
z - the z coordinate of the line start point
color - color (or Texture) of the line
dx - the difference of x coordinates of the line end and start points
dy - the difference of y coordinates of the line end and start points
dz - the difference of z coordinates of the line end and start points
width - the line width
zHeight - the height of a line along Z-axis
style - the line stroke style (only solid is supported)

ShapeLine

@Deprecated
public ShapeLine(ShapeDrawMode drawMode,
 boolean ispublic,
 double x,
 double y,
 double z,
 Paint color,
 double dx,
 double dy,
 double dz,
 double width,
 double zHeight,
 LineStyle style,
 LineArrowStyle beginArrowStyle,
 double beginArrowOffset,
 double beginArrowLength,
 double beginArrowWidth,
 LineArrowStyle endArrowStyle,
 double endArrowOffset,
 double endArrowLength,
 double endArrowWidth)
Deprecated.
this constructor is deprecated since version 8.4 and will be removed in the future. Use ShapeArrowLine instead. Constructs a line with specific attributes and possible arrows a the end(s).
Parameters:
drawMode - where to draw this shape: 2D, 3D or 2D+3D
ispublic - if true, the shape is visible on container's presentation
x - the x coordinate of the line start point
y - the y coordinate of the line start point
z - the z coordinate of the line start point
color - color (or Texture) of the line
dx - the difference of x coordinates of the line end and start points
dy - the difference of y coordinates of the line end and start points
dz - the difference of z coordinates of the line end and start points
width - the line width
zHeight - the height of a line along Z-axis
style - the line stroke style (only solid is supported)
beginArrowStyle - the style of the start arrow, default value is ARROW_NONE
beginArrowOffset - the offset of the start arrow (0..1, where 0=start of line), default value is 0
beginArrowLength - the length factor of the start arrow, it is multiplied by line width to obtain arrow figure length, default value is 4
beginArrowWidth - the width factor of the start arrow, it is multiplied by line width to obtain arrow figure width, default value is 3
endArrowStyle - the style of the start arrow, default value is ARROW_NONE
endArrowOffset - the offset of the start arrow (0..1, where 0=start of line), default value is 0
endArrowLength - the length factor of the start arrow, it is multiplied by line width to obtain arrow figure length, default value is 4
endArrowWidth - the width factor of the start arrow, it is multiplied by line width to obtain arrow figure width, default value is 3

Method Details

setColor

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

setColor

public void setColor(Paint color)
Sets the color (or Texture) of the line.
Parameters:
color - the new color, null = do not draw the line

getColor

public Color getColor()
Returns the color of the line, or null if line has no color or has texture (in this case getTexture() should be used instead)
Returns:
the color of the line

getTexture

public Texture getTexture()
Returns the texture of the line, if the line has it
Returns:
the texture of the line

setDx

public void setDx(double dx)
Sets the difference of x coordinates of the line end and start points.
Parameters:
dx - the new difference of x coordinates of the line end and start points

getDx

public double getDx()
Returns the difference of x coordinates of the line end and start points.
Specified by:
getDx in interface Segment2D
Returns:
the difference of x coordinates of the line end and start points

setDy

public void setDy(double dy)
Sets the difference of y coordinates of the line end and start points.
Parameters:
dy - the new difference of y coordinates of the line end and start points

getDy

public double getDy()
Returns the difference of y coordinates of the line end and start points.
Specified by:
getDy in interface Segment2D
Returns:
the difference of y coordinates of the line end and start points

setDz

public void setDz(double dz)
Sets the difference of z coordinates of the line end and start points.
Parameters:
dz - the new difference of z coordinates of the line end and start points

getDz

public double getDz()
Returns the difference of z coordinates of the line end and start points.
Specified by:
getDz in interface Segment3D
Returns:
the difference of z coordinates of the line end and start points

setEndX

public void setEndX(double endx)
Sets the x coordinate of the line end point.
Parameters:
endx - the new value of x coordinate of line end

getEndX

public double getEndX()
Returns the x coordinate of the line end point.
Specified by:
getEndX in interface Segment2D
Returns:
the x coordinate of the line end

setEndY

public void setEndY(double endy)
Sets the y coordinate of the line end point.
Parameters:
endy - the new value of y coordinate of line end

getEndY

public double getEndY()
Returns the y coordinate of the line end point.
Specified by:
getEndY in interface Segment2D
Returns:
the y coordinate of the line end

setEndZ

public void setEndZ(double endz)
Sets the z coordinate of the line end point.
Parameters:
endz - the new value of z coordinate of line end

getEndZ

public double getEndZ()
Returns the z coordinate of the line end point.
Specified by:
getEndZ in interface Segment3D
Returns:
the z coordinate of the line end

getZOffset

public double getZOffset()
Description copied from interface: Locatable3D
Returns the offset from z coordinate of the location base.
This e.g. returns getZHeight() for some 3D shapes
Specified by:
getZOffset in interface Locatable3D
Overrides:
getZOffset in class Shape3D
Returns:
the offset from z coordinate of the location

setZHeight

public void setZHeight(double zHeight)
Sets the height of the shape along Z-axis
Parameters:
zHeight - the new value of z-height

getZHeight

public double getZHeight()
Returns the height of the shape along Z-axis
Returns:
the height of the shape along Z-axis

randomPointInside

public Point randomPointInside(Random rng)
Description copied from class: Shape
Returns the randomly chosen point inside the shape area.
This method utilises the given Random Number Generator.
Throws error if this shape type doesn't support returning random point inside.
Overrides:
randomPointInside in class Shape
Parameters:
rng - the random number generator.
Returns:
the randomly chosen point inside the shape area.

length

public double length()
Returns the length of the line.
Returns:
the length of the line
Since:
7.1

getLength

@AnyLogicLegacyAPI
public double getLength()
This function is obsolete. Please use length() instead

setLineWidth

public void setLineWidth(double width)
Sets the width of the line
Parameters:
width - the new width of the line

getLineWidth

public double getLineWidth()
Returns the width of the line.
Returns:
the width of the line

setLineStyle

public void setLineStyle(LineStyle lineStyle)
Sets the style of the line: LINE_STYLE_SOLID, LINE_STYLE_DOTTED or LINE_STYLE_DASHED
Parameters:
lineStyle - the new style of the line

getLineStyle

public LineStyle getLineStyle()
Returns the style of the line: LINE_STYLE_SOLID, LINE_STYLE_DOTTED or LINE_STYLE_DASHED
Returns:
the style of the line

setBeginArrowStyle

@Deprecated
public void setBeginArrowStyle(LineArrowStyle beginArrowStyle)
Deprecated.
this method is deprecated since version 8.4 and will be removed in the future. Use ShapeArrowLine instead.

setBeginArrowOffset

@Deprecated
public void setBeginArrowOffset(double beginArrowOffset)
Deprecated.
this method is deprecated since version 8.4 and will be removed in the future. Use ShapeArrowLine instead.

setBeginArrowLength

@Deprecated
public void setBeginArrowLength(double beginArrowLength)
Deprecated.
this method is deprecated since version 8.4 and will be removed in the future. Use ShapeArrowLine instead.

setBeginArrowWidth

@Deprecated
public void setBeginArrowWidth(double beginArrowWidth)
Deprecated.
this method is deprecated since version 8.4 and will be removed in the future. Use ShapeArrowLine instead.

setEndArrowStyle

@Deprecated
public void setEndArrowStyle(LineArrowStyle endArrowStyle)
Deprecated.
this method is deprecated since version 8.4 and will be removed in the future. Use ShapeArrowLine instead.

setEndArrowOffset

@Deprecated
public void setEndArrowOffset(double endArrowOffset)
Deprecated.
this method is deprecated since version 8.4 and will be removed in the future. Use ShapeArrowLine instead.

setEndArrowLength

@Deprecated
public void setEndArrowLength(double endArrowLength)
Deprecated.
this method is deprecated since version 8.4 and will be removed in the future. Use ShapeArrowLine instead.

setEndArrowWidth

@Deprecated
public void setEndArrowWidth(double endArrowWidth)
Deprecated.
this method is deprecated since version 8.4 and will be removed in the future. Use ShapeArrowLine instead.

getBeginArrowStyle

@Deprecated
public LineArrowStyle getBeginArrowStyle()
Deprecated.
this method is deprecated since version 8.4 and will be removed in the future. Use ShapeArrowLine instead.

getBeginArrowOffset

@Deprecated
public float getBeginArrowOffset()
Deprecated.
this method is deprecated since version 8.4 and will be removed in the future. Use ShapeArrowLine instead.

getBeginArrowLength

@Deprecated
public float getBeginArrowLength()
Deprecated.
this method is deprecated since version 8.4 and will be removed in the future. Use ShapeArrowLine instead.

getBeginArrowWidth

@Deprecated
public float getBeginArrowWidth()
Deprecated.
this method is deprecated since version 8.4 and will be removed in the future. Use ShapeArrowLine instead.

getEndArrowStyle

@Deprecated
public LineArrowStyle getEndArrowStyle()
Deprecated.
this method is deprecated since version 8.4 and will be removed in the future. Use ShapeArrowLine instead.

getEndArrowOffset

@Deprecated
public float getEndArrowOffset()
Deprecated.
this method is deprecated since version 8.4 and will be removed in the future. Use ShapeArrowLine instead.

getEndArrowLength

@Deprecated
public float getEndArrowLength()
Deprecated.
this method is deprecated since version 8.4 and will be removed in the future. Use ShapeArrowLine instead.

getEndArrowWidth

@Deprecated
public float getEndArrowWidth()
Deprecated.
this method is deprecated since version 8.4 and will be removed in the future. Use ShapeArrowLine instead.

contains

public boolean contains(double px,
 double py)
Always returns false as line has no area and does not contain any point.
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

clone

public ShapeLine 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

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 Shape
Parameters:
att - attribute names
val - attribute values
publicOnly - TODO

getPresentable

public Presentable getPresentable()
Description copied from class: Shape
Returns the Presentable object (Agent or Experiment) where this shape belongs to, or null.
Overrides:
getPresentable in class Shape
Returns:
the Presentable that owns this shape, or null

setContextReference_xjal

@AnyLogicInternalAPI
@Deprecated
public void setContextReference_xjal(Presentable contextReference)
Deprecated.