@OpenApiAll public class DefaultFormatter extends java.lang.Object implements IFormatter
Modifier and Type | Field and Description |
---|---|
protected float |
dpi
Number of DOT per inch.
|
protected java.util.Properties |
properties
Engine properties.
|
protected StyledDocument |
styledDocument
Styled document.
|
DOT_PER_INCH
Constructor and Description |
---|
DefaultFormatter()
Create a default formatter without properties.
|
DefaultFormatter(java.util.Properties properties)
Create a default formatter with specific properties.
|
Modifier and Type | Method and Description |
---|---|
java.lang.Object |
format(java.lang.Object value)
Convert an Object value into default format.
|
static int |
getImageFlag(java.lang.String autoImageOption)
Convert auto image option from
TemplateConstants.TEMPLATE_AUTO_IMAGE into transformation flag. |
IFormatter |
getObjectFormater(java.lang.Class<?> targetType)
Returns the formatter for the target type class or current formatter if target type class is not registered.
|
java.util.Properties |
getProperties()
Return a properties.
|
void |
registerObjectFormatter(java.lang.Class<?> targetType,
IFormatter formatter)
Register an object formatter to be used to format values of a given target class.
|
void |
setProperties(java.util.Properties properties)
Passes along the properties from the template engine indicating the properties to be used in formatter.
|
void |
setStyledDocument(StyledDocument styledDocument)
Set a
StyledDocument to be used with this formatter. |
protected void |
writeImage(Image image,
java.lang.String imageFormat,
java.io.File outputFile,
boolean forceWrite)
Write an image into output file.
|
protected void |
writeImage(Image image,
java.lang.String imageFormat,
java.io.OutputStream outputStream,
boolean forceWrite)
Write an image into output stream.
|
protected java.util.Properties properties
protected StyledDocument styledDocument
protected float dpi
public DefaultFormatter()
public DefaultFormatter(java.util.Properties properties)
properties
- a template propertiespublic void registerObjectFormatter(java.lang.Class<?> targetType, IFormatter formatter)
registerObjectFormatter
in interface IFormatter
targetType
- the Class object of the type to be formattedformatter
- the instance of object of the IFormatter
class. If this is null, then any existing
definition will be removed.public IFormatter getObjectFormater(java.lang.Class<?> targetType)
getObjectFormater
in interface IFormatter
targetType
- the Class object of the type to be formattedIFormatter
class.public void setProperties(java.util.Properties properties)
properties
- Propertiespublic java.util.Properties getProperties()
public void setStyledDocument(StyledDocument styledDocument)
StyledDocument
to be used with this formatter.setStyledDocument
in interface IFormatter
styledDocument
- A {link StyledDocument}protected void writeImage(Image image, java.lang.String imageFormat, java.io.OutputStream outputStream, boolean forceWrite) throws java.io.IOException
image
- ImageimageFormat
- output image formatoutputStream
- output streamforceWrite
- force to write the image to output streamjava.io.IOException
- if an error occurs during writing.protected void writeImage(Image image, java.lang.String imageFormat, java.io.File outputFile, boolean forceWrite) throws java.io.IOException
image
- ImageimageFormat
- output image formatoutputFile
- output fileforceWrite
- force to write the image to output streamjava.io.IOException
- if an error occurs during writing.public java.lang.Object format(java.lang.Object value)
format
in interface IFormatter
value
- converting valuepublic static int getImageFlag(java.lang.String autoImageOption)
TemplateConstants.TEMPLATE_AUTO_IMAGE
into transformation flag.autoImageOption
- auto image option; (value 0, 1, 2, 3)Copyright © 2010 - No Magic Asia