Options
Public/Protected
  • Public
  • Public/Protected
  • All
Menu

GoJS API 文档

Hierarchy

  • 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.

Index

Constructors

constructor

  • new Spot(x?: number, y?: number, offx?: number, offy?: number): Spot
  • The default constructor produces the Spot(0, 0, 0, 0), at the top-left corner.

    Parameters

    • Optional x: number

      The x value of the Spot. Default is zero.

    • Optional y: number

      The y value of the Spot. Default is zero.

    • Optional offx: number

      (Optional) The absolute x offset. Default is zero.

    • Optional offy: number

      (Optional) The absolute y offset. Default is zero.

    Returns Spot

Properties

offsetX : number

  • Gets or sets the offsetX value of the Spot. 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.

offsetY : number

  • Gets or sets the offsetY value of the Spot. 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.

x : number

  • Gets or sets the x value of the Spot, a fractional value between zero and one.

    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.

y : number

  • Gets or sets the y value of the Spot, a fractional value between zero and one.

    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.

Methods

Virtual copy

  • Create a copy of this Spot, with the same values.

    Returns Spot

equals

  • equals(spot: Spot): boolean
  • Two spots are equal if all four property values are the same.

    Parameters

    • spot: Spot

      The Spot to compare to the current Spot.

    Returns boolean

    True if the two spots are equal, false otherwise.

includesSide

  • includesSide(side: Spot): boolean
  • This predicate is true if this Spot is a side that includes the side(s) given by the argument Spot.

    Parameters

    Returns boolean

    false if either this Spot or the argument Spot is not a "Side"; true if the side(s) that this Spot represents are a superset or the same set of sides represented by the argument Spot.

isDefault

  • isDefault(): boolean
  • True if this is a special spot indicating that the real spot value will come from another source.

    Returns boolean

isNoSpot

  • isNoSpot(): boolean
  • True if this is an unspecific special spot, such as Spot.None or one of the sides.

    Returns boolean

isNone

  • isNone(): boolean
  • True if this is a special spot referring to no particular spot or side.

    Returns boolean

isSide

  • isSide(): boolean
  • True if this is a special spot referring to one (or more) of the sides. This is false if the spot is Spot.None.

    Returns boolean

isSpot

  • isSpot(): boolean
  • True if this is a specific spot, not a side nor Spot.None.

    Returns boolean

opposite

  • Return a new spot that is opposite this spot. The X and Y values will be an equal distance away from the center on the other side of the center. The OffsetX and OffsetY values are also negated.

    The result is meaningless if isNoSpot is true.

    Returns Spot

Static parse

  • parse(str: string): Spot
  • This static function can be used to read in a Spot from a string that was produced by Spot.stringify.

    go.Spot.parse("0 1 2 3") produces the Spot new go.Spot(0, 1, 2, 3).

    Parameters

    • str: string

    Returns Spot

set

  • Modify this Spot so that its X, Y, OffsetX, and OffsetY values are the same as the given Spot.

    Parameters

    • s: Spot

      the given Spot.

    Returns Spot

    this.

setTo

  • setTo(x: number, y: number, offx: number, offy: number): Spot
  • Modify this Spot with new X, Y, OffsetX, and OffsetY values.

    Parameters

    • x: number
    • y: number
    • offx: number
    • offy: number

    Returns Spot

    this.

Static stringify

  • stringify(val: Spot): string
  • This static function can be used to write out a Spot as a string that can be read by Spot.parse.

    go.Spot.stringify(new go.Spot(0, 1, 2, 3)) produces the string "0 1 2 3".

    Parameters

    Returns string

Constants

Static AllSides : Spot

The set of points on all sides of the bounding rectangle.

Static Bottom : Spot

A synonym for Spot.BottomCenter.

Static BottomCenter : Spot

The specific point at the middle of the bottom side of bounding rectangle.

Static BottomLeft : Spot

The specific point at the bottom-left corner of the bounding rectangle.

Static BottomLeftSides : Spot

The set of points at the left or bottom sides of the bounding rectangle.

Static BottomRight : Spot

The specific point at the bottom-right corner of the bounding rectangle.

Static BottomRightSides : Spot

The set of points at the right or bottom sides of the bounding rectangle.

Static BottomSide : Spot

The set of points at the bottom side of the bounding rectangle.

Static Center : Spot

The specific point at the very center of the bounding rectangle.

Static Default : Spot

Use this value to indicate that the real spot value is inherited from elsewhere.

Static Left : Spot

A synonym for Spot.LeftCenter.

Static LeftCenter : Spot

The specific point at the middle of the left side of bounding rectangle.

Static LeftRightSides : Spot

The set of points at the left or right sides of the bounding rectangle.

Static LeftSide : Spot

The set of points at the left side of the bounding rectangle.

Static MiddleBottom : Spot

A synonym for Spot.BottomCenter.

Static MiddleLeft : Spot

A synonym for Spot.LeftCenter.

Static MiddleRight : Spot

A synonym for Spot.RightCenter.

Static MiddleTop : Spot

A synonym for Spot.TopCenter.

Static None : Spot

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.

Static NotBottomSide : Spot

The set of points on all sides of bounding rectangle except bottom side.

Static NotLeftSide : Spot

The set of points on all sides of the bounding rectangle except left side.

Static NotRightSide : Spot

The set of points on all sides of the bounding rectangle except right side.

Static NotTopSide : Spot

The set of points on all sides of the bounding rectangle except top side.

Static Right : Spot

A synonym for Spot.RightCenter.

Static RightCenter : Spot

The specific point at the middle of the right side of bounding rectangle.

Static RightSide : Spot

The set of points at the right side of the bounding rectangle.

Static Top : Spot

A synonym for Spot.TopCenter.

Static TopBottomSides : Spot

The set of points at the top or bottom sides of the bounding rectangle.

Static TopCenter : Spot

The specific point at the center of the top side of the bounding rectangle.

Static TopLeft : Spot

The specific point at the top-left corner of the bounding rectangle.

Static TopLeftSides : Spot

The set of points at the top or left sides of the bounding rectangle.

Static TopRight : Spot

The specific point at the top-right corner of the bounding rectangle.

Static TopRightSides : Spot

The set of points at the top or right sides of the bounding rectangle.

Static TopSide : Spot

The set of points at the top side of the bounding rectangle.

加入 GoJS 交流群
GoJS 交流群 (769862113)