Package com.nomagic.magicreport.format
Class RTFFormatter
java.lang.Object
com.nomagic.magicreport.format.DefaultFormatter
com.nomagic.magicreport.format.RTFFormatter
- All Implemented Interfaces:
IFormatter
This class provides implementation for RTF format output. Extend from DefaultFormatter, this class provide
additional support for BufferedImage, and RTF escaped characters.
- Since:
- Jun 11, 2007 10:49:57 PM
- Version:
- 1.0 Jun 11, 2007
-
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final floatThe number of hundredths of millimeters (0.01 mm) in an inch.static final StringThe image property indicates that image will be temporary stored as a link during process and it will be replaced with binary data in post-process.static final floatThe number of appropriate max image height in pixels.static final floatThe number of appropriate max image width in pixels.static final floatThe number of twips in an inch.protected static final intThe number of WMF header length.Fields inherited from class com.nomagic.magicreport.format.DefaultFormatter
properties, styledDocumentFields inherited from interface com.nomagic.magicreport.format.IFormatter
DOT_PER_INCH -
Constructor Summary
ConstructorsConstructorDescriptionRTFFormatter(Properties properties) Create a RTF formatter with with specific properties. -
Method Summary
Modifier and TypeMethodDescriptionprotected ITool.RetainedStringcreateBookmark(Bookmark bookmark) Create a RTF bookmark string from givenBookmarkobject.protected ITool.RetainedStringcreateImage(Image image) Create a RTF image string from givenImageobject.protected ITool.RetainedStringcreateImage(Image image, int width, int height, int flag) Create a RTF image string from givenImageobject.longcreateImageBody(Image image, Writer writer) Create image body to writer.protected ITool.RetainedStringcreateImageFooter(Image image, int width, int height, int flag) Create an image footer.protected ITool.RetainedStringcreateImageHeader(Image image, int width, int height, int flag) Create an image header.protected ITool.RetainedStringcreateImageProperty(float w, float h, int flag) protected ITool.RetainedStringcreateImageProperty(Image image, float w, float h, int flag) Calculate Property of image.protected ITool.RetainedStringcreateLink(Link link) Create a RTF link string from givenLinkobject.Convert an Object value into RTF format.protected StringgetImageFormat(Image image) Return the image format.float[]Calculation for total paper width and total paper height after minus margin of page in twips.protected booleanisLargeImage(Image image) Compare the width and height of the image and paper if the image is greater than paper, it's considered as large image.Methods inherited from class com.nomagic.magicreport.format.DefaultFormatter
getImageFlag, getObjectFormater, getProperties, registerObjectFormatter, setProperties, setStyledDocument, writeImage, writeImage, writeImage
-
Field Details
-
HMM_PER_INCH
public static final float HMM_PER_INCHThe number of hundredths of millimeters (0.01 mm) in an inch.- See Also:
-
TWIPS_PER_INCH
public static final float TWIPS_PER_INCHThe number of twips in an inch.- See Also:
-
MAX_WIDTH_IN_PIXELS
public static final float MAX_WIDTH_IN_PIXELSThe number of appropriate max image width in pixels.- See Also:
-
MAX_HEIGHT_IN_PIXELS
public static final float MAX_HEIGHT_IN_PIXELSThe number of appropriate max image height in pixels.- See Also:
-
LINKED_PICTURE
The image property indicates that image will be temporary stored as a link during process and it will be replaced with binary data in post-process.- See Also:
-
WMF_PLACEABLE_HEADER_SIZE
protected static final int WMF_PLACEABLE_HEADER_SIZEThe number of WMF header length.- See Also:
-
-
Constructor Details
-
RTFFormatter
Create a RTF formatter with with specific properties.- Parameters:
properties- template properties
-
-
Method Details
-
format
Convert an Object value into RTF format.- Specified by:
formatin interfaceIFormatter- Overrides:
formatin classDefaultFormatter- Parameters:
value- converting value- Returns:
- object in default format.
-
createImage
Create a RTF image string from givenImageobject.- Parameters:
image- anImageobject- Returns:
- The String in RTF image format.
- Throws:
IOException- when IO error occurs
-
createImage
protected ITool.RetainedString createImage(Image image, int width, int height, int flag) throws IOException Create a RTF image string from givenImageobject.- Parameters:
image- anImageobjectwidth- the target image widthheight- the target image heightflag- scaling image flag- Returns:
- The String in RTF image format.
- Throws:
IOException- when IO error occurs
-
createImageHeader
Create an image header.- Parameters:
image- Image objectwidth- target image widthheight- target image heightflag- target image flag- Returns:
- image header
- See Also:
-
createImageBody
Create image body to writer.- Parameters:
image- an Image objectwriter- the writer- Returns:
- total written characters
- Throws:
IOException- if exception occurs
-
createImageProperty
-
createImageProperty
Calculate Property of image.picscalex - scale in x picscaley - scale in y picw - Width of image(0.01 mm) pich - Height of image(0.01 mm) picwgoal - Width of image(twips) pichgoal - Height of image(twips)Units Used ---------- 1 Twip = 1/20 Point 1 Point = 1/72 Inch 1 Twip = 1/1440 Inch 1 Inch = 2.54 cm 1 Inch = 25.4 mm 1 Inch = 2540 (0.01)mm- Parameters:
w- image widthh- image heightflag- scaling image flag- Returns:
- String property of image in rtf tag
-
getImageFormat
Return the image format.- Parameters:
image- the Image- Returns:
- the image format
-
getPageSize
public float[] getPageSize()Calculation for total paper width and total paper height after minus margin of page in twips.- Returns:
- float[] array of paper width and paper height
-
isLargeImage
Compare the width and height of the image and paper if the image is greater than paper, it's considered as large image.- Parameters:
image- image want to compare with paper- Returns:
- true if image is larger than paper size
-
createBookmark
Create a RTF bookmark string from givenBookmarkobject.- Parameters:
bookmark- anBookmarkobject- Returns:
- The String in RTF bookmark format.
- Throws:
IOException- when IO error occurs
-
createLink
Create a RTF link string from givenLinkobject.- Parameters:
link- anLinkobject- Returns:
- The String in RTF link format.
- Throws:
IOException- when IO error occurs
-