documentationfor yFiles for HTML 2.6

BendDecorator

Helps in decorating the lookup method of IBend instances by providing access to decorators for the most common types.

Inheritance Hierarchy
BendDecorator

Remarks

Predefined LookupDecorator<TDecoratedType,TInterface> are made available through properties like e.g. highlightDecorator. Note that the list of possible decorations that are available using this class is not exhaustive in any way. This is merely a way to provide access to those interfaces that are more commonly being decorated by the developer.

Typically, a configured instance of this class is available through bendDecorator on the GraphDecorator which is returned by decorator on an IGraph.

This decorator can be used to conveniently decorate the lookup of IBends in an IGraph. It serves as a factory for predefined LookupDecorator<TDecoratedType,TInterface> instances that are specifically useful for the IBend type.

Examples

The bend can be decorated in various ways. setImplementation decorates the bend's lookup to return the same instance for each bend.

graph.decorator.bendDecorator.handleDecorator.setImplementation(
  new ConstantHandle()
)

setImplementation with a predicate decorates the bend's lookup only to return the same instance for each bend for which the predicate returns true.

graph.decorator.bendDecorator.handleDecorator.setImplementation(
  (bend) => bend.tag !== null,
  new ConstantHandle()
)

setFactory calls the provided factory method to return a new instance of the queried type created for the given bend or for bends for which the predicate returns true, respectively:

graph.decorator.bendDecorator.handleDecorator.setFactory(
  (bend) => new CustomHandle(bend)
)
graph.decorator.bendDecorator.handleDecorator.setFactory(
  (bend) => bend.tag !== null,
  (bend) => new CustomHandle(bend)
)

setImplementationWrapper calls the provided factory method to return a new instance of the queried type which wraps the default implementation, once for all bends and once only for bends for which the predicate returns true.

graph.decorator.bendDecorator.handleDecorator.setImplementationWrapper(
  (bend, original) => new HandleWrapper(bend, original)
)
graph.decorator.bendDecorator.handleDecorator.setImplementationWrapper(
  (bend) => bend.tag !== null,
  (bend, original) => new HandleWrapper(bend, original)
)graph.decorator.bendDecorator.handleDecorator.setImplementationWrapper(
  (bend, original) => new HandleWrapper(bend!, original)
)
graph.decorator.bendDecorator.handleDecorator.setImplementationWrapper(
  (bend) => bend.tag !== null,
  (bend, original) => new HandleWrapper(bend!, original)
)

Finally hideImplementation hides the default implementation by letting the lookup always return null for all bends and for bends for which the predicate returns true, respectively

graph.decorator.bendDecorator.handleDecorator.hideImplementation()
graph.decorator.bendDecorator.handleDecorator.hideImplementation(
  (bend) => bend.tag !== null
)

Each of these methods returns a IContextLookupChainLink which can be used to remove the modified behavior again:

constructor() {}

/**
 * @param {!IGraph} graph
 */
registerLookup(graph) {
  this.chainLink = graph.decorator.bendDecorator.handleDecorator.setFactory(
    (bend) => new CustomHandle(bend)
  )
}

/**
 * @param {!IGraph} graph
 */
deregisterLookup(graph) {
  graph.decorator.bendDecorator.remove(this.chainLink)
}constructor() {}

registerLookup(graph: IGraph): void {
  this.chainLink = graph.decorator.bendDecorator.handleDecorator.setFactory(
    (bend) => new CustomHandle(bend)
  )!
}

deregisterLookup(graph: IGraph): void {
  graph.decorator.bendDecorator.remove(this.chainLink)
}

Type Details

yfiles module
view-component
yfiles-umd modules
All view modules
Legacy UMD name
yfiles.graph.BendDecorator

See Also

Constructors

Properties

Methods