public class FSSVGImage extends Object implements FSImage
background-image, list-style-image, ...)
stay vector art in the output.
Unlike a replaced svg element there is no box to size against here: the
image starts out at the size the SVG asks for and is resized by the layout, for example by
background-size. Because of that the size is mutable, and each user gets its
own instance via copy() while the expensive parts - the parsed element and the
already built images - stay shared.
Output devices recognize this class in drawImage and hand it back to the
SVG drawer instead of treating it as a bitmap.
| Modifier and Type | Method and Description |
|---|---|
FSSVGImage |
copy()
Returns an independently sizable view of this image.
|
static FSSVGImage |
create(Element svgElement,
SVGDrawer drawer,
double dotsPerPixel,
String uri)
Creates an image for the given SVG root element.
|
void |
drawSVG(OutputDevice outputDevice,
double x,
double y)
Draws the SVG at its current size, with the top left corner at the given position
in dots.
|
int |
getHeight() |
Element |
getSVGElement()
The root
svg element, for callers that would rather draw the SVG
themselves than go through this image. |
String |
getUri()
The URI this image was loaded from, for logging.
|
int |
getWidth() |
boolean |
isAwaitingSize()
Whether this image has no size of its own and is still waiting for CSS to give it one.
|
void |
scale(int width,
int height) |
void |
sizeToDefaultObjectSize(int availableWidth,
int availableHeight)
Sizes an SVG that has no size of its own to the area it is being painted into, which is
what CSS calls the default object size.
|
public static FSSVGImage create(Element svgElement, SVGDrawer drawer, double dotsPerPixel, String uri)
public FSSVGImage copy()
public void sizeToDefaultObjectSize(int availableWidth,
int availableHeight)
viewBox is
respected, so the image is made as large as it can be inside the area without changing
its shape. Does nothing once the size is settled, or for an SVG that has a size already.
This is how a browser sizes a background image whose SVG is written in percentages or
carries no width and height at all: the image fills the background positioning area
unless background-size says otherwise.
public boolean isAwaitingSize()
public void drawSVG(OutputDevice outputDevice, double x, double y)
public String getUri()
public Element getSVGElement()
svg element, for callers that would rather draw the SVG
themselves than go through this image.Copyright © 2004–2026. All rights reserved.