public class SVGGenerator extends java.lang.Object implements GraphicsGenerator
| Constructor and Description |
|---|
SVGGenerator(double width,
double height) |
| Modifier and Type | Method and Description |
|---|---|
void |
addRectangle(double x,
double y,
double width,
double height)
Adds a rectangle to the path
|
void |
close() |
void |
fillPath(int color)
Fills the current path and ends it
|
byte[] |
getResult()
Returns the generated graphics as a byte array
|
void |
lineTo(double x,
double y)
Adds a line segment to the open path from the previous point to the speicifed position.
|
void |
moveTo(double x,
double y)
Moves the current point of the open path to the specified position.
|
int |
putMultilineText(java.lang.String text,
double x,
double y,
double maxWidth,
int fontSize)
Adds several lines of text to the graphics.
|
void |
putText(java.lang.String text,
double x,
double y,
int fontSize,
boolean isBold)
Adds text to the graphics.
|
void |
putTextLines(java.lang.String[] lines,
double x,
double y,
int fontSize)
Adds several lines of text to the graphics.
|
void |
setTransformation(double translateX,
double translateY,
double scale)
Sets a translation and a scale factor for the subsequent operations
|
void |
startPath()
Starts a path that can be filled or stroked
|
void |
strokePath(double strokeWidth,
int color)
Strokes the current path and ends it
|
public SVGGenerator(double width,
double height)
throws java.io.IOException
java.io.IOExceptionpublic void close()
throws java.io.IOException
close in interface java.io.Closeableclose in interface java.lang.AutoCloseablejava.io.IOExceptionpublic void startPath()
throws java.io.IOException
GraphicsGeneratorstartPath in interface GraphicsGeneratorjava.io.IOException - thrown if the graphics cannot be generatedpublic void moveTo(double x,
double y)
throws java.io.IOException
GraphicsGeneratormoveTo in interface GraphicsGeneratorx - x-coordinate of positiony - y-coordinate of positionjava.io.IOException - thrown if the graphics cannot be generatedpublic void lineTo(double x,
double y)
throws java.io.IOException
GraphicsGeneratorlineTo in interface GraphicsGeneratorx - x-coordinate of positiony - y-coordinate of positionjava.io.IOException - thrown if the graphics cannot be generatedpublic void addRectangle(double x,
double y,
double width,
double height)
throws java.io.IOException
GraphicsGeneratoraddRectangle in interface GraphicsGeneratorx - the rectangle's left position (in mm)y - the rectangle's top position (in mm)width - the rectangle's width (in mm)height - rectangle's height (in mm)java.io.IOException - thrown if the graphics cannot be generatedpublic void fillPath(int color)
throws java.io.IOException
GraphicsGeneratorfillPath in interface GraphicsGeneratorcolor - the fill color (expressed similar to HTML, e.g. 0xffffff for white)java.io.IOException - thrown if the graphics cannot be generatedpublic void strokePath(double strokeWidth,
int color)
throws java.io.IOException
GraphicsGeneratorstrokePath in interface GraphicsGeneratorstrokeWidth - the stroke width (in pt)color - the stroke color (expressed similar to HTML, e.g. 0xffffff for white)java.io.IOException - thrown if the graphics cannot be generatedpublic void putText(java.lang.String text,
double x,
double y,
int fontSize,
boolean isBold)
throws java.io.IOException
GraphicsGeneratorputText in interface GraphicsGeneratortext - the textx - x position of the text's start (in mm)y - y position of the text's top (in mm)fontSize - the font size (in pt)isBold - indicates if the text is in bold or regular weightjava.io.IOException - thrown if the graphics cannot be generatedpublic int putMultilineText(java.lang.String text,
double x,
double y,
double maxWidth,
int fontSize)
throws java.io.IOException
GraphicsGeneratorThe specified text is automatically broken into several lines if a text line would exceed the specified maximum length of a text line. Newlines can be used to force a line break.
putMultilineText in interface GraphicsGeneratortext - the textx - x position of the text's start (in mm)y - y position of the text's top (in mm)maxWidth - maximum length of text line / width of text block (in mm)fontSize - the font size (in pt)java.io.IOException - thrown if the graphics cannot be generatedpublic void putTextLines(java.lang.String[] lines,
double x,
double y,
int fontSize)
throws java.io.IOException
GraphicsGeneratorputTextLines in interface GraphicsGeneratorlines - the text linesx - x position of the text's start (in mm)y - y position of the text's top (in mm)fontSize - the font size (in pt)java.io.IOException - thrown if the graphics cannot be generatedpublic void setTransformation(double translateX,
double translateY,
double scale)
throws java.io.IOException
GraphicsGeneratorsetTransformation in interface GraphicsGeneratortranslateX - translation in x direction (in mm)translateY - translation in y direction (in mm)scale - scale fator (1.0 = no scaling)java.io.IOException - thrown if the graphics cannot be generatedpublic byte[] getResult()
throws java.io.IOException
GraphicsGeneratorgetResult in interface GraphicsGeneratorjava.io.IOException - thrown if the graphics cannot be generated