Factory interface which is used by implementations that know how to create Visuals for rendering into a given IRenderContext.
Remarks
The methods createVisual and updateVisual manage the actual visual representation, the Visual. The createVisual method is called when the object's visualization should become visible for the first time. In the subsequent redrawing process, the updateVisual method is called with the Visual instance of the previous rendering step. In this method, the given Visual instance's values (e.g. the position) can be updated instead of creating a new Visual instance.
Keep in mind:
- Instances must not store references to created Visuals, as those may be cleaned up without the IVisualCreator knowing. Furthermore, createVisual may be called multiple times in different contexts. If updateVisual operates on stored Visual references, those stored references may not refer to the Visual instance passed to updateVisual.
- Implementations have to be aware that updateVisual might be called with a Visual which has been created by a different IVisualCreator.
- An IVisualCreator may live longer than any of its created Visuals.
- An IVisualCreator may create more than just one Visual.
Type Details
- yfiles module
- view-component
- yfiles-umd modules
- All view modules
- Legacy UMD name
- yfiles.view.IVisualCreator
See Also
Methods
This method is called by the framework to create a Visual that will be included into the IRenderContext.
Remarks
Parameters
A map of options to pass to the method.
- context - IRenderContext
- The context that describes where the visual will be used.
Returns
- ↪Visual
- The visual to include in the canvas object visual tree. This may be
null
.
See Also
This method updates or replaces a previously created Visual for inclusion in the IRenderContext.
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
.
I most cases oldVisual
is a visual instance that has been returned by the createVisual method of this instance. This is, however, not guaranteed. Implementations have to be aware of this.
Parameters
A map of options to pass to the method.
- context - IRenderContext
- The context that describes where the visual will be used in.
- oldVisual - Visual
- The visual instance to be updated.
Returns
- ↪Visual
oldVisual
, if this instance modified the visual, or a new visual that should replace the existing one in the canvas object visual tree.
See Also
Static Methods
Creates an implementation of the interface IVisualCreator from the given definition.
Remarks
Parameters
A map of options to pass to the method.
- createVisual - function(IRenderContext):Visual
This method is called by the framework to create a Visual that will be included into the IRenderContext.
This property holds the implementation for createVisual.
- updateVisual - function(IRenderContext, Visual):Visual
This method updates or replaces a previously created Visual for inclusion in the IRenderContext.
This property holds the implementation for updateVisual.
Returns
- ↪IVisualCreator
- An instance of the IVisualCreator interface based on the given definition.