## org.apache.batik.apps.rasterizer
Class Main

    java.lang.Object
      org.apache.batik.apps.rasterizer.Main

All Implemented Interfaces:
  SVGConverterController

public class Main
extends java.lang.Object
implements SVGConverterController

Handles command line parameters to configure the `SVGConverter` and rasterizer images.
Each command line option is handled by an `OptionHandler` which is responsible for converting the option into a configuration of the `SVGConverter` which is used to perform the conversion.

Nested Class Summary
`static class` `Main.AbstractOptionHandler` This abstract implementation of the `OptionHandler` interface throws an exception if the number of arguments passed to the `handleOption` method does not match the number of expected optionValues.
`static class` `Main.ColorOptionHandler` Base class for options which expect a `Color` optionValue.
`static class` `Main.FloatOptionHandler` Base class for options which expect the single optionValue to be a float.
`static class` `Main.NoValueOptionHandler` Base class for options with no option value (i.e., the presence of the option means something in itself.
`static interface` `Main.OptionHandler` Interface for handling one command line option
`static class` `Main.RectangleOptionHandler` Base class for options which expect a `Rectangle` optionValue.
`static class` `Main.SingleValueOptionHandler` Base class for options with a single option value.

Field Summary
`protected java.util.Vector` `args` Vector of arguments describing the conversion task to be performed.
`static java.lang.String` `CL_OPTION_ALLOWED_SCRIPTS` Option to specify the set of allowed scripts
`static java.lang.String` `CL_OPTION_ALLOWED_SCRIPTS_DESCRIPTION`
`static java.lang.String` `CL_OPTION_ALTERNATE_STYLESHEET` Option to specify the CSS alternate stylesheet when converting the SVG images
`static java.lang.String` `CL_OPTION_ALTERNATE_STYLESHEET_DESCRIPTION`
`static java.lang.String` `CL_OPTION_AOI` Option to specify the area of interest in the output image.
`static java.lang.String` `CL_OPTION_AOI_DESCRIPTION`
`static java.lang.String` `CL_OPTION_BACKGROUND_COLOR` Option to specify the output image's background color
`static java.lang.String` `CL_OPTION_BACKGROUND_COLOR_DESCRIPTION`
`static java.lang.String` `CL_OPTION_CONSTRAIN_SCRIPT_ORIGIN` Option to determine whether scripts a constrained to the same origin as the document referencing them.
`static java.lang.String` `CL_OPTION_CONSTRAIN_SCRIPT_ORIGIN_DESCRIPTION`
`static java.lang.String` `CL_OPTION_DEFAULT_FONT_FAMILY` Option to specify the default value for the font-family CSS property when converting the SVG image
`static java.lang.String` `CL_OPTION_DEFAULT_FONT_FAMILY_DESCRIPTION`
`static java.lang.String` `CL_OPTION_DPI` Option to specify the resolution for the output image
`static java.lang.String` `CL_OPTION_DPI_DESCRIPTION`
`static java.lang.String` `CL_OPTION_HEIGHT` Option to specify the output image's height
`static java.lang.String` `CL_OPTION_HEIGHT_DESCRIPTION`
`static java.lang.String` `CL_OPTION_INDEXED` Option to specify if the PNG should be indexed.
`static java.lang.String` `CL_OPTION_INDEXED_DESCRIPTION`
`static java.lang.String` `CL_OPTION_LANGUAGE` Option to specify the user language with which SVG documents should be processed
`static java.lang.String` `CL_OPTION_LANGUAGE_DESCRIPTION`
`static java.lang.String` `CL_OPTION_MAX_HEIGHT` Option to specify the output image's maximum height.
`static java.lang.String` `CL_OPTION_MAX_HEIGHT_DESCRIPTION`
`static java.lang.String` `CL_OPTION_MAX_WIDTH` Option to specify the output image's maximum width.
`static java.lang.String` `CL_OPTION_MAX_WIDTH_DESCRIPTION`
`static java.lang.String` `CL_OPTION_MEDIA_TYPE` Option to specify the CSS media type when converting the SVG image
`static java.lang.String` `CL_OPTION_MEDIA_TYPE_DESCRIPTION`
`static java.lang.String` `CL_OPTION_MIME_TYPE` Option to specify the output image's mime type
`static java.lang.String` `CL_OPTION_MIME_TYPE_DESCRIPTION`
`static java.lang.String` `CL_OPTION_ONLOAD` Option to specify that the converted SVG files should be after the dispatch of the 'onload' event.
`static java.lang.String` `CL_OPTION_ONLOAD_DESCRIPTION`
`static java.lang.String` `CL_OPTION_OUTPUT` Option to specify the output directory or file
`static java.lang.String` `CL_OPTION_OUTPUT_DESCRIPTION`
`static java.lang.String` `CL_OPTION_QUALITY` Option to specify the output JPEG quality
`static java.lang.String` `CL_OPTION_QUALITY_DESCRIPTION`
`static java.lang.String` `CL_OPTION_SECURITY_OFF` Option to turn off secure execution of scripts
`static java.lang.String` `CL_OPTION_SECURITY_OFF_DESCRIPTION`
`static java.lang.String` `CL_OPTION_USER_STYLESHEET` Option to specify an addition user stylesheet
`static java.lang.String` `CL_OPTION_USER_STYLESHEET_DESCRIPTION`
`static java.lang.String` `CL_OPTION_VALIDATE` Option to specify that the converted SVG files should be validated during the conversion process.
`static java.lang.String` `CL_OPTION_VALIDATE_DESCRIPTION`
`static java.lang.String` `CL_OPTION_WIDTH` Option to specify the output image's width
`static java.lang.String` `CL_OPTION_WIDTH_DESCRIPTION`
`static java.lang.String` `ERROR_ILLEGAL_ARGUMENT` Error when an illegal option value was passed to the app {0} Option {1} Option description
`static java.lang.String` `ERROR_NOT_ENOUGH_OPTION_VALUES` Error when there are missing option values: {0} Option {1} Option description
`static java.lang.String` `ERROR_WHILE_CONVERTING_FILES`
`static java.lang.String` `MESSAGE_ABOUT_TO_TRANSCODE`
`static java.lang.String` `MESSAGE_ABOUT_TO_TRANSCODE_SOURCE`
`static java.lang.String` `MESSAGE_CONVERSION_FAILED`
`static java.lang.String` `MESSAGE_CONVERSION_SUCCESS`
`protected static java.util.Map` `mimeTypeMap` Static map containing all the mime types understood by the rasterizer
`protected static java.util.Map` `optionMap` Static map containing all the option handlers able to analyze the various options.
`static java.lang.String` `RASTERIZER_SECURITY_POLICY` URL for Squiggle's security policy file
`static java.lang.String` `USAGE` Describes the command line options for the rasterizer

Constructor Summary
`Main(java.lang.String[] args)`

Method Summary
`protected void` `error(java.lang.String errorCode, java.lang.Object[] errorArgs)`
`void` `execute()`
`protected java.lang.String[]` `expandSources(java.util.Vector sources)` Scans the input vector and replaces directories with the list of SVG files they contain
`static void` `main(java.lang.String[] args)`
`void` `onSourceTranscodingSuccess(SVGConverterSource source, java.io.File dest)` Invoked when the rasterizer successfully transcoded the input source.
`boolean` `proceedOnSourceTranscodingFailure(SVGConverterSource source, java.io.File dest, java.lang.String errorCode)` Invoked when the rasterizer got an error while transcoding the input source.
`boolean` `proceedWithComputedTask(Transcoder transcoder, java.util.Map hints, java.util.Vector sources, java.util.Vector dest)` Invoked when the rasterizer has computed the exact description of what it should do.
`boolean` `proceedWithSourceTranscoding(SVGConverterSource source, java.io.File dest)` Invoked when the rasterizer is about to start transcoding of a given source.
`protected java.lang.String` `toString(java.lang.String[] v)`
`void` `validateConverterConfig(SVGConverter c)` Template methods which subclasses may implement to do whatever is needed.

Methods inherited from class java.lang.Object
`clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

Field Detail

### RASTERIZER_SECURITY_POLICY

    public static final java.lang.String RASTERIZER_SECURITY_POLICY

  URL for Squiggle's security policy file

  See Also:
    Constant Field Values

### USAGE

    public static java.lang.String USAGE

  Describes the command line options for the rasterizer

### CL_OPTION_OUTPUT

    public static java.lang.String CL_OPTION_OUTPUT

  Option to specify the output directory or file

### CL_OPTION_OUTPUT_DESCRIPTION

    public static java.lang.String CL_OPTION_OUTPUT_DESCRIPTION

### CL_OPTION_MIME_TYPE

    public static java.lang.String CL_OPTION_MIME_TYPE

  Option to specify the output image's mime type

### CL_OPTION_MIME_TYPE_DESCRIPTION

    public static java.lang.String CL_OPTION_MIME_TYPE_DESCRIPTION

### CL_OPTION_WIDTH

    public static java.lang.String CL_OPTION_WIDTH

  Option to specify the output image's width

### CL_OPTION_WIDTH_DESCRIPTION

    public static java.lang.String CL_OPTION_WIDTH_DESCRIPTION

### CL_OPTION_HEIGHT

    public static java.lang.String CL_OPTION_HEIGHT

  Option to specify the output image's height

### CL_OPTION_HEIGHT_DESCRIPTION

    public static java.lang.String CL_OPTION_HEIGHT_DESCRIPTION

### CL_OPTION_MAX_WIDTH

    public static java.lang.String CL_OPTION_MAX_WIDTH

  Option to specify the output image's maximum width.

### CL_OPTION_MAX_WIDTH_DESCRIPTION

    public static java.lang.String CL_OPTION_MAX_WIDTH_DESCRIPTION

### CL_OPTION_MAX_HEIGHT

    public static java.lang.String CL_OPTION_MAX_HEIGHT

  Option to specify the output image's maximum height.

### CL_OPTION_MAX_HEIGHT_DESCRIPTION

    public static java.lang.String CL_OPTION_MAX_HEIGHT_DESCRIPTION

### CL_OPTION_AOI

    public static java.lang.String CL_OPTION_AOI

  Option to specify the area of interest in the output image.

### CL_OPTION_AOI_DESCRIPTION

    public static java.lang.String CL_OPTION_AOI_DESCRIPTION

### CL_OPTION_BACKGROUND_COLOR

    public static java.lang.String CL_OPTION_BACKGROUND_COLOR

  Option to specify the output image's background color

### CL_OPTION_BACKGROUND_COLOR_DESCRIPTION

    public static java.lang.String CL_OPTION_BACKGROUND_COLOR_DESCRIPTION

### CL_OPTION_MEDIA_TYPE

    public static java.lang.String CL_OPTION_MEDIA_TYPE

  Option to specify the CSS media type when converting the SVG image

### CL_OPTION_MEDIA_TYPE_DESCRIPTION

    public static java.lang.String CL_OPTION_MEDIA_TYPE_DESCRIPTION

### CL_OPTION_DEFAULT_FONT_FAMILY

    public static java.lang.String CL_OPTION_DEFAULT_FONT_FAMILY

  Option to specify the default value for the font-family CSS property when converting the SVG image

### CL_OPTION_DEFAULT_FONT_FAMILY_DESCRIPTION

    public static java.lang.String CL_OPTION_DEFAULT_FONT_FAMILY_DESCRIPTION

### CL_OPTION_ALTERNATE_STYLESHEET

    public static java.lang.String CL_OPTION_ALTERNATE_STYLESHEET

  Option to specify the CSS alternate stylesheet when converting the SVG images

### CL_OPTION_ALTERNATE_STYLESHEET_DESCRIPTION

    public static java.lang.String CL_OPTION_ALTERNATE_STYLESHEET_DESCRIPTION

### CL_OPTION_VALIDATE

    public static java.lang.String CL_OPTION_VALIDATE

  Option to specify that the converted SVG files should be validated during the conversion process.

### CL_OPTION_VALIDATE_DESCRIPTION

    public static java.lang.String CL_OPTION_VALIDATE_DESCRIPTION

### CL_OPTION_ONLOAD

    public static java.lang.String CL_OPTION_ONLOAD

  Option to specify that the converted SVG files should be after the dispatch of the 'onload' event.

### CL_OPTION_ONLOAD_DESCRIPTION

    public static java.lang.String CL_OPTION_ONLOAD_DESCRIPTION

### CL_OPTION_LANGUAGE

    public static java.lang.String CL_OPTION_LANGUAGE

  Option to specify the user language with which SVG documents should be processed

### CL_OPTION_LANGUAGE_DESCRIPTION

    public static java.lang.String CL_OPTION_LANGUAGE_DESCRIPTION

### CL_OPTION_USER_STYLESHEET

    public static java.lang.String CL_OPTION_USER_STYLESHEET

  Option to specify an addition user stylesheet

### CL_OPTION_USER_STYLESHEET_DESCRIPTION

    public static java.lang.String CL_OPTION_USER_STYLESHEET_DESCRIPTION

### CL_OPTION_DPI

    public static java.lang.String CL_OPTION_DPI

  Option to specify the resolution for the output image

### CL_OPTION_DPI_DESCRIPTION

    public static java.lang.String CL_OPTION_DPI_DESCRIPTION

### CL_OPTION_QUALITY

    public static java.lang.String CL_OPTION_QUALITY

  Option to specify the output JPEG quality

### CL_OPTION_QUALITY_DESCRIPTION

    public static java.lang.String CL_OPTION_QUALITY_DESCRIPTION

### CL_OPTION_INDEXED

    public static java.lang.String CL_OPTION_INDEXED

  Option to specify if the PNG should be indexed.

### CL_OPTION_INDEXED_DESCRIPTION

    public static java.lang.String CL_OPTION_INDEXED_DESCRIPTION

### CL_OPTION_ALLOWED_SCRIPTS

    public static java.lang.String CL_OPTION_ALLOWED_SCRIPTS

  Option to specify the set of allowed scripts

### CL_OPTION_ALLOWED_SCRIPTS_DESCRIPTION

    public static java.lang.String CL_OPTION_ALLOWED_SCRIPTS_DESCRIPTION

### CL_OPTION_CONSTRAIN_SCRIPT_ORIGIN

    public static java.lang.String CL_OPTION_CONSTRAIN_SCRIPT_ORIGIN

  Option to determine whether scripts a constrained to the same origin as the document referencing them.

### CL_OPTION_CONSTRAIN_SCRIPT_ORIGIN_DESCRIPTION

    public static java.lang.String CL_OPTION_CONSTRAIN_SCRIPT_ORIGIN_DESCRIPTION

### CL_OPTION_SECURITY_OFF

    public static java.lang.String CL_OPTION_SECURITY_OFF

  Option to turn off secure execution of scripts

### CL_OPTION_SECURITY_OFF_DESCRIPTION

    public static java.lang.String CL_OPTION_SECURITY_OFF_DESCRIPTION

### optionMap

    protected static java.util.Map optionMap

  Static map containing all the option handlers able to analyze the various options.

### mimeTypeMap

    protected static java.util.Map mimeTypeMap

  Static map containing all the mime types understood by the rasterizer

### args

    protected java.util.Vector args

  Vector of arguments describing the conversion task to be performed.

### ERROR_NOT_ENOUGH_OPTION_VALUES

    public static final java.lang.String ERROR_NOT_ENOUGH_OPTION_VALUES

  Error when there are missing option values: {0} Option {1} Option description

  See Also:
    Constant Field Values

### ERROR_ILLEGAL_ARGUMENT

    public static final java.lang.String ERROR_ILLEGAL_ARGUMENT

  Error when an illegal option value was passed to the app {0} Option {1} Option description

  See Also:
    Constant Field Values

### ERROR_WHILE_CONVERTING_FILES

    public static final java.lang.String ERROR_WHILE_CONVERTING_FILES

See Also:
  Constant Field Values

### MESSAGE_ABOUT_TO_TRANSCODE

    public static final java.lang.String MESSAGE_ABOUT_TO_TRANSCODE

See Also:
  Constant Field Values

### MESSAGE_ABOUT_TO_TRANSCODE_SOURCE

    public static final java.lang.String MESSAGE_ABOUT_TO_TRANSCODE_SOURCE

See Also:
  Constant Field Values

### MESSAGE_CONVERSION_FAILED

    public static final java.lang.String MESSAGE_CONVERSION_FAILED

See Also:
  Constant Field Values

### MESSAGE_CONVERSION_SUCCESS

    public static final java.lang.String MESSAGE_CONVERSION_SUCCESS

See Also:
  Constant Field Values

Constructor Detail

### Main

    public Main(java.lang.String[] args)

Method Detail

### error

    protected void error(java.lang.String errorCode,
                         java.lang.Object[] errorArgs)

### execute

    public void execute()

### toString

    protected java.lang.String toString(java.lang.String[] v)

### validateConverterConfig

    public void validateConverterConfig(SVGConverter c)

  Template methods which subclasses may implement to do whatever is needed. For example, this can be used for test purposes.

### expandSources

    protected java.lang.String[] expandSources(java.util.Vector sources)

  Scans the input vector and replaces directories with the list of SVG files they contain

### main

    public static void main(java.lang.String[] args)

### proceedWithComputedTask

    public boolean proceedWithComputedTask(Transcoder transcoder,
                                           java.util.Map hints,
                                           java.util.Vector sources,
                                           java.util.Vector dest)

  Description copied from interface: `SVGConverterController`
  Invoked when the rasterizer has computed the exact description of what it should do. The controller should return true if the transcoding process should proceed or false otherwise.

  Specified by:
    `proceedWithComputedTask` in interface `SVGConverterController`
  Parameters:
    `transcoder` - Transcoder which will be used
    `hints` - set of hints that were set on the transcoder
    `sources` - list of SVG sources it will convert.
    `dest` - list of destination file it will use

### proceedWithSourceTranscoding

    public boolean proceedWithSourceTranscoding(SVGConverterSource source,
                                                java.io.File dest)

  Description copied from interface: `SVGConverterController`
  Invoked when the rasterizer is about to start transcoding of a given source. The controller should return true if the source should be transcoded and false otherwise.

  Specified by:
    `proceedWithSourceTranscoding` in interface `SVGConverterController`

### proceedOnSourceTranscodingFailure

    public boolean proceedOnSourceTranscodingFailure(SVGConverterSource source,
                                                     java.io.File dest,
                                                     java.lang.String errorCode)

  Description copied from interface: `SVGConverterController`
  Invoked when the rasterizer got an error while transcoding the input source. The controller should return true if the transcoding process should continue on other sources and it should return false if it should not.

  Specified by:
    `proceedOnSourceTranscodingFailure` in interface `SVGConverterController`
  Parameters:
    `errorCode` - see the `SVGConverter` error code descriptions.

### onSourceTranscodingSuccess

    public void onSourceTranscodingSuccess(SVGConverterSource source,
                                           java.io.File dest)

  Description copied from interface: `SVGConverterController`
  Invoked when the rasterizer successfully transcoded the input source.

  Specified by:
    `onSourceTranscodingSuccess` in interface `SVGConverterController`

Copyright © 2004 Apache Software Foundation. All Rights Reserved.