com.xmlmind.fo.graphic
Interface GraphicFactory

All Known Implementing Classes:
GraphicFactoryBase, GraphicFactoryImpl

public interface GraphicFactory

Factory allowing to create Graphic objects.

Such factories must be registered with XMLmind XSL-FO Converter using GraphicFactories.register(com.xmlmind.fo.graphic.GraphicFactory).

The implementations of this interface are expected to be thread-safe.


Method Summary
 Graphic convertGraphic(Graphic graphic, String format, double xScale, double yScale, Object clientData, GraphicEnv env)
          Converts specified graphic to specified format, while optionally rescaling it.
 Graphic createGraphic(String location, String format, Object clientData, GraphicEnv env)
          Creates a graphic which represents the illustration stored as specified location.
 String[] getInputFormats()
          Returns the list of input MIME types supported by createGraphic(java.lang.String, java.lang.String, java.lang.Object, com.xmlmind.fo.graphic.GraphicEnv).
 String getName()
          Returns the name of this factory.
 String[] getOutputFormats()
          Returns the list of output MIME types supported by convertGraphic(com.xmlmind.fo.graphic.Graphic, java.lang.String, double, double, java.lang.Object, com.xmlmind.fo.graphic.GraphicEnv).
 String getParameter(String name)
          Returns the value of the parameter having specified name.
 void setParameter(String name, String value)
          Sets parameter having specified name and specified value.
 

Method Detail

getName

String getName()
Returns the name of this factory.


setParameter

void setParameter(String name,
                  String value)
                  throws IllegalArgumentException
Sets parameter having specified name and specified value.

Parameters:
name - name of the parameter
value - value of the parameter. Specify null to restore the default value of parameter name
Throws:
IllegalArgumentException - if specified parameter is unknown or if specified value is invalid.
See Also:
getParameter(java.lang.String)

getParameter

String getParameter(String name)
Returns the value of the parameter having specified name. Returns null if the parameter is unknown.

Parameters:
name - name of the parameter
See Also:
setParameter(java.lang.String, java.lang.String)

getInputFormats

String[] getInputFormats()
Returns the list of input MIME types supported by createGraphic(java.lang.String, java.lang.String, java.lang.Object, com.xmlmind.fo.graphic.GraphicEnv).


getOutputFormats

String[] getOutputFormats()
Returns the list of output MIME types supported by convertGraphic(com.xmlmind.fo.graphic.Graphic, java.lang.String, double, double, java.lang.Object, com.xmlmind.fo.graphic.GraphicEnv).

In order to be useful to XMLmind XSL-FO Converter, a factory must return one or more of "image/png", "image/x-wmf", "image/x-emf".


createGraphic

Graphic createGraphic(String location,
                      String format,
                      Object clientData,
                      GraphicEnv env)
                      throws Exception
Creates a graphic which represents the illustration stored as specified location.

IMPORTANT: the created Graphic must bear the resolution information stored in the source located by location. If this source does not contain any resolution information then the resolution fields of created Graphic must be set to 0.

Parameters:
location - location of the graphic file. The string form of an URL. May be a "data:" URL.
format - MIME type of the image to be created. This format is guaranteed to be listed by getInputFormats().
clientData - opaque client data to be associated with the newly created graphic
env - services provided by XMLmind XSL-FO Converter
Returns:
a newly created graphic
Throws:
Exception - if, for any reason, this method fails

convertGraphic

Graphic convertGraphic(Graphic graphic,
                       String format,
                       double xScale,
                       double yScale,
                       Object clientData,
                       GraphicEnv env)
                       throws Exception
Converts specified graphic to specified format, while optionally rescaling it.

Even when there is apparently nothing to do (that is, same format, no scaling), this method saves a copy of graphic and returns the saved copy. This method never returns graphic.

IMPORTANT: if graphic has resolution information and if image format format allows to store this information, then this resolution information must be stored in the source of the newly created Graphic.

Parameters:
graphic - graphic to be converted
format - MIME type of the image to be created. This format is guaranteed to be listed by getOutputFormats().
xScale - scaling factor to apply to the width of graphic
yScale - scaling factor to apply to the height of graphic
clientData - opaque client data to be associated with the newly created graphic
env - services provided by XMLmind XSL-FO Converter
Returns:
a newly created graphic
Throws:
Exception - if, for any reason, this method fails