|
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||
java.lang.Objectcom.xmlmind.fo.graphic.GraphicFactoryBase
com.xmlmind.fo.graphic.GraphicFactoryImpl
public final class GraphicFactoryImpl
An implementation of GraphicFactory based on ImageIO.
This means that this factory supports at least the following formats:
"image/bmp" (Java 1.5+), "image/gif",
"image/png", "image/jpeg".
However this factory only allows to save images as JPEG or PNG files.
| Field Summary |
|---|
| Fields inherited from class com.xmlmind.fo.graphic.GraphicFactoryBase |
|---|
factoryName |
| Constructor Summary | |
|---|---|
GraphicFactoryImpl()
Constructs a factory leveraging ImageIO. |
|
| 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 GraphicFactory.createGraphic(java.lang.String, java.lang.String, java.lang.Object, com.xmlmind.fo.graphic.GraphicEnv). |
String[] |
getOutputFormats()
Returns the list of output MIME types supported by GraphicFactory.convertGraphic(com.xmlmind.fo.graphic.Graphic, java.lang.String, double, double, java.lang.Object, com.xmlmind.fo.graphic.GraphicEnv). |
static BufferedImage |
scaleImage(BufferedImage image,
double xScale,
double yScale)
Returns a scaled instance of specified image. |
static void |
writeImage(BufferedImage image,
double xRes,
double yRes,
String format,
File outFile)
Save specified image to specified file. |
| Methods inherited from class com.xmlmind.fo.graphic.GraphicFactoryBase |
|---|
getName, getParameter, setParameter |
| Methods inherited from class java.lang.Object |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Constructor Detail |
|---|
public GraphicFactoryImpl()
ImageIO.
| Method Detail |
|---|
public String[] getInputFormats()
GraphicFactoryGraphicFactory.createGraphic(java.lang.String, java.lang.String, java.lang.Object, com.xmlmind.fo.graphic.GraphicEnv).
public String[] getOutputFormats()
GraphicFactoryGraphicFactory.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".
public Graphic createGraphic(String location,
String format,
Object clientData,
GraphicEnv env)
throws Exception
GraphicFactoryIMPORTANT: 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.
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 GraphicFactory.getInputFormats().clientData - opaque client data to be associated with the
newly created graphicenv - services provided by XMLmind XSL-FO Converter
Exception - if, for any reason, this method fails
public Graphic convertGraphic(Graphic graphic,
String format,
double xScale,
double yScale,
Object clientData,
GraphicEnv env)
throws Exception
GraphicFactoryEven 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.
graphic - graphic to be convertedformat - MIME type of the image to be created.
This format is guaranteed to be listed by GraphicFactory.getOutputFormats().xScale - scaling factor to apply to the width of graphicyScale - scaling factor to apply to the height of graphicclientData - opaque client data to be associated with the
newly created graphicenv - services provided by XMLmind XSL-FO Converter
Exception - if, for any reason, this method fails
public static BufferedImage scaleImage(BufferedImage image,
double xScale,
double yScale)
This helper function is intented to be used to implement not only this factory, but also other factories.
image - image to be scaledxScale - scaling factor to apply to the width of imageyScale - scaling factor to apply to the height of image
public static void writeImage(BufferedImage image,
double xRes,
double yRes,
String format,
File outFile)
throws Exception
This helper function is intented to be used to implement not only this factory, but also other factories.
image - image to be savedxRes - horizontal resolution of image in DPI.
A negative or null number means unknown.yRes - vertical resolution of image in DPI.
A negative or null number means unknown.format - output MIME type. Example: "image/png".outFile - save file
Exception - if, for any reason, this method fails
|
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||