public class SvgFragment extends SvgContainer
Of particular importance is that the svg fragment can also contain a viewbox which can be used for scaling the image to a particular size. Therefore this element is where the real-world rendered dimensions interact with the svg dimenions.
Modifier and Type | Field and Description |
---|---|
(package private) SvgTransform |
boundsTransform |
(package private) java.lang.Float |
height |
(package private) boolean |
preserveAspectRatio |
(package private) float[] |
viewBox
viewBox[0] == x
viewBox[1] == y
viewBox[2] == w
viewBox[3] == h
|
(package private) java.lang.Float |
width |
(package private) java.lang.Float |
x |
(package private) java.lang.Float |
y |
elements
description, fill, stroke, title, transform
Constructor and Description |
---|
SvgFragment(SvgContainer container,
java.lang.String id) |
Modifier and Type | Method and Description |
---|---|
void |
apply(org.eclipse.swt.graphics.GC gc,
org.eclipse.swt.graphics.Rectangle bounds)
Apply this svg fragment to the given graphics context, scaled to fit within
the given bounds.
|
SvgElement |
getElement(java.lang.String id) |
SvgFragment |
getFragment() |
java.util.Map<java.lang.String,java.lang.String> |
getStyles(java.lang.String className)
Return a map of css styles for the given class name, if it exists.
|
float[] |
getViewport() |
boolean |
hasElement(java.lang.String id)
Returns true if this fragment contains an SvgElement with the given id.
|
boolean |
isOutermost()
Returns true if this SvgFragment is at the outermost level, meaning it
is a direct child of the SvgDocument.
|
(package private) void |
put(SvgElement element) |
add, apply, getElements, isEmpty
getDescription, getFill, getStroke, getTitle, getTransform
getAncestry, getContainer, getId, setContainer
java.lang.Float x
java.lang.Float y
java.lang.Float width
java.lang.Float height
float[] viewBox
SvgTransform boundsTransform
boolean preserveAspectRatio
SvgFragment(SvgContainer container, java.lang.String id)
public void apply(org.eclipse.swt.graphics.GC gc, org.eclipse.swt.graphics.Rectangle bounds)
gc
- the graphics contextbounds
- the bounds to which this fragment will be scaledpublic SvgElement getElement(java.lang.String id)
getElement
in class SvgElement
public SvgFragment getFragment()
getFragment
in class SvgElement
public java.util.Map<java.lang.String,java.lang.String> getStyles(java.lang.String className)
Each SvgFragment can contain a style element which consists of css styles.
className
- the name of the css class to return styles for.public float[] getViewport()
getViewport
in class SvgElement
public boolean hasElement(java.lang.String id)
id
- the id of the elementpublic boolean isOutermost()
void put(SvgElement element)