com.lowagie.text.rtf.graphic

Class RtfShape

public class RtfShape extends RtfAddableElement

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.

Version: $Id: RtfShape.java 3591 2008-08-27 17:19:27Z howard_s $

Author: Mark Hall (Mark.Hall@mail.room3b.eu) Thomas Bickel (tmb99@inode.at)

Field Summary
RtfShapePositionposition
The RtfShapePosition that defines position settings for this RtfShape.
HashMapproperties
A HashMap with RtfShapePropertys that define further shape properties.
intshapeNr
The shape nr is a random unique id.
StringshapeText
Text that is contained in the shape.
static intSHAPE_ARC
Constant for an arc shape.
static intSHAPE_ARROR_THICK
Constant for a thick arrow.
static intSHAPE_ARROW
Constant for an arrow.
static intSHAPE_BALLOON
Constant for a balloon shape.
static intSHAPE_CAN
Constant for a can shape.
static intSHAPE_CUBE
Constant for a cube shape.
static intSHAPE_DIAMOND
Constant for a diamond.
static intSHAPE_DONUT
Constant for a donut shape.
static intSHAPE_ELLIPSE
Constant for an ellipse.
static intSHAPE_FREEFORM
Constant for a free form shape.
static intSHAPE_HEXAGON
Constant for a hexagon.
static intSHAPE_HOME_PLATE
Constant for a home plate style shape.
static intSHAPE_LINE
Constant for a line shape.
static intSHAPE_OCTAGON
Constant for an ocatagon.
static intSHAPE_PARALLELOGRAM
Constant for a parallelogram.
static intSHAPE_PICTURE_FRAME
Constant for a Picture Frame.
static intSHAPE_RECTANGLE
Constant for a rectangle.
static intSHAPE_ROUND_RECTANGLE
Constant for a rounded rectangle.
static intSHAPE_SEAL
Constant for a seal shape.
static intSHAPE_STAR
Constant for a star.
static intSHAPE_TRAPEZOID
Constant for a trapezoid.
static intSHAPE_TRIANGLE_ISOSCELES
Constant for a isosceles triangle.
static intSHAPE_TRIANGLE_RIGHT
Constant for a right triangle.
static intSHAPE_WRAP_BOTH
Text is wrapped on the left and right side.
static intSHAPE_WRAP_LARGEST
Text is wrapped on the largest side.
static intSHAPE_WRAP_LEFT
Text is wrapped on the left side.
static intSHAPE_WRAP_NONE
Text is not wrapped around the shape.
static intSHAPE_WRAP_RIGHT
Text is wrapped on the right side.
static intSHAPE_WRAP_THROUGH
Text is wrapped through the shape.
static intSHAPE_WRAP_TIGHT_BOTH
Text is tightly wrapped on the left and right side.
static intSHAPE_WRAP_TIGHT_LARGEST
Text is tightly wrapped on the largest side.
static intSHAPE_WRAP_TIGHT_LEFT
Text is tightly wrapped on the left side.
static intSHAPE_WRAP_TIGHT_RIGHT
Text is tightly wrapped on the right side.
static intSHAPE_WRAP_TOP_BOTTOM
Text is wrapped to the top and bottom.
inttype
The shape type.
intwrapping
The wrapping mode.
Constructor Summary
RtfShape(int type, RtfShapePosition position)
Constructs a new RtfShape of a given shape at the given RtfShapePosition.
Method Summary
voidsetProperty(RtfShapeProperty property)
Sets a property.
voidsetShapeText(String shapeText)
Sets the text to display in this RtfShape.
voidsetWrapping(int wrapping)
Set the wrapping mode.
voidwriteContent(OutputStream result)
Writes the RtfShape.

Field Detail

position

private RtfShapePosition position
The RtfShapePosition that defines position settings for this RtfShape.

properties

private HashMap properties
A HashMap with RtfShapePropertys that define further shape properties.

shapeNr

private int shapeNr
The shape nr is a random unique id.

shapeText

private String shapeText
Text that is contained in the shape.

SHAPE_ARC

public static final int SHAPE_ARC
Constant for an arc shape.

SHAPE_ARROR_THICK

public static final int SHAPE_ARROR_THICK
Constant for a thick arrow.

SHAPE_ARROW

public static final int SHAPE_ARROW
Constant for an arrow.

SHAPE_BALLOON

public static final int SHAPE_BALLOON
Constant for a balloon shape.

SHAPE_CAN

public static final int SHAPE_CAN
Constant for a can shape.

SHAPE_CUBE

public static final int SHAPE_CUBE
Constant for a cube shape.

SHAPE_DIAMOND

public static final int SHAPE_DIAMOND
Constant for a diamond.

SHAPE_DONUT

public static final int SHAPE_DONUT
Constant for a donut shape.

SHAPE_ELLIPSE

public static final int SHAPE_ELLIPSE
Constant for an ellipse. Use this to create circles.

SHAPE_FREEFORM

public static final int SHAPE_FREEFORM
Constant 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.

SHAPE_HEXAGON

public static final int SHAPE_HEXAGON
Constant for a hexagon.

SHAPE_HOME_PLATE

public static final int SHAPE_HOME_PLATE
Constant for a home plate style shape.

SHAPE_LINE

public static final int SHAPE_LINE
Constant for a line shape.

SHAPE_OCTAGON

public static final int SHAPE_OCTAGON
Constant for an ocatagon.

SHAPE_PARALLELOGRAM

public static final int SHAPE_PARALLELOGRAM
Constant for a parallelogram.

SHAPE_PICTURE_FRAME

public static final int SHAPE_PICTURE_FRAME
Constant for a Picture Frame.

SHAPE_RECTANGLE

public static final int SHAPE_RECTANGLE
Constant for a rectangle.

SHAPE_ROUND_RECTANGLE

public static final int SHAPE_ROUND_RECTANGLE
Constant for a rounded rectangle. The roundness is set via a RtfShapeProperty with the name PROPERTY_ADJUST_VALUE.

SHAPE_SEAL

public static final int SHAPE_SEAL
Constant for a seal shape.

SHAPE_STAR

public static final int SHAPE_STAR
Constant for a star.

SHAPE_TRAPEZOID

public static final int SHAPE_TRAPEZOID
Constant for a trapezoid.

SHAPE_TRIANGLE_ISOSCELES

public static final int SHAPE_TRIANGLE_ISOSCELES
Constant for a isosceles triangle.

SHAPE_TRIANGLE_RIGHT

public static final int SHAPE_TRIANGLE_RIGHT
Constant for a right triangle.

SHAPE_WRAP_BOTH

public static final int SHAPE_WRAP_BOTH
Text is wrapped on the left and right side.

SHAPE_WRAP_LARGEST

public static final int SHAPE_WRAP_LARGEST
Text is wrapped on the largest side.

SHAPE_WRAP_LEFT

public static final int SHAPE_WRAP_LEFT
Text is wrapped on the left side.

SHAPE_WRAP_NONE

public static final int SHAPE_WRAP_NONE
Text is not wrapped around the shape.

SHAPE_WRAP_RIGHT

public static final int SHAPE_WRAP_RIGHT
Text is wrapped on the right side.

SHAPE_WRAP_THROUGH

public static final int SHAPE_WRAP_THROUGH
Text is wrapped through the shape.

SHAPE_WRAP_TIGHT_BOTH

public static final int SHAPE_WRAP_TIGHT_BOTH
Text is tightly wrapped on the left and right side.

SHAPE_WRAP_TIGHT_LARGEST

public static final int SHAPE_WRAP_TIGHT_LARGEST
Text is tightly wrapped on the largest side.

SHAPE_WRAP_TIGHT_LEFT

public static final int SHAPE_WRAP_TIGHT_LEFT
Text is tightly wrapped on the left side.

SHAPE_WRAP_TIGHT_RIGHT

public static final int SHAPE_WRAP_TIGHT_RIGHT
Text is tightly wrapped on the right side.

SHAPE_WRAP_TOP_BOTTOM

public static final int SHAPE_WRAP_TOP_BOTTOM
Text is wrapped to the top and bottom.

type

private int type
The shape type.

wrapping

private int wrapping
The wrapping mode. Defaults to SHAPE_WRAP_NONE;

Constructor Detail

RtfShape

public RtfShape(int type, RtfShapePosition position)
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 Detail

setProperty

public void setProperty(RtfShapeProperty property)
Sets a property.

Parameters: property The property to set for this RtfShape.

setShapeText

public void setShapeText(String shapeText)
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

public void writeContent(OutputStream result)
Writes the RtfShape. Some settings are automatically translated into or require other properties and these are set first.