Java Code Examples for com.lowagie.text.Rectangle#setBottom()

The following examples show how to use com.lowagie.text.Rectangle#setBottom() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: PdfCell.java    From gcs with Mozilla Public License 2.0 6 votes vote down vote up
/**
 * Gets a Rectangle that is altered to fit on the page.
 *
 * @param top the top position
 * @param bottom the bottom position
 * @return a <CODE>Rectangle</CODE>
 */

@Override
public Rectangle rectangle(float top, float bottom) {
	Rectangle tmp = new Rectangle(getLeft(), getBottom(), getRight(), getTop());
	tmp.cloneNonPositionParameters(this);
	if (getTop() > top) {
		tmp.setTop(top);
		tmp.setBorder(border - (border & TOP));
	}
	if (getBottom() < bottom) {
		tmp.setBottom(bottom);
		tmp.setBorder(border - (border & BOTTOM));
	}
	return tmp;
}
 
Example 2
Source File: FieldPositioningEvents.java    From gcs with Mozilla Public License 2.0 6 votes vote down vote up
/**
 * @see com.lowagie.text.pdf.PdfPageEvent#onGenericTag(com.lowagie.text.pdf.PdfWriter,
 *      com.lowagie.text.Document, com.lowagie.text.Rectangle, java.lang.String)
 */
@Override
public void onGenericTag(PdfWriter writer, Document document, Rectangle rect, String text) {
	rect.setBottom(rect.getBottom() - 3);
	PdfFormField field = (PdfFormField) genericChunkFields.get(text);
	if (field == null) {
		TextField tf = new TextField(writer, new Rectangle(rect.getLeft(padding), rect.getBottom(padding), rect.getRight(padding), rect.getTop(padding)), text);
		tf.setFontSize(14);
		try {
			field = tf.getTextField();
		} catch (Exception e) {
			throw new ExceptionConverter(e);
		}
	} else {
		field.put(PdfName.RECT, new PdfRectangle(rect.getLeft(padding), rect.getBottom(padding), rect.getRight(padding), rect.getTop(padding)));
	}
	if (parent == null) {
		writer.addAnnotation(field);
	} else {
		parent.addKid(field);
	}
}
 
Example 3
Source File: FieldPositioningEvents.java    From itext2 with GNU Lesser General Public License v3.0 6 votes vote down vote up
/**
 * @see com.lowagie.text.pdf.PdfPageEvent#onGenericTag(com.lowagie.text.pdf.PdfWriter, com.lowagie.text.Document, com.lowagie.text.Rectangle, java.lang.String)
 */
public void onGenericTag(PdfWriter writer, Document document,
		Rectangle rect, String text) {
	rect.setBottom(rect.getBottom() - 3);
	PdfFormField field = (PdfFormField) genericChunkFields.get(text);
	if (field == null) {
		TextField tf = new TextField(writer, new Rectangle(rect.getLeft(padding), rect.getBottom(padding), rect.getRight(padding), rect.getTop(padding)), text);
		tf.setFontSize(14);
		try {
			field = tf.getTextField();
		} catch (Exception e) {
			throw new ExceptionConverter(e);
		}
	}
	else {
		field.put(PdfName.RECT,  new PdfRectangle(rect.getLeft(padding), rect.getBottom(padding), rect.getRight(padding), rect.getTop(padding)));
	}
	if (parent == null)
		writer.addAnnotation(field);
	else
		parent.addKid(field);
}
 
Example 4
Source File: PdfCell.java    From itext2 with GNU Lesser General Public License v3.0 5 votes vote down vote up
/**
 * Gets a Rectangle that is altered to fit on the page.
 *
 * @param	top		the top position
 * @param	bottom	the bottom position
 * @return	a <CODE>Rectangle</CODE>
 */

public Rectangle rectangle(float top, float bottom) {
    Rectangle tmp = new Rectangle(getLeft(), getBottom(), getRight(), getTop());
    tmp.cloneNonPositionParameters(this);
    if (getTop() > top) {
        tmp.setTop(top);
        tmp.setBorder(border - (border & TOP));
    }
    if (getBottom() < bottom) {
        tmp.setBottom(bottom);
        tmp.setBorder(border - (border & BOTTOM));
    }
    return tmp;
}
 
Example 5
Source File: PdfContext.java    From geomajas-project-server with GNU Affero General Public License v3.0 5 votes vote down vote up
/**
 * Move this rectangle to the specified bottom-left point.
 *
 * @param rect rectangle to move
 * @param x new x origin
 * @param y new y origin
 */
public void moveRectangleTo(Rectangle rect, float x, float y) {
	float width = rect.getWidth();
	float height = rect.getHeight();
	rect.setLeft(x);
	rect.setBottom(y);
	rect.setRight(rect.getLeft() + width);
	rect.setTop(rect.getBottom() + height);
}
 
Example 6
Source File: PdfContext.java    From geomajas-project-server with GNU Affero General Public License v3.0 5 votes vote down vote up
/**
 * Translate this rectangle over the specified following distances.
 *
 * @param rect rectangle to move
 * @param dx delta x
 * @param dy delta y
 */
public void translateRectangle(Rectangle rect, float dx, float dy) {
	float width = rect.getWidth();
	float height = rect.getHeight();
	rect.setLeft(rect.getLeft() + dx);
	rect.setBottom(rect.getBottom() + dy);
	rect.setRight(rect.getLeft() + dx + width);
	rect.setTop(rect.getBottom() + dy + height);
}