Central interface used by the CanvasComponent to render elements from the scene graph.
Remarks
Type Details
- yfiles module
- view-component
- yfiles-umd modules
- All view modules
- Legacy UMD name
- yfiles.view.ICanvasObjectDescriptor
See Also
Methods
Returns an implementation of IBoundsProvider that can determine the visible bounds of the rendering of the user object.
Remarks
Parameters
A map of options to pass to the method.
- forUserObject - Object
- the user object to query the bounds for
Returns
- ↪IBoundsProvider
- An implementation of IBoundsProvider to determine the bounds of the visualization.
Returns an implementation of IHitTestable that can determine whether the rendering of the user object has been hit at a given coordinate.
Remarks
Parameters
A map of options to pass to the method.
- forUserObject - Object
- the user object to do the hit testing for
Returns
- ↪IHitTestable
- An implementation of IHitTestable to determine visibility.
Returns an implementation of IVisibilityTestable that can determine if the rendering of the user object would be visible in a given context.
Remarks
Parameters
A map of options to pass to the method.
- forUserObject - Object
- the user object to query visibility for
Returns
- ↪IVisibilityTestable
- An implementation of IVisibilityTestable to determine visibility.
Returns an implementation of IVisualCreator that will create the Visual tree for the user object.
Remarks
Parameters
A map of options to pass to the method.
- forUserObject - Object
- the user object to create a Visual for
Returns
- ↪IVisualCreator
- An implementation of IVisualCreator to create or update the visualization.
Determines whether the given canvas object is deemed dirty and needs updating.
Parameters
A map of options to pass to the method.
- context - ICanvasContext
- The context that will be used for the update.
- canvasObject - ICanvasObject
- The object to check.
Returns
- ↪boolean
- Whether an update is needed.
See Also
Constants
A descriptor that treats userObject as an instance of IVisualCreator and ignores the dirty flag.
Remarks
This descriptor tries to cast the userObject to IVisualCreator and use this instance to handle the visual representation of the ICanvasObject.
If the userObject does not implement IVisualCreator nothing will be displayed.
This descriptor will always update the visual and thus ignore the dirty flag.
Examples
const canvasObject = graphComponent.backgroundGroup.addChild(
new RectangleVisualCreator(rectangle),
ICanvasObjectDescriptor.ALWAYS_DIRTY_INSTANCE
)
See Also
A descriptor that treats userObject as an instance of ILookup to obtain suitable interface implementations and ignores the dirty flag.
Remarks
This descriptor tries to cast the userObject to ILookup and obtain the appropriate interface implementations for its methods from it.
If the userObject does not implement ILookup nothing will be displayed.
This descriptor will always update the Visual and thus ignore the dirty flag.
Examples
// the node provides an IVisualCreator via its lookup
const canvasObject = graphComponent.backgroundGroup.addChild(
node,
ICanvasObjectDescriptor.ALWAYS_DIRTY_LOOKUP
)
See Also
A descriptor that treats userObject as Visual to use directly.
Remarks
If the userObject is not a Visual nothing will be displayed.
This descriptor ignores the dirty flag and always assumes a dirty visual. This will only make a difference for WebGL2Visuals and other HtmlCanvasVisuals.
An implementation that treats userObject as an instance of IVisualCreator and considers the dirty flag.
Remarks
This descriptor tries to cast the userObject to IVisualCreator and use this instance to handle the visual representation of the ICanvasObject.
If the userObject does not implement IVisualCreator nothing will be displayed.
This descriptor will respect the dirty flag.
Examples
const canvasObject = graphComponent.backgroundGroup.addChild(
new RectangleVisualCreator(rectangle),
ICanvasObjectDescriptor.DYNAMIC_DIRTY_INSTANCE
)
See Also
A descriptor that treats userObject as an instance of ILookup to obtain suitable interface implementations and considers the dirty flag.
Remarks
This descriptor tries to cast the userObject to ILookup and obtain the appropriate interface implementations for its methods from it.
If the userObject does not implement ILookup nothing will be displayed.
This descriptor will respect the dirty flag.
Examples
// the node provides an IVisualCreator via its lookup
const canvasObject = graphComponent.backgroundGroup.addChild(
node,
ICanvasObjectDescriptor.DYNAMIC_DIRTY_LOOKUP
)
See Also
A descriptor that treats userObject as Visual to use directly.
Remarks
If the userObject is not a Visual nothing will be displayed.
This descriptor will respect the dirty flag.
Examples
image
to the canvas.const image = window.document.createElementNS(
'http://www.w3.org/2000/svg',
'image'
)
image.setAttributeNS(
'http://www.w3.org/1999/xlink',
'href',
'resources/background.png'
)
image.x.baseVal.value = 1
image.y.baseVal.value = 1
image.width.baseVal.value = 100
image.height.baseVal.value = 100
const visual = new SvgVisual(image)
graphComponent.rootGroup.addChild(
visual,
ICanvasObjectDescriptor.VISUAL
)
See Also
An implementation that returns an ICanvasObjectDescriptor that does nothing.