org.apache.fop.render.rtf.rtflib.rtfdoc
Class RtfExternalGraphic
public class RtfExternalGraphic
Creates an RTF image from an external graphic file.
This class belongs to the tag processing.
Supports relative path like "../test.gif", too (01-08-24)
Limitations:
Only the image types PNG, JPEG and EMF are supported
The GIF is supported, too, but will be converted to JPG
Only the attributes SRC (required), WIDTH, HEIGHT, SCALING are supported
The SCALING attribute supports (uniform | non-uniform)
Known Bugs:
If the emf image has a desired size, the image will be clipped
The emf, jpg & png image will not be displayed in correct size
protected int | graphicCompressionRate - Graphic compression rate
|
protected int | height - The height of the image (in pixels)
|
protected int | heightDesired - The desired height (in twips)
|
protected int | heightPercent - The desired percent value of the height
|
protected boolean | perCentH - Flag whether the desired height is a percentage
|
protected boolean | perCentW - Flag whether the desired width is a percentage
|
protected boolean | scaleUniform - Flag whether the image size shall be adjusted
|
protected URL | url - The url of the image
|
protected int | width - The width of the image (in pixels)
|
protected int | widthDesired - The desired width (in twips)
|
protected int | widthPercent - The desired percent value of the width
|
int | getCompressionRate() - Gets the compression rate for the image in percent.
|
boolean | isEmpty()
|
boolean | setCompressionRate(int percent) - Sets the compression rate for the image in percent.
|
void | setCropping(int left, int top, int right, int bottom) - Sets cropping values for all four edges for the \piccrop*N commands.
|
void | setHeight(String theHeight) - Sets the desired height of the image.
|
void | setHeightTwips(int twips) - Sets the desired height of the image.
|
void | setImageData(byte[] data) - Sets the binary imagedata of the image.
|
void | setScaling(String value) - Sets the flag whether the image size shall be adjusted.
|
void | setURL(String urlString) - Sets the url of the image.
|
void | setUniformScaling(boolean uniform) - Sets the flag whether the image size shall be adjusted.
|
void | setWidth(String theWidth) - Sets the desired width of the image.
|
void | setWidthTwips(int twips) - Sets the desired width of the image.
|
protected void | writeRtfContent() - RtfElement override - catches ExternalGraphicException and writes a warning
message to the document if image cannot be read
|
protected void | writeRtfContentWithException() - Writes the RTF content to m_writer - this one throws ExternalGraphicExceptions
|
close , getRtfAttributes , isEmpty , newLine , okToWriteRtf , toString , writeAttributes , writeControlWord , writeControlWordNS , writeExceptionInRtf , writeGroupMark , writeOneAttribute , writeOneAttributeNS , writeRtf , writeRtfContent , writeRtfPrefix , writeRtfSuffix , writeStarControlWord , writeStarControlWordNS |
graphicCompressionRate
protected int graphicCompressionRate
Graphic compression rate
height
protected int height
The height of the image (in pixels)
heightDesired
protected int heightDesired
The desired height (in twips)
heightPercent
protected int heightPercent
The desired percent value of the height
perCentH
protected boolean perCentH
Flag whether the desired height is a percentage
perCentW
protected boolean perCentW
Flag whether the desired width is a percentage
scaleUniform
protected boolean scaleUniform
Flag whether the image size shall be adjusted
url
protected URL url
The url of the image
width
protected int width
The width of the image (in pixels)
widthDesired
protected int widthDesired
The desired width (in twips)
widthPercent
protected int widthPercent
The desired percent value of the width
RtfExternalGraphic
public RtfExternalGraphic(RtfContainer container,
Writer writer)
throws IOException
Default constructor.
Create an RTF element as a child of given container.
container
- a RtfContainer
valuewriter
- a Writer
value
RtfExternalGraphic
public RtfExternalGraphic(RtfContainer container,
Writer writer,
RtfAttributes attributes)
throws IOException
Default constructor.
container
- a RtfContainer
valuewriter
- a Writer
valueattributes
- a RtfAttributes
value
getCompressionRate
public int getCompressionRate()
Gets the compression rate for the image in percent.
isEmpty
public boolean isEmpty()
- isEmpty in interface RtfElement
- true if this element would generate no "useful" RTF content
setCompressionRate
public boolean setCompressionRate(int percent)
Sets the compression rate for the image in percent.
percent
- Compression rate
- true if the compression rate is valid (0..100), false if invalid
setCropping
public void setCropping(int left,
int top,
int right,
int bottom)
Sets cropping values for all four edges for the \piccrop*N commands.
A positive value crops toward the center of the picture;
a negative value crops away from the center, adding a space border around the picture
left
- left cropping value (in twips)top
- top cropping value (in twips)right
- right cropping value (in twips)bottom
- bottom cropping value (in twips)
setHeight
public void setHeight(String theHeight)
Sets the desired height of the image.
theHeight
- The desired image height (as a string in twips or as a percentage)
setHeightTwips
public void setHeightTwips(int twips)
Sets the desired height of the image.
twips
- The desired image height (in twips)
setImageData
public void setImageData(byte[] data)
throws IOException
Sets the binary imagedata of the image.
data
- binary imagedata as read from file.
setScaling
public void setScaling(String value)
Sets the flag whether the image size shall be adjusted.
value
- true image width or height shall be adjusted automatically\n
false no adjustment
setURL
public void setURL(String urlString)
throws IOException
Sets the url of the image.
urlString
- Image url like "file://..."
setUniformScaling
public void setUniformScaling(boolean uniform)
Sets the flag whether the image size shall be adjusted.
uniform
- true image width or height shall be adjusted automatically\n
false no adjustment
setWidth
public void setWidth(String theWidth)
Sets the desired width of the image.
theWidth
- The desired image width (as a string in twips or as a percentage)
setWidthTwips
public void setWidthTwips(int twips)
Sets the desired width of the image.
twips
- The desired image width (in twips)
writeRtfContent
protected void writeRtfContent()
throws IOException
RtfElement override - catches ExternalGraphicException and writes a warning
message to the document if image cannot be read
- writeRtfContent in interface RtfElement
writeRtfContentWithException
protected void writeRtfContentWithException()
throws IOException
Writes the RTF content to m_writer - this one throws ExternalGraphicExceptions
Copyright 1999-2008 The Apache Software Foundation. All Rights Reserved.