Some utilities for creating svg DOM documents and elements.
createClip
public static final Element createClip(Document doc,
Element els,
String id)
Create an SVG Clip.
doc
- the document to create the elementels
- the child elements that make the clipid
- the id of the clipping path
createEllipse
public static final Element createEllipse(Document doc,
float cx,
float cy,
float rx,
float ry)
Create an SVG Ellipse
doc
- the document to create the elementcx
- the centre x positioncy
- the centre y positionrx
- the x axis radiusry
- the y axis radius
createG
public static final Element createG(Document doc)
Create an SVG G.
doc
- the document to create the element
createImage
public static final Element createImage(Document doc,
String ref,
float width,
float height)
Create and svg image element.
doc
- the document to create the elementref
- the href link to the imagewidth
- the width to set on the imageheight
- the height to set on the image
createLine
public static final Element createLine(Document doc,
float x,
float y,
float x2,
float y2)
Create an SVG Line
doc
- the document to create the elementx
- the start x positiony
- the start y positionx2
- the end x positiony2
- the end y position
createPath
public static final Element createPath(Document doc,
String str)
Create an SVG Path.
doc
- the document to create the elementstr
- the string for the d attribute on the path
createRect
public static final Element createRect(Document doc,
float x,
float y,
float width,
float height)
Create an SVG Rectangle.
doc
- the document to create the elementx
- the start x positiony
- the start y positionwidth
- the width of the rectangleheight
- the height of the rectangle
- the new rectangle element
createSVGDocument
public static final Document createSVGDocument(float width,
float height)
Create a new svg document with batik.
width
- the width of the root svg elementheight
- the height of the root svg element
createText
public static final Element createText(Document doc,
float x,
float y,
String str)
Create an SVG Text object.
doc
- the document to create the elementx
- the start x positiony
- the start y positionstr
- the string
getStringBounds
public static final Rectangle2D getStringBounds(String str,
java.awt.Font font)
Get the string bounds for a particular string given the font.
str
- the stringfont
- the font
getStringHeight
public static final float getStringHeight(String str,
java.awt.Font font)
Get the string height for a particular string given the font.
str
- the stringfont
- the font
- the height of the string in the given font
getStringWidth
public static final float getStringWidth(String str,
java.awt.Font font)
Get the string width for a particular string given the font.
str
- the stringfont
- the font
- the width of the string in the given font
wrapText
public static final Element wrapText(Document doc,
String str,
java.awt.Font font,
float width)
Create some SVG text that is wrapped into a specified width.
doc
- the document to create the elementsstr
- the string to wrapfont
- the fontwidth
- the width to wrap
- the new element containing the wrapped text