Packagecom.yworks.yfiles.geom
Classpublic class LineSegment
InheritanceLineSegment Inheritance YObject Inheritance Object
Implements PlaneObject

This class represents a line segment in the plane. A line segment is defined by its two end points.



Public Properties
 PropertyDefined By
  boundingBox : YRectangle
[read-only] Returns the smallest Rectangle which contains the object.
LineSegment
  deltaX : Number
[read-only] Returns the distance from start to end point in x-coordinates.
LineSegment
  deltaY : Number
[read-only] Returns the distance from start to end point in y-coordinates.
LineSegment
  firstEndPoint : YPoint
[read-only] Returns the first end point of the line segment.
LineSegment
  horizontal : Boolean
[read-only] Determines if the interval is horizontal.
LineSegment
  scope : Number
[read-only] Returns the slope of the line segment.
LineSegment
  secondEndPoint : YPoint
[read-only] Returns the second end point of the line segment.
LineSegment
  vertical : Boolean
[read-only] Returns if this segment is considered vertical, i.e.
LineSegment
  xOffset : Number
[read-only] Returns the y value of the line on x coordinate 0.
LineSegment
Public Methods
 MethodDefined By
  
LineSegment(p1:YPoint, p2:YPoint, init:Boolean = true)
Returns a new LineSegment.
LineSegment
  
[static] Checks whether a line segment intersects a box.
LineSegment
  
boxIntersectsSegment2(box:YRectangle, x1:Number, y1:Number, x2:Number, y2:Number):Boolean
[static] Checks whether a line segment intersects a box.
LineSegment
  
boxIntersectsSegment3(boxX1:Number, boxY1:Number, boxX2:Number, boxY2:Number, sX1:Number, sY1:Number, sX2:Number, sY2:Number):Boolean
[static] Checks whether a line segment intersects a paraxial box.
LineSegment
  
contains(point:YPoint):Boolean
Checks whether a given point lies on this line segment.
LineSegment
 Inherited
equals(o:Object):Boolean
YObject
  
getClass():Class
[override]
LineSegment
  
[static] Returns intersection point between the two line segments, if there is one or null if the two line segments do not intersect.
LineSegment
 Inherited
hashCode():int
YObject
  
Checks whether the line segment intersects a point.
LineSegment
  
Checks whether the line segment intersects a box.
LineSegment
  
isInXIntervall(x:Number):Boolean
Returns if the projection on the X axis of the line segment covers a certain point on the X Axis.
LineSegment
  
isInYIntervall(y:Number):Boolean
Returns if the projection on the Y axis of the line segment covers a certain point on the Y Axis.
LineSegment
  
length():Number
Returns the length of the line segment, this is the value of the Euclidean norm.
LineSegment
  
[static] Returns a new LineSegment.
LineSegment
  
Returns the affine line defined by the end points of the line segment.
LineSegment
  
toString():String
String representation of the line.
LineSegment
  
Returns the vector pointing from the first end point to the second end point of the line segment.
LineSegment
Protected Methods
 MethodDefined By
  
Initializes this object.
LineSegment
Property Detail
boundingBoxproperty
boundingBox:YRectangle  [read-only]

Returns the smallest Rectangle which contains the object.


Implementation
    public function get boundingBox():YRectangle
deltaXproperty 
deltaX:Number  [read-only]

Returns the distance from start to end point in x-coordinates.


Implementation
    public function get deltaX():Number
deltaYproperty 
deltaY:Number  [read-only]

Returns the distance from start to end point in y-coordinates.


Implementation
    public function get deltaY():Number
firstEndPointproperty 
firstEndPoint:YPoint  [read-only]

Returns the first end point of the line segment.


Implementation
    public function get firstEndPoint():YPoint
horizontalproperty 
horizontal:Boolean  [read-only]

Determines if the interval is horizontal.


Implementation
    public function get horizontal():Boolean
scopeproperty 
scope:Number  [read-only]

Returns the slope of the line segment.


Implementation
    public function get scope():Number
secondEndPointproperty 
secondEndPoint:YPoint  [read-only]

Returns the second end point of the line segment.


Implementation
    public function get secondEndPoint():YPoint
verticalproperty 
vertical:Boolean  [read-only]

Returns if this segment is considered vertical, i.e. the x values of the end point differ less then 0.00000001


Implementation
    public function get vertical():Boolean
xOffsetproperty 
xOffset:Number  [read-only]

Returns the y value of the line on x coordinate 0.


Implementation
    public function get xOffset():Number
Constructor Detail
LineSegment()Constructor
public function LineSegment(p1:YPoint, p2:YPoint, init:Boolean = true)

Returns a new LineSegment.

Parameters
p1:YPoint — the first end point of the line segment.
 
p2:YPoint — the second end point of the line segment.
 
init:Boolean (default = true) — An internally used switch to help handle proper instance initialization in inheritance chains where classes can have multiple constructor-like factory methods. This parameter can safely be ignored/omitted when calling the constructor.
Method Detail
boxIntersectsSegment()method
public static function boxIntersectsSegment(box:YRectangle, s:YPoint, t:YPoint):Boolean

Checks whether a line segment intersects a box.

Parameters

box:YRectangle — A rectangle.
 
s:YPoint — first end point of the line segment.
 
t:YPoint — second end point of the line segment.

Returns
Booleantrue if the line segments intersects the box, false otherwise.
boxIntersectsSegment2()method 
public static function boxIntersectsSegment2(box:YRectangle, x1:Number, y1:Number, x2:Number, y2:Number):Boolean

Checks whether a line segment intersects a box. Implemented using the Cohen-Sutherland algorithm.

Parameters

box:YRectangle — A rectangle
 
x1:Number — x-coordinate of the first end point of the line segment
 
y1:Number — y-coordinate of the first end point of the line segment
 
x2:Number — x-coordinate of the second end point of the line segment
 
y2:Number — y-coordinate of the second end point of the line segment

Returns
Booleantrue if the line segment intersects the box, false otherwise.
boxIntersectsSegment3()method 
public static function boxIntersectsSegment3(boxX1:Number, boxY1:Number, boxX2:Number, boxY2:Number, sX1:Number, sY1:Number, sX2:Number, sY2:Number):Boolean

Checks whether a line segment intersects a paraxial box. Implemented using the Cohen-Sutherland algorithm.

Parameters

boxX1:Number — x-coordinate of the upper left corner of the box
 
boxY1:Number — y-coordinate of the upper left corner of the box
 
boxX2:Number — x-coordinate of the lower right corner of the box
 
boxY2:Number — y-coordinate of the lower right corner of the box
 
sX1:Number — x-coordinate of the first end point of the line segment
 
sY1:Number — y-coordinate of the first end point of the line segment
 
sX2:Number — x-coordinate of the second end point of the line segment
 
sY2:Number — y-coordinate of the second end point of the line segment

Returns
Booleantrue if the line segment intersects the box, false otherwise.
contains()method 
public function contains(point:YPoint):Boolean

Checks whether a given point lies on this line segment.

Parameters

point:YPoint — an arbitrary point.

Returns
Booleantrue if the line segments intersects the box, false otherwise.
getClass()method 
override public function getClass():Class

Returns
Class
getIntersection()method 
public static function getIntersection(s1:LineSegment, s2:LineSegment):YPoint

Returns intersection point between the two line segments, if there is one or null if the two line segments do not intersect.

Parameters

s1:LineSegment — first line segment
 
s2:LineSegment — second line segment

Returns
YPoint
initLineSegment()method 
protected final function initLineSegment(p1:YPoint, p2:YPoint):void

Initializes this object. See the documentation of the corresponding factory method newLineSegment() for details.

Parameters

p1:YPoint
 
p2:YPoint

See also

intersectsPoint()method 
public function intersectsPoint(p:YPoint):Boolean

Checks whether the line segment intersects a point.

Parameters

p:YPoint — a point

Returns
Booleantrue if the line segments intersects the given point, false otherwise.
intersectsRectangle()method 
public function intersectsRectangle(box:YRectangle):Boolean

Checks whether the line segment intersects a box.

Parameters

box:YRectangle — A rectangle.

Returns
Booleantrue if the line segments intersects the box, false otherwise.
isInXIntervall()method 
public function isInXIntervall(x:Number):Boolean

Returns if the projection on the X axis of the line segment covers a certain point on the X Axis.

Parameters

x:Number

Returns
Boolean
isInYIntervall()method 
public function isInYIntervall(y:Number):Boolean

Returns if the projection on the Y axis of the line segment covers a certain point on the Y Axis.

Parameters

y:Number

Returns
Boolean
length()method 
public function length():Number

Returns the length of the line segment, this is the value of the Euclidean norm.

Returns
Number — an value > 0.
newLineSegment()method 
public static function newLineSegment(p1:YPoint, p2:YPoint):LineSegment

Returns a new LineSegment.

Parameters

p1:YPoint — the first end point of the line segment.
 
p2:YPoint — the second end point of the line segment.

Returns
LineSegment
toAffineLine()method 
public function toAffineLine():AffineLine

Returns the affine line defined by the end points of the line segment.

Returns
AffineLine
toString()method 
public function toString():String

String representation of the line.

Returns
String
toYVector()method 
public function toYVector():YVector

Returns the vector pointing from the first end point to the second end point of the line segment.

Returns
YVector