documentationfor yFiles for HTML 3.0.0.2

EdgeDecorator

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

Inheritance Hierarchy
EdgeDecorator

Remarks

Predefined LookupDecorator<TDecoratedType,TInterface> are made available through properties like e.g. highlightRenderer. 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 edges on the GraphDecorator which is returned by decorator on an IGraph.

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

Examples

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

graph.decorator.edges.selectionRenderer.addConstant(
  new ConstantSelection(),
)

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

graph.decorator.edges.selectionRenderer.addConstant(
  (edge) => edge.tag !== null,
  new ConstantSelection(),
)

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

graph.decorator.edges.selectionRenderer.addFactory(
  (edge) => new CustomSelection(edge),
)
graph.decorator.edges.selectionRenderer.addFactory(
  (edge) => edge.tag !== null,
  (edge) => new CustomSelection(edge),
)

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

graph.decorator.edges.selectionRenderer.addWrapperFactory(
  (edge, original) => new SelectionWrapper(edge, original),
)
graph.decorator.edges.selectionRenderer.addWrapperFactory(
  (edge) => edge.tag !== null,
  (edge, original) => new SelectionWrapper(edge, original),
)

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

graph.decorator.edges.selectionRenderer.hide()
graph.decorator.edges.selectionRenderer.hide((edge) => edge.tag !== null)

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

constructor() {}

registerLookup(graph: IGraph): void {
  this.chainLink = graph.decorator.edges.selectionRenderer.addFactory(
    (edge) => new CustomSelection(edge),
  )!
}

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

Type Details

yFiles module
view

See Also

Constructors

Properties

Methods