com.vaadin.flow.component.icon.
Class SvgIcon
All Implemented Interfaces:
AttachNotifier
, ClickNotifier<SvgIcon>
, DetachNotifier
, HasElement
, HasStyle
, HasTooltip
, Serializable
Component for displaying an icon from a SVG file.
Author:
Vaadin Ltd
See Also:
-
Constructor Summary
ConstructorsConstructorDescriptionSvgIcon()
Default constructor.
Creates an SVG icon with the given resource
SvgIcon
(AbstractStreamResource src, String symbol) Creates an SVG icon with the given resource
Creates an SVG icon with the given source
Creates 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.
void
Sets the color of the icon.
void
Defines the source of the icon from the given
StreamResource
The resource must contain a valid SVG element.void
setSrc
(AbstractStreamResource src, String symbol) Defines the src and the symbol to be used in the icon.
void
Sets the URL of the SVG file to be used as the icon.
void
Defines the src and the symbol to be used in the icon.
void
Defines the symbol identifier that references an ID of an element contained in the SVG element assigned to the
setSrc(String)
property.Methods inherited from class com.vaadin.flow.component.icon.AbstractIcon
setSize
Methods 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, setVisible
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
Methods inherited from interface com.vaadin.flow.component.AttachNotifier
addAttachListener
Methods inherited from interface com.vaadin.flow.component.ClickNotifier
addClickListener, addClickShortcut, addDoubleClickListener, addSingleClickListener
Methods inherited from interface com.vaadin.flow.component.DetachNotifier
addDetachListener
Methods inherited from interface com.vaadin.flow.component.HasElement
getElement
Methods inherited from interface com.vaadin.flow.component.HasStyle
addClassName, addClassNames, getClassName, getClassNames, getStyle, hasClassName, removeClassName, removeClassNames, setClassName, setClassName
Methods 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 pathSee Also:
-
SvgIcon
Creates an SVG icon with the given source and symbol
Parameters:
src
- the SVG file pathsymbol
- the symbol reference of the iconSee Also:
-
SvgIcon
Creates an SVG icon with the given resource
Parameters:
src
- the resource valueSee Also:
-
SvgIcon
Creates an SVG icon with the given resource
Parameters:
src
- the resource valuesymbol
- the symbol reference of the iconSee 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 iconSee Also:
-
setSrc
Defines the source of the icon from the given
StreamResource
The resource must contain a valid SVG element.Parameters:
src
- the source value, not null -
setSrc
Defines 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 iconSee 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:
AbstractIcon
Sets 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:
setColor
in classAbstractIcon<SvgIcon>
Parameters:
color
- the color to set, may benull
to clear the value -
getColor
Description copied from class:
AbstractIcon
Gets the color of this icon as a String.
Specified by:
getColor
in classAbstractIcon<SvgIcon>
Returns:
the color of the icon, or
null
if the color has not been set
-