Class CollaborationAvatarGroup
- All Implemented Interfaces:
AttachNotifier,DetachNotifier,HasElement,HasSize,HasStyle,HasTheme,Serializable
AvatarGroup component which integrates with the
CollaborationEngine. It updates the avatars in real time based on the
other attached avatar groups connected to the same topic.- Since:
- 1.0
- Author:
- Vaadin Ltd
- See Also:
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic interfaceCallback for creating a download handler for the avatar image for a specific user.static interfaceDeprecated, for removal: This API element is subject to removal in a future version. -
Constructor Summary
ConstructorsConstructorDescriptionCollaborationAvatarGroup(UserInfo localUser, String topicId) Creates a new collaboration avatar group component with the provided local user and topic id. -
Method Summary
Modifier and TypeMethodDescriptionvoidaddThemeVariants(AvatarGroupVariant... variants) Adds theme variants to the avatar group component.Creates an instance of the user's ownAvatarin this avatar group.getI18n()Gets the internationalization object previously set for this component.Gets the currently used image handler callback.Deprecated, for removal: This API element is subject to removal in a future version.UsesetImageHandler(ImageHandler)instead.Gets the maximum number of avatars to display, ornullif no max has been set.booleanGets whether the user's own avatar is displayed in the avatar group or not.voidremoveThemeVariants(AvatarGroupVariant... variants) Removes theme variants from the avatar group component.voidSets the internationalization properties for this component.voidsetImageHandler(CollaborationAvatarGroup.ImageHandler imageHandler) Sets an image handler callback for dynamically loading avatar images for a given user.voidsetImageProvider(CollaborationAvatarGroup.ImageProvider imageProvider) Deprecated, for removal: This API element is subject to removal in a future version.UsesetImageHandler(ImageHandler)instead.voidSets the the maximum number of avatars to display.voidsetOwnAvatarVisible(boolean ownAvatarVisible) Sets whether to display user's own avatar in the avatar group or not.voidSets the topic to use with this component.Methods inherited from class com.vaadin.flow.component.Composite
getChildren, getContent, getElement, initContentMethods inherited from class com.vaadin.flow.component.Component
addListener, findAncestor, fireEvent, from, get, getEventBus, getId, getListeners, getLocale, getParent, getTranslation, getTranslation, getTranslation, getTranslation, getTranslation, getTranslation, getUI, hasListener, isAttached, isTemplateMapped, isVisible, onAttach, onDetach, onEnabledStateChanged, removeFromParent, scrollIntoView, scrollIntoView, set, setElement, setId, setVisibleMethods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface com.vaadin.flow.component.AttachNotifier
addAttachListenerMethods inherited from interface com.vaadin.flow.component.DetachNotifier
addDetachListenerMethods inherited from interface com.vaadin.flow.component.HasElement
getElementMethods inherited from interface com.vaadin.flow.component.HasSize
getHeight, getHeightUnit, getMaxHeight, getMaxWidth, getMinHeight, getMinWidth, getWidth, getWidthUnit, setHeight, setHeight, setHeightFull, setMaxHeight, setMaxHeight, setMaxWidth, setMaxWidth, setMinHeight, setMinHeight, setMinWidth, setMinWidth, setSizeFull, setSizeUndefined, setWidth, setWidth, setWidthFullMethods inherited from interface com.vaadin.flow.component.HasStyle
addClassName, addClassNames, getClassName, getClassNames, getStyle, hasClassName, removeClassName, removeClassNames, setClassName, setClassNameMethods inherited from interface com.vaadin.flow.component.HasTheme
addThemeName, addThemeNames, getThemeName, getThemeNames, hasThemeName, removeThemeName, removeThemeNames, setThemeName, setThemeName
-
Constructor Details
-
CollaborationAvatarGroup
Creates a new collaboration avatar group component with the provided local user and topic id.The provided user information is used in the local user's avatar which is displayed to the other users.
Whenever another collaboration avatar group with the same topic id is attached to another user's UI, this avatar group is updated to include an avatar with that user's information.
If a
nulltopic id is provided, the component won't display any avatars, until connecting to a non-null topic withsetTopic(String).- Parameters:
localUser- the information of the local usertopicId- the id of the topic to connect to, ornullto not connect the component to any topic- Since:
- 1.0
-
-
Method Details
-
setTopic
Sets the topic to use with this component. The connection to the previous topic (if any) and existing avatars are removed. Connection to the new topic is opened and avatars of collaborating users in the new topic are populated to this component.If the topic id is
null, no avatars will be displayed.- Parameters:
topicId- the topic id to use, ornullto not use any topic- Since:
- 1.0
-
getMaxItemsVisible
Gets the maximum number of avatars to display, ornullif no max has been set.- Returns:
- the max number of avatars
- Since:
- 1.0
- See Also:
-
setMaxItemsVisible
Sets the the maximum number of avatars to display.By default, all the avatars are displayed. When max is set, the overflowing avatars are grouped into one avatar.
- Parameters:
max- the max number of avatars, ornullto remove the max- Since:
- 1.0
- See Also:
-
addThemeVariants
Adds theme variants to the avatar group component.- Parameters:
variants- theme variants to add- Since:
- 1.0
- See Also:
-
AvatarGroup#addThemeVariants(AvatarGroupVariant...)
-
removeThemeVariants
Removes theme variants from the avatar group component.- Parameters:
variants- theme variants to remove- Since:
- 1.0
- See Also:
-
AvatarGroup#removeThemeVariants(AvatarGroupVariant...)
-
getI18n
Gets the internationalization object previously set for this component.Note: updating the object content that is gotten from this method will not update the lang on the component if not set back using
setI18n(AvatarGroupI18n)- Returns:
- the i18n object. It will be
null, if the i18n properties haven't been set. - Since:
- 1.0
-
setI18n
Sets the internationalization properties for this component.- Parameters:
i18n- the internationalized properties, notnull- Since:
- 1.0
-
setImageProvider
@Deprecated(since="6.5", forRemoval=true) public void setImageProvider(CollaborationAvatarGroup.ImageProvider imageProvider) Deprecated, for removal: This API element is subject to removal in a future version.UsesetImageHandler(ImageHandler)instead.Sets an image provider callback for dynamically loading avatar images for a given user. The image can be loaded on-demand from a database or using any other source of IO streams.If no image callback is defined, then the image URL defined by
UserInfo.getImage()is directly passed to the browser. This means that avatar images need to be available as static files or served dynamically from a custom servlet. This is the default.Usage example:
collaborationAvatarGroup.setImageProvider(userInfo -> { StreamResource streamResource = new StreamResource( "avatar_" + userInfo.getId(), () -> { User userEntity = userRepository .findById(userInfo.getId()); byte[] profilePicture = userEntity.getProfilePicture(); return new ByteArrayInputStream(profilePicture); }); streamResource.setContentType("image/png"); return streamResource; });- Parameters:
imageProvider- the image provider to use, ornullto use image URLs directly from the user info object- Since:
- 1.0
-
getImageProvider
@Deprecated(since="6.5", forRemoval=true) public CollaborationAvatarGroup.ImageProvider getImageProvider()Deprecated, for removal: This API element is subject to removal in a future version.UsesetImageHandler(ImageHandler)instead.Gets the currently used image provider callback.- Returns:
- the current image provider callback, or
nullif no callback is set - Since:
- 1.0
- See Also:
-
setImageHandler
Sets an image handler callback for dynamically loading avatar images for a given user. The image can be loaded on-demand from a database or using any other source of IO streams.If no image handler callback is defined, then the image URL defined by
UserInfo.getImage()is directly passed to the browser. This means that avatar images need to be available as static files or served dynamically from a custom servlet. This is the default. Usage example:collaborationAvatarGroup.setImageHandler(userInfo -> { DownloadHandler downloadHandler = DownloadHandler .fromInputStream(context -> { User userEntity = userRepository .findById(userInfo.getId()); byte[] profilePicture = userEntity.getProfilePicture(); return new DownloadResponse( new ByteArrayInputStream(profilePicture), "avatar_" + userInfo.getId(), "image/png", -1); }); return downloadHandler; });- Parameters:
imageHandler- the image handler to use, ornullto use image URLs directly from the user info object- Since:
- 6.5
-
getImageHandler
Gets the currently used image handler callback.- Returns:
- the current image handler callback, or
nullif no callback is set - Since:
- 6.5
- See Also:
-
isOwnAvatarVisible
public boolean isOwnAvatarVisible()Gets whether the user's own avatar is displayed in the avatar group or not.- Returns:
trueif the user's own avatar is included in the group,falseif not- Since:
- 1.0
- See Also:
-
setOwnAvatarVisible
public void setOwnAvatarVisible(boolean ownAvatarVisible) Sets whether to display user's own avatar in the avatar group or not. The default value istrue.To display user's own avatar separately from other users, you can set this to
false, create a separateAvatarcomponent and place it anywhere you like in your view.- Parameters:
ownAvatarVisible-trueto include user's own avatar,falseto not include it- Since:
- 1.0
-
createOwnAvatar
Creates an instance of the user's ownAvatarin this avatar group.- Returns:
- an instance of the user's own avatar
-
setImageHandler(ImageHandler)instead.