org.jfor.jfor.rtflib.rtfdoc
Class RtfExternalGraphic
java.lang.Object
org.jfor.jfor.rtflib.rtfdoc.RtfElement
org.jfor.jfor.rtflib.rtfdoc.RtfExternalGraphic
- public class RtfExternalGraphic
- extends RtfElement
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
- Author:
- Andreas Putz
Field Summary |
protected int |
graphicCompressionRate
Graphic compression rate |
protected int |
height
The height of the image |
protected int |
heightDesired
The desired height |
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 java.net.URL |
url
The url of the image |
protected int |
width
The width of the image |
protected int |
widthDesired
The desired width |
protected int |
widthPercent
The desired percent value of the width |
Method Summary |
int |
getCompressionRate()
Gets the compression rate for the image in percent. |
boolean |
isEmpty()
true if this element would generate no "useful" RTF content |
boolean |
setCompressionRate(int percent)
Sets the compression rate for the image in percent. |
void |
setHeight(java.lang.String theHeight)
Sets the desired height of the image. |
void |
setScaling(java.lang.String value)
Sets the flag whether the image size shall be adjusted. |
void |
setURL(java.lang.String urlString)
Sets the url of the image. |
void |
setWidth(java.lang.String theWidth)
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 |
Methods inherited from class org.jfor.jfor.rtflib.rtfdoc.RtfElement |
close, dump, getParentOfClass, getRtfAttributes, getRtfFile, isClosed, okToWriteRtf, toString, writeAttributes, writeControlWord, writeControlWordNS, writeExceptionInRtf, writeGroupMark, writeOneAttribute, writeOneAttributeNS, writeRtf, writeRtfPrefix, writeRtfSuffix, writeStarControlWord, writeStarControlWordNS |
Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait |
url
protected java.net.URL url
- The url of the image
height
protected int height
- The height of the image
heightPercent
protected int heightPercent
- The desired percent value of the height
heightDesired
protected int heightDesired
- The desired height
perCentH
protected boolean perCentH
- Flag whether the desired height is a percentage
width
protected int width
- The width of the image
widthPercent
protected int widthPercent
- The desired percent value of the width
widthDesired
protected int widthDesired
- The desired width
perCentW
protected boolean perCentW
- Flag whether the desired width is a percentage
scaleUniform
protected boolean scaleUniform
- Flag whether the image size shall be adjusted
graphicCompressionRate
protected int graphicCompressionRate
- Graphic compression rate
RtfExternalGraphic
public RtfExternalGraphic(RtfContainer container,
java.io.Writer writer)
throws java.io.IOException
- Default constructor.
Create an RTF element as a child of given container.
- Parameters:
container
- a RtfContainer
valuewriter
- a Writer
value
RtfExternalGraphic
public RtfExternalGraphic(RtfContainer container,
java.io.Writer writer,
RtfAttributes attributes)
throws java.io.IOException
- Default constructor.
- Parameters:
container
- a RtfContainer
valuewriter
- a Writer
valueattributes
- a RtfAttributes
value
writeRtfContent
protected void writeRtfContent()
throws java.io.IOException
- RtfElement override - catches ExternalGraphicException and writes a warning
message to the document if image cannot be read
- Specified by:
writeRtfContent
in class RtfElement
- Throws:
java.io.IOException
writeRtfContentWithException
protected void writeRtfContentWithException()
throws java.io.IOException
- Writes the RTF content to m_writer - this one throws ExternalGraphicExceptions
- Throws:
java.io.IOException
- On error
setHeight
public void setHeight(java.lang.String theHeight)
- Sets the desired height of the image.
- Parameters:
theHeight
- The desired image height
setWidth
public void setWidth(java.lang.String theWidth)
- Sets the desired width of the image.
- Parameters:
theWidth
- The desired image width
setScaling
public void setScaling(java.lang.String value)
- Sets the flag whether the image size shall be adjusted.
- Parameters:
value
- true image width or height shall be adjusted automatically\n
false no adjustment
setURL
public void setURL(java.lang.String urlString)
throws java.io.IOException
- Sets the url of the image.
- Parameters:
urlString
- Image url like "file://..."
- Throws:
java.io.IOException
- On error
getCompressionRate
public int getCompressionRate()
- Gets the compression rate for the image in percent.
- Returns:
- Compression rate
setCompressionRate
public boolean setCompressionRate(int percent)
- Sets the compression rate for the image in percent.
- Parameters:
percent
- Compression rate
- Returns:
- true: The compression rate is valid (0..100)\n
false: The compression rate is invalid
isEmpty
public boolean isEmpty()
- true if this element would generate no "useful" RTF content
- Specified by:
isEmpty
in class RtfElement