Template factory for creating visual representations of arbitrary data objects.
Inheritance Hierarchy
IVisualTemplate
Remarks
Implementations of this class have the purpose of creating a SvgVisual that serves as the visual representation of the object associated with this instance. This special-purpose interface is only used in some places where the user interface can be customized. The IVisualCreator interface is the main interface used by the CanvasComponent.
Type Details
- yfiles module
- view-component
- yfiles-umd modules
- All view modules
- Legacy UMD name
- yfiles.view.IVisualTemplate
See Also
In most cases, the visual is created with createVisual and translated internally to the proper location. updateVisual is only called if the object bounds change. In some cases, updateVisual may never be called, e.g. for handle templates.
Methods
This method is called by the framework to create a SvgVisual with the given bounds
.
Remarks
CanvasComponent uses this interface through the ICanvasObjectDescriptor to populate the visual canvas object tree.
Parameters
options - Object
A map of options to pass to the method.
A map of options to pass to the method.
- context - IRenderContext
- The context that describes where the visual will be used.
- bounds - Rect
- The current bounds to use for the visual.
- dataObject - Object
- The data object to visualize.
Returns
- ↪SvgVisual
- The visual to include in the canvas object visual tree. This may be
null
.
See Also
updateVisual
(context: IRenderContext, oldVisual: SvgVisual, bounds: Rect, dataObject: Object) : SvgVisualThis method updates or replaces a previously created SvgVisual to adjust to the changed bounds
.
Remarks
The CanvasComponent uses this method to give implementations a chance to update an existing Visual that has previously been created by the same instance during a call to createVisual. Implementation may update the
oldVisual
and return that same reference, or create a new visual and return the new instance or null
.Parameters
options - Object
A map of options to pass to the method.
A map of options to pass to the method.
- context - IRenderContext
- The context that describes where the visual will be used in.
- oldVisual - SvgVisual
- The visual instance that had been returned the last time the createVisual method was called on this instance.
- bounds - Rect
- The current bounds to use for the visual.
- dataObject - Object
- The data object to visualize.
Returns
- ↪SvgVisual
oldVisual
, if this instance modified the visual, or a new visual that should replace the existing one in the canvas object visual tree.
This method is only called if the
bounds
have changed. in some cases, it might never be called. It should not be used to update the visual based on contextual information. Instead, you should use a custom ICanvasObjectDescriptor for the visualized object.Static Methods
Creates an implementation of the interface IVisualTemplate from the given definition.
Remarks
The given object must contain exactly the abstract members of the IVisualTemplate interface. No member may be omitted and no additional members can be added. While additional custom members can later be added directly on the instance, this is discouraged.
Parameters
options - Object
A map of options to pass to the method.
A map of options to pass to the method.
- createVisual - function(IRenderContext, Rect, any):SvgVisual
This method is called by the framework to create a SvgVisual with the given
bounds
.This property holds the implementation for createVisual.
- updateVisual - function(IRenderContext, SvgVisual, Rect, any):SvgVisual
This method updates or replaces a previously created SvgVisual to adjust to the changed
bounds
.This property holds the implementation for updateVisual.
Returns
- ↪IVisualTemplate
- An instance of the IVisualTemplate interface based on the given definition.