⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 section.java

📁 源码包含生成 PDF 和 HTML 的类库
💻 JAVA
📖 第 1 页 / 共 2 页
字号:
     * Adds a marked section. For use in class MarkedSection only!     */    public MarkedSection addMarkedSection() {    	MarkedSection section = new MarkedSection(new Section(null, numberDepth + 1));    	add(section);    	return section;    }        /**     * Creates a <CODE>Section</CODE>, adds it to this <CODE>Section</CODE> and returns it.     *     * @param	title		the title of the new section     * @return  a new Section object     */    public Section addSection(Paragraph title) {        return addSection(0, title, numberDepth + 1);    }        /**     * Adds a <CODE>Section</CODE> to this <CODE>Section</CODE> and returns it.     *     * @param	indentation	the indentation of the new section     * @param	title		the title of the new section     * @param	numberDepth	the numberDepth of the section     * @return  a new Section object     */    public Section addSection(float indentation, String title, int numberDepth) {        return addSection(indentation, new Paragraph(title), numberDepth);    }        /**     * Adds a <CODE>Section</CODE> to this <CODE>Section</CODE> and returns it.     *     * @param	title		the title of the new section     * @param	numberDepth	the numberDepth of the section     * @return  a new Section object     */    public Section addSection(String title, int numberDepth) {        return addSection(new Paragraph(title), numberDepth);    }        /**     * Adds a <CODE>Section</CODE> to this <CODE>Section</CODE> and returns it.     *     * @param	indentation	the indentation of the new section     * @param	title		the title of the new section     * @return  a new Section object     */    public Section addSection(float indentation, String title) {        return addSection(indentation, new Paragraph(title));    }        /**     * Adds a <CODE>Section</CODE> to this <CODE>Section</CODE> and returns it.     *     * @param	title		the title of the new section     * @return  a new Section object     */    public Section addSection(String title) {        return addSection(new Paragraph(title));    }        // public methods        /**     * Sets the title of this section.     *     * @param	title	the new title     */    public void setTitle(Paragraph title) {        this.title = title;    }	/**     * Returns the title, preceded by a certain number of sectionnumbers.     *     * @return	a <CODE>Paragraph</CODE>     */    public Paragraph getTitle() {        return constructTitle(title, numbers, numberDepth, numberStyle);    }        /**     * Constructs a Paragraph that will be used as title for a Section or Chapter.     * @param	title	the title of the section     * @param	numbers	a list of sectionnumbers     * @param	numberDepth	how many numbers have to be shown     * @param	numberStyle	the numbering style     * @return	a Paragraph object	 * @since	iText 2.0.8     */    public static Paragraph constructTitle(Paragraph title, ArrayList numbers, int numberDepth, int numberStyle) {    	if (title == null) {    		return null;    	}        int depth = Math.min(numbers.size(), numberDepth);        if (depth < 1) {            return title;        }        StringBuffer buf = new StringBuffer(" ");        for (int i = 0; i < depth; i++) {            buf.insert(0, ".");            buf.insert(0, ((Integer) numbers.get(i)).intValue());        }        if (numberStyle == NUMBERSTYLE_DOTTED_WITHOUT_FINAL_DOT) {        	buf.deleteCharAt(buf.length() - 2);        }        Paragraph result = new Paragraph(title);        result.add(0, new Chunk(buf.toString(), title.getFont()));        return result;    }        /**     * Sets the depth of the sectionnumbers that will be shown preceding the title.     * <P>     * If the numberdepth is 0, the sections will not be numbered. If the numberdepth     * is 1, the section will be numbered with their own number. If the numberdepth is     * higher (for instance x > 1), the numbers of x - 1 parents will be shown.     *     * @param	numberDepth		the new numberDepth     */    public void setNumberDepth(int numberDepth) {        this.numberDepth = numberDepth;    }    	/**     * Returns the numberdepth of this <CODE>Section</CODE>.     *     * @return	the numberdepth     */    public int getNumberDepth() {        return numberDepth;    }    /**     * Sets the style for numbering sections.     * Possible values are NUMBERSTYLE_DOTTED: 1.2.3. (the default)     * or NUMBERSTYLE_DOTTED_WITHOUT_FINAL_DOT: 1.2.3	 * @since	iText 2.0.8     */	public void setNumberStyle(int numberStyle) {		this.numberStyle = numberStyle;	}		/**	 * Gets the style used for numbering sections.	 * @since	iText 2.0.8	 * @return	a value corresponding with a numbering style	 */	public int getNumberStyle() {		return numberStyle;	}        /**     * Sets the indentation of this <CODE>Section</CODE> on the left side.     *     * @param	indentation		the indentation     */    public void setIndentationLeft(float indentation) {        indentationLeft = indentation;    }	/**     * Returns the indentation of this <CODE>Section</CODE> on the left side.     *     * @return	the indentation     */    public float getIndentationLeft() {        return indentationLeft;    }        /**     * Sets the indentation of this <CODE>Section</CODE> on the right side.     *     * @param	indentation		the indentation     */    public void setIndentationRight(float indentation) {        indentationRight = indentation;    }	/**     * Returns the indentation of this <CODE>Section</CODE> on the right side.     *     * @return	the indentation     */    public float getIndentationRight() {        return indentationRight;    }        /**     * Sets the indentation of the content of this <CODE>Section</CODE>.     *     * @param	indentation		the indentation     */    public void setIndentation(float indentation) {        this.indentation = indentation;    }	/**     * Returns the indentation of the content of this <CODE>Section</CODE>.     *     * @return	the indentation     */    public float getIndentation() {        return indentation;    }        /** Setter for property bookmarkOpen.     * @param bookmarkOpen false if the bookmark children are not     * visible.     */    public void setBookmarkOpen(boolean bookmarkOpen) {        this.bookmarkOpen = bookmarkOpen;    }        /**     * Getter for property bookmarkOpen.     * @return Value of property bookmarkOpen.     */    public boolean isBookmarkOpen() {        return bookmarkOpen;    }        /**     * Setter for property triggerNewPage.     * @param triggerNewPage true if a new page has to be triggered.     */	public void setTriggerNewPage(boolean triggerNewPage) {		this.triggerNewPage = triggerNewPage;	}    /**     * Getter for property bookmarkOpen.     * @return Value of property triggerNewPage.     */    public boolean isTriggerNewPage() {		return triggerNewPage && notAddedYet;	}        /**     * Sets the bookmark title. The bookmark title is the same as the section title but     * can be changed with this method.     * @param bookmarkTitle the bookmark title     */        public void setBookmarkTitle(String bookmarkTitle) {        this.bookmarkTitle = bookmarkTitle;    }	/**     * Gets the bookmark title.     * @return the bookmark title     */        public Paragraph getBookmarkTitle() {        if (bookmarkTitle == null)            return getTitle();        else            return new Paragraph(bookmarkTitle);    }        /**     * Changes the Chapter number.     */    public void setChapterNumber(int number) {    	numbers.set(numbers.size() - 1, new Integer(number));    	Object s;    	for (Iterator i = iterator(); i.hasNext(); ) {    		s = i.next();    		if (s instanceof Section) {    			((Section)s).setChapterNumber(number);    		}    	}    }	/**     * Returns the depth of this section.     *     * @return	the depth     */    public int getDepth() {        return numbers.size();    }        // private methods        /**     * Sets the number of this section.     *     * @param	number		the number of this section     * @param	numbers		an <CODE>ArrayList</CODE>, containing the numbers of the Parent     */    private void setNumbers(int number, ArrayList numbers) {        this.numbers = new ArrayList();        this.numbers.add(new Integer(number));        this.numbers.addAll(numbers);    }	/**	 * Indicates if this is the first time the section is added.	 * @since	iText2.0.8	 * @return	true if the section wasn't added yet	 */	public boolean isNotAddedYet() {		return notAddedYet;	}	/**	 * Sets the indication if the section was already added to	 * the document.	 * @since	iText2.0.8	 * @param notAddedYet	 */	public void setNotAddedYet(boolean notAddedYet) {		this.notAddedYet = notAddedYet;	}        /**     * @since	iText 2.0.8     */    protected boolean isAddedCompletely() {		return addedCompletely;	}    	/**     * @since	iText 2.0.8	 */	protected void setAddedCompletely(boolean addedCompletely) {		this.addedCompletely = addedCompletely;	}		/**	 * @since	iText 2.0.8	 * @see com.lowagie.text.LargeElement#flushContent()	 */	public void flushContent() {		setNotAddedYet(false);		title = null;		Element element;		for (Iterator i = iterator(); i.hasNext(); ) {			element = (Element)i.next();			if (element instanceof Section) {				Section s = (Section)element;				if (!s.isComplete() && size() == 1) {					s.flushContent();					return;				}				else {					s.setAddedCompletely(true);				}			}			i.remove();		}	}	/**     * @since	iText 2.0.8	 * @see com.lowagie.text.LargeElement#isComplete()	 */	public boolean isComplete() {		return complete;	}	/**     * @since	iText 2.0.8	 * @see com.lowagie.text.LargeElement#setComplete(boolean)	 */	public void setComplete(boolean complete) {		this.complete = complete;	}	/**	 * Adds a new page to the section.	 * @since	2.1.1	 */	public void newPage() {		this.add(Chunk.NEXTPAGE);	}}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -