Class: TagComponent
component.TagComponent
classdesc
Component for showing and editing tags with different
geometries composed from 2D basic image coordinates (see the
Viewer class documentation for more information about coordinate
systems).
The add
method is used for adding new tags or replacing
tags already in the set. Tags are removed by id.
If a tag already in the set has the same id as one of the tags added, the old tag will be removed and the added tag will take its place.
The tag component mode can be set to either be non interactive or to be in creating mode of a certain geometry type.
The tag properties can be updated at any time and the change will be visibile immediately.
Tags are only relevant to a single image because they are based on 2D basic image coordinates. Tags related to a certain image should be removed when the viewer is moved to another image.
To retrive and use the tag component
example
var viewer = new Viewer({ component: { tag: true } }, ...);
var tagComponent = viewer.getComponent("tag");
#
Hierarchy↳
TagComponent
#
Events#
on• on(type
, handler
): void
Event fired when a geometry has been created.
example
// Initialize the viewervar viewer = new Viewer({ // viewer options });var component = viewer.getComponent('<component-name>');// Set an event listenercomponent.on('geometrycreated', function() { console.log("A geometrycreated event has occurred.");});
#
ParametersName | Type |
---|---|
type | "geometrycreate" |
handler | (event : ComponentGeometryEvent ) => void |
#
Returnsvoid
#
Overrides#
Defined incomponent/tag/TagComponent.ts:571
• on(type
, handler
): void
Event fired when an interaction to create a geometry ends.
description
A create interaction can by a geometry being created
or by the creation being aborted.
example
// Initialize the viewervar viewer = new Viewer({ // viewer options });var component = viewer.getComponent('<component-name>');// Set an event listenercomponent.on('tagcreateend', function() { console.log("A tagcreateend event has occurred.");});
#
ParametersName | Type |
---|---|
type | "tagcreateend" |
handler | (event : ComponentStateEvent ) => void |
#
Returnsvoid
#
Defined incomponent/tag/TagComponent.ts:593
• on(type
, handler
): void
Event fired when an interaction to create a geometry starts.
description
A create interaction starts when the first vertex
is created in the geometry.
example
// Initialize the viewervar viewer = new Viewer({ // viewer options });var component = viewer.getComponent('<component-name>');// Set an event listenercomponent.on('tagcreatestart', function() { console.log("A tagcreatestart event has occurred.");});
#
ParametersName | Type |
---|---|
type | "tagcreatestart" |
handler | (event : ComponentStateEvent ) => void |
#
Returnsvoid
#
Defined incomponent/tag/TagComponent.ts:615
• on(type
, handler
): void
Event fired when the create mode is changed.
example
// Initialize the viewervar viewer = new Viewer({ // viewer options });var component = viewer.getComponent('<component-name>');// Set an event listenercomponent.on('tagmode', function() { console.log("A tagmode event has occurred.");});
#
ParametersName | Type |
---|---|
type | "tagmode" |
handler | (event : ComponentTagModeEvent ) => void |
#
Returnsvoid
#
Defined incomponent/tag/TagComponent.ts:634
• on(type
, handler
): void
Event fired when the tags collection has changed.
example
// Initialize the viewervar viewer = new Viewer({ // viewer options });var component = viewer.getComponent('<component-name>');// Set an event listenercomponent.on('tags', function() { console.log("A tags event has occurred.");});
#
ParametersName | Type |
---|---|
type | "tags" |
handler | (event : ComponentStateEvent ) => void |
#
Returnsvoid
#
Defined incomponent/tag/TagComponent.ts:653
#
Properties#
componentNameâ–ª Static
componentName: ComponentName
= "tag"
inheritdoc
#
Overrides#
Defined incomponent/tag/TagComponent.ts:98
#
Accessors#
activated• get
activated(): boolean
Get activated.
#
Returnsboolean
Value indicating if the component is currently active.
#
Defined in#
defaultConfiguration• get
defaultConfiguration(): TConfiguration
Get default configuration.
#
ReturnsTConfiguration
Default configuration for component.
#
Defined in#
name• get
name(): string
Get name.
description
The name of the component. Used when interacting with the
component through the Viewer's API.
#
Returnsstring
#
Defined in#
Methods#
addâ–¸ add(tags
): void
Add tags to the tag set or replace tags in the tag set.
description
If a tag already in the set has the same
id as one of the tags added, the old tag will be removed
the added tag will take its place.
example
tagComponent.add([tag1, tag2]);
#
ParametersName | Type | Description |
---|---|---|
tags | Tag [] | Tags to add. |
#
Returnsvoid
#
Defined incomponent/tag/TagComponent.ts:289
#
calculateRectâ–¸ calculateRect(geometry
): Promise
<number
[]>
Calculate the smallest rectangle containing all the points in the points geometry.
description
The result may be different depending on if the
current image is an spherical or not. If the
current image is an spherical the rectangle may
wrap the horizontal border of the image.
#
ParametersName | Type |
---|---|
geometry | PointsGeometry |
#
ReturnsPromise
<number
[]>
Promise to the rectangle on the format specified for the RectGeometry in basic coordinates.
#
Defined incomponent/tag/TagComponent.ts:323
#
changeModeâ–¸ changeMode(mode
): void
Change the current tag mode.
description
Change the tag mode to one of the create modes for creating new geometries.
fires
tagmode
example
tagComponent.changeMode(TagMode.CreateRect);
#
ParametersName | Type | Description |
---|---|---|
mode | TagMode | New tag mode. |
#
Returnsvoid
#
Defined incomponent/tag/TagComponent.ts:398
#
configureâ–¸ configure(configuration
): void
Configure the component.
#
ParametersName | Type | Description |
---|---|---|
configuration | TagConfiguration | Component configuration. |
#
Returnsvoid
#
Inherited from#
Defined in#
createâ–¸ create(): void
Force the creation of a geometry programatically using its current vertices.
description
The method only has an effect when the tag
mode is either of the following modes:
TagMode.CreatePoints TagMode.CreatePolygon TagMode.CreateRect TagMode.CreateRectDrag
In the case of points or polygon creation, only the created vertices are used, i.e. the mouse position is disregarded.
In the case of rectangle creation the position of the mouse at the time of the method call is used as one of the vertices defining the rectangle.
fires
geometrycreate
example
tagComponent.on("geometrycreate", function(geometry) { console.log(geometry);});
tagComponent.create();
#
Returnsvoid
#
Defined incomponent/tag/TagComponent.ts:371
#
fireâ–¸ fire(type
, event
): void
#
ParametersName | Type |
---|---|
type | "geometrycreate" |
event | ComponentGeometryEvent |
#
Returnsvoid
#
Overrides#
Defined in../doc/component/tag/TagComponent.ts:402
â–¸ fire(type
, event
): void
#
ParametersName | Type |
---|---|
type | "tagmode" |
event | ComponentTagModeEvent |
#
Returnsvoid
#
OverridesComponent.fire
#
Defined in../doc/component/tag/TagComponent.ts:406
#
getâ–¸ get(tagId
): Tag
Returns the tag in the tag set with the specified id, or undefined if the id matches no tag.
example
var tag = tagComponent.get("tagId");
#
ParametersName | Type | Description |
---|---|---|
tagId | string | Id of the tag. |
#
Returns#
Defined incomponent/tag/TagComponent.ts:436
#
getAllâ–¸ getAll(): Tag
[]
Returns an array of all tags.
example
var tags = tagComponent.getAll();
#
ReturnsTag
[]
#
Defined incomponent/tag/TagComponent.ts:453
#
getTagIdsAtâ–¸ getTagIdsAt(pixelPoint
): Promise
<string
[]>
Returns an array of tag ids for tags that contain the specified point.
description
The pixel point must lie inside the polygon or rectangle
of an added tag for the tag id to be returned. Tag ids for
tags that do not have a fill will also be returned if the point is inside
the geometry of the tag. Tags with point geometries can not be retrieved.
No tag ids will be returned for polygons rendered in cropped spherical or rectangles rendered in spherical.
Notice that the pixelPoint argument requires x, y coordinates from pixel space.
With this function, you can use the coordinates provided by mouse events to get information out of the tag component.
If no tag at exist the pixel point, an empty array will be returned.
example
tagComponent.getTagIdsAt([100, 100]) .then((tagIds) => { console.log(tagIds); });
#
ParametersName | Type | Description |
---|---|---|
pixelPoint | number [] | Pixel coordinates on the viewer element. |
#
ReturnsPromise
<string
[]>
Promise to the ids of the tags that contain the specified pixel point.
#
Defined incomponent/tag/TagComponent.ts:494
#
hasâ–¸ has(tagId
): boolean
Check if a tag exist in the tag set.
example
var tagExists = tagComponent.has("tagId");
#
ParametersName | Type | Description |
---|---|---|
tagId | string | Id of the tag. |
#
Returnsboolean
#
Defined incomponent/tag/TagComponent.ts:530
#
offâ–¸ off(type
, handler
): void
Unsubscribe from an event by its name.
#
ParametersName | Type |
---|---|
type | "geometrycreate" |
handler | (event : ComponentGeometryEvent ) => void |
#
Returnsvoid
#
Overrides#
Defined incomponent/tag/TagComponent.ts:534
â–¸ off(type
, handler
): void
#
ParametersName | Type |
---|---|
type | "tagmode" |
handler | (event : ComponentTagModeEvent ) => void |
#
Returnsvoid
#
OverridesComponent.off
#
Defined incomponent/tag/TagComponent.ts:538
â–¸ off(type
, handler
): void
#
ParametersName | Type |
---|---|
type | "tagcreateend" | "tagcreatestart" | "tags" |
handler | (event : ComponentStateEvent ) => void |
#
Returnsvoid
#
OverridesComponent.off
#
Defined incomponent/tag/TagComponent.ts:542
#
removeâ–¸ remove(tagIds
): void
Remove tags with the specified ids from the tag set.
example
tagComponent.remove(["id-1", "id-2"]);
#
ParametersName | Type | Description |
---|---|---|
tagIds | string [] | Ids for tags to remove. |
#
Returnsvoid
#
Defined incomponent/tag/TagComponent.ts:674
#
removeAllâ–¸ removeAll(): void
Remove all tags from the tag set.
example
tagComponent.removeAll();
#
Returnsvoid