C

NodeReshapeHandleProvider

Default implementation of the IReshapeHandleProvider interface for nodes.

Remarks

The actual reshaping is delegated to an IReshapeHandler.

Examples

Decorate lookup to customize node resizing
// decorate reshape handle provider
const nodeDecorator = graphComponent.graph.decorator.nodes
nodeDecorator.reshapeHandleProvider.addFactory((node) => {
  // lookup the reshape handler that performs the actual resizing
  const reshapeHandler = node.lookup(IReshapeHandler) as IReshapeHandler
  // create a provider for handles at the node corners
  const handleProvider = new NodeReshapeHandleProvider(
    node,
    reshapeHandler,
    HandlePositions.CORNERS,
  )
  // use a different reshape policy
  handleProvider.reshapePolicy = ReshapePolicy.MAXIMUM
  return handleProvider
})

Members

Show:

Constructors

Creates a default instance that provides handles for each of the handlePositions given for the node.

Parameters

node: INode
The node to provide reshape handles for.
reshapeHandler: IReshapeHandler
The reshape handler to delegate the actual reshaping to.
handlePositions: HandlePositions
A bitwise combination of all handle positions this instance should provide a handle for.

Properties

Gets or sets the event recognizer that determines if the center of the reshapeable is kept during the reshape gesture.
The default detects the current platform and delegates either to META_IS_DOWN (macOS) or CTRL_IS_DOWN (other platforms).
final

Examples

Always keeping the node center
// always keep the center of the node
provider.centerReshapeRecognizer = EventRecognizers.ALWAYS

See Also

API
ratioReshapeRecognizer
Gets or sets the bitwise combination of all handle positions this instance provides a handle for.
Gets or sets the maximal bounds this reshapeable may fill.
The value is stored by reference. The default is INFINITE, which does not restrict the area at all.
conversionfinal
Gets or sets the maximum size allowed for the reshapeable.
The default value is INFINITE.
conversion

Property Value

The maximum size.

See Also

API
maximumSize
Gets or sets the minimum rectangular area that needs to be contained in the reshapeable.
The default value is EMPTY.
conversion

Property Value

The minimum size.

See Also

API
minimumEnclosedArea
Gets or sets the minimum size allowed for the reshapeable.
The default value is ZERO.
conversion

Property Value

The minimum size.

See Also

API
minimumSize
Gets the node to provide reshape handles for.
readonlyfinal
Gets or sets the event recognizer that determines if the width/height ratio of the reshapeable is kept during the reshape gesture.

This value is set as ratioReshapeRecognizer of the handle provided in getHandle.

The default value is null.

final

Examples

Always keeping the node ratio
// always keep the aspect ratio
provider.ratioReshapeRecognizer = EventRecognizers.ALWAYS

See Also

API
centerReshapeRecognizer, reshapePolicy
Gets the reshape handler to delegate the actual reshaping to.
readonlyfinal
Gets or sets the policy that determines how the mouse location is interpreted when the reshape gesture shall keep the aspect ratio.

The ratioReshapeRecognizer is used to determine whether the aspect ratio shall be kept at all. If ratioReshapeRecognizer is not set, the NodeReshapeHandlerHandle provided in getHandle uses the directionalConstraintRecognizer of the HandleInputMode managing this handle.

getHandle propagates this policy value to the reshapePolicy of its TOP_LEFT, TOP_RIGHT, BOTTOM_LEFT and BOTTOM_RIGHT handles. For LEFT and RIGHT handles, HORIZONTAL is used. For TOP and BOTTOM handles, VERTICAL is used.

The default value is PROJECTION.

conversionfinal

Examples

Extend the node bounds to the mouse location
// when keeping the aspect ratio extend the node bounds to the mouse location
provider.reshapePolicy = ReshapePolicy.MAXIMUM
Gets or sets an INodeSizeConstraintProvider that is passed to the queried handles.
final

Methods

Returns the handlePositions property.

Parameters

context: IInputModeContext
The context for which the handles are queried.

Return Value

HandlePositions
A bitwise combination of all handle positions this instance provides a handle for if queried in getHandle.
Provides a NodeReshapeHandlerHandle that uses the reshapeHandler to perform the actual reshaping.

The minimumSize, maximumSize, minimumEnclosedArea, maximumBoundingArea, ratioReshapeRecognizer and centerReshapeRecognizer are propagated to the NodeReshapeHandlerHandle.

The reshapePolicy is only propagated if the position is neither HORIZONTAL nor VERTICAL. If position is HORIZONTAL, HORIZONTAL is set. If position is VERTICAL, VERTICAL is set.

This method may be called for each possible single position contained in the set as returned by getAvailableHandles.

Parameters

inputModeContext: IInputModeContext
The context for which the handles are queried.
position: HandlePositions
The position to provide an instance for.

Return Value

IHandle
A handle implementation.