org.apache.batik.apps.rasterizer
public class SVGConverter extends Object
Nested Class Summary | |
---|---|
static class | SVGConverter.SVGFileFilter
Convenience class to filter svg files |
Field Summary | |
---|---|
protected String | allowedScriptTypes Set of allowed script types. |
protected String | alternateStylesheet Alternate stylesheet for which should be applied to the SVG |
protected Rectangle2D | area Output AOI area. |
protected Color | backgroundColor Background color for the output images. |
protected boolean | constrainScriptOrigin Controls whether scripts can only have the same origin as
the document which references them. |
protected SVGConverterController | controller
Controls some aspects of the converter's operation,
such as whether or not it should proceed in some
error situations. |
protected String | defaultFontFamily Default value for the font-family when it is unspecified |
protected DestinationType | destinationType Result type |
protected File | dst
Destination image path. |
protected static float | DEFAULT_HEIGHT Default height |
protected static float | DEFAULT_QUALITY Default quality value. |
protected static DestinationType | DEFAULT_RESULT_TYPE Default result type |
protected static float | DEFAULT_WIDTH Default width |
protected boolean | executeOnload Execute the 'onload' scripts flag |
static String | ERROR_CANNOT_ACCESS_TRANSCODER |
static String | ERROR_CANNOT_COMPUTE_DESTINATION |
static String | ERROR_CANNOT_OPEN_OUTPUT_FILE |
static String | ERROR_CANNOT_OPEN_SOURCE |
static String | ERROR_CANNOT_READ_SOURCE |
static String | ERROR_CANNOT_USE_DST_FILE |
static String | ERROR_NO_SOURCES_SPECIFIED |
static String | ERROR_OUTPUT_NOT_WRITEABLE |
static String | ERROR_SOURCE_SAME_AS_DESTINATION |
static String | ERROR_UNABLE_TO_CREATE_OUTPUT_DIR |
static String | ERROR_WHILE_RASTERIZING_FILE |
protected List | files Contents of fileset elements. |
protected float | height Output image height. |
protected int | indexed Should output Image be indexed . |
protected String | language Language |
protected float | maxHeight Maximum output image height. |
protected float | maxWidth Maximum output image width. |
protected String | mediaType Media type for which the SVG image should be rendered |
protected static float | MAXIMUM_QUALITY Maximum quality value |
protected float | pixelUnitToMillimeter Millimeters Per Pixel |
protected float | quality Output image quality. |
protected boolean | securityOff Controls whether scripts should be run securely or not |
protected float | snapshotTime Document time to seek to. |
protected List | sources Sources files or URLs |
protected static String | SVG_EXTENSION SVG file extension |
protected String | userStylesheet User stylesheet |
protected boolean | validate Validation flag |
protected float | width Output image width. |
Constructor Summary | |
---|---|
SVGConverter() | |
SVGConverter(SVGConverterController controller) |
Method Summary | |
---|---|
protected List | computeDstFiles(List sources)
Populates a vector with destination files names
computed from the names of the files in the sources vector
and the value of the dst property |
protected List | computeSources()
Populates a vector with the set of SVG files from the
srcDir if it is not null and with the sources (files or URLs)
if any. |
protected Map | computeTranscodingHints()
Computes the set of transcoding hints to use for the operation |
protected void | createOutputDir(File output)
Creates directories for output files if needed.
|
void | execute()
Starts the conversion process. |
String | getAllowedScriptTypes()
Returns the list of allowed script types.
|
String | getAlternateStylesheet() |
Rectangle2D | getArea() |
Color | getBackgroundColor() |
boolean | getConstrainScriptOrigin()
Returns whether scripts can only be loaded from the same
origin as the documents referencing them. |
String | getDefaultFontFamily() |
protected String | getDestinationFile(String file)
Get the name of the result image file.
|
DestinationType | getDestinationType() |
File | getDst() |
boolean | getExecuteOnload()
Returns true if the scripts attached to the DOM using 'onload'
event attribute is going to be executed before rasterizing,
false otherwise. |
String[] | getFileNRef(String fileName) |
float | getHeight() |
int | getIndexed() |
String | getLanguage() |
float | getMaxHeight() |
float | getMaxWidth() |
String | getMediaType() |
float | getPixelUnitToMillimeter() |
float | getQuality() |
boolean | getSecurityOff()
Returns whether or not scripts will be run securely |
float | getSnapshotTime()
Returns the document to to seek to before rasterizing. |
List | getSources() |
String | getUserStylesheet() |
boolean | getValidate() |
float | getWidth() |
protected boolean | isFile(File f)
Returns true if f is a File. |
protected boolean | isWriteable(File file)
Checks if the application is allowed to write to the file.
|
void | setAllowedScriptTypes(String allowedScriptTypes)
Sets the set of allowed script types (i.e., the set of possible
values for the type attribute in the <script> element),
as a comma separated list of allowed values. |
void | setAlternateStylesheet(String alternateStylesheet)
Sets the alternateStyleSheet value. |
void | setArea(Rectangle2D area)
Sets the area as a Rectangle. |
void | setBackgroundColor(Color backgroundColor)
Sets the backgroundColor value. |
void | setConstrainScriptOrigin(boolean constrainScriptOrigin)
Sets whether scripts should only be loaded from the same
location as the documents referencing them. |
void | setDefaultFontFamily(String defaultFontFamily)
Sets the defaultFontFamily value. |
void | setDestinationType(DestinationType destinationType)
Sets the destinationType attribute value.
|
void | setDst(File dst)
When converting a single source, dst can be a file.
|
void | setExecuteOnload(boolean b)
Sets whether or not scripts attached to the DOM using 'onload'
event attribute must be executed before rasterizing.
|
void | setHeight(float height)
In less than or equal to zero, the height is not
constrained on the output image. |
void | setIndexed(int bits)
Tells the PNG encoder to reduce the image to 256 colors, so the
PNG file is indexed. |
void | setLanguage(String language)
Sets the user language. |
void | setMaxHeight(float height)
If less than or equal to zero, the maximum height
does not have any effect on the output image.
|
void | setMaxWidth(float width)
If less than or equal to zero, the maximum width
does not have any effect on the output image.
|
void | setMediaType(String mediaType)
Sets the mediaType value. |
void | setPixelUnitToMillimeter(float pixelUnitToMillimeter)
Sets the millimeters per pixel constant. |
void | setQuality(float quality)
Sets the JPEG encoding quality. |
void | setSecurityOff(boolean securityOff)
Sets whether or not scripts should be run securely |
void | setSnapshotTime(float t)
Sets the document time to seek to before rasterizing.
|
void | setSources(String[] sources)
Sets the list of individual SVG sources. |
void | setUserStylesheet(String userStylesheet)
Sets the user stylesheet. |
void | setValidate(boolean validate)
Defines whether or not input sources should be validated in
the conversion process |
void | setWidth(float width)
In less than or equal to zero, the width is not
constrained on the output image. |
protected void | transcode(SVGConverterSource inputFile, File outputFile, Transcoder transcoder)
Converts the input image to the result image.
with the given transcoder. |
Parameters: output Output file with path.
Throws: SVGConverterException Output directory doesn't exist and it can't be created.
Throws: SVGConverterException thrown if parameters are not set correctly.
See Also: SVGConverter
This method modifies the result filename, it changes the existing suffix to correspong the result file type. It also adds the suffix if the file doesn't have one.
Parameters: file Result file name as a String object.
Returns: Name of the file. The directory of the file is not returned. The returned string is empty if the parameter is not a file.
f
is found to be a file if
it exists and is a file. If it does not exist, it is declared
to be a file if it has the same extension as the DestinationType.Parameters: file File to be checked.
Returns: true if the file is writeable and false otherwise.
Parameters: b true means scripts will be executed
Parameters: t the document time, in seconds