Class SvgIcon
- All Implemented Interfaces:
com.vaadin.flow.component.AttachNotifier,com.vaadin.flow.component.ClickNotifier<SvgIcon>,com.vaadin.flow.component.DetachNotifier,com.vaadin.flow.component.HasElement,com.vaadin.flow.component.HasStyle,com.vaadin.flow.component.shared.HasTooltip,Serializable
- Author:
- Vaadin Ltd
- See Also:
-
Constructor Summary
ConstructorsConstructorDescriptionSvgIcon()Default constructor.SvgIcon(com.vaadin.flow.server.AbstractStreamResource src) Deprecated, for removal: This API element is subject to removal in a future version.Deprecated, for removal: This API element is subject to removal in a future version.UseSvgIcon(DownloadHandler, String)insteadSvgIcon(com.vaadin.flow.server.streams.DownloadHandler src) Creates an SVG icon with the given download handler resource.Creates an SVG icon with the given download handler resource.Creates an SVG icon with the given sourceCreates an SVG icon with the given source and symbol -
Method Summary
Modifier and TypeMethodDescriptiongetColor()Gets the color of this icon as a String.getSrc()Gets the source defined in the icon.Gets the symbol defined in the icon.voidSets the color of the icon.voidsetSrc(com.vaadin.flow.server.AbstractStreamResource src) Deprecated, for removal: This API element is subject to removal in a future version.UsesetSrc(DownloadHandler)insteadvoidDeprecated, for removal: This API element is subject to removal in a future version.UsesetSrc(DownloadHandler, String)insteadvoidsetSrc(com.vaadin.flow.server.streams.DownloadHandler src) Defines the source of the icon from the givenDownloadHandlerThe resource must contain a valid SVG element.voidDefines the src and the symbol to be used in the icon.voidSets the URL of the SVG file to be used as the icon.voidDefines the src and the symbol to be used in the icon.voidDefines the symbol identifier that references an ID of an element contained in the SVG element assigned to thesetSrc(String)property.Methods inherited from class com.vaadin.flow.component.icon.AbstractIcon
setSizeMethods inherited from class com.vaadin.flow.component.Component
addListener, findAncestor, fireEvent, from, get, getChildren, getElement, 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.ClickNotifier
addClickListener, addClickShortcut, addDoubleClickListener, addSingleClickListenerMethods 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.HasStyle
addClassName, addClassNames, getClassName, getClassNames, getStyle, hasClassName, removeClassName, removeClassNames, setClassName, setClassNameMethods inherited from interface com.vaadin.flow.component.shared.HasTooltip
getTooltip, setTooltipText
-
Constructor Details
-
SvgIcon
public SvgIcon()Default constructor. Creates an empty SVG icon. -
SvgIcon
Creates an SVG icon with the given source- Parameters:
src- the SVG file path- See Also:
-
SvgIcon
Creates an SVG icon with the given source and symbol- Parameters:
src- the SVG file pathsymbol- the symbol reference of the icon- See Also:
-
SvgIcon
@Deprecated(since="24.8", forRemoval=true) public SvgIcon(com.vaadin.flow.server.AbstractStreamResource src) Deprecated, for removal: This API element is subject to removal in a future version.UseSvgIcon(DownloadHandler)insteadCreates an SVG icon with the given resource- Parameters:
src- the resource value- See Also:
-
SvgIcon
@Deprecated(since="24.8", forRemoval=true) public SvgIcon(com.vaadin.flow.server.AbstractStreamResource src, String symbol) Deprecated, for removal: This API element is subject to removal in a future version.UseSvgIcon(DownloadHandler, String)insteadCreates an SVG icon with the given resource- Parameters:
src- the resource valuesymbol- the symbol reference of the icon- See Also:
-
SvgIcon
public SvgIcon(com.vaadin.flow.server.streams.DownloadHandler src) Creates an SVG icon with the given download handler resource.Sets the
Content-Dispositionheader toinlinefor pre-defined download handlers, created by factory methods inDownloadHandler, as well as for otherAbstractDownloadHandlerimplementations.- Parameters:
src- the download handler resource- See Also:
-
SvgIcon
Creates an SVG icon with the given download handler resource.Sets the
Content-Dispositionheader toinlinefor pre-defined download handlers, created by factory methods inDownloadHandler, as well as for otherAbstractDownloadHandlerimplementations.- Parameters:
src- the download handler resourcesymbol- the symbol reference of the icon- See Also:
-
-
Method Details
-
setSrc
Sets the URL of the SVG file to be used as the icon. The value can be:- A path to a standalone SVG file
-
A path in the format `"path/to/file.svg#symbol-id"` to an SVG file, where "symbol-id" refers to an id of an element (generally a `
` element) to be rendered in the icon component. Note that the sprite file needs to follow the same-origin policy
- Alternatively, the source can be defined as a string in the format `"data:image/svg+xml,`
- Parameters:
src- the source file of the icon
-
setSrc
Defines the src and the symbol to be used in the icon.- Parameters:
src- the path of the icon sprite filesymbol- the symbol reference of the icon- See Also:
-
setSrc
@Deprecated(since="24.8", forRemoval=true) public void setSrc(com.vaadin.flow.server.AbstractStreamResource src) Deprecated, for removal: This API element is subject to removal in a future version.UsesetSrc(DownloadHandler)insteadDefines the source of the icon from the givenStreamResourceThe resource must contain a valid SVG element.- Parameters:
src- the source value, not null
-
setSrc
@Deprecated(since="24.8", forRemoval=true) public void setSrc(com.vaadin.flow.server.AbstractStreamResource src, String symbol) Deprecated, for removal: This API element is subject to removal in a future version.UsesetSrc(DownloadHandler, String)insteadDefines the src and the symbol to be used in the icon.- Parameters:
src- the source of the icon sprite file, not nullsymbol- the symbol reference of the icon- See Also:
-
setSrc
public void setSrc(com.vaadin.flow.server.streams.DownloadHandler src) Defines the source of the icon from the givenDownloadHandlerThe resource must contain a valid SVG element.Sets the
Content-Dispositionheader toinlinefor pre-defined download handlers, created by factory methods inDownloadHandler, as well as for otherAbstractDownloadHandlerimplementations.- Parameters:
src- the source value, not null
-
setSrc
Defines the src and the symbol to be used in the icon.Sets the
Content-Dispositionheader toinlinefor pre-defined download handlers, created by factory methods inDownloadHandler, as well as for otherAbstractDownloadHandlerimplementations.- Parameters:
src- the source of the icon sprite file, not nullsymbol- the symbol reference of the icon- See Also:
-
getSrc
Gets the source defined in the icon.- Returns:
- the source defined or
null
-
setSymbol
Defines the symbol identifier that references an ID of an element contained in the SVG element assigned to the
setSrc(String)property.If there's an identifier in the path defined in
setSrc(String)in the moment this method is called, the value passed tosetSymbol(String)will be used.- Parameters:
symbol- the symbol identifier of the icon to be shown
-
getSymbol
Gets the symbol defined in the icon.- Returns:
- the symbol defined or
null
-
setColor
Description copied from class:AbstractIconSets the color of the icon.The color should be in a format understood by the browser, e.g. "orange", "#FF9E2C" or "rgb(255, 158, 44)".
- Specified by:
setColorin classAbstractIcon<SvgIcon>- Parameters:
color- the color to set, may benullto clear the value
-
getColor
Description copied from class:AbstractIconGets the color of this icon as a String.- Specified by:
getColorin classAbstractIcon<SvgIcon>- Returns:
- the color of the icon, or
nullif the color has not been set
-
SvgIcon(DownloadHandler)instead