Class SVGUtil
java.lang.Object
org.abego.treelayout.demo.svg.SVGUtil
A set of methods to generate SVG content.
Mainly to keep the footprint small only a very limited set of SVG functionality is supported. In case more features are required have a look at Batik - Java SVG Toolkit.
Example
String s = doc(svg(
160,
200,
rect(0, 0, 160, 200, "fill:red;")
+ svg(10, 10, 100, 100,
rect(0, 0, 100, 100, "fill:orange; stroke:rgb(0,0,0);"))
+ line(20, 20, 100, 100, "stroke:black; stroke-width:2px;")
+ line(20, 100, 100, 20, "stroke:black; stroke-width:2px;")
+ text(10, 140,
"font-family:verdana; font-size:20px; font-weight:bold;",
"Hello world")));
File file = new File("demo.svg");
FileWriter w = null;
try {
w = new FileWriter(file);
w.write(s);
} finally {
if (w != null) {
w.close();
}
}
(see main(String[]))
-
Constructor Summary
Constructors -
Method Summary
-
Constructor Details
-
SVGUtil
public SVGUtil()
-
-
Method Details
-
svg
-
svg
-
svg
-
svg
-
rect
-
rect
-
rect
-
rect
-
line
-
line
-
text
-
text
-
doc
-
viewSVG
- Throws:
IOException
-
main
Creates a sample SVG file "demo.svg"- Parameters:
args- option '-view': view the just created file (may not be supported on all platforms)- Throws:
IOException-
-