Java Code Examples for com.lowagie.text.Rectangle#getRight()
The following examples show how to use
com.lowagie.text.Rectangle#getRight() .
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: FieldPositioningEvents.java From gcs with Mozilla Public License 2.0 | 6 votes |
/** * @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 2
Source File: FieldPositioningEvents.java From itext2 with GNU Lesser General Public License v3.0 | 6 votes |
/** * @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 3
Source File: PdfPTable.java From Knowage-Server with GNU Affero General Public License v3.0 | 5 votes |
/** * Sets the percentage width of the table from the absolute column width. * * @param columnWidth the absolute width of each column * @param pageSize the page size * @throws DocumentException */ public void setWidthPercentage(float columnWidth[], Rectangle pageSize) throws DocumentException { if (columnWidth.length != getNumberOfColumns()) throw new IllegalArgumentException("Wrong number of columns."); float totalWidth = 0; for (int k = 0; k < columnWidth.length; ++k) totalWidth += columnWidth[k]; widthPercentage = totalWidth / (pageSize.getRight() - pageSize.getLeft()) * 100f; setWidths(columnWidth); }
Example 4
Source File: PdfPTable.java From gcs with Mozilla Public License 2.0 | 5 votes |
/** * Sets the percentage width of the table from the absolute column width. * * @param columnWidth the absolute width of each column * @param pageSize the page size * @throws DocumentException */ public void setWidthPercentage(float columnWidth[], Rectangle pageSize) throws DocumentException { if (columnWidth.length != getNumberOfColumns()) { throw new IllegalArgumentException("Wrong number of columns."); } float totalWidth = 0; for (float element : columnWidth) { totalWidth += element; } widthPercentage = totalWidth / (pageSize.getRight() - pageSize.getLeft()) * 100f; setWidths(columnWidth); }
Example 5
Source File: PdfAnnotationsImp.java From gcs with Mozilla Public License 2.0 | 5 votes |
public static PdfAnnotation convertAnnotation(PdfWriter writer, Annotation annot, Rectangle defaultRect) throws IOException { switch (annot.annotationType()) { case Annotation.URL_NET: return new PdfAnnotation(writer, annot.llx(), annot.lly(), annot.urx(), annot.ury(), new PdfAction((URL) annot.attributes().get(Annotation.URL))); case Annotation.URL_AS_STRING: return new PdfAnnotation(writer, annot.llx(), annot.lly(), annot.urx(), annot.ury(), new PdfAction((String) annot.attributes().get(Annotation.FILE))); case Annotation.FILE_DEST: return new PdfAnnotation(writer, annot.llx(), annot.lly(), annot.urx(), annot.ury(), new PdfAction((String) annot.attributes().get(Annotation.FILE), (String) annot.attributes().get(Annotation.DESTINATION))); case Annotation.SCREEN: boolean sparams[] = (boolean[]) annot.attributes().get(Annotation.PARAMETERS); String fname = (String) annot.attributes().get(Annotation.FILE); String mimetype = (String) annot.attributes().get(Annotation.MIMETYPE); PdfFileSpecification fs; if (sparams[0]) { fs = PdfFileSpecification.fileEmbedded(writer, fname, fname, null); } else { fs = PdfFileSpecification.fileExtern(writer, fname); } PdfAnnotation ann = PdfAnnotation.createScreen(writer, new Rectangle(annot.llx(), annot.lly(), annot.urx(), annot.ury()), fname, fs, mimetype, sparams[1]); return ann; case Annotation.FILE_PAGE: return new PdfAnnotation(writer, annot.llx(), annot.lly(), annot.urx(), annot.ury(), new PdfAction((String) annot.attributes().get(Annotation.FILE), ((Integer) annot.attributes().get(Annotation.PAGE)).intValue())); case Annotation.NAMED_DEST: return new PdfAnnotation(writer, annot.llx(), annot.lly(), annot.urx(), annot.ury(), new PdfAction(((Integer) annot.attributes().get(Annotation.NAMED)).intValue())); case Annotation.LAUNCH: return new PdfAnnotation(writer, annot.llx(), annot.lly(), annot.urx(), annot.ury(), new PdfAction((String) annot.attributes().get(Annotation.APPLICATION), (String) annot.attributes().get(Annotation.PARAMETERS), (String) annot.attributes().get(Annotation.OPERATION), (String) annot.attributes().get(Annotation.DEFAULTDIR))); default: return new PdfAnnotation(writer, defaultRect.getLeft(), defaultRect.getBottom(), defaultRect.getRight(), defaultRect.getTop(), new PdfString(annot.title(), PdfObject.TEXT_UNICODE), new PdfString(annot.content(), PdfObject.TEXT_UNICODE)); } }
Example 6
Source File: PdfPTable.java From itext2 with GNU Lesser General Public License v3.0 | 5 votes |
/** * Sets the percentage width of the table from the absolute column width. * * @param columnWidth the absolute width of each column * @param pageSize the page size * @throws DocumentException */ public void setWidthPercentage(float columnWidth[], Rectangle pageSize) throws DocumentException { if (columnWidth.length != getNumberOfColumns()) throw new IllegalArgumentException("Wrong number of columns."); float totalWidth = 0; for (int k = 0; k < columnWidth.length; ++k) totalWidth += columnWidth[k]; widthPercentage = totalWidth / (pageSize.getRight() - pageSize.getLeft()) * 100f; setWidths(columnWidth); }
Example 7
Source File: PdfAnnotationsImp.java From itext2 with GNU Lesser General Public License v3.0 | 5 votes |
public static PdfAnnotation convertAnnotation(PdfWriter writer, Annotation annot, Rectangle defaultRect) throws IOException { switch(annot.annotationType()) { case Annotation.URL_NET: return new PdfAnnotation(writer, annot.llx(), annot.lly(), annot.urx(), annot.ury(), new PdfAction((URL) annot.attributes().get(Annotation.URL))); case Annotation.URL_AS_STRING: return new PdfAnnotation(writer, annot.llx(), annot.lly(), annot.urx(), annot.ury(), new PdfAction((String) annot.attributes().get(Annotation.FILE))); case Annotation.FILE_DEST: return new PdfAnnotation(writer, annot.llx(), annot.lly(), annot.urx(), annot.ury(), new PdfAction((String) annot.attributes().get(Annotation.FILE), (String) annot.attributes().get(Annotation.DESTINATION))); case Annotation.SCREEN: boolean sparams[] = (boolean[])annot.attributes().get(Annotation.PARAMETERS); String fname = (String) annot.attributes().get(Annotation.FILE); String mimetype = (String) annot.attributes().get(Annotation.MIMETYPE); PdfFileSpecification fs; if (sparams[0]) fs = PdfFileSpecification.fileEmbedded(writer, fname, fname, null); else fs = PdfFileSpecification.fileExtern(writer, fname); PdfAnnotation ann = PdfAnnotation.createScreen(writer, new Rectangle(annot.llx(), annot.lly(), annot.urx(), annot.ury()), fname, fs, mimetype, sparams[1]); return ann; case Annotation.FILE_PAGE: return new PdfAnnotation(writer, annot.llx(), annot.lly(), annot.urx(), annot.ury(), new PdfAction((String) annot.attributes().get(Annotation.FILE), ((Integer) annot.attributes().get(Annotation.PAGE)).intValue())); case Annotation.NAMED_DEST: return new PdfAnnotation(writer, annot.llx(), annot.lly(), annot.urx(), annot.ury(), new PdfAction(((Integer) annot.attributes().get(Annotation.NAMED)).intValue())); case Annotation.LAUNCH: return new PdfAnnotation(writer, annot.llx(), annot.lly(), annot.urx(), annot.ury(), new PdfAction((String) annot.attributes().get(Annotation.APPLICATION),(String) annot.attributes().get(Annotation.PARAMETERS),(String) annot.attributes().get(Annotation.OPERATION),(String) annot.attributes().get(Annotation.DEFAULTDIR))); default: return new PdfAnnotation(writer, defaultRect.getLeft(), defaultRect.getBottom(), defaultRect.getRight(), defaultRect.getTop(), new PdfString(annot.title(), PdfObject.TEXT_UNICODE), new PdfString(annot.content(), PdfObject.TEXT_UNICODE)); } }
Example 8
Source File: FloatingBoxesTest.java From itext2 with GNU Lesser General Public License v3.0 | 5 votes |
/** * @see com.lowagie.text.pdf.PdfPCellEvent#cellLayout(com.lowagie.text.pdf.PdfPCell, * com.lowagie.text.Rectangle, com.lowagie.text.pdf.PdfContentByte[]) */ public void cellLayout(PdfPCell cell, Rectangle position, PdfContentByte[] canvases) { float x1 = position.getLeft() + 2; float x2 = position.getRight() - 2; float y1 = position.getTop() - 2; float y2 = position.getBottom() + 2; PdfContentByte canvas = canvases[PdfPTable.LINECANVAS]; canvas.setRGBColorStroke(0xFF, 0x00, 0x00); canvas.rectangle(x1, y1, x2 - x1, y2 - y1); canvas.stroke(); canvas.resetRGBColorStroke(); }
Example 9
Source File: RectangleConverter.java From geomajas-project-server with GNU Affero General Public License v3.0 | 5 votes |
@Override public String toString(Object obj) { Rectangle rectangle = (Rectangle) obj; if (obj == null) { return null; } return rectangle.getLeft() + "," + rectangle.getBottom() + "," + rectangle.getRight() + "," + rectangle.getTop(); }
Example 10
Source File: VectorLayerComponentImpl.java From geomajas-project-server with GNU Affero General Public License v3.0 | 5 votes |
private Rectangle calculateLabelRect(PdfContext context, InternalFeature f, String label, Font font) { Rectangle textSize = context.getTextSize(label, font); float margin = 0.25f * font.getSize(); Rectangle rect = new Rectangle(textSize.getWidth() + 2 * margin, textSize.getHeight() + 2 * margin); Coordinate labelPosition = geoService.calcDefaultLabelPosition(f); // SPRINT-53 Labels should be rendered in Screen Space new MapToUserFilter().filter(labelPosition); context.moveRectangleTo(rect, (float) labelPosition.x - rect.getWidth() / 2f, (float) labelPosition.y - rect.getHeight() / 2f); if (f.getGeometry() instanceof Point) { float shiftHeight = 0.5f * (rect.getHeight() + getSymbolHeight(f)); // move up 15 pixels to make the symbol visible context.moveRectangleTo(rect, rect.getLeft(), rect.getBottom() + shiftHeight + SYMBOL_CONNECT_LENGTH); } if (rect.getLeft() < 0) { context.moveRectangleTo(rect, 10, rect.getBottom()); } if (rect.getBottom() < 0) { context.moveRectangleTo(rect, rect.getLeft(), 10); } if (rect.getTop() > getBounds().getHeight()) { context.moveRectangleTo(rect, rect.getLeft(), getBounds().getHeight() - rect.getHeight() - 10); } if (rect.getRight() > getBounds().getWidth()) { context.moveRectangleTo(rect, getBounds().getWidth() - rect.getWidth() - 10, rect.getBottom()); } return rect; }
Example 11
Source File: MapComponentImpl.java From geomajas-project-server with GNU Affero General Public License v3.0 | 5 votes |
private void renderViewPort(ViewPortComponentImpl viewPort, PdfContext context) { Coordinate portOrigin = viewPort.getLocation(); float x = (float) (portOrigin.x - location.x) * getPpUnit(); float y = (float) (portOrigin.y - location.y) * getPpUnit(); Rectangle shadowRect = new Rectangle(x, y, x + viewPort.getBounds().getWidth() / viewPort.getZoomScale(), y + viewPort.getBounds().getHeight() / viewPort.getZoomScale()); context.fillRectangle(shadowRect, context.makeTransparent(Color.lightGray, 0.5f)); context.strokeRectangle(shadowRect, Color.white, 1); Rectangle rect = context.toRelative(viewPort.getBounds()); // connection lines float deltaLeft = shadowRect.getLeft() - rect.getLeft(); float deltaRight = shadowRect.getRight() - rect.getRight(); float deltaBottom = shadowRect.getBottom() - rect.getBottom(); float deltaTop = shadowRect.getTop() - rect.getTop(); if ((deltaLeft <= 0 && deltaBottom >= 0) || (deltaLeft >= 0 && deltaBottom <= 0)) { context.drawLine(rect.getLeft(), rect.getBottom(), shadowRect.getLeft(), shadowRect.getBottom(), Color.white, 1); } if ((deltaLeft >= 0 && deltaTop >= 0) || (deltaLeft <= 0 && deltaTop <= 0)) { context.drawLine(rect.getLeft(), rect.getTop(), shadowRect.getLeft(), shadowRect.getTop(), Color.white, 1); } if ((deltaRight <= 0 && deltaBottom <= 0) || (deltaRight >= 0 && deltaBottom >= 0)) { context.drawLine(rect.getRight(), rect.getBottom(), shadowRect.getRight(), shadowRect.getBottom(), Color.white, 1); } if ((deltaRight >= 0 && deltaTop <= 0) || (deltaRight <= 0 && deltaTop >= 0)) { context.drawLine(rect.getRight(), rect.getTop(), shadowRect.getRight(), shadowRect.getTop(), Color.white, 1); } }
Example 12
Source File: PdfRectangle.java From gcs with Mozilla Public License 2.0 | 4 votes |
public PdfRectangle(Rectangle rectangle) { this(rectangle.getLeft(), rectangle.getBottom(), rectangle.getRight(), rectangle.getTop(), 0); }
Example 13
Source File: PdfRectangle.java From itext2 with GNU Lesser General Public License v3.0 | 4 votes |
public PdfRectangle(Rectangle rectangle) { this(rectangle.getLeft(), rectangle.getBottom(), rectangle.getRight(), rectangle.getTop(), 0); }
Example 14
Source File: PdfRectangle.java From gcs with Mozilla Public License 2.0 | 2 votes |
/** * Constructs a <CODE>PdfRectangle</CODE>-object with a <CODE>Rectangle</CODE>-object. * * @param rectangle a <CODE>Rectangle</CODE> */ public PdfRectangle(Rectangle rectangle, int rotation) { this(rectangle.getLeft(), rectangle.getBottom(), rectangle.getRight(), rectangle.getTop(), rotation); }
Example 15
Source File: PdfRectangle.java From itext2 with GNU Lesser General Public License v3.0 | 2 votes |
/** * Constructs a <CODE>PdfRectangle</CODE>-object with a <CODE>Rectangle</CODE>-object. * * @param rectangle a <CODE>Rectangle</CODE> */ public PdfRectangle(Rectangle rectangle, int rotation) { this(rectangle.getLeft(), rectangle.getBottom(), rectangle.getRight(), rectangle.getTop(), rotation); }
Example 16
Source File: PdfContext.java From geomajas-project-server with GNU Affero General Public License v3.0 | 2 votes |
/** * Converts an absolute rectangle to a relative one wrt to the current coordinate system. * * @param rect absolute rectangle * @return relative rectangle */ public Rectangle toRelative(Rectangle rect) { return new Rectangle(rect.getLeft() - origX, rect.getBottom() - origY, rect.getRight() - origX, rect.getTop() - origY); }