Structures

RenderEventArgs

This is object parameter of rendering callback function

primitives.common.RenderEventArgs

Properties

NameTypeDefaultDescription
contextobjectnullContext object of the node
elementobjectnullReference to DOM element.
idstringnullNode id
isCursorbooleanfalseThe rendered item is current diagram cursor item
isSelectedbooleanfalseThe rendered item is selected
renderingModeRenderingModenullThis option indicates current template state.
templateNamestringnullNode template name

Point

Class represents pair of x and y coordinates that define a point in 2D plane.

primitives.common.Point

Constructor

Point(arg0, arg1)

Class represents pair of x and y coordinates that define a point in 2D plane.

ParamTypeDefaultDescription
arg0SizePoint object to clone.
arg0numberThe x coordinate.
arg1numberThe y coordinate.

Properties

NameTypeDefaultDescription
contextobjectnullReference to the context object associated with this point.
xnumbernullThe x coordinate
ynumbernullThe y coordinate

Functions

clone()

Clones the point

Returns: Point - returns copy of the point.

distanceTo(arg0, arg1)

Calculates distance to the specified point

Returns: number - returns distance to the specified point

ParamTypeDefaultDescription
arg0PointPoint
arg0numberX coordinate
arg1numberY coordinate

equalTo(point)

Checks if points are equal

Returns: boolean - returns true if points are equal.

ParamTypeDefaultDescription
pointPointPoint

getCSS(units)

Returns size in form of CSS style object.

Returns: object - css style object

ParamTypeDefaultDescription
unitsstring"px"The string name of units.

scale(scale)

Scales the point location by the specified value

Returns: Point - returns reference to the current point.

ParamTypeDefaultDescription
scalenumberscale

swap(point)

Swaps values of 2 points

ParamTypeDefaultDescription
pointPointThe point to swap values with

toString(units)

Returns point in form of CSS style string.

Returns: string - css style string.

ParamTypeDefaultDescription
unitsstring"px"The string name of units.

Rect

Class describes the width, height and location of rectangle.

primitives.common.Rect

Constructor

Rect(arg0, arg1, arg2, arg3)

Class describes the width, height and location of rectangle.

ParamTypeDefaultDescription
arg0RectRectangle to clone.
arg0PointThe top left point.
arg1PointThe bottom right point.
arg0numberThe x coordinate of top left corner.
arg1numberThe y coordinate of top left corner.
arg2numberRect width.
arg3numberRect height.

Properties

NameTypeDefaultDescription
contextobjectnullReference to context object associated with this rectangle.
heightnumbernullThe height of rectangle.
widthnumbernullThe width of rectangle.
xnumbernullThe location x coordinate
ynumbernullThe location y coordinate

Functions

addRect(arg0, arg1, arg2, arg3)

Expands the rectangle boundaries to contain the specified rectangle.

Returns: Rect - returns reference to the current rectangle.

ParamTypeDefaultDescription
arg0RectThe rectangle to contain.
arg0numberThe x coordinate of top left corner.
arg1numberThe y coordinate of top left corner.
arg2numberundefinedWidth.
arg3numberundefinedHeight.

bottom()

Bottom

Returns: number - returns y-axis coordinate of the bottom side of the rectangle

centerPoint()

Center point

Returns: Point - returns center point of the rectangle.

contains(arg0, arg1)

Checks if the rectangle contains given point

Returns: boolean - returns true if the rectangle contains the specified point; otherwise, false.

ParamTypeDefaultDescription
arg0PointThe point to check.
arg0numberThe x coordinate of the point to check.
arg1numberThe y coordinate of the point to check.

cropByRect(rect)

Crops the rectangle by the boundaries of the specified rectangle.

Returns: Rect - returns reference to the current rectangle.

ParamTypeDefaultDescription
rectRectThe rectangle that is used to crop boundaries by

equalTo(rect)

Checks if rectangles are equal

Returns: boolean - returns true if rectangles are equal.

ParamTypeDefaultDescription
rectRectRectangle

getCSS(units)

Returns rectangle location and size in form of CSS style object.

Returns: object - css style object

ParamTypeDefaultDescription
unitsstring"px"The string name of units.

horizontalCenter()

Horizontal center

Returns: number - returns x-axis coordinate of the center point of the rectangle.

invert()

Inverts rectangle coordinates

Returns: Rect - returns reference to the current rectangle.

isEmpty()

Checks if rectangle is empty. Rectangle is empty if one of its sizes is undefined or less than zero.

Returns: boolean - returns true if rectangle is empty.

left()

Left

Returns: number - returns x coordinate of the rectangle

loopEdges(callback)

Loops edges of the rectangle in the clockwise order: Top, Right, Bottom, Left

Returns: Rect - returns reference to the current rectangle.

ParamTypeDefaultDescription
callbackloopRectEdgesCallbackA callback function to iterate over sides of the rectangle.

Callbacks

loopRectEdgesCallback(vector, placementType)

Callback for iterating rectangle's sides

Returns: boolean - returns true to break iteration process

ParamTypeDefaultDescription
vectorVectorVector connecting two corners of the rectangle's side
placementTypePlacementTypeThe current side

offset(arg0, arg1, arg2, arg3)

Expands rectangle boundaries by using specified value in all directions. Value can be negative.

ParamTypeDefaultDescription
arg0numberThe amount by which to expand or shrink the sides of the rectangle.
arg0numberLeft side
arg1numberTop side
arg2numberRight side
arg3numberBottom side

overlaps(rect)

Checks if the rectangle overlaps the specified rectangle

Returns: boolean - returns true if two rectangles overlap each other.

ParamTypeDefaultDescription
rectRectThe rectangle to check overlaping for.

right()

Right

Returns: number - returns x-axis coordinate of the right side of the rectangle

scale(scale)

Scales the rectangle by the specified value

Returns: Rect - returns reference to the current rectangle.

ParamTypeDefaultDescription
scalenumberscale

toString(units)

Returns rectangle location and size in form of CSS style string.

Returns: string - css style string.

ParamTypeDefaultDescription
unitsstring"px"The string name of units.

top()

Top

Returns: number - returns y coordinate of the rectangle

translate(x, y)

Moves the rectangle by the specified horizontal and vertical offsets.

Returns: Rect - returns reference to the current rectangle.

ParamTypeDefaultDescription
xnumberHorizontal offset
ynumberVertical offset

validate()

Validates rectangle properties

Returns: boolean - returns true if rectangle properties are valid.

verticalCenter()

Vertical center

Returns: number - returns y-axis coordinate of the center point of the rectangle.

Matrix

Square matrix having 2 rows and 2 columns.

primitives.common.Matrix

Constructor

Matrix(arg0, arg1, arg2, arg3)

Square matrix having 2 rows and 2 columns.

ParamTypeDefaultDescription
arg0MatrixMatrix to clone
arg0numberA1 - top left.
arg1numberB1 - top right.
arg2numberA2 - bottom left.
arg3numberB2 - bottom right.

Functions

determinant()

Finds matrix determinant

Returns: number - returns matrix determinant

Size

Size object defines width and height.

primitives.common.Size

Constructor

Size(arg0, arg1)

Size object defines width and height.

ParamTypeDefaultDescription
arg0SizeSize object to clone.
arg0numberWidth.
arg1numberHeight.

Properties

NameTypeDefaultDescription
heightnumber0The height
widthnumber0The width

Functions

addSize(size)

Extends the current size by the other size.

Returns: Size - returns reference to the current size object

ParamTypeDefaultDescription
sizeSizeThe size to use as extension.

cropBySize(size)

Crops the size by the other size object.

Returns: Size - returns reference to the current size object

ParamTypeDefaultDescription
sizeSizeThe size to use as the crop boundaries.

getCSS(units)

Returns size in form of CSS style object.

Returns: object - css style object

ParamTypeDefaultDescription
unitsstring"px"The string name of units.

invert()

Inverts size dimensions

Returns: Size - returns reference to the current size.

scale(scale)

Scales the size by the specified value

Returns: Size - returns reference to the current size.

ParamTypeDefaultDescription
scalenumberscale

validate()

Validates size properties

Returns: boolean - returns true if size properties are valid.

Thickness

Class describes the thickness of a frame around rectangle.

primitives.common.Thickness

Constructor

Thickness(left, top, right, bottom)

Class describes the thickness of a frame around rectangle.

ParamTypeDefaultDescription
leftnumberLeft.
topnumberTop.
rightnumberRight.
bottomnumberBottom.

Properties

NameTypeDefaultDescription
bottombottomThe thickness for the bottom side of the rectangle.
leftleftThe thickness for the left side of the rectangle.
rightrightThe thickness for the right side of the rectangle.
toptopThe thickness for the upper side of the rectangle.

Functions

isEmpty()

Checks object is empty

Returns: boolean - returns true if object has no thickness defined for any of its sides

toString(units)

Returns thickness object in form of CSS style string. It is conversion to padding style string.

Returns: string - css style string.

ParamTypeDefaultDescription
unitsstring"px"The string name of units.

Vector

Class defines a vector in 2D plane.

primitives.common.Vector

Constructor

Vector(arg0, arg1)

Class defines a vector in 2D plane.

ParamTypeDefaultDescription
arg0VectorVector object to clone.
arg0PointFrom point.
arg1PointTo point

Properties

NameTypeDefaultDescription
contextobjectnullReference to context object associated with this vector.
fromnullThe start point
tonullThe end point

Functions

equalTo(vector)

Checks if vectors are equal

Returns: boolean - returns true if vectors are equal.

ParamTypeDefaultDescription
vectorVectorVector

getIntersectionPoint(vector, strict, rounding)

Finds intersection point of two vectors

Returns: Point|null - returns intersection point or null if intersection does not exists

ParamTypeDefaultDescription
vectorVectorThe vector to find intersection with
strictbooleanIf true then intersection point should belong to both vectors
roundingnumberThe precision of calculations

getLine()

Gets line

Returns: number[] - returns line coefficients

getLineKey()

Gets line key

Returns: string - returns unique line key

getMiddlePoint()

Returns middle point of the current vector

Returns: Point - returns middle point

intersect(vector)

Checks if two vectors have intersection point

Returns: boolean - returns true if vectors intersect

ParamTypeDefaultDescription
vectorvectorThe vector to check intersection with

isNull()

Checks if start and end points are the same

Returns: boolean - returns true if start and end points are the same.

length()

Vector length

Returns: number - returns vector length

offset(offset)

Offsets vector coordinates

ParamTypeDefaultDescription
offsetnumberOffset

relateTo(vector)

Finds how two vectors relate to each other

Returns: VectorRelationType - returns how the vector relates to the specified vector

ParamTypeDefaultDescription
vectorVectorThe vector to relate with
Have questions? Ask for help on Github.