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

📄 cell.java

📁 有关对pdf操作的代码
💻 JAVA
📖 第 1 页 / 共 2 页
字号:
	 * Setter for maxLines	 * @param value the maximum number of lines	 */	public void setMaxLines(int value) {		maxLines = value;	}		/**	 * Getter for maxLines	 * @return the maxLines value	 */	public int getMaxLines() {		return maxLines;	}			/**	 * Setter for showTruncation	 * @param value	Can be null for avoiding marking the truncation.	 */	public void setShowTruncation(String value) {		showTruncation = value;	}		/**	 * Getter for showTruncation	 * @return the showTruncation value	 */	public String getShowTruncation() {		return showTruncation;	}	/**	 * Sets the value of useAscender.	 * @param use use ascender height if true	 */	public void setUseAscender(boolean use) {	    useAscender = use;	}	/**	 * Gets the value of useAscender	 * @return useAscender	 */	public boolean isUseAscender() {	    return useAscender;	}	/**	 * Sets the value of useDescender.	 * @param use use descender height if true	 */	public void setUseDescender(boolean use) {	    useDescender = use;	}	/**	 * gets the value of useDescender	 * @return useDescender	 */	public boolean isUseDescender() {	    return useDescender;	}	/**	 * Sets the value of useBorderPadding.	 * @param use adjust layout for borders if true	 */	public void setUseBorderPadding(boolean use) {	    useBorderPadding = use;	}	/**	 * Gets the value of useBorderPadding.	 * @return useBorderPadding	 */	public boolean isUseBorderPadding() {	    return useBorderPadding;	}	/**	 * Does this <CODE>Cell</CODE> force a group change?	 *	 * @return	a value	 */	public boolean getGroupChange() {		return groupChange;	}	/**	 * Sets group change.	 *	 * @param	value	the new value	 */	public void setGroupChange(boolean value) {		groupChange = value;	}	// arraylist stuff	/**	 * Gets the number of <CODE>Element</CODE>s in the Cell.	 *	 * @return	a <CODE>size</CODE>.	 */	public int size() {		return arrayList.size();	}	/**	 * Gets an iterator of <CODE>Element</CODE>s.	 *	 * @return	an <CODE>Iterator</CODE>.	 */	public Iterator getElements() {		return arrayList.iterator();	}		/**	 * Clears all the <CODE>Element</CODE>s of this <CODE>Cell</CODE>.	 */	public void clear() {		arrayList.clear();	}	/**	 * Checks if the <CODE>Cell</CODE> is empty.	 *	 * @return	<CODE>false</CODE> if there are non-empty <CODE>Element</CODE>s in the <CODE>Cell</CODE>.	 */	public boolean isEmpty() {		switch(size()) {			case 0:				return true;			case 1:				Element element = (Element) arrayList.get(0);				switch (element.type()) {					case Element.CHUNK:						return ((Chunk) element).isEmpty();					case Element.ANCHOR:					case Element.PHRASE:					case Element.PARAGRAPH:						return ((Phrase) element).isEmpty();					case Element.LIST:						return ((List) element).isEmpty();				}			return false;			default:				return false;		}	}		/**	 * Makes sure there is at least 1 object in the Cell.	 *	 * Otherwise it might not be shown in the table.	 */	void fill() {		if (size() == 0) arrayList.add(new Paragraph(0));	}	/**	 * Checks if this <CODE>Cell</CODE> is a placeholder for a (nested) table.	 *	 * @return	true if the only element in this cell is a table	 */	public boolean isTable() {		return (size() == 1)			&& (((Element)arrayList.get(0)).type() == Element.TABLE);	}		/**	 * Adds an element to this <CODE>Cell</CODE>.	 * <P>	 * Remark: you can't add <CODE>ListItem</CODE>s, <CODE>Row</CODE>s, <CODE>Cell</CODE>s,	 * <CODE>JPEG</CODE>s, <CODE>GIF</CODE>s or <CODE>PNG</CODE>s to a <CODE>Cell</CODE>.	 *	 * @param element The <CODE>Element</CODE> to add	 * @throws BadElementException if the method was called with a <CODE>ListItem</CODE>, <CODE>Row</CODE> or <CODE>Cell</CODE>	 */	public void addElement(Element element) throws BadElementException {		if (isTable()) {			Table table = (Table) arrayList.get(0);			Cell tmp = new Cell(element);			tmp.setBorder(NO_BORDER);			tmp.setColspan(table.getColumns());			table.addCell(tmp);			return;		}		switch(element.type()) {			case Element.LISTITEM:			case Element.ROW:			case Element.CELL:				throw new BadElementException("You can't add listitems, rows or cells to a cell.");			case Element.LIST:				List list = (List)element;				if (Float.isNaN(leading)) {					setLeading(list.getTotalLeading());				}				if (list.isEmpty()) return;				arrayList.add(element);				return;			case Element.ANCHOR:			case Element.PARAGRAPH:			case Element.PHRASE:				Phrase p = (Phrase)element;				if (Float.isNaN(leading)) {					setLeading(p.getLeading());				}				if (p.isEmpty()) return;				arrayList.add(element);				return;			case Element.CHUNK:				if (((Chunk) element).isEmpty()) return;				arrayList.add(element);				return;			case Element.TABLE:				Table table = new Table(3);				float[] widths = new float[3];				widths[1] = ((Table)element).getWidth();				switch(((Table)element).getAlignment()) {					case Element.ALIGN_LEFT:						widths[0] = 0f;						widths[2] = 100f - widths[1];						break;					case Element.ALIGN_CENTER:						widths[0] = (100f - widths[1]) / 2f;						widths[2] = widths[0];						break;					case Element.ALIGN_RIGHT:						widths[0] = 100f - widths[1];						widths[2] = 0f;				}				table.setWidths(widths);				Cell tmp;				if (arrayList.isEmpty()) {					table.addCell(getDummyCell());				}				else {					tmp = new Cell();					tmp.setBorder(NO_BORDER);					tmp.setColspan(3);					for (Iterator i = arrayList.iterator(); i.hasNext(); ) {						tmp.add(i.next());					}					table.addCell(tmp);				}				tmp = new Cell();				tmp.setBorder(NO_BORDER);				table.addCell(tmp);				table.insertTable((Table)element);				tmp = new Cell();				tmp.setBorder(NO_BORDER);				table.addCell(tmp);				table.addCell(getDummyCell());				clear();				arrayList.add(table);				return;			default:				arrayList.add(element);		}	}	/**	 * Add an <CODE>Object</CODE> to this cell.	 *	 * @param o the object to add	 * @return always <CODE>true</CODE>	 */	public boolean add(Object o) {		try {			this.addElement((Element) o);			return true;		}		catch(ClassCastException cce) {			throw new ClassCastException("You can only add objects that implement the Element interface.");		}		catch(BadElementException bee) {			throw new ClassCastException(bee.getMessage());		}	}	// helper methods		/**     * Get dummy cell used when merging inner tables.      * @return a cell with colspan 3 and no border     */    private static Cell getDummyCell() {        Cell cell = new Cell(true);        cell.setColspan(3);        cell.setBorder(NO_BORDER);        return cell;	}	/**	 * Creates a PdfPCell based on this Cell object.	 * @return a PdfPCell	 * @throws BadElementException	 */	public PdfPCell createPdfPCell() throws BadElementException {		if (rowspan > 1) throw new BadElementException("PdfPCells can't have a rowspan > 1");		if (isTable()) return new PdfPCell(((Table)arrayList.get(0)).createPdfPTable());		PdfPCell cell = new PdfPCell();		cell.setVerticalAlignment(verticalAlignment);		cell.setHorizontalAlignment(horizontalAlignment);		cell.setColspan(colspan);		cell.setUseBorderPadding(useBorderPadding);		cell.setUseDescender(useDescender);		cell.setLeading(getLeading(), 0);		cell.cloneNonPositionParameters(this);		cell.setNoWrap(getMaxLines() == 1);		for (Iterator i = getElements(); i.hasNext(); ) {            Element e = (Element)i.next();            if (e.type() == Element.PHRASE || e.type() == Element.PARAGRAPH) {                Paragraph p = new Paragraph((Phrase)e);                p.setAlignment(horizontalAlignment);                e = p;            }			cell.addElement(e);		}		return cell;	}	// unsupported Rectangle methods	/**	 * This method throws an <CODE>UnsupportedOperationException</CODE>.	 * @return NA	 */	public float getTop() {		throw new UnsupportedOperationException("Dimensions of a Cell can't be calculated. See the FAQ.");	}	/**	 * This method throws an <CODE>UnsupportedOperationException</CODE>.	 * @return NA	 */	public float getBottom() {		throw new UnsupportedOperationException("Dimensions of a Cell can't be calculated. See the FAQ.");	}	/**	 * This method throws an <CODE>UnsupportedOperationException</CODE>.	 * @return NA	 */	public float getLeft() {		throw new UnsupportedOperationException("Dimensions of a Cell can't be calculated. See the FAQ.");	}	/**	 * This method throws an <CODE>UnsupportedOperationException</CODE>.	 * @return NA	 */	public float getRight() {		throw new UnsupportedOperationException("Dimensions of a Cell can't be calculated. See the FAQ.");	}	/**	 * This method throws an <CODE>UnsupportedOperationException</CODE>.	 * @param margin	 * @return NA	 */	public float top(int margin) {		throw new UnsupportedOperationException("Dimensions of a Cell can't be calculated. See the FAQ.");	}	/**	 * This method throws an <CODE>UnsupportedOperationException</CODE>.	 * @param margin	 * @return NA	 */	public float bottom(int margin) {		throw new UnsupportedOperationException("Dimensions of a Cell can't be calculated. See the FAQ.");	}	/**	 * This method throws an <CODE>UnsupportedOperationException</CODE>.	 * @param margin	 * @return NA	 */	public float left(int margin) {		throw new UnsupportedOperationException("Dimensions of a Cell can't be calculated. See the FAQ.");	}	/**	 * This method throws an <CODE>UnsupportedOperationException</CODE>.	 * @param margin NA	 * @return NA	 */	public float right(int margin) {		throw new UnsupportedOperationException("Dimensions of a Cell can't be calculated. See the FAQ.");	}	/**	 * This method throws an <CODE>UnsupportedOperationException</CODE>.	 * @param value NA	 */	public void setTop(int value) {		throw new UnsupportedOperationException("Dimensions of a Cell are attributed automagically. See the FAQ.");	}	/**	 * This method throws an <CODE>UnsupportedOperationException</CODE>.	 * @param value NA	 */	public void setBottom(int value) {		throw new UnsupportedOperationException("Dimensions of a Cell are attributed automagically. See the FAQ.");	}	/**	 * This method throws an <CODE>UnsupportedOperationException</CODE>.	 * @param value NA	 */	public void setLeft(int value) {		throw new UnsupportedOperationException("Dimensions of a Cell are attributed automagically. See the FAQ.");	}	/**	 * This method throws an <CODE>UnsupportedOperationException</CODE>.	 * @param value NA	 */	public void setRight(int value) {		throw new UnsupportedOperationException("Dimensions of a Cell are attributed automagically. See the FAQ.");	}}

⌨️ 快捷键说明

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