Package com.vaadin.flow.server
Class PwaIcon
- java.lang.Object
-
- com.vaadin.flow.server.PwaIcon
-
- All Implemented Interfaces:
Serializable
public class PwaIcon extends Object implements Serializable
Implementation of icons used in PWA resources. Creates the href automatically based on - baseName (the file name with path, as icons/icon.png") - width (width of icon) - height (height of icon) - (possibly) fileHash (the hashcode of image file) The href will be set as:[basename]-[width]x[height].png{?[filehash]}The trailing ?[filehash] will be added if icon cache is not controlled by service worker: cached = false Icon caching is left to the browser if it's not cached with service worker.- Since:
- 1.2
- See Also:
- Serialized Form
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static classPwaIcon.DomainPlace where icon belongs to (header or manifest.webmanifest).
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description org.jsoup.nodes.ElementasElement()Gets anElementpresentation of the icon.protected BufferedImagegetBaseImage()StringgetCacheFormat()Gets the cache-string used in Google Workbox caching.PwaIcon.DomaingetDomain()Gets the iconPwaIcon.Domain.intgetHeight()Gets height of an icon.StringgetHref()Gets the value of the href attribute.StringgetRelHref()Return href with '/' -prefix and removed possible ?[fileHash].StringgetSizes()Gets the value of the sizes attribute.StringgetType()Gets the value of the type attribute.intgetWidth()Gets width of an icon.voidsetImage(BufferedImage image)Sets the image presenting the icon.voidsetRegistry(PwaRegistry registry)booleanshouldBeCached()Should the icon be cached by the Service Worker.voidwrite(OutputStream outputStream)Writes the icon image to output stream.
-
-
-
Constructor Detail
-
PwaIcon
protected PwaIcon(PwaIcon icon)
-
-
Method Detail
-
asElement
public org.jsoup.nodes.Element asElement()
Gets anElementpresentation of the icon.- Returns:
- an
Elementpresentation of the icon
-
getWidth
public int getWidth()
Gets width of an icon.- Returns:
- width of an icon
-
getHeight
public int getHeight()
Gets height of an icon.- Returns:
- height of an icon
-
shouldBeCached
public boolean shouldBeCached()
Should the icon be cached by the Service Worker.- Returns:
- should the icon be cached by the Service Worker.
-
getSizes
public String getSizes()
Gets the value of the sizes attribute.- Returns:
- value of the sizes attribute
-
getHref
public String getHref()
Gets the value of the href attribute.- Returns:
- value of the href attribute
-
getRelHref
public String getRelHref()
Return href with '/' -prefix and removed possible ?[fileHash]. Used in matching, when serving images.- Returns:
- href with '/' -prefix and removed possible ?[fileHash]
-
getCacheFormat
public String getCacheFormat()
Gets the cache-string used in Google Workbox caching.- Returns:
- "{ url: '[href]', revision: '[fileHash' }"
-
getType
public String getType()
Gets the value of the type attribute.- Returns:
- value of the type attribute
-
getDomain
public PwaIcon.Domain getDomain()
Gets the iconPwaIcon.Domain.- Returns:
- the domain of the icon
-
setRegistry
public void setRegistry(PwaRegistry registry)
-
setImage
public void setImage(BufferedImage image)
Sets the image presenting the icon.- Parameters:
image- the image in png format
-
write
public void write(OutputStream outputStream)
Writes the icon image to output stream.- Parameters:
outputStream- output stream to write the icon image to
-
getBaseImage
protected BufferedImage getBaseImage()
-
-