com.xmlmind.fo.graphic
Class GraphicFactories

java.lang.Object
  extended by com.xmlmind.fo.graphic.GraphicFactories

public final class GraphicFactories
extends Object

The registry of all graphic factories used by XMLmind XSL-FO Converter.

Initially this registry contains factories for the "image/bmp" (Java 1.5+), "image/gif", "image/png", "image/jpeg", "image/x-wmf" and "image/x-emf" input formats.

Moreover, if jai_imageio.jar is referenced in the CLASSPATH, this adds the TIFF, JPEG 2000 and PNM input formats.

Moreover, if Java 1.5+ is used to run XMLmind XSL-FO Converter and if xfc_ext is in its CLASSPATH, additional factories for "image/svg+xml" and "application/mathml+xml" graphics are also automatically registered.

This class is thread-safe.


Method Summary
static Graphic convertGraphic(Graphic graphic, String[] formats, double xScale, double yScale, Object clientData, GraphicEnv env)
          Convenience method: find a factory allowing to convert specified graphic to any of the specified output formats then invokes GraphicFactory.convertGraphic(com.xmlmind.fo.graphic.Graphic, java.lang.String, double, double, java.lang.Object, com.xmlmind.fo.graphic.GraphicEnv).
static Graphic convertGraphic(Graphic graphic, String format, double xScale, double yScale, Object clientData, GraphicEnv env)
          Convenience method: find a factory allowing to convert specified graphic to specified output format then invokes GraphicFactory.convertGraphic(com.xmlmind.fo.graphic.Graphic, java.lang.String, double, double, java.lang.Object, com.xmlmind.fo.graphic.GraphicEnv).
static Graphic createGraphic(String location, String format, Object clientData, GraphicEnv env)
          Convenience method: find a factory supporting specified input format then invokes GraphicFactory.createGraphic(java.lang.String, java.lang.String, java.lang.Object, com.xmlmind.fo.graphic.GraphicEnv).
static GraphicFactory get(String format)
          Returns a factory supporting the specified input format.
static GraphicFactory get(String inFormat, String outFormat)
          Returns a factory allowing to convert specified input format to specified output format.
static GraphicFactory getByName(String name)
          Returns a factory having specified name.
static void register(GraphicFactory factory)
          Registers specified factory.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Method Detail

register

public static void register(GraphicFactory factory)
Registers specified factory.


get

public static GraphicFactory get(String format)
Returns a factory supporting the specified input format.

Each register factory is tested in turn, starting from the last registered ones.

Parameters:
format - input format
Returns:
a factory if found; null otherwise.

get

public static GraphicFactory get(String inFormat,
                                 String outFormat)
Returns a factory allowing to convert specified input format to specified output format.

Each register factory is tested in turn, starting from the last registered ones.

Parameters:
inFormat - input format
outFormat - output format
Returns:
a factory if found; null otherwise

getByName

public static GraphicFactory getByName(String name)
Returns a factory having specified name.

Each register factory is tested in turn, starting from the last registered ones.

Parameters:
name - name of the factory, case-insensitive
Returns:
a factory if found; null otherwise

createGraphic

public static Graphic createGraphic(String location,
                                    String format,
                                    Object clientData,
                                    GraphicEnv env)
                             throws Exception
Convenience method: find a factory supporting specified input format then invokes GraphicFactory.createGraphic(java.lang.String, java.lang.String, java.lang.Object, com.xmlmind.fo.graphic.GraphicEnv).

a RuntimeException is raised if a suitable factory is not found.

Throws:
Exception

convertGraphic

public static Graphic convertGraphic(Graphic graphic,
                                     String format,
                                     double xScale,
                                     double yScale,
                                     Object clientData,
                                     GraphicEnv env)
                              throws Exception
Convenience method: find a factory allowing to convert specified graphic to specified output format then invokes GraphicFactory.convertGraphic(com.xmlmind.fo.graphic.Graphic, java.lang.String, double, double, java.lang.Object, com.xmlmind.fo.graphic.GraphicEnv).

a RuntimeException is raised if a suitable factory is not found.

When possible (depends on graphic.getFormat(), on format and on the available factories), this method will always prefer to save a JPEG image to a JPEG file.

Throws:
Exception
See Also:
convertGraphic(Graphic, String[], double, double, Object, GraphicEnv)

convertGraphic

public static Graphic convertGraphic(Graphic graphic,
                                     String[] formats,
                                     double xScale,
                                     double yScale,
                                     Object clientData,
                                     GraphicEnv env)
                              throws Exception
Convenience method: find a factory allowing to convert specified graphic to any of the specified output formats then invokes GraphicFactory.convertGraphic(com.xmlmind.fo.graphic.Graphic, java.lang.String, double, double, java.lang.Object, com.xmlmind.fo.graphic.GraphicEnv).

a RuntimeException is raised if a suitable factory is not found.

When possible (depends on graphic.getFormat(), on formats and on the available factories), this method will always prefer to save a JPEG image as a JPEG file.

Throws:
Exception