AnyLogic AnyLogic
Expand
Font size
All Implemented Interfaces:
com.anylogic.engine.internal.Child, Locatable2D, Locatable3D, AggregatableAnimationElement, HasLevel, LevelElement, SVGElement, Segment2D, Segment3D, java.io.Serializable, java.lang.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

Constructors 
ShapeLine()
Constructs a line with default attributes.
ShapeLine​(boolean ispublic, double x, double y, java.awt.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, java.awt.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, java.awt.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.
Constructor Description

Method Summary

All Methods Instance Methods Concrete Methods Deprecated Methods 
ShapeLine clone()
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
boolean contains​(double px, double py)
Always returns false as line has no area and does not contain any point.
float getBeginArrowLength()
Deprecated.
this method is deprecated since version 8.4 and will be removed in the future.
float getBeginArrowOffset()
Deprecated.
this method is deprecated since version 8.4 and will be removed in the future.
LineArrowStyle getBeginArrowStyle()
Deprecated.
this method is deprecated since version 8.4 and will be removed in the future.
float getBeginArrowWidth()
Deprecated.
this method is deprecated since version 8.4 and will be removed in the future.
java.awt.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)
double getDx()
Returns the difference of x coordinates of the line end and start points.
double getDy()
Returns the difference of y coordinates of the line end and start points.
double getDz()
Returns the difference of z coordinates of the line end and start points.
float getEndArrowLength()
Deprecated.
this method is deprecated since version 8.4 and will be removed in the future.
float getEndArrowOffset()
Deprecated.
this method is deprecated since version 8.4 and will be removed in the future.
LineArrowStyle getEndArrowStyle()
Deprecated.
this method is deprecated since version 8.4 and will be removed in the future.
float getEndArrowWidth()
Deprecated.
this method is deprecated since version 8.4 and will be removed in the future.
double getEndX()
Returns the x coordinate of the line end point.
double getEndY()
Returns the y coordinate of the line end point.
double getEndZ()
Returns the z coordinate of the line end point.
double getLength()
This function is obsolete.
LineStyle getLineStyle()
Returns the style of the line: LINE_STYLE_SOLID, LINE_STYLE_DOTTED or LINE_STYLE_DASHED
double getLineWidth()
Returns the width of the line.
Presentable getPresentable()
Returns the Presentable object (Agent or Experiment) where this shape belongs to, or null.
Texture getTexture()
Returns the texture of the line, if the line has it
double getZHeight()
Returns the height of the shape along Z-axis
double getZOffset()
Returns the offset from z coordinate of the location base.
This e.g. returns getZHeight() for some 3D shapes
double length()
Returns the length of the line.
void postSVGShapeSpecificAttributes​(java.util.List<java.lang.String> att, java.util.List<java.lang.String> val, boolean publicOnly)
Posts general properties specific to a particular shape class.
Point randomPointInside​(java.util.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.
void setBeginArrowLength​(double beginArrowLength)
Deprecated.
this method is deprecated since version 8.4 and will be removed in the future.
void setBeginArrowOffset​(double beginArrowOffset)
Deprecated.
this method is deprecated since version 8.4 and will be removed in the future.
void setBeginArrowStyle​(LineArrowStyle beginArrowStyle)
Deprecated.
this method is deprecated since version 8.4 and will be removed in the future.
void setBeginArrowWidth​(double beginArrowWidth)
Deprecated.
this method is deprecated since version 8.4 and will be removed in the future.
void setColor​(java.awt.Color color)
Sets the color of the line.
void setColor​(java.awt.Paint color)
Sets the color (or Texture) of the line.
void setContextReference_xjal​(Presentable contextReference)
Deprecated.
void setDx​(double dx)
Sets the difference of x coordinates of the line end and start points.
void setDy​(double dy)
Sets the difference of y coordinates of the line end and start points.
void setDz​(double dz)
Sets the difference of z coordinates of the line end and start points.
void setEndArrowLength​(double endArrowLength)
Deprecated.
this method is deprecated since version 8.4 and will be removed in the future.
void setEndArrowOffset​(double endArrowOffset)
Deprecated.
this method is deprecated since version 8.4 and will be removed in the future.
void setEndArrowStyle​(LineArrowStyle endArrowStyle)
Deprecated.
this method is deprecated since version 8.4 and will be removed in the future.
void setEndArrowWidth​(double endArrowWidth)
Deprecated.
this method is deprecated since version 8.4 and will be removed in the future.
void setEndX​(double endx)
Sets the x coordinate of the line end point.
void setEndY​(double endy)
Sets the y coordinate of the line end point.
void setEndZ​(double endz)
Sets the z coordinate of the line end point.
void setLineStyle​(LineStyle lineStyle)
Sets the style of the line: LINE_STYLE_SOLID, LINE_STYLE_DOTTED or LINE_STYLE_DASHED
void setLineWidth​(double width)
Sets the width of the line
void setZHeight​(double zHeight)
Sets the height of the shape along Z-axis
Modifier and Type Method Description

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 com.anylogic.engine.presentation.Shape

executeUserAction, findSVGElement, getGroup, getLevel, getName, getRotation, getScaleX, getScaleY, getSVGId, getX, getY, isJava2DSwingPresentation, isPublic_xjal, isSVGPresentation, isVisible, onAggregatorVisibilityChanged, onClick, randomPointInside, removeSVGFromOwner, removeSVGImage, resetSVGState, restoreOwner, setLevel, setPublic_xjal, setScale, setScaleX, setScaleY, setVisible, setX, setY, 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, postInitialize

Methods inherited from interface com.anylogic.engine.Segment2D

getX, getY

Methods inherited from interface com.anylogic.engine.Segment3D

getZ

Constructor Detail

ShapeLine

public ShapeLine()
Constructs a line with default attributes.

ShapeLine

public ShapeLine​(boolean ispublic,
                 double x,
                 double y,
                 java.awt.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,
                 java.awt.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,
                 java.awt.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 Detail

setColor

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

setColor

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

getColor

public java.awt.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​(java.util.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​(java.util.List<java.lang.String> att,
                                           java.util.List<java.lang.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.
How can we improve this article?