Class Spot
A Spot represents a relative point from (0,0) to (1,1) within the bounds of a rectangular area plus an absolute offset.
Use the static functions Spot.parse and Spot.stringify to convert to and from a standard string representation that is independent of the current locale.
When an instance of this class is the value of a property of a GraphObject class or Diagram or CommandHandler or a Tool class, you should treat the object as if it were frozen or read-only -- you cannot modify its properties. This allows the property to return a value without allocating a new instance. If you need to do your own calculations with the value, call copy to make a new instance with the same values that you can modify.
Many methods modify the object's properties and then return a reference to "this" object. The only instance method to allocate a new object is the copy method. The static Spot.parse method also allocates a new object.
The "Debug" implementation of this class is significantly slower than the "Release" implementation, mostly due to additional error checking.
You cannot inherit from this class.
Constructor Summary Details
| Returns | Name | Description |
|---|---|---|
|
Spot(x, y, offx, offy)
|
The default constructor produces the Spot(0, 0, 0, 0), at the top-left corner. More...
|
Properties Summary Details
| Returns | Name | Description |
|---|---|---|
{number}
|
offsetX
|
Gets or sets the offsetX value of the Spot. More...
The value may be negative.
If this represents a side value instead of a specific spot, this value is meaningless.
A Spot(0,0,5,5) of a large rectangle is near the top-left corner, inside the rectangle. A Spot(1,1,5,5) would be near the bottom-right corner, outside the rectangle. A Spot(1,1,-5,-5) would also be near the bottom-right corner, but inside the rectangle. |
{number}
|
offsetY
|
Gets or sets the offsetY value of the Spot. More...
The value may be negative.
If this represents a side value instead of a specific spot, this value is meaningless.
A Spot(0,0,5,5) of a large rectangle is near the top-left corner, inside the rectangle. A Spot(1,1,5,5) would be near the bottom-right corner, outside the rectangle. A Spot(1,1,-5,-5) would also be near the bottom-right corner, but inside the rectangle. |
{number}
|
x
|
Gets or sets the x value of the Spot, a fractional value between zero and one. More...
The Spot(0,0) of a rectangle is at the top-left corner. This value is commonly available as Spot.TopLeft. The Spot(0.5,1) would be at the middle of the bottom side. That value is commonly available as Spot.MiddleBottom. |
{number}
|
y
|
Gets or sets the y value of the Spot, a fractional value between zero and one. More...
The Spot(0,1) of a rectangle is at the bottom-left corner. This value is commonly available as Spot.BottomLeft. The Spot(1,0.5) would be at the middle of the right side. That value is commonly available as Spot.MiddleRight. |
Method Summary Details
| Returns | Name | Description |
|---|---|---|
{Spot}
|
copy()
|
Create a copy of this Spot, with the same values.
|
{boolean}
|
equals(spot)
|
|
{boolean}
|
includesSide(side)
|
This predicate is true if this Spot is a side that
includes the side(s) given by the argument Spot. More...
|
{boolean}
|
isDefault()
|
True if this is a special spot referring to the default spot.
|
{boolean}
|
isNoSpot()
|
True if this is an unspecific special spot, such as Spot.None
or one of the sides.
|
{boolean}
|
isSide()
|
|
{boolean}
|
isSpot()
|
True if this is a specific spot, not a side nor Spot.None.
|
{Spot}
|
opposite()
|
|
<static>
{Spot}
|
Spot.parse(str)
|
This static function can be used to read in a Spot from a string that was produced by Spot.stringify. More...
|
{Spot}
|
set(s)
|
|
{Spot}
|
setTo(x, y, offx, offy)
|
|
<static>
{string}
|
Spot.stringify(val)
|
This static function can be used to write out a Spot as a string that can be read by Spot.parse. More...
|
Constants Summary Details
| Returns | Name | Description |
|---|---|---|
| <constant> {Spot} |
AllSides
|
The set of points on all sides of the bounding rectangle.
|
| <constant> {Spot} |
Bottom
|
A synonym for Spot.BottomCenter.
|
| <constant> {Spot} |
BottomCenter
|
The specific point at the middle of the bottom side of bounding rectangle.
|
| <constant> {Spot} |
BottomLeft
|
The specific point at the bottom-left corner of the bounding rectangle.
|
| <constant> {Spot} |
BottomLeftSides
|
The set of points at the left or bottom sides of the bounding rectangle.
|
| <constant> {Spot} |
BottomRight
|
The specific point at the bottom-right corner of the bounding rectangle.
|
| <constant> {Spot} |
BottomRightSides
|
The set of points at the right or bottom sides of the bounding rectangle.
|
| <constant> {Spot} |
BottomSide
|
The set of points at the bottom side of the bounding rectangle.
|
| <constant> {Spot} |
Center
|
The specific point at the very center of the bounding rectangle.
|
| <constant> {Spot} |
Default
|
Use this value to indicate that the real spot value is inherited from elsewhere.
|
| <constant> {Spot} |
Left
|
A synonym for Spot.LeftCenter.
|
| <constant> {Spot} |
LeftCenter
|
The specific point at the middle of the left side of bounding rectangle.
|
| <constant> {Spot} |
LeftRightSides
|
The set of points at the left or right sides of the bounding rectangle.
|
| <constant> {Spot} |
LeftSide
|
The set of points at the left side of the bounding rectangle.
|
| <constant> {Spot} |
MiddleBottom
|
A synonym for Spot.BottomCenter.
|
| <constant> {Spot} |
MiddleLeft
|
A synonym for Spot.LeftCenter.
|
| <constant> {Spot} |
MiddleRight
|
A synonym for Spot.RightCenter.
|
| <constant> {Spot} |
MiddleTop
|
A synonym for Spot.TopCenter.
|
| <constant> {Spot} |
None
|
Use this Spot value to indicate no particular spot --
code looking for a particular point on an element will need to do their
own calculations to determine the desired point depending on the
circumstances.
|
| <constant> {Spot} |
NotBottomSide
|
The set of points on all sides of bounding rectangle except bottom side.
|
| <constant> {Spot} |
NotLeftSide
|
The set of points on all sides of the bounding rectangle except left side.
|
| <constant> {Spot} |
NotRightSide
|
The set of points on all sides of the bounding rectangle except right side.
|
| <constant> {Spot} |
NotTopSide
|
The set of points on all sides of the bounding rectangle except top side.
|
| <constant> {Spot} |
Right
|
A synonym for Spot.RightCenter.
|
| <constant> {Spot} |
RightCenter
|
The specific point at the middle of the right side of bounding rectangle.
|
| <constant> {Spot} |
RightSide
|
The set of points at the right side of the bounding rectangle.
|
| <constant> {Spot} |
Top
|
A synonym for Spot.TopCenter.
|
| <constant> {Spot} |
TopBottomSides
|
The set of points at the top or bottom sides of the bounding rectangle.
|
| <constant> {Spot} |
TopCenter
|
The specific point at the center of the top side of the bounding rectangle.
|
| <constant> {Spot} |
TopLeft
|
The specific point at the top-left corner of the bounding rectangle.
|
| <constant> {Spot} |
TopLeftSides
|
The set of points at the top or left sides of the bounding rectangle.
|
| <constant> {Spot} |
TopRight
|
The specific point at the top-right corner of the bounding rectangle.
|
| <constant> {Spot} |
TopRightSides
|
The set of points at the top or right sides of the bounding rectangle.
|
| <constant> {Spot} |
TopSide
|
The set of points at the top side of the bounding rectangle.
|