Package com.lowagie.text.rtf.graphic
Class RtfShape
java.lang.Object
com.lowagie.text.Chunk
com.lowagie.text.rtf.RtfAddableElement
com.lowagie.text.rtf.graphic.RtfShape
- All Implemented Interfaces:
com.lowagie.text.Element
,RtfBasicElement
,com.lowagie.text.RtfElementInterface
The RtfShape provides the interface for adding shapes to
the RTF document. This will only work for Word 97+, older
Word versions are not supported by this class.
Only very simple shapes are directly supported by the RtfShape. For more complex shapes you will have to read the RTF specification (iText follows the 1.6 specification) and add the desired properties via the RtfShapeProperty.
One thing to keep in mind is that distances are not expressed in the standard iText point, but in EMU where 1 inch = 914400 EMU or 1 cm = 360000 EMU.
Only very simple shapes are directly supported by the RtfShape. For more complex shapes you will have to read the RTF specification (iText follows the 1.6 specification) and add the desired properties via the RtfShapeProperty.
One thing to keep in mind is that distances are not expressed in the standard iText point, but in EMU where 1 inch = 914400 EMU or 1 cm = 360000 EMU.
- Version:
- $Id: RtfShape.java 3591 2008-08-27 17:19:27Z howard_s $
-
Field Summary
FieldsModifier and TypeFieldDescriptionprivate final RtfShapePosition
The RtfShapePosition that defines position settings for this RtfShape.private final Map
<String, RtfShapeProperty> A HashMap with RtfShapePropertys that define further shape properties.static final int
Constant for an arc shape.static final int
Constant for a thick arrow.static final int
Constant for an arrow.static final int
Constant for a balloon shape.static final int
Constant for a can shape.static final int
Constant for a cube shape.static final int
Constant for a diamond.static final int
Constant for a donut shape.static final int
Constant for an ellipse.static final int
Constant for a free form shape.static final int
Constant for a hexagon.static final int
Constant for a home plate style shape.static final int
Constant for a line shape.static final int
Constant for an ocatagon.static final int
Constant for a parallelogram.static final int
Constant for a Picture Frame.static final int
Constant for a rectangle.static final int
Constant for a rounded rectangle.static final int
Constant for a seal shape.static final int
Constant for a star.static final int
Constant for a trapezoid.static final int
Constant for a isosceles triangle.static final int
Constant for a right triangle.static final int
Text is wrapped on the left and right side.static final int
Text is wrapped on the largest side.static final int
Text is wrapped on the left side.static final int
Text is not wrapped around the shape.static final int
Text is wrapped on the right side.static final int
Text is wrapped through the shape.static final int
Text is tightly wrapped on the left and right side.static final int
Text is tightly wrapped on the largest side.static final int
Text is tightly wrapped on the left side.static final int
Text is tightly wrapped on the right side.static final int
Text is wrapped to the top and bottom.private int
The shape nr is a random unique id.private String
Text that is contained in the shape.private final int
The shape type.private int
The wrapping mode.Fields inherited from class com.lowagie.text.rtf.RtfAddableElement
doc, inHeader, inTable
Fields inherited from class com.lowagie.text.Chunk
ACTION, attributes, BACKGROUND, CHAR_SPACING, COLOR, content, ENCODING, font, GENERICTAG, HSCALE, HYPHENATION, IMAGE, LOCALDESTINATION, LOCALGOTO, NEWLINE, NEWPAGE, NEXTPAGE, OBJECT_REPLACEMENT_CHARACTER, PDFANNOTATION, REMOTEGOTO, SEPARATOR, SKEW, SPLITCHARACTER, SUBSUPSCRIPT, TAB, TEXTRENDERMODE, UNDERLINE
Fields inherited from interface com.lowagie.text.Element
ALIGN_BASELINE, ALIGN_BOTTOM, ALIGN_CENTER, ALIGN_JUSTIFIED, ALIGN_JUSTIFIED_ALL, ALIGN_LEFT, ALIGN_MIDDLE, ALIGN_RIGHT, ALIGN_TOP, ALIGN_UNDEFINED, ANCHOR, ANNOTATION, AUTHOR, CCITT_BLACKIS1, CCITT_ENCODEDBYTEALIGN, CCITT_ENDOFBLOCK, CCITT_ENDOFLINE, CCITTG3_1D, CCITTG3_2D, CCITTG4, CELL, CHAPTER, CHUNK, CREATIONDATE, CREATOR, FOOTNOTE, HEADER, IMGRAW, IMGTEMPLATE, JBIG2, JPEG, JPEG2000, KEYWORDS, LIST, LISTITEM, MARKED, MODIFICATIONDATE, MULTI_COLUMN_TEXT, PARAGRAPH, PHRASE, PRODUCER, PTABLE, RECTANGLE, ROW, SECTION, SUBJECT, TABLE, TITLE, YMARK
Fields inherited from interface com.lowagie.text.rtf.RtfBasicElement
CLOSE_GROUP, COMMA_DELIMITER, DELIMITER, OPEN_GROUP, TWIPS_FACTOR
-
Constructor Summary
ConstructorsConstructorDescriptionRtfShape
(int type, RtfShapePosition position) Constructs a new RtfShape of a given shape at the given RtfShapePosition. -
Method Summary
Modifier and TypeMethodDescriptionvoid
setProperty
(RtfShapeProperty property) Sets a property.void
setShapeText
(String shapeText) Sets the text to display in this RtfShape.void
setWrapping
(int wrapping) Set the wrapping mode.void
writeContent
(OutputStream result) Writes the RtfShape.Methods inherited from class com.lowagie.text.rtf.RtfAddableElement
intToByteArray, isEmpty, setInHeader, setInTable, setRtfDocument
Methods inherited from class com.lowagie.text.Chunk
append, getCharacterSpacing, getChunkAttributes, getChunks, getContent, getFont, getHorizontalScaling, getHyphenation, getImage, getTextRise, getWidthPoint, hasAttributes, isContent, isNestable, process, setAction, setAnchor, setAnchor, setAnnotation, setBackground, setBackground, setCharacterSpacing, setChunkAttributes, setFont, setGenericTag, setHorizontalScaling, setHyphenation, setLocalDestination, setLocalGoto, setNewPage, setRemoteGoto, setRemoteGoto, setSkew, setSplitCharacter, setTextRenderMode, setTextRise, setUnderline, setUnderline, toString, type
-
Field Details
-
SHAPE_PICTURE_FRAME
public static final int SHAPE_PICTURE_FRAMEConstant for a Picture Frame.- See Also:
-
SHAPE_FREEFORM
public static final int SHAPE_FREEFORMConstant for a free form shape. The shape verticies must be specified with an array of Point objects in a RtfShapeProperty with the name PROPERTY_VERTICIES.- See Also:
-
SHAPE_RECTANGLE
public static final int SHAPE_RECTANGLEConstant for a rectangle.- See Also:
-
SHAPE_ROUND_RECTANGLE
public static final int SHAPE_ROUND_RECTANGLEConstant for a rounded rectangle. The roundness is set via a RtfShapeProperty with the name PROPERTY_ADJUST_VALUE.- See Also:
-
SHAPE_ELLIPSE
public static final int SHAPE_ELLIPSEConstant for an ellipse. Use this to create circles.- See Also:
-
SHAPE_DIAMOND
public static final int SHAPE_DIAMONDConstant for a diamond.- See Also:
-
SHAPE_TRIANGLE_ISOSCELES
public static final int SHAPE_TRIANGLE_ISOSCELESConstant for a isosceles triangle.- See Also:
-
SHAPE_TRIANGLE_RIGHT
public static final int SHAPE_TRIANGLE_RIGHTConstant for a right triangle.- See Also:
-
SHAPE_PARALLELOGRAM
public static final int SHAPE_PARALLELOGRAMConstant for a parallelogram.- See Also:
-
SHAPE_TRAPEZOID
public static final int SHAPE_TRAPEZOIDConstant for a trapezoid.- See Also:
-
SHAPE_HEXAGON
public static final int SHAPE_HEXAGONConstant for a hexagon.- See Also:
-
SHAPE_OCTAGON
public static final int SHAPE_OCTAGONConstant for an ocatagon.- See Also:
-
SHAPE_STAR
public static final int SHAPE_STARConstant for a star.- See Also:
-
SHAPE_ARROW
public static final int SHAPE_ARROWConstant for an arrow.- See Also:
-
SHAPE_ARROR_THICK
public static final int SHAPE_ARROR_THICKConstant for a thick arrow.- See Also:
-
SHAPE_HOME_PLATE
public static final int SHAPE_HOME_PLATEConstant for a home plate style shape.- See Also:
-
SHAPE_CUBE
public static final int SHAPE_CUBEConstant for a cube shape.- See Also:
-
SHAPE_BALLOON
public static final int SHAPE_BALLOONConstant for a balloon shape.- See Also:
-
SHAPE_SEAL
public static final int SHAPE_SEALConstant for a seal shape.- See Also:
-
SHAPE_ARC
public static final int SHAPE_ARCConstant for an arc shape.- See Also:
-
SHAPE_LINE
public static final int SHAPE_LINEConstant for a line shape.- See Also:
-
SHAPE_CAN
public static final int SHAPE_CANConstant for a can shape.- See Also:
-
SHAPE_DONUT
public static final int SHAPE_DONUTConstant for a donut shape.- See Also:
-
SHAPE_WRAP_NONE
public static final int SHAPE_WRAP_NONEText is not wrapped around the shape.- See Also:
-
SHAPE_WRAP_TOP_BOTTOM
public static final int SHAPE_WRAP_TOP_BOTTOMText is wrapped to the top and bottom.- See Also:
-
SHAPE_WRAP_BOTH
public static final int SHAPE_WRAP_BOTHText is wrapped on the left and right side.- See Also:
-
SHAPE_WRAP_LEFT
public static final int SHAPE_WRAP_LEFTText is wrapped on the left side.- See Also:
-
SHAPE_WRAP_RIGHT
public static final int SHAPE_WRAP_RIGHTText is wrapped on the right side.- See Also:
-
SHAPE_WRAP_LARGEST
public static final int SHAPE_WRAP_LARGESTText is wrapped on the largest side.- See Also:
-
SHAPE_WRAP_TIGHT_BOTH
public static final int SHAPE_WRAP_TIGHT_BOTHText is tightly wrapped on the left and right side.- See Also:
-
SHAPE_WRAP_TIGHT_LEFT
public static final int SHAPE_WRAP_TIGHT_LEFTText is tightly wrapped on the left side.- See Also:
-
SHAPE_WRAP_TIGHT_RIGHT
public static final int SHAPE_WRAP_TIGHT_RIGHTText is tightly wrapped on the right side.- See Also:
-
SHAPE_WRAP_TIGHT_LARGEST
public static final int SHAPE_WRAP_TIGHT_LARGESTText is tightly wrapped on the largest side.- See Also:
-
SHAPE_WRAP_THROUGH
public static final int SHAPE_WRAP_THROUGHText is wrapped through the shape.- See Also:
-
shapeNr
private int shapeNrThe shape nr is a random unique id. -
type
private final int typeThe shape type. -
position
The RtfShapePosition that defines position settings for this RtfShape. -
properties
A HashMap with RtfShapePropertys that define further shape properties. -
wrapping
private int wrappingThe wrapping mode. Defaults to SHAPE_WRAP_NONE; -
shapeText
Text that is contained in the shape.
-
-
Constructor Details
-
RtfShape
Constructs a new RtfShape of a given shape at the given RtfShapePosition.- Parameters:
type
- The type of shape to create.position
- The RtfShapePosition to create this RtfShape at.
-
-
Method Details
-
setProperty
Sets a property.- Parameters:
property
- The property to set for this RtfShape.
-
setShapeText
Sets the text to display in this RtfShape.- Parameters:
shapeText
- The text to display.
-
setWrapping
public void setWrapping(int wrapping) Set the wrapping mode.- Parameters:
wrapping
- The wrapping mode to use for this RtfShape.
-
writeContent
Writes the RtfShape. Some settings are automatically translated into or require other properties and these are set first.- Specified by:
writeContent
in interfaceRtfBasicElement
- Specified by:
writeContent
in classRtfAddableElement
- Parameters:
result
- TheOutputStream
to write the content to- Throws:
IOException
-