Packagecom.yworks.yfiles.geom
Classpublic class YPoint
InheritanceYPoint Inheritance YObject Inheritance Object
Implements Comparable

This class represents a point in the plane with double coordinates. This class implements the immutable design pattern.



Public Properties
 PropertyDefined By
  x : Number
[read-only] Returns the x-coordinate of the point object.
YPoint
  y : Number
[read-only] Returns the y-coordinate of the point object.
YPoint
Public Methods
 MethodDefined By
  
YPoint(x:Number, y:Number, init:Boolean = true)
Creates a new YPoint object for a given position.
YPoint
  
[static] Adds two points and returns the result.
YPoint
  
compareTo(o:Object):int
Comparable implementation.
YPoint
  
distance(p1:YPoint, p2:YPoint):Number
[static] Returns the euclidean distance between two points.
YPoint
  
distance2(x1:Number, y1:Number, x2:Number, y2:Number):Number
[static] Returns the euclidean distance between two points.
YPoint
  
distanceTo(p:YPoint):Number
Returns the euclidean distance between this point and a given point.
YPoint
  
distanceTo2(x:Number, y:Number):Number
Returns the euclidean distance between this point and a given point.
YPoint
  
equals(o:Object):Boolean
[override] Tests a point to equality to another point.
YPoint
  
getClass():Class
[override]
YPoint
  
hashCode():int
[override]
YPoint
  
[static] Returns a point that geometrically lies in in the middle of the line formed by the given points.
YPoint
  
moveBy(x:Number, y:Number):YPoint
Returns the point, got by moving this point to another position.
YPoint
  
[static] Creates a new YPoint at location (0,0)
YPoint
  
newYPoint2(x:Number, y:Number):YPoint
[static] Creates a new YPoint object for a given position.
YPoint
  
[static] Subtracts two points (p1 - p2) and returns the result.
YPoint
  
[static] Returns a copy of the given point with exchanged x- and y-coordinates.
YPoint
  
toString():String
Returns the coordinates of the point as string.
YPoint
Protected Methods
 MethodDefined By
  
Initializes this object.
YPoint
  
initYPoint2(x:Number, y:Number):void
Initializes this object.
YPoint
Public Constants
 ConstantDefined By
  ORIGIN : YPoint
[static] A YPoint constant with coordinates (0,0).
YPoint
Property Detail
xproperty
x:Number  [read-only]

Returns the x-coordinate of the point object.


Implementation
    public function get x():Number
yproperty 
y:Number  [read-only]

Returns the y-coordinate of the point object.


Implementation
    public function get y():Number
Constructor Detail
YPoint()Constructor
public function YPoint(x:Number, y:Number, init:Boolean = true)

Creates a new YPoint object for a given position.

Parameters
x:Number — the x coordinate of the point.
 
y:Number — the y coordinate of the point.
 
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
add()method
public static function add(p1:YPoint, p2:YPoint):YPoint

Adds two points and returns the result.

Parameters

p1:YPoint — an arbitrary instance of YPoint.
 
p2:YPoint — an arbitrary instance of YPoint.

Returns
YPoint
compareTo()method 
public function compareTo(o:Object):int

Comparable implementation. YPoints are ordered by ascending x-coordinates. If the x-coordinates of two points equal, then these points are ordered by ascending y-coordinates.

Parameters

o:Object

Returns
int
distance()method 
public static function distance(p1:YPoint, p2:YPoint):Number

Returns the euclidean distance between two points.

Parameters

p1:YPoint — an arbitrary point
 
p2:YPoint — an arbitrary point

Returns
Number — the Euclidean distance between p1 and p2.
distance2()method 
public static function distance2(x1:Number, y1:Number, x2:Number, y2:Number):Number

Returns the euclidean distance between two points.

Parameters

x1:Number — x-coordinate of first point
 
y1:Number — y-coordinate of first point
 
x2:Number — x-coordinate of second point
 
y2:Number — y-coordinate of second point

Returns
Number — the euclidean distance between first and second point
distanceTo()method 
public function distanceTo(p:YPoint):Number

Returns the euclidean distance between this point and a given point.

Parameters

p:YPoint — an arbitrary point

Returns
Number — the Euclidean distance between this point and p.
distanceTo2()method 
public function distanceTo2(x:Number, y:Number):Number

Returns the euclidean distance between this point and a given point.

Parameters

x:Number — the x coordinate of an arbitrary point
 
y:Number — the y coordinate of an arbitrary point

Returns
Number — the Euclidean distance between this point and the point (x,y).
equals()method 
override public function equals(o:Object):Boolean

Tests a point to equality to another point. This test returns true if the o is also an instance of YPoint and has the same coordinates as the instance on which equals is invoked.

Parameters

o:Object — an arbitrary instance.

Returns
Boolean
getClass()method 
override public function getClass():Class

Returns
Class
hashCode()method 
override public function hashCode():int

Returns
int
initYPoint1()method 
protected final function initYPoint1():void

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

See also

initYPoint2()method 
protected final function initYPoint2(x:Number, y:Number):void

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

Parameters

x:Number
 
y:Number

See also

midPoint()method 
public static function midPoint(p1:YPoint, p2:YPoint):YPoint

Returns a point that geometrically lies in in the middle of the line formed by the given points.

Parameters

p1:YPoint — an arbitrary instance of YPoint.
 
p2:YPoint — an arbitrary instance of YPoint.

Returns
YPoint
moveBy()method 
public function moveBy(x:Number, y:Number):YPoint

Returns the point, got by moving this point to another position.

Parameters

x:Number — the value which is added on the x-coordinate of the point.
 
y:Number — the value which is added on the y-coordinate of the point.

Returns
YPoint — a new instance of YPoint which is the result of the moving operation.
newYPoint1()method 
public static function newYPoint1():YPoint

Creates a new YPoint at location (0,0)

Returns
YPoint
newYPoint2()method 
public static function newYPoint2(x:Number, y:Number):YPoint

Creates a new YPoint object for a given position.

Parameters

x:Number — the x coordinate of the point.
 
y:Number — the y coordinate of the point.

Returns
YPoint
subtract()method 
public static function subtract(p1:YPoint, p2:YPoint):YPoint

Subtracts two points (p1 - p2) and returns the result.

Parameters

p1:YPoint — an arbitrary instance of YPoint.
 
p2:YPoint — an arbitrary instance of YPoint.

Returns
YPoint
swap()method 
public static function swap(p:YPoint):YPoint

Returns a copy of the given point with exchanged x- and y-coordinates.

Parameters

p:YPoint — an arbitrary instance of YPoint.

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

Returns the coordinates of the point as string.

Returns
String
Constant Detail
ORIGINConstant
public static const ORIGIN:YPoint

A YPoint constant with coordinates (0,0).