- Home
- Learn
- Samples
- Intro
- API
- Register
- Download
- Forum
- Contact
- Buy
- Activate

GoJS Class Index

## Diagram Classes

- Adornment
- AnimationManager
- CommandHandler
- Diagram
- DiagramEvent
- GraphObject
- Group
- InputEvent
- Layer
- Link
- Node
- Overview
- Palette
- Panel
- Part
- Picture
- Placeholder
- RowColumnDefinition
- Shape
- TextBlock

## Geometry Classes

- Brush
- Geometry
- Margin
- PathFigure
- PathSegment
- Point
- Rect
- Size
- Spot

## Model Classes

- Binding
- ChangedEvent
- GraphLinksModel
- Model
- Transaction
- TreeModel
- UndoManager

## Layout Classes

- CircularLayout
- ForceDirectedLayout
- GridLayout
- LayeredDigraphLayout
- Layout
- LayoutNetwork
- TreeLayout

## Tool Classes

- ActionTool
- ClickCreatingTool
- ClickSelectingTool
- ContextMenuTool
- DraggingTool
- DragSelectingTool
- LinkingBaseTool
- LinkingTool
- LinkReshapingTool
- PanningTool
- RelinkingTool
- ResizingTool
- RotatingTool
- TextEditingTool
- Tool
- ToolManager

## Collection Classes

- Iterable
- Iterator
- List
- Map
- Set

GoJS® Diagramming Components
version 1.5.20 for JavaScript/HTML
by Northwoods Software®

# Class Size

A Size describes a width and a height in two-dimensional coordinates. The width and height must both be non-negative.

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

Size(w, h)

The default constructor produces the Size(0,0). More... This constructor may take either zero arguments or two arguments.

Parameters:
{number=} w
  The initial width (must be non-negative).
{number=} h
  The initial height (must be non-negative).

## Properties Summary Details

Returns | Name | Description
--- | --- | ---
{number} | height | Gets or sets the height value of the Size. More... The value must not be negative.
{number} | width | Gets or sets the width value of the Size. More... The value must not be negative.

## Method Summary Details

Returns | Name | Description
--- | --- | ---

{Size}

copy()

Create a copy of this Size, with the same values.

Returns:
{Size}

{boolean}

equals(s)

Indicates whether the given Size is equal to the current Size. More... See also:

- equalTo

Parameters:
{Size} s
  The Size to compare to the current Size.

Returns:
{boolean} True if the Sizes have the same width and height, false otherwise.

{boolean}

equalTo(w, h)

Indicates whether the given size is equal to this Size. More... See also:

- equals

Parameters:
{number} w
  the width.
{number} h
  the height.

Returns:
{boolean} True if the Sizes have the same width and height, false otherwise.

{boolean}

isReal()

True if this Size has Width and Height values that are real numbers and not infinity.

Returns:
{boolean}

<static> {Size}

Size.parse(str)

This static function can be used to read in a Size from a string that was produced by Size.stringify. More...

`go.Size.parse("1 2")` produces the Size `new go.Size(1, 2)`.

Parameters:
{string} str

Returns:
{Size}

{Size}

set(s)

Modify this Size so that its Width and Height values are the same as the given Size. More...

Parameters:
{Size} s
  the given Size.

Returns:
{Size} this.

{Size}

setTo(w, h)

Modify this Size with new Width and Height values. More...

Parameters:
{number} w
  the width.
{number} h
  the height.

Returns:
{Size} this.

<static> {string}

Size.stringify(val)

This static function can be used to write out a Size as a string that can be read by Size.parse. More...

`go.Size.stringify(new go.Size(1, 2))` produces the string "1 2".

Parameters:
{Size} val

Returns:
{string}