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

📄 section.java

📁 iText是一个能够快速产生PDF文件的java类库。iText的java类对于那些要产生包含文本
💻 JAVA
📖 第 1 页 / 共 2 页
字号:
        return addSection(0, title, numberDepth);
    }
    
    /**
     * 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, preceeded by a certain number of sectionnumbers.
     *
     * @return	a <CODE>Paragraph</CODE>
     */
    public Paragraph getTitle() {
        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());
        }
        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 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;
	}
    
    /**
     * 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);
    }
    
    // deprecated stuff
    
    /**
	 * Returns the title, preceeded by a certain number of sectionnumbers.
	 *
	 * @return	a <CODE>Paragraph</CODE>
	 * @deprecated Use {@link #getTitle()} instead
	 */
	public Paragraph title() {
		return getTitle();
	}
    
    /**
	 * Returns the numberdepth of this <CODE>Section</CODE>.
	 *
	 * @return	the numberdepth
	 * @deprecated Use {@link #getNumberDepth()} instead
	 */
	public int numberDepth() {
		return getNumberDepth();
	}
    
    /**
	 * Returns the indentation of this <CODE>Section</CODE> on the left side.
	 *
	 * @return	the indentation
	 * @deprecated Use {@link #getIndentationLeft()} instead
	 */
	public float indentationLeft() {
		return getIndentationLeft();
	}
    
    /**
	 * Returns the indentation of this <CODE>Section</CODE> on the right side.
	 *
	 * @return	the indentation
	 * @deprecated Use {@link #getIndentationRight()} instead
	 */
	public float indentationRight() {
		return getIndentationRight();
	}
    
    /**
	 * Returns the indentation of the content of this <CODE>Section</CODE>.
	 *
	 * @return	the indentation
	 * @deprecated Use {@link #getIndentation()} instead
	 */
	public float indentation() {
		return getIndentation();
	}
    
    /**
	 * Returns the depth of this section.
	 *
	 * @return	the depth
	 * @deprecated Use {@link #getDepth()} instead
	 */
	public int depth() {
		return getDepth();
	}
    
    /**
     * Creates a given <CODE>Section</CODE> following a set of attributes and adds it to this one.
     *
     * @param	attributes	the attributes
     * @return      a Section
     * @deprecated Use ElementFactory.getSection(this, attributes)
     */
    public Section addSection(java.util.Properties attributes) {
    	return com.lowagie.text.factories.ElementFactory.getSection(this, attributes);
    }
}

⌨️ 快捷键说明

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