|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectorg.apache.batik.apps.rasterizer.SVGConverter
public class SVGConverter
This application can be used to convert SVG images to raster images.
Possible result raster image formats are PNG, JPEG, TIFF, and PDF.
The Batik Transcoder API is used to execute the conversion. FOP is
needed to be able to transcode to the PDF format
The source has to be list of files or URL (set by the setSources
method).
The destination can be:
DestinationType
documentation.
Nested Class Summary | |
---|---|
static class |
SVGConverter.SVGFileFilter
Convenience class to filter svg files |
Field Summary | |
---|---|
protected java.lang.String |
allowedScriptTypes
Set of allowed script types. |
protected java.lang.String |
alternateStylesheet
Alternate stylesheet for which should be applied to the SVG |
protected java.awt.geom.Rectangle2D |
area
Output AOI area. |
protected java.awt.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 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 java.lang.String |
defaultFontFamily
Default value for the font-family when it is unspecified |
protected DestinationType |
destinationType
Result type |
protected java.io.File |
dst
Destination image path. |
static java.lang.String |
ERROR_CANNOT_ACCESS_TRANSCODER
|
static java.lang.String |
ERROR_CANNOT_COMPUTE_DESTINATION
|
static java.lang.String |
ERROR_CANNOT_OPEN_OUTPUT_FILE
|
static java.lang.String |
ERROR_CANNOT_OPEN_SOURCE
|
static java.lang.String |
ERROR_CANNOT_READ_SOURCE
|
static java.lang.String |
ERROR_CANNOT_USE_DST_FILE
|
static java.lang.String |
ERROR_NO_SOURCES_SPECIFIED
|
static java.lang.String |
ERROR_OUTPUT_NOT_WRITEABLE
|
static java.lang.String |
ERROR_SOURCE_SAME_AS_DESTINATION
|
static java.lang.String |
ERROR_UNABLE_TO_CREATE_OUTPUT_DIR
|
static java.lang.String |
ERROR_WHILE_RASTERIZING_FILE
|
protected boolean |
executeOnload
Execute the 'onload' scripts flag |
protected java.util.List |
files
Contents of fileset elements. |
protected float |
height
Output image height. |
protected int |
indexed
Should output Image be indexed . |
protected java.lang.String |
language
Language |
protected float |
maxHeight
Maximum output image height. |
protected static float |
MAXIMUM_QUALITY
Maximum quality value |
protected float |
maxWidth
Maximum output image width. |
protected java.lang.String |
mediaType
Media type for which the SVG image should be rendered |
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 java.util.List |
sources
Sources files or URLs |
protected static java.lang.String |
SVG_EXTENSION
SVG file extension |
protected java.lang.String |
userStylesheet
User stylesheet |
protected boolean |
validate
Validation flag |
protected float |
width
Output image width. |
Constructor Summary | |
---|---|
SVGConverter()
|
|
SVGConverter(SVGConverterController controller)
|
Method Summary | |
---|---|
protected java.util.List |
computeDstFiles(java.util.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 java.util.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 java.util.Map |
computeTranscodingHints()
Computes the set of transcoding hints to use for the operation |
protected void |
createOutputDir(java.io.File output)
Creates directories for output files if needed. |
void |
execute()
Starts the conversion process. |
java.lang.String |
getAllowedScriptTypes()
Returns the list of allowed script types. |
java.lang.String |
getAlternateStylesheet()
|
java.awt.geom.Rectangle2D |
getArea()
|
java.awt.Color |
getBackgroundColor()
|
boolean |
getConstrainScriptOrigin()
Returns whether scripts can only be loaded from the same origin as the documents referencing them. |
java.lang.String |
getDefaultFontFamily()
|
protected java.lang.String |
getDestinationFile(java.lang.String file)
Get the name of the result image file. |
DestinationType |
getDestinationType()
|
java.io.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. |
java.lang.String[] |
getFileNRef(java.lang.String fileName)
|
float |
getHeight()
|
int |
getIndexed()
|
java.lang.String |
getLanguage()
|
float |
getMaxHeight()
|
float |
getMaxWidth()
|
java.lang.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. |
java.util.List |
getSources()
|
java.lang.String |
getUserStylesheet()
|
boolean |
getValidate()
|
float |
getWidth()
|
protected boolean |
isFile(java.io.File f)
Returns true if f is a File. |
protected boolean |
isWriteable(java.io.File file)
Checks if the application is allowed to write to the file. |
void |
setAllowedScriptTypes(java.lang.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(java.lang.String alternateStylesheet)
Sets the alternateStyleSheet value. |
void |
setArea(java.awt.geom.Rectangle2D area)
Sets the area as a Rectangle. |
void |
setBackgroundColor(java.awt.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(java.lang.String defaultFontFamily)
Sets the defaultFontFamily value. |
void |
setDestinationType(DestinationType destinationType)
Sets the destinationType attribute value. |
void |
setDst(java.io.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(java.lang.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(java.lang.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(java.lang.String[] sources)
Sets the list of individual SVG sources. |
void |
setUserStylesheet(java.lang.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,
java.io.File outputFile,
Transcoder transcoder)
Converts the input image to the result image. |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
---|
public static final java.lang.String ERROR_NO_SOURCES_SPECIFIED
public static final java.lang.String ERROR_CANNOT_COMPUTE_DESTINATION
public static final java.lang.String ERROR_CANNOT_USE_DST_FILE
public static final java.lang.String ERROR_CANNOT_ACCESS_TRANSCODER
public static final java.lang.String ERROR_SOURCE_SAME_AS_DESTINATION
public static final java.lang.String ERROR_CANNOT_READ_SOURCE
public static final java.lang.String ERROR_CANNOT_OPEN_SOURCE
public static final java.lang.String ERROR_OUTPUT_NOT_WRITEABLE
public static final java.lang.String ERROR_CANNOT_OPEN_OUTPUT_FILE
public static final java.lang.String ERROR_UNABLE_TO_CREATE_OUTPUT_DIR
public static final java.lang.String ERROR_WHILE_RASTERIZING_FILE
protected static final java.lang.String SVG_EXTENSION
protected static final float DEFAULT_QUALITY
protected static final float MAXIMUM_QUALITY
protected static final DestinationType DEFAULT_RESULT_TYPE
protected static final float DEFAULT_WIDTH
protected static final float DEFAULT_HEIGHT
protected DestinationType destinationType
protected float height
protected float width
protected float maxHeight
protected float maxWidth
protected float quality
protected int indexed
protected java.awt.geom.Rectangle2D area
protected java.lang.String language
protected java.lang.String userStylesheet
protected float pixelUnitToMillimeter
protected boolean validate
protected boolean executeOnload
protected float snapshotTime
protected java.lang.String allowedScriptTypes
protected boolean constrainScriptOrigin
protected boolean securityOff
protected java.util.List sources
protected java.io.File dst
protected java.awt.Color backgroundColor
protected java.lang.String mediaType
protected java.lang.String defaultFontFamily
protected java.lang.String alternateStylesheet
protected java.util.List files
protected SVGConverterController controller
SVGConverterController
Constructor Detail |
---|
public SVGConverter()
public SVGConverter(SVGConverterController controller)
Method Detail |
---|
public void setDestinationType(DestinationType destinationType)
public DestinationType getDestinationType()
public void setHeight(float height)
public float getHeight()
public void setWidth(float width)
public float getWidth()
public void setMaxHeight(float height)
public float getMaxHeight()
public void setMaxWidth(float width)
public float getMaxWidth()
public void setQuality(float quality) throws java.lang.IllegalArgumentException
java.lang.IllegalArgumentException
public float getQuality()
public void setIndexed(int bits) throws java.lang.IllegalArgumentException
java.lang.IllegalArgumentException
public int getIndexed()
public void setLanguage(java.lang.String language)
UserAgent.getLanguages()
)
is used.
public java.lang.String getLanguage()
public void setUserStylesheet(java.lang.String userStylesheet)
public java.lang.String getUserStylesheet()
public void setPixelUnitToMillimeter(float pixelUnitToMillimeter)
UserAgent.getPixelUnitToMillimeter()
)
to be used.
public float getPixelUnitToMillimeter()
public void setArea(java.awt.geom.Rectangle2D area)
public java.awt.geom.Rectangle2D getArea()
public void setSources(java.lang.String[] sources)
execute()
);
public java.util.List getSources()
public void setDst(java.io.File dst)
public java.io.File getDst()
public void setBackgroundColor(java.awt.Color backgroundColor)
public java.awt.Color getBackgroundColor()
public void setMediaType(java.lang.String mediaType)
public java.lang.String getMediaType()
public void setDefaultFontFamily(java.lang.String defaultFontFamily)
public java.lang.String getDefaultFontFamily()
public void setAlternateStylesheet(java.lang.String alternateStylesheet)
public java.lang.String getAlternateStylesheet()
public void setValidate(boolean validate)
public boolean getValidate()
public void setExecuteOnload(boolean b)
b
- true means scripts will be executedpublic boolean getExecuteOnload()
public void setSnapshotTime(float t)
t
- the document time, in secondspublic float getSnapshotTime()
public void setAllowedScriptTypes(java.lang.String allowedScriptTypes)
public java.lang.String getAllowedScriptTypes()
setAllowedScriptTypes(java.lang.String)
public void setConstrainScriptOrigin(boolean constrainScriptOrigin)
public boolean getConstrainScriptOrigin()
public void setSecurityOff(boolean securityOff)
public boolean getSecurityOff()
protected boolean isFile(java.io.File f)
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.
public void execute() throws SVGConverterException
SVGConverterException
- thrown if parameters are not set correctly.protected java.util.List computeDstFiles(java.util.List sources) throws SVGConverterException
SVGConverterException
protected java.util.List computeSources() throws SVGConverterException
SVGConverterException
public java.lang.String[] getFileNRef(java.lang.String fileName)
protected java.util.Map computeTranscodingHints()
protected void transcode(SVGConverterSource inputFile, java.io.File outputFile, Transcoder transcoder) throws SVGConverterException
SVGConverterException
protected java.lang.String getDestinationFile(java.lang.String file)
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.
file
- Result file name as a String object.
protected void createOutputDir(java.io.File output) throws SVGConverterException
output
- Output file with path.
SVGConverterException
- Output directory doesn't exist and it can't be created.protected boolean isWriteable(java.io.File file)
file
- File to be checked.
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |