Constructor: |
public Chunk() {
this.content = new StringBuffer();
this.font = new Font();
}
|
public Chunk(Chunk ck) {
if (ck.content != null) {
content = new StringBuffer(ck.content.toString());
}
if (ck.font != null) {
font = new Font(ck.font);
}
if (ck.attributes != null) {
attributes = new HashMap(ck.attributes);
}
}
A Chunk copy constructor. Parameters:
ck - the Chunk to be copied
|
public Chunk(String content) {
this(content, new Font());
}
Constructs a chunk of text with a certain content, without specifying a
Font . Parameters:
content -
the content
|
public Chunk(char c) {
this(c, new Font());
}
Constructs a chunk of text with a char, without specifying a Font
. Parameters:
c -
the content
|
public Chunk(DrawInterface separator) {
this(separator, false);
}
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) {
this.content = new StringBuffer(content);
this.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) {
this.content = new StringBuffer();
this.content.append(c);
this.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) {
this(OBJECT_REPLACEMENT_CHARACTER, new Font());
setAttribute(SEPARATOR, new Object[] {separator, Boolean.valueOf(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) {
this(separator, tabPosition, false);
}
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) {
this(OBJECT_REPLACEMENT_CHARACTER, new Font());
Image copyImage = Image.getInstance(image);
copyImage.setAbsolutePosition(Float.NaN, Float.NaN);
setAttribute(IMAGE, new Object[] { copyImage, new Float(offsetX),
new Float(offsetY), Boolean.FALSE });
}
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) {
this(OBJECT_REPLACEMENT_CHARACTER, new Font());
if (tabPosition < 0) {
throw new IllegalArgumentException("A tab position may not be lower than 0; yours is " + tabPosition);
}
setAttribute(TAB, new Object[] {separator, new Float(tabPosition), Boolean.valueOf(newline), new Float(0)});
}
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) {
this(OBJECT_REPLACEMENT_CHARACTER, new Font());
setAttribute(IMAGE, new Object[] { image, new Float(offsetX),
new Float(offsetY), Boolean.valueOf(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 Detail: |
public StringBuffer append(String string) {
return content.append(string);
}
appends some text to this Chunk . |
public HashMap getAttributes() {
return attributes;
}
Gets the attributes for this Chunk .
It may be null. |
public ArrayList getChunks() {
ArrayList tmp = new ArrayList();
tmp.add(this);
return tmp;
}
Gets all the chunks in this element. |
public String getContent() {
return content.toString();
}
Returns the content of this Chunk . |
public Font getFont() {
return font;
}
Gets the font of this Chunk . |
public float getHorizontalScaling() {
if (attributes == null)
return 1f;
Float f = (Float) attributes.get(HSCALE);
if (f == null)
return 1f;
return f.floatValue();
}
Gets the horizontal scaling. |
public HyphenationEvent getHyphenation() {
if (attributes == null) return null;
return (HyphenationEvent) attributes.get(Chunk.HYPHENATION);
}
Returns the hyphenation (if present). |
public Image getImage() {
if (attributes == null)
return null;
Object obj[] = (Object[]) attributes.get(Chunk.IMAGE);
if (obj == null)
return null;
else {
return (Image) obj[0];
}
}
|
public float getTextRise() {
if (attributes != null && attributes.containsKey(SUBSUPSCRIPT)) {
Float f = (Float) attributes.get(SUBSUPSCRIPT);
return f.floatValue();
}
return 0.0f;
}
Gets the text displacement relative to the baseline. |
public float getWidthPoint() {
if (getImage() != null) {
return getImage().getScaledWidth();
}
return font.getCalculatedBaseFont(true).getWidthPoint(getContent(),
font.getCalculatedSize())
* getHorizontalScaling();
}
Gets the width of the Chunk in points. |
public boolean hasAttributes() {
return attributes != null;
}
Checks the attributes of this Chunk . |
public boolean isContent() {
return true;
}
|
public boolean isEmpty() {
return (content.toString().trim().length() == 0)
&& (content.toString().indexOf("\n") == -1)
&& (attributes == null);
}
Checks is this Chunk is empty. |
public boolean isNestable() {
return true;
}
|
public boolean process(ElementListener listener) {
try {
return listener.add(this);
} catch (DocumentException de) {
return false;
}
}
Processes the element by adding it (or the different parts) to an
ElementListener . |
public Chunk setAction(PdfAction action) {
return setAttribute(ACTION, action);
}
Sets an action for this Chunk . |
public Chunk setAnchor(URL url) {
return setAttribute(ACTION, new PdfAction(url.toExternalForm()));
}
Sets an anchor for this Chunk . |
public Chunk setAnchor(String url) {
return setAttribute(ACTION, new PdfAction(url));
}
Sets an anchor for this Chunk . |
public Chunk setAnnotation(PdfAnnotation annotation) {
return setAttribute(PDFANNOTATION, annotation);
}
Sets a generic annotation to this Chunk . |
public void setAttributes(HashMap attributes) {
this.attributes = attributes;
}
Sets the attributes all at once. |
public Chunk setBackground(Color color) {
return setBackground(color, 0, 0, 0, 0);
}
Sets the color of the background Chunk . |
public Chunk setBackground(Color color,
float extraLeft,
float extraBottom,
float extraRight,
float extraTop) {
return setAttribute(BACKGROUND, new Object[] { color,
new float[] { extraLeft, extraBottom, extraRight, extraTop } });
}
Sets the color and the size of the background Chunk . |
public void setFont(Font font) {
this.font = font;
}
Sets the font of this Chunk . |
public Chunk setGenericTag(String text) {
return setAttribute(GENERICTAG, text);
}
|
public Chunk setHorizontalScaling(float scale) {
return setAttribute(HSCALE, new 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) {
return setAttribute(HYPHENATION, hyphenation);
}
sets the hyphenation engine to this Chunk . |
public Chunk setLocalDestination(String name) {
return setAttribute(LOCALDESTINATION, name);
}
Sets a local destination for this Chunk . |
public Chunk setLocalGoto(String name) {
return setAttribute(LOCALGOTO, name);
}
|
public Chunk setNewPage() {
return setAttribute(NEWPAGE, null);
}
|
public Chunk setRemoteGoto(String filename,
String name) {
return setAttribute(REMOTEGOTO, new Object[] { filename, name });
}
Sets a goto for a remote destination for this Chunk . |
public Chunk setRemoteGoto(String filename,
int page) {
return setAttribute(REMOTEGOTO, new Object[] { filename,
new Integer(page) });
}
Sets a goto for a remote destination for this Chunk . |
public Chunk setSkew(float alpha,
float beta) {
alpha = (float) Math.tan(alpha * Math.PI / 180);
beta = (float) Math.tan(beta * Math.PI / 180);
return setAttribute(SKEW, new float[] { alpha, beta });
}
Skews the text to simulate italic and other effects. Try alpha=0
and beta=12 . |
public Chunk setSplitCharacter(SplitCharacter splitCharacter) {
return setAttribute(SPLITCHARACTER, splitCharacter);
}
Sets the split characters. |
public Chunk setTextRenderMode(int mode,
float strokeWidth,
Color strokeColor) {
return setAttribute(TEXTRENDERMODE, new Object[] { new Integer(mode),
new Float(strokeWidth), strokeColor });
}
Sets the text rendering mode. It can outline text, simulate bold and make
text invisible. |
public Chunk setTextRise(float rise) {
return setAttribute(SUBSUPSCRIPT, new Float(rise));
}
|
public Chunk setUnderline(float thickness,
float yPosition) {
return setUnderline(null, thickness, 0f, yPosition, 0f,
PdfContentByte.LINE_CAP_BUTT);
}
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) {
if (attributes == null)
attributes = new HashMap();
Object obj[] = {
color,
new float[] { thickness, thicknessMul, yPosition, yPositionMul, cap } };
Object unders[][] = Utilities.addToArray((Object[][]) attributes.get(UNDERLINE),
obj);
return setAttribute(UNDERLINE, unders);
}
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() {
return getContent();
}
Returns the content of this Chunk . |
public int type() {
return Element.CHUNK;
}
Gets the type of the text element. |