Margin class

A Margin represents a band of space outside or inside a rectangular area, with possibly different values on each of the four sides.

Example uses include GraphObject#margin, Panel#padding, and Diagram#padding.

Use the static functions Margin.parse and Margin.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 Margin.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.

Available extensions
Annotations
  • @JS()
  • @staticInterop

Constructors

Margin([num? t, num? r, num? b, num? l])
factory

Properties

bottom num

Available on Margin, provided by the Margin$Typings extension

Gets or sets the bottom value of this margin. Default is 0.
getter/setter pair
hashCode int
The hash code for this object.
no setterinherited
left num

Available on Margin, provided by the Margin$Typings extension

Gets or sets the left value of this margin. Default is 0.
getter/setter pair

Available on Margin, provided by the Margin$Typings extension

Gets or sets the right value of this margin. Default is 0.
getter/setter pair
runtimeType Type
A representation of the runtime type of the object.
no setterinherited
top num

Available on Margin, provided by the Margin$Typings extension

Gets or sets the top value of this margin. Default is 0.
getter/setter pair

Methods

copy() Margin

Available on Margin, provided by the Margin$Typings extension

Create a copy of this Margin, with the same values. @expose @return {Margin}
equals(Margin m) bool

Available on Margin, provided by the Margin$Typings extension

Indicates whether the given Margin is equal to this Margin. @param {Margin} m The Margin to compare to this Margin. @return {boolean} True if the two Margins have identical Top and Right and Bottom and Left values, false otherwise. @see #equalTo
equalsApprox(Margin m) bool

Available on Margin, provided by the Margin$Typings extension

(undocumented) True when the given Margin is nearly equal to this Margin. @param {Margin} m The Margin to compare to the current Margin. @return {boolean} True if the two Margins have Top, Right, Bottom and Left values within 0.5, false otherwise.
equalTo(num t, num r, num b, num l) bool

Available on Margin, provided by the Margin$Typings extension

Indicates whether the given margin is equal to this Margin. @param {number} t top. @param {number} r right. @param {number} b bottom. @param {number} l left. @return {boolean} True if the two Margins have identical Top and Right and Bottom and Left values, false otherwise. @see #equals
isReal() bool

Available on Margin, provided by the Margin$Typings extension

True if this Margin has values that are real numbers and not infinity. @return {boolean}
noSuchMethod(Invocation invocation) → dynamic
Invoked when a nonexistent method or property is accessed.
inherited
set(Margin m) Margin

Available on Margin, provided by the Margin$Typings extension

Modify this Margin so that its Top, Right, Bottom, and Left values are the same as the given Margin. @param {Margin} m the given Margin. @return {Margin} this.
setTo(num t, num r, num b, num l) Margin

Available on Margin, provided by the Margin$Typings extension

Modify this Margin with new Top, Right, Bottom, and Left values. @param {number} t top. @param {number} r right. @param {number} b bottom. @param {number} l left. @return {Margin} this.
toString() String
A string representation of this object.
inherited

Operators

operator ==(Object other) bool
The equality operator.
inherited

Static Methods

alloc() Margin
free(Margin temp) → void
parse(String str) Margin
This static function can be used to read in a Margin from a string that was produced by Margin.stringify.
stringify(Margin val) String
This static function can be used to write out a Margin as a string that can be read by Margin.parse.