@ApplicationScoped public class SvgDataUriGenerator extends Object
| Modifier and Type | Field and Description |
|---|---|
static String |
SVG_CONTENT_TYPE |
static String |
SVG_DATA_URI_BASE64 |
static String |
SVG_DATA_URI_UTF8 |
| Constructor and Description |
|---|
SvgDataUriGenerator() |
| Modifier and Type | Method and Description |
|---|---|
static String |
encodeBase64(String dataUriDecoded)
Encodes the specified data-uri string in XML/Base64 format.
|
static String |
encodeUtf8(String dataUriDecoded)
Encodes the specified data-uri string in XML/UTF8 format.
|
String |
generate(com.google.gwt.safehtml.shared.SafeUri svgUri)
Generates an SVG data-uri with no external resource references, if any.
|
String |
generate(com.google.gwt.safehtml.shared.SafeUri svgUri,
Collection<com.google.gwt.safehtml.shared.SafeUri> svgDefs,
Collection<String> validUseRefIds)
Generates a single SVG data-uri from different input SVG declarations.
|
public static final String SVG_CONTENT_TYPE
public static final String SVG_DATA_URI_BASE64
public static final String SVG_DATA_URI_UTF8
public static String encodeUtf8(String dataUriDecoded)
public static String encodeBase64(String dataUriDecoded)
public String generate(com.google.gwt.safehtml.shared.SafeUri svgUri)
GWT DataResource does not support external references, used for example
by the use element.
public String generate(com.google.gwt.safehtml.shared.SafeUri svgUri, Collection<com.google.gwt.safehtml.shared.SafeUri> svgDefs, Collection<String> validUseRefIds)
As GWT DataResource does not like SVG external references, this is an alternative solution that creates a composite SVG declaration by joining each SVG declaration given from the arguments.
Given a parent SVG declaration, which contain external resource references to other
SVG declarations, and its given SVG referenced declarations, it aggregates the
referenced elements in a SVG Def element, and generates a composite
SVG which encapsulates the parent and referenced ones in a single declaration. It also
handles the external resource references, within the parent SVG, in order to match the actual
content, and removes the invalid references.
It generates a valid SVG declaration as:
svgUri - The parent SVG declaration data-uri, which may contain external resource references.svgDefs - The external resources which are referenced in the parent SVG declaration, given by the svgUri argument.validUseRefIds - The valid external reference identifiers to keep in the resulting declaration. Usually those are
the SVG identifiers for each of the declarations given by the svgDefs argument.Copyright © 2001–2017 JBoss by Red Hat. All rights reserved.