📄 chunk.java
字号:
* @return a <CODE>StringBuffer</CODE> */ public StringBuffer append(String string) { return content.append(string); } // methods to retrieve information/** * Gets the font of this <CODE>Chunk</CODE>. * * @return a <CODE>Font</CODE> */ public Font font() { return font; }/** * Sets the font of this <CODE>Chunk</CODE>. * * @param font a <CODE>Font</CODE> */ public void setFont(Font font) { this.font = font; }/** * Returns the content of this <CODE>Chunk</CODE>. * * @return a <CODE>String</CODE> */ public String content() { return content.toString(); }/** * Checks is this <CODE>Chunk</CODE> is empty. * * @return <CODE>false</CODE> if the Chunk contains other characters than space. */ public boolean isEmpty() { return (content.toString().trim().length() == 0) && (content.toString().indexOf("\n") == -1) && (attributes == null); }/** * Sets the text displacement relative to the baseline. Positive values rise the text, * negative values lower the text. * <P> * It can be used to implement sub/superscript. * @param rise the displacement in points * @return this <CODE>Chunk</CODE> */ public Chunk setTextRise(float rise) { return setAttribute(SUBSUPSCRIPT, new Float(rise)); }/** * Sets an action for this <CODE>Chunk</CODE>. * * @param action the action * @return this <CODE>Chunk</CODE> */ public Chunk setAction(PdfAction action) { return setAttribute(ACTION, action); }/** * Sets an anchor for this <CODE>Chunk</CODE>. * * @param url the <CODE>URL</CODE> to link to * @return this <CODE>Chunk</CODE> */ public Chunk setAnchor(URL url) { return setAttribute(ACTION, new PdfAction(url.toExternalForm())); }/** * Sets an anchor for this <CODE>Chunk</CODE>. * * @param url the url to link to * @return this <CODE>Chunk</CODE> */ public Chunk setAnchor(String url) { return setAttribute(ACTION, new PdfAction(url)); }/** * Sets a local goto for this <CODE>Chunk</CODE>. * <P> * There must be a local destination matching the name. * @param name the name of the destination to go to * @return this <CODE>Chunk</CODE> */ public Chunk setLocalGoto(String name) { return setAttribute(LOCALGOTO, name); }/** * Sets the color of the background <CODE>Chunk</CODE>. * @param color the color of the background * @return this <CODE>Chunk</CODE> */ public Chunk setBackground(Color color) { return setAttribute(BACKGROUND, color); }/** * Sets a generic annotation to this <CODE>Chunk</CODE>. * @param annotation the annotation * @return this <CODE>Chunk</CODE> */ public Chunk setAnnotation(PdfAnnotation annotation) { return setAttribute(PDFANNOTATION, annotation); }/** sets the hyphenation engine to this <CODE>Chunk</CODE>. * @param hyphenation the hyphenation engine * @return this <CODE>Chunk</CODE> */ public Chunk setHyphenation(HyphenationEvent hyphenation) { return setAttribute(HYPHENATION, hyphenation); }/** * Sets a goto for a remote destination for this <CODE>Chunk</CODE>. * * @param filename the file name of the destination document * @param name the name of the destination to go to * @return this <CODE>Chunk</CODE> */ public Chunk setRemoteGoto(String filename, String name) { return setAttribute(REMOTEGOTO, new Object[]{filename, name}); }/** * Sets a goto for a remote destination for this <CODE>Chunk</CODE>. * * @param filename the file name of the destination document * @param page the page of the destination to go to. First page is 1 * @return this <CODE>Chunk</CODE> */ public Chunk setRemoteGoto(String filename, int page) { return setAttribute(REMOTEGOTO, new Object[]{filename, new Integer(page)}); }/** * Sets a local destination for this <CODE>Chunk</CODE>. * * @param name the name for this destination * @return this <CODE>Chunk</CODE> */ public Chunk setLocalDestination(String name) { return setAttribute(LOCALDESTINATION, name); }/** * Sets the generic tag <CODE>Chunk</CODE>. * <P> * The text for this tag can be retrieved with <CODE>PdfPageEvent</CODE>. * * @param text the text for the tag * @return this <CODE>Chunk</CODE> */ public Chunk setGenericTag(String text) { return setAttribute(GENERICTAG, text); }/** * Sets the split characters. * * @param splitCharacter the <CODE>SplitCharacter</CODE> interface * @return this <CODE>Chunk</CODE> */ public Chunk setSplitCharacter(SplitCharacter splitCharacter) { return setAttribute(SPLITCHARACTER, splitCharacter); }/** * Sets a new page tag.. * @return this <CODE>Chunk</CODE> */ public Chunk setNewPage() { return setAttribute(NEWPAGE, null); }/** * Sets an arbitrary attribute. * * @param name the key for the attribute * @param obj the value of the attribute * @return this <CODE>Chunk</CODE> */ private Chunk setAttribute(String name, Object obj) { if (attributes == null) attributes = new HashMap(); attributes.put(name, obj); return this; }/** * Gets the attributes for this <CODE>Chunk</CODE>. * <P> * It may be null. * * @return the attributes for this <CODE>Chunk</CODE> */ public HashMap getAttributes() { return attributes; }/** * Checks the attributes of this <CODE>Chunk</CODE>. * * @return false if there aren't any. */ public boolean hasAttributes() { return attributes != null; }/** * Returns the image. */ 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]; } }/** * Checks if a given tag corresponds with this object. * * @param tag the given tag * @return true if the tag corresponds */ public static boolean isTag(String tag) { return ElementTags.CHUNK.equals(tag); }/** * @see com.lowagie.text.MarkupAttributes#setMarkupAttribute(java.lang.String, java.lang.String) */ public void setMarkupAttribute(String name, String value) { markupAttributes = (markupAttributes == null) ? new Properties() : markupAttributes; markupAttributes.put(name, value); }/** * @see com.lowagie.text.MarkupAttributes#setMarkupAttributes(java.util.Properties) */ public void setMarkupAttributes(Properties markupAttributes) { this.markupAttributes = markupAttributes; }/** * @see com.lowagie.text.MarkupAttributes#getMarkupAttribute(java.lang.String) */ public String getMarkupAttribute(String name) { return (markupAttributes == null) ? null : String.valueOf(markupAttributes.get(name)); }/** * @see com.lowagie.text.MarkupAttributes#getMarkupAttributeNames() */ public Set getMarkupAttributeNames() { return getKeySet(markupAttributes); }/** * @see com.lowagie.text.MarkupAttributes#getMarkupAttributes() */ public Properties getMarkupAttributes() { return markupAttributes; } public static Set getKeySet(Hashtable table) { return (table == null) ? Collections.EMPTY_SET : table.keySet(); }}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -