public class SVGExternalFileResolver extends Object
When AndroidSVG encounters a reference to an external object, such as an image, it will call the associated method on this class in an attempt to load it.
The default behaviour of each method is to tell AndroidSVG that the reference could not be found. Extend this class and override the methods if you want to customise how AndroidSVG treats font, image, and external CSS references.
public class MyResolver {
// Override the default method implementations with your own.
// See the code for SimpleAssetResolver class, for examples of how to do that.
}
// Register your resolver with AndroidSVG
SVG.registerExternalFileResolver(new MyResolver());
// Your resolver will now be used when an SVG is parsed or rendered,
SVG mySVG = SVG.getFromX();
| Constructor and Description |
|---|
SVGExternalFileResolver() |
| Modifier and Type | Method and Description |
|---|---|
boolean |
isFormatSupported(String mimeType)
Called by renderer to determine whether a particular format is supported.
|
String |
resolveCSSStyleSheet(String url)
Called by the parser to resolve CSS stylesheet file references in <?xml-stylesheet?>
processing instructions.
|
Typeface |
resolveFont(String fontFamily,
int fontWeight,
String fontStyle)
Called by renderer to resolve font references in <text> elements.
|
Bitmap |
resolveImage(String filename)
Called by renderer to resolve image file references in <image> elements.
|
public Typeface resolveFont(String fontFamily, int fontWeight, String fontStyle)
An implementation of this method should return a Typeface instance, or null
if you want the renderer to ignore this font request.
Note that AndroidSVG does not attempt to cache Typeface references. If you want them cached, for speed or memory reasons, you should do so yourself.
fontFamily - Font family as specified in a font-family style attribute.fontWeight - Font weight as specified in a font-weight style attribute.fontStyle - Font style as specified in a font-style style attribute.public Bitmap resolveImage(String filename)
An implementation of this method should return a Bitmap instance, or null if
you want the renderer to ignore this image.
Note that AndroidSVG does not attempt to cache Bitmap references. If you want them cached, for speed or memory reasons, you should do so yourself.
filename - the filename as provided in the xlink:href attribute of a <image> element.public String resolveCSSStyleSheet(String url)
An implementation of this method should return a String whose contents
correspond to the URL passed in.
Note that AndroidSVG does not attempt to cache stylesheet references. If you want them cached, for speed or memory reasons, you should do so yourself.
url - the URL of the CSS file as it appears in the SVG file.public boolean isFormatSupported(String mimeType)
requiredFormats
conditionals.mimeType - A MIME type (such as "image/jpeg").resolveImage() implementation supports this file format.