Class: OpenSeadragonLabelsRenderer
Defined in: openseadragon/OpenSeadragonLabelsRenderer.ts:62
Renderer for the tiled images of Labels data objects
The tiles of a labels object carry label IDs rather than colors, and are recolored by a data transfer (see OpenSeadragonContext.updateTiledImageDataTransfer) that looks each ID up in a color lookup table, which folds the visibility and opacity into the alpha channel. Layer and object opacity are not part of it; OpenSeadragon applies them when drawing the tiled image.
A label image does not enumerate its labels (see LabelsData), so the lookup table is resolved per object for the labels that the referenced table lists, in the same way as the WebGL renderers resolve the appearance of their items, and every other label is resolved as it is first drawn (see _resolveDataTransfer).
As data transfers are compared by identity, each object's data transfer is kept (see resolveObject) until its data or one of the configurations it was resolved from changes, so that tiles are only recolored when needed.
Extends
OpenSeadragonRendererBase<Labels,LabelsData,OpenSeadragonLabelsSyncContext>
Constructors
Constructor
new OpenSeadragonLabelsRenderer(
context,onInitialized,onError,options?):OpenSeadragonLabelsRenderer
Defined in: openseadragon/OpenSeadragonRendererBase.ts:69
Creates a new OpenSeadragonRendererBase instance and asynchronously adds its anchor
The renderer must not be used before onInitialized has been called;
onError is called instead if adding the anchor failed or was aborted.
Parameters
context
The OpenSeadragon context that provides access to the viewer and other shared state
onInitialized
() => void
Called once the anchor has been added to the world
onError
(error) => void
Called if the anchor could not be added
options?
Optional abort signal and world index at which to insert the anchor
anchorIndex?
number
signal?
AbortSignal
Returns
OpenSeadragonLabelsRenderer
Inherited from
OpenSeadragonRendererBase< Labels, LabelsData, OpenSeadragonLabelsSyncContext >.constructor
Properties
context
readonlycontext:OpenSeadragonContext
Defined in: openseadragon/OpenSeadragonRendererBase.ts:51
Inherited from
OpenSeadragonRendererBase.context
Methods
destroy()
destroy():
Promise<void>
Defined in: openseadragon/OpenSeadragonRendererBase.ts:215
Destroys the renderer by removing the anchor tiled image and all rendered objects from the OpenSeadragon viewer
Rendered objects whose tiled images have not been added to the world yet are only marked for deletion, and are removed as soon as they arrive.
The renderer is unusable afterwards: it has no anchor anymore, so updateBounds does nothing, _cleanRenderedObjects throws, and tiled images that still arrive are removed right away.
Returns
Promise<void>
Inherited from
OpenSeadragonRendererBase.destroy
getTiledImageDataTransfer()
protectedgetTiledImageDataTransfer(ref):DataTransfer|undefined
Defined in: openseadragon/OpenSeadragonLabelsRenderer.ts:149
Returns the data transfer resolved for the given labels object
A labels object has a single tiled image, whose tiles carry the label IDs, and no backdrop, so the index is not looked at.
Parameters
ref
ObjectRef<Labels, LabelsData>
The labels reference for which to get the data transfer
Returns
DataTransfer | undefined
The data transfer resolved by resolveObject, or
undefined if the object has not been resolved
Overrides
OpenSeadragonRendererBase.getTiledImageDataTransfer
getTiledImageOpacity()
protectedgetTiledImageOpacity(ref,_index):number
Defined in: openseadragon/OpenSeadragonRendererBase.ts:327
Computes the effective opacity for one of an object's tiled images
Returns 0 when either the layer or the object is invisible; otherwise
multiplies layer and object opacities. The channel index is ignored here,
i.e. all tiled images of an object share the same opacity; subclasses
override this to additionally apply per-channel visibility and opacity. The
channel index is omitted for an object's backdrop, which carries the opacity
of the object itself.
Parameters
ref
ObjectRef<Labels, LabelsData>
The object reference for which to compute the opacity
_index
number | null
The index of the tiled image (e.g. channel), or null for the object's backdrop
Returns
number
The effective opacity for the tiled image
Inherited from
OpenSeadragonRendererBase.getTiledImageOpacity
getTileSources()
protectedgetTileSources(data): (string|object|CustomTileSource)[]
Defined in: openseadragon/OpenSeadragonRendererBase.ts:288
Returns the tile sources for the given object data
Parameters
data
The object data (image or labels) for which to retrieve the tile sources
Returns
(string | object | CustomTileSource)[]
The tile sources, one per tiled image of the object. Defaults to the single tile source of the data; renderers of multi-channel data override this.
Inherited from
OpenSeadragonRendererBase.getTileSources
resolveObject()
protectedresolveObject(labels,data,context,options?):Promise<void>
Defined in: openseadragon/OpenSeadragonLabelsRenderer.ts:109
Resolves the data transfer of a labels object, unless it is up to date
An object's data transfer is kept as long as its data and its label color, visibility and opacity configurations are unchanged, and is resolved anew otherwise (see _resolveDataTransfer). If resolving from the referenced table fails, e.g. because the table failed to load, the failure is logged and the object's labels are resolved without table data instead, until its data or one of its configurations changes.
Parameters
labels
The labels object to resolve
data
The loaded data of the labels object
context
OpenSeadragonLabelsSyncContext
The inputs of the current synchronization
options?
Optional abort signal
signal?
AbortSignal
Returns
Promise<void>
A promise that resolves once the data transfer has been resolved
Todo
Changes to the color, visibility and opacity maps themselves are not detected; they are only re-read when a configuration referencing them changes.
Overrides
OpenSeadragonRendererBase.resolveObject
retainObjects()
protectedretainObjects(labels):void
Defined in: openseadragon/OpenSeadragonLabelsRenderer.ts:81
Drops the data transfers of all labels objects other than the given ones
Parameters
labels
Labels[]
The labels objects about to be displayed
Returns
void
Overrides
OpenSeadragonRendererBase.retainObjects
setExtraBounds()
setExtraBounds(
bounds):void
Defined in: openseadragon/OpenSeadragonRendererBase.ts:201
Sets additional bounds to be covered by the anchor
Used to include content that is not rendered by OpenSeadragon (e.g. points and shapes rendered with WebGL) in the viewer's world bounds. Takes effect on the next updateBounds call.
Parameters
bounds
Rect[]
Additional bounds, in world coordinates
Returns
void
Inherited from
OpenSeadragonRendererBase.setExtraBounds
synchronize()
synchronize(
layers,objects,context,options?):Promise<void>
Defined in: openseadragon/OpenSeadragonRendererBase.ts:106
Synchronizes the viewer's tiled images with the current model state
Loads all objects assigned to the given layers, removes the tiled images that are no longer needed, and creates or updates the remaining ones. Resolves once the tiled images have actually been added to the world, i.e. once the viewer reflects the given model state.
Objects whose tiled images cannot be created, e.g. because their data provides no tile sources, are logged and skipped, just like objects whose data failed to load (see _loadObjects).
Parameters
layers
Layer[]
Layers to render
objects
Labels[]
Objects (images or labels) to display
context
OpenSeadragonLabelsSyncContext
The inputs to synchronize with: an immutable snapshot of the model state and loaders that the renderer needs. It carries inputs only; a renderer that derives state from an object does so in resolveObject.
options?
Optional abort signal
signal?
AbortSignal
Returns
Promise<void>
Inherited from
OpenSeadragonRendererBase.synchronize
updateBounds()
updateBounds(
options?):Promise<void>
Defined in: openseadragon/OpenSeadragonRendererBase.ts:164
Resizes the anchor to the bounding box of all tiled images and extra bounds
Rendered objects whose tiled images have not been added to the world yet are ignored; they update the anchor themselves upon arrival (see _createRenderedObject). Does nothing once the renderer has been destroyed, as there is no anchor to resize anymore.
Parameters
options?
Optional abort signal
signal?
AbortSignal
Returns
Promise<void>
Inherited from
OpenSeadragonRendererBase.updateBounds
usesAdditiveBlending()
protectedusesAdditiveBlending(_data):boolean
Defined in: openseadragon/OpenSeadragonRendererBase.ts:309
Returns whether the channels of the given object data are blended additively
The channels of an object that blends additively are composited with OpenSeadragon's "lighter" operation onto an opaque black backdrop below them, so that they add up among themselves while the backdrop hides whatever is below the object, thereby compositing the object as a whole over it. Objects that do not blend additively have no backdrop and keep OpenSeadragon's default composite operation, i.e. each of their channels is composited over the one below it.
Parameters
_data
The object data (image or labels) to check
Returns
boolean
Whether the object's channels are blended additively. Defaults to false.
Inherited from
OpenSeadragonRendererBase.usesAdditiveBlending