Home » iText-2.1.7 » com.lowagie » text » [javadoc | source]
com.lowagie.text
public class: Chunk [javadoc | source]
java.lang.Object
   com.lowagie.text.Chunk

All Implemented Interfaces:
    Element

Direct Known Subclasses:
    RtfTotalPageNumber, RtfField, AbstractRtfField, RtfAnchor, RtfPageNumber, PdfBarcode, GenericRtfField, RtfTabGroup, RtfShapeProperty, RtfTOCEntry, RtfTableOfContents, RtfShapePosition, RtfPageNumber, RtfShape, RtfAddableElement, RtfTOCEntry, RtfTOC, RtfTab, RtfDirectContent

This is the smallest significant part of text that can be added to a document.

Most elements can be divided in one or more Chunks. A chunk is a String with a certain Font. All other layout parameters should be defined in the object to which this chunk of text is added.

Example:


Chunk chunk = new Chunk("Hello world",
FontFactory.getFont(FontFactory.COURIER, 20, Font.ITALIC, new Color(255, 0,
0)));  document.add(chunk);

Field Summary
public static final  String OBJECT_REPLACEMENT_CHARACTER    The character stand in for an image or a separator. 
public static final  Chunk NEWLINE    This is a Chunk containing a newline. 
public static final  Chunk NEXTPAGE    This is a Chunk containing a newpage. 
protected  StringBuffer content    This is the content of this chunk of text. 
protected  Font font    This is the Font of this chunk of text. 
protected  HashMap attributes    Contains some of the attributes for this Chunk. 
public static final  String SEPARATOR    Key for drawInterface of the Separator.
    since: 2.1.2 -
 
public static final  String TAB    Key for drawInterface of the tab.
    since: 2.1.2 -
 
public static final  String HSCALE    Key for text horizontal scaling. 
public static final  String UNDERLINE    Key for underline. 
public static final  String SUBSUPSCRIPT    Key for sub/superscript. 
public static final  String SKEW    Key for text skewing. 
public static final  String BACKGROUND    Key for background. 
public static final  String TEXTRENDERMODE    Key for text rendering mode. 
public static final  String SPLITCHARACTER    Key for split character. 
public static final  String HYPHENATION    Key for hyphenation. 
public static final  String REMOTEGOTO    Key for remote goto. 
public static final  String LOCALGOTO    Key for local goto. 
public static final  String LOCALDESTINATION    Key for local destination. 
public static final  String GENERICTAG    Key for generic tag. 
public static final  String IMAGE    Key for image. 
public static final  String ACTION    Key for Action. 
public static final  String NEWPAGE    Key for newpage. 
public static final  String PDFANNOTATION    Key for annotation. 
public static final  String COLOR    Key for color. 
public static final  String ENCODING    Key for encoding. 
Constructor:
 public Chunk() 
 public Chunk(Chunk ck) 
    A Chunk copy constructor.
    Parameters:
    ck - the Chunk to be copied
 public Chunk(String content) 
    Constructs a chunk of text with a certain content, without specifying a Font.
    Parameters:
    content - the content
 public Chunk(char c) 
 public Chunk(DrawInterface separator) 
    Creates a separator Chunk. Note that separator chunks can't be used in combination with tab chunks!
    Parameters:
    separator - the drawInterface to use to draw the separator.
    since: 2.1.2 -
 public Chunk(String content,
    Font font) 
    Constructs a chunk of text with a certain content and a certain Font.
    Parameters:
    content - the content
    font - the font
 public Chunk(char c,
    Font font) 
    Constructs a chunk of text with a char and a certain Font.
    Parameters:
    c - the content
    font - the font
 public Chunk(DrawInterface separator,
    boolean vertical) 
    Creates a separator Chunk. Note that separator chunks can't be used in combination with tab chunks!
    Parameters:
    separator - the drawInterface to use to draw the separator.
    vertical - true if this is a vertical separator
    since: 2.1.2 -
 public Chunk(DrawInterface separator,
    float tabPosition) 
    Creates a tab Chunk. Note that separator chunks can't be used in combination with tab chunks!
    Parameters:
    separator - the drawInterface to use to draw the tab.
    tabPosition - an X coordinate that will be used as start position for the next Chunk.
    since: 2.1.2 -
 public Chunk(Image image,
    float offsetX,
    float offsetY) 
    Constructs a chunk containing an Image.
    Parameters:
    image - the image
    offsetX - the image offset in the x direction
    offsetY - the image offset in the y direction
 public Chunk(DrawInterface separator,
    float tabPosition,
    boolean newline) 
    Creates a tab Chunk. Note that separator chunks can't be used in combination with tab chunks!
    Parameters:
    separator - the drawInterface to use to draw the tab.
    tabPosition - an X coordinate that will be used as start position for the next Chunk.
    newline - if true, a newline will be added if the tabPosition has already been reached.
    since: 2.1.2 -
 public Chunk(Image image,
    float offsetX,
    float offsetY,
    boolean changeLeading) 
    Constructs a chunk containing an Image.
    Parameters:
    image - the image
    offsetX - the image offset in the x direction
    offsetY - the image offset in the y direction
    changeLeading - true if the leading has to be adapted to the image
Method from com.lowagie.text.Chunk Summary:
append,   getAttributes,   getChunks,   getContent,   getFont,   getHorizontalScaling,   getHyphenation,   getImage,   getTextRise,   getWidthPoint,   hasAttributes,   isContent,   isEmpty,   isNestable,   process,   setAction,   setAnchor,   setAnchor,   setAnnotation,   setAttributes,   setBackground,   setBackground,   setFont,   setGenericTag,   setHorizontalScaling,   setHyphenation,   setLocalDestination,   setLocalGoto,   setNewPage,   setRemoteGoto,   setRemoteGoto,   setSkew,   setSplitCharacter,   setTextRenderMode,   setTextRise,   setUnderline,   setUnderline,   toString,   type
Methods from java.lang.Object:
clone,   equals,   finalize,   getClass,   hashCode,   notify,   notifyAll,   toString,   wait,   wait,   wait
Method from com.lowagie.text.Chunk Detail:
 public StringBuffer append(String string) 
    appends some text to this Chunk.
 public HashMap getAttributes() 
    Gets the attributes for this Chunk.

    It may be null.

 public ArrayList getChunks() 
    Gets all the chunks in this element.
 public String getContent() 
    Returns the content of this Chunk.
 public Font getFont() 
    Gets the font of this Chunk.
 public float getHorizontalScaling() 
    Gets the horizontal scaling.
 public HyphenationEvent getHyphenation() 
    Returns the hyphenation (if present).
 public Image getImage() 
    Returns the image.
 public float getTextRise() 
    Gets the text displacement relative to the baseline.
 public float getWidthPoint() 
    Gets the width of the Chunk in points.
 public boolean hasAttributes() 
    Checks the attributes of this Chunk.
 public boolean isContent() 
 public boolean isEmpty() 
    Checks is this Chunk is empty.
 public boolean isNestable() 
 public boolean process(ElementListener listener) 
    Processes the element by adding it (or the different parts) to an ElementListener.
 public Chunk setAction(PdfAction action) 
    Sets an action for this Chunk.
 public Chunk setAnchor(URL url) 
    Sets an anchor for this Chunk.
 public Chunk setAnchor(String url) 
    Sets an anchor for this Chunk.
 public Chunk setAnnotation(PdfAnnotation annotation) 
    Sets a generic annotation to this Chunk.
 public  void setAttributes(HashMap attributes) 
    Sets the attributes all at once.
 public Chunk setBackground(Color color) 
    Sets the color of the background Chunk.
 public Chunk setBackground(Color color,
    float extraLeft,
    float extraBottom,
    float extraRight,
    float extraTop) 
    Sets the color and the size of the background Chunk.
 public  void setFont(Font font) 
    Sets the font of this Chunk.
 public Chunk setGenericTag(String text) 
    Sets the generic tag Chunk.

    The text for this tag can be retrieved with PdfPageEvent.

 public Chunk setHorizontalScaling(float scale) 
    Sets the text horizontal scaling. A value of 1 is normal and a value of 0.5f shrinks the text to half it's width.
 public Chunk setHyphenation(HyphenationEvent hyphenation) 
    sets the hyphenation engine to this Chunk.
 public Chunk setLocalDestination(String name) 
    Sets a local destination for this Chunk.
 public Chunk setLocalGoto(String name) 
    Sets a local goto for this Chunk.

    There must be a local destination matching the name.

 public Chunk setNewPage() 
    Sets a new page tag..
 public Chunk setRemoteGoto(String filename,
    String name) 
    Sets a goto for a remote destination for this Chunk.
 public Chunk setRemoteGoto(String filename,
    int page) 
    Sets a goto for a remote destination for this Chunk.
 public Chunk setSkew(float alpha,
    float beta) 
    Skews the text to simulate italic and other effects. Try alpha=0 and beta=12.
 public Chunk setSplitCharacter(SplitCharacter splitCharacter) 
    Sets the split characters.
 public Chunk setTextRenderMode(int mode,
    float strokeWidth,
    Color strokeColor) 
    Sets the text rendering mode. It can outline text, simulate bold and make text invisible.
 public Chunk setTextRise(float rise) 
    Sets the text displacement relative to the baseline. Positive values rise the text, negative values lower the text.

    It can be used to implement sub/superscript.

 public Chunk setUnderline(float thickness,
    float yPosition) 
    Sets an horizontal line that can be an underline or a strikethrough. Actually, the line can be anywhere vertically and has always the Chunk width. Multiple call to this method will produce multiple lines.
 public Chunk setUnderline(Color color,
    float thickness,
    float thicknessMul,
    float yPosition,
    float yPositionMul,
    int cap) 
    Sets an horizontal line that can be an underline or a strikethrough. Actually, the line can be anywhere vertically and has always the Chunk width. Multiple call to this method will produce multiple lines.
 public String toString() 
    Returns the content of this Chunk.
 public int type() 
    Gets the type of the text element.