public interface IDisposeVisualCallback
removedVisual
when the
visual will be removed.
Clients have to register this callback in a IVisualCreator.createVisual(IRenderContext)
method using method IRenderContext.setDisposeCallback(Node, IDisposeVisualCallback)
if the visual occupies resources which have to be cleaned up after the visual is no longer needed.
The method will be called when the removedVisual
is removed to free the resources which are allocated by that
visual.
This callback can also be used to support caching for temporarily removed visuals. A visual is removed temporarily when it is moved out of the viewport and re-added when it is moved back into the viewport.
If the visual should be cached the callback has to return the visual. When it is re-added IVisualCreator.updateVisual(IRenderContext, Node)
is called for the visual. Note that it is possible that the visual will not be cached or discarded without furhter
notice. Thus, this callback has to free its resources (if necessary) for temporarily removed visuals, too. As a
concequence, for cached visuals the IVisualCreator.updateVisual(IRenderContext, Node)
method has to be able to
re-allocate the necessary resources.
Modifier and Type | Method and Description |
---|---|
Node |
dispose(IRenderContext context,
Node removedVisual,
boolean dispose)
A callback which will be called to free the resources which are occupied by the given
removedVisual when the
visual will be removed. |
Node dispose(IRenderContext context, Node removedVisual, boolean dispose)
removedVisual
when the
visual will be removed.
Clients have to register this callback in a IVisualCreator.createVisual(IRenderContext)
method using method IRenderContext.setDisposeCallback(Node, IDisposeVisualCallback)
if the visual occupies
resources which have to be cleaned up after the visual is no longer needed.
The method will be called when the removedVisual
is removed to free the resources which are allocated by that
visual.
This callback can also be used to support caching for temporarily removed visuals. A visual is removed temporarily when it is moved out of the viewport and re-added when it is moved back into the viewport.
If the visual should be cached the callback has to return the visual. When it is re-added IVisualCreator.updateVisual(IRenderContext, Node)
is called for the visual. Note that it is possible that the visual will not be cached or discarded without furhter
notice. Thus, this callback has to free its resources (if necessary) for temporarily removed visuals, too. As a
concequence, for cached visuals the IVisualCreator.updateVisual(IRenderContext, Node)
method has to be able to re-allocate the necessary resources.
context
- A valid render context.removedVisual
- The visual whose resources need to be freed.dispose
- Indicates that the visual is not going to be used again in any case and can be disposed for good. In the case that this
parameter is set to true
clients should take this as a signal to free the resources used by the
removedVisual
. If this parameter is set to false, the visual is eventually made visible in the scene graph
of the CanvasControl
again and may therefore be reused. Note that there is no guarantee
that the visual is not garbage collected anyways if VisualCaching
is set to VisualCachingPolicy.WEAK
.null
otherwise.IRenderContext.setDisposeCallback(Node, IDisposeVisualCallback)