JSVG - A Java SVG implementation
The SVG logo rendered using JSVG
JSVG is an SVG user agent using AWT graphics. Its aim is to provide a small and fast implementation. This library is under active development and doesn't yet support all features of the SVG specification, some of which it decidedly won't support at all. This implementation only tries to be a static user agent meaning it won't support any scripting languages or interaction. Animations aren't currently implemented but are planned to be supported.
This library aims to be as lightweight as possible. Generally JSVG uses ~50% less memory than svgSalamander and ~98% less than Batik.
How to use
The library is available on maven central:
dependencies {
implementation("com.github.weisj:jsvg:0.0.3")
}
Also nightly snapshot builds will be release to maven:
repositories {
maven {
url = uri("https://oss.sonatype.org/content/repositories/snapshots/")
}
}
configurations.all {
resolutionStrategy.cacheChangingModulesFor(0, "seconds")
}
dependencies {
implementation("com.github.weisj:jsvg:latest.integration")
}
To load an svg icon you can use the SVGLoader
class. It will produce an SVGDocument
which can be rendered to any Graphics2D
object you like (e.g. a BufferedImage
or a swing component).
Supported features
For supported elements most of the attributes which apply to them are implemented.
-
✅ : The element is supported. Note that this doesn't mean that every attribute is supported. - (
✅ ): The element is supported, but won't have any effect (e.g. it's currently not possible to query the content of a<desc>
element) -
☑️ : The element is partially implemented and might not support most basic features of the element. -
❌ : The element is currently not supported -
⚠️ : The element is deprecated in the spec and has a low priority of getting implemented. -
🧪 : The element is an experimental part of the svg 2.* spec. It may not fully behave as expected.
Shape and container elements
Element | Status |
---|---|
a |
|
circle |
|
clipPath |
|
defs |
|
ellipse |
|
foreignObject |
|
g |
|
image |
|
line |
|
marker |
|
mask |
|
path |
|
polygon |
|
polyline |
|
rect |
|
svg |
|
symbol |
|
use |
|
view | ( |
Paint server elements
Element | Status |
---|---|
linearGradient |
|
|
|
|
|
|
|
pattern |
|
radialGradient |
|
solidColor |
|
stop |
|
Text elements
Element | Status |
---|---|
text |
|
textPath |
|
|
|
tspan |
|
Animation elements
Element | Status |
---|---|
animate |
|
|
|
animateMotion |
|
animateTransform |
|
mpath |
|
set |
|
switch |
|
Filter elements
Element | Status |
---|---|
feBlend |
|
feColorMatrix |
|
feComponentTransfer |
|
feComposite |
|
feConvolveMatrix |
|
feDiffuseLighting |
|
feDisplacementMap |
|
feDistantLight |
|
feFlood |
|
feFuncA |
|
feFuncB |
|
feFuncG |
|
feFuncR |
|
feGaussianBlur |
|
feImage |
|
feMerge |
|
feMergeNode |
|
feMorphology |
|
feOffset |
|
fePointLight |
|
feSpecularLighting |
|
feSpotLight |
|
feTile |
|
feTurbulence |
|
filter |
|
Font elements
Element | Status |
---|---|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Other elements
Element | Status |
---|---|
desc | ( |
title | ( |
metadata | ( |
color-profile |
|
|
|
script |
|
style |
|