List of usage examples for com.lowagie.text Rectangle getBottom
public float getBottom()
From source file:com.teag.reports.CashFlows.java
private Rectangle placeHeading() { String header = "Estimate Of Net Worth & Estate Distribution - Scenario #1 As Is (in 000's)"; BaseFont font = PageUtils.LoadFont("GARA.TTF"); Rectangle rect = new Rectangle(document.getPageSize()); rect.setBottom(rect.getTop() - (72 * .6f)); HeadingText ht = new HeadingText(this.writer); rect.setBottom(rect.getBottom() - (72 * .33f)); ht.setColor(57, 57, 57);/*from w w w.j av a 2s.c om*/ ht.setCapsColor(98, 98, 98); ht.display(rect, 12f, font, 3f, header, HeadingText.DHT_CENTER); rect.setTop(rect.getBottom() - _1_8TH); rect.setBottom(prctFull.getBottom()); rect.setLeft(_1_2TH); rect.setRight(rect.getLeft() + 11.f * 72); PageBorder pb = new PageBorder(writer); pb.setLicense(userInfo.getPlannerFirstName() + " " + userInfo.getPlannerLastName()); pb.drawNoBorder(document, Integer.toString(pageNum)); drawLifeExp(); return (rect); }
From source file:com.teag.reports.EstatePlan.java
private void page1() { EstatePlanTable ept = new EstatePlanTable(); ClientBean cb = new ClientBean(); CFRow row;//from w ww . java 2s . co m float tallest = 0; drawHeader(client, ""); String header = "Estimate Of Cash Flows - Scenario #2 After (in 000's)"; Rectangle agt = placeHeading(header); cb.setPrimaryId(clientID); cb.initialize(); ept.setClient(cb); ept.setScenarioId(epg.getScenarioId()); ept.setEstate(epg); ept.initialize(); ept.resetRows(); int colCount = MAX_COLS; float baseWidths[] = this.initWidths(colCount - 1); float widths[] = this.calcWidths(baseWidths, 11.0f * 72); Rectangle rct = new Rectangle(prctFull); rct.setLeft(_1_4TH); rct.setRight(rct.getLeft() + 756); Rectangle r = doRow(leList(), widths, agt, colCount - 1); rct.setTop(r.getBottom()); r = doRow(agesList(), widths, rct, colCount - 1); rct.setTop(r.getBottom()); r = doRow(fiscalYearList(), widths, rct, colCount - 1); rct.setTop(r.getBottom()); tallest = tallest < r.getHeight() ? r.getHeight() : tallest; boolean nPage = false; while ((row = ept.getRow()) != null) { if (rct.getTop() < (.5f * 72) + tallest) { // need to span to a new page newPage(); drawHeader(client, ""); header = "Estimate Of Net Worth - Scenario #2 After (in 000's)"; agt = placeHeading(header); rct = new Rectangle(prctFull); rct.setLeft(_1_4TH); rct.setRight(rct.getLeft() + 756); r = doRow(leList(), widths, agt, colCount - 1); rct.setTop(r.getBottom()); r = doRow(agesList(), widths, rct, colCount - 1); rct.setTop(r.getBottom()); r = doRow(fiscalYearList(), widths, rct, colCount - 1); rct.setTop(r.getBottom()); tallest = tallest < r.getHeight() ? r.getHeight() : tallest; nPage = true; } String pdfRow[] = buildRow(row, colCount); //Rectangle r = doSimpleRow(pdfRow, rct); if ((row.getHeader().startsWith("III.") || row.getHeader().startsWith("IV.")) || row.getHeader().startsWith("II") && !nPage) { // need to span to a new page newPage(); drawHeader(client, ""); header = "Estimate Of Net Worth - Scenario #2 After (in 000's)"; agt = placeHeading(header); rct = new Rectangle(prctFull); rct.setLeft(_1_4TH); rct.setRight(rct.getLeft() + 756); r = doRow(leList(), widths, agt, colCount - 1); rct.setTop(r.getBottom()); r = doRow(agesList(), widths, rct, colCount - 1); rct.setTop(r.getBottom()); r = doRow(fiscalYearList(), widths, rct, colCount - 1); rct.setTop(r.getBottom()); tallest = tallest < r.getHeight() ? r.getHeight() : tallest; } nPage = false; r = this.doRow(pdfRow, widths, rct, colCount - 1); tallest = tallest < r.getHeight() ? r.getHeight() : tallest; rct.setTop(r.getBottom()); /* if(rct.getTop() < (.5f * 72) + tallest) { // need to span to a new page newPage(); drawHeader(client, ""); header = "Estimate Of Net Worth - Scenario #2 After (in 000's)"; agt = placeHeading(header); rct = new Rectangle(prctFull); rct.setLeft(_1_4TH); rct.setRight(rct.getLeft() + 756); r = doRow(leList(), widths, agt, colCount-1); rct.setTop(r.getBottom()); r = doRow(agesList(),widths,rct,colCount-1); rct.setTop(r.getBottom()); r = doRow(fiscalYearList(),widths,rct,colCount-1); rct.setTop(r.getBottom()); tallest = tallest < r.getHeight() ? r.getHeight() : tallest; nPage = true; } */ } }
From source file:com.teag.reports.EstatePlan.java
private Rectangle placeHeading(String header) { BaseFont font = PageUtils.LoadFont("GARA.TTF"); Rectangle rect = new Rectangle(document.getPageSize()); rect.setBottom(rect.getTop() - (72 * .6f)); HeadingText ht = new HeadingText(this.writer); rect.setBottom(rect.getBottom() - (72 * .33f)); ht.setColor(57, 57, 57);// www . j a va2s. co m ht.setCapsColor(98, 98, 98); ht.display(rect, 12f, font, 3f, header, HeadingText.DHT_CENTER); rect.setTop(rect.getBottom() - _1_8TH); rect.setBottom(prctFull.getBottom()); rect.setLeft(_1_2TH); rect.setRight(rect.getLeft() + 11.0f * 72); drawHeader(client, ""); PageBorder pb = new PageBorder(writer); pb.setLicense(userInfo.getPlannerFirstName() + " " + userInfo.getPlannerLastName()); pb.drawNoBorder(document, Integer.toString(pageNum)); drawLifeExp(); return (rect); }
From source file:es.gob.afirma.signers.pades.PdfPreProcessor.java
License:Open Source License
/** Sobreimpone una imagen en un documento PDF. * @param extraParams Datos de la imagen a añadir como <a href="doc-files/extraparams.html">parámetros adicionales</a> * @param stp Estampador de PDF, debe abrirse y cerrarse fuera de este método * @throws IOException Cuando ocurren errores de entrada / salida */ static void addImage(final Properties extraParams, final PdfStamper stp) throws IOException { if (extraParams == null || stp == null) { return;//from w ww . j a v a2 s. c o m } final String imageDataBase64 = extraParams.getProperty("image"); //$NON-NLS-1$ if (imageDataBase64 == null || imageDataBase64.length() < 1) { return; } final byte[] image = Base64.decode(imageDataBase64); final Rectangle rect = getPositionOnPage(extraParams, "image"); //$NON-NLS-1$ if (rect == null) { return; } final String imagePage = extraParams.getProperty("imagePage"); //$NON-NLS-1$ if (imagePage == null) { return; } final int pageNum; try { pageNum = Integer.parseInt(imagePage); } catch (final NumberFormatException e) { throw new IOException( "Se ha indicado un numero de pagina con formato invalido para insertar la imagen (" + imagePage //$NON-NLS-1$ + "): " + e, //$NON-NLS-1$ e); } addImage(image, (int) rect.getWidth(), (int) rect.getHeight(), (int) rect.getLeft(), (int) rect.getBottom(), pageNum, null, stp); LOGGER.info("Anadida imagen al PDF antes de la firma"); //$NON-NLS-1$ }
From source file:org.geomajas.plugin.print.component.impl.MapComponentImpl.java
License:Open Source License
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);// www. j ava 2 s . co m } 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); } }
From source file:org.geomajas.plugin.print.component.impl.PrintComponentImpl.java
License:Open Source License
private void layoutChild(PrintComponent<?> child, Rectangle box) { LayoutConstraint layoutConstraint = child.getConstraint(); float bx = box.getLeft(); float by = box.getBottom(); float bw = box.getWidth(); float bh = box.getHeight(); float cw = child.getBounds().getWidth(); float ch = child.getBounds().getHeight(); float marginX = layoutConstraint.getMarginX(); float marginY = layoutConstraint.getMarginY(); float absw = layoutConstraint.getWidth(); float absh = layoutConstraint.getHeight(); float x = 0;// w w w . j a v a 2 s . c o m float y = 0; float w = cw; float h = ch; switch (layoutConstraint.getAlignmentX()) { case LayoutConstraint.LEFT: x = bx + marginX; break; case LayoutConstraint.CENTER: x = bx + (bw - cw) / 2; break; case LayoutConstraint.RIGHT: x = bx + bw - marginX - cw; break; case LayoutConstraint.JUSTIFIED: x = bx + marginX; w = bw - 2 * marginX; break; case LayoutConstraint.ABSOLUTE: x = marginX; w = absw; break; default: throw new IllegalStateException("Unknown X alignment " + layoutConstraint.getAlignmentX()); } switch (layoutConstraint.getAlignmentY()) { case LayoutConstraint.BOTTOM: y = by + marginY; break; case LayoutConstraint.CENTER: y = by + (bh - ch) / 2; break; case LayoutConstraint.TOP: y = by + bh - marginY - ch; break; case LayoutConstraint.JUSTIFIED: y = by + marginY; h = bh - 2 * marginY; break; case LayoutConstraint.ABSOLUTE: y = marginY; h = absh; break; default: throw new IllegalStateException("Unknown Y alignment " + layoutConstraint.getAlignmentY()); } child.setBounds(new Rectangle(x, y, x + w, y + h)); }
From source file:org.geomajas.plugin.print.component.impl.VectorLayerComponentImpl.java
License:Open Source License
private void drawLabel(PdfContext context, InternalFeature f) { LabelStyleInfo labelType = styleInfo.getLabelStyle(); String label = f.getLabel();/*from www. j a va 2s .c om*/ if (label != null) { Font font = new Font("Helvetica", Font.ITALIC, 10); Color fontColor = Color.black; if (labelType.getFontStyle() != null) { fontColor = context.getColor(labelType.getFontStyle().getColor(), labelType.getFontStyle().getOpacity()); } Rectangle rect = calculateLabelRect(context, f, label, font); Color bgColor = Color.white; if (labelType.getBackgroundStyle() != null) { bgColor = context.getColor(labelType.getBackgroundStyle().getFillColor(), labelType.getBackgroundStyle().getFillOpacity()); } context.fillRoundRectangle(rect, bgColor, 3); Color borderColor = Color.black; if (labelType.getBackgroundStyle() != null) { borderColor = context.getColor(labelType.getBackgroundStyle().getStrokeColor(), labelType.getBackgroundStyle().getStrokeOpacity()); } float linewidth = 0.5f; if (labelType.getBackgroundStyle() != null) { linewidth = labelType.getBackgroundStyle().getStrokeWidth(); } context.strokeRoundRectangle(rect, borderColor, linewidth, 3); context.drawText(label, font, rect, fontColor); if (f.getGeometry() instanceof Point) { context.drawLine(0.5f * (rect.getLeft() + rect.getRight()), rect.getBottom(), 0.5f * (rect.getLeft() + rect.getRight()), rect.getBottom() - SYMBOL_CONNECT_LENGTH, borderColor, linewidth); } } }
From source file:org.geomajas.plugin.print.component.impl.VectorLayerComponentImpl.java
License:Open Source License
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); }//from w w w . j a v a2 s . c om 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; }
From source file:org.geomajas.plugin.print.component.PdfContext.java
License:Open Source License
/** * Draw text in the center of the specified box. * * @param text text/*from w w w .ja v a 2 s . co m*/ * @param font font * @param box box to put text int * @param fontColor colour */ public void drawText(String text, Font font, Rectangle box, Color fontColor) { template.saveState(); // get the font DefaultFontMapper mapper = new DefaultFontMapper(); BaseFont bf = mapper.awtToPdf(font); template.setFontAndSize(bf, font.getSize()); // calculate descent float descent = 0; if (text != null) { descent = bf.getDescentPoint(text, font.getSize()); } // calculate the fitting size Rectangle fit = getTextSize(text, font); // draw text if necessary template.setColorFill(fontColor); template.beginText(); template.showTextAligned(PdfContentByte.ALIGN_LEFT, text, origX + box.getLeft() + 0.5f * (box.getWidth() - fit.getWidth()), origY + box.getBottom() + 0.5f * (box.getHeight() - fit.getHeight()) - descent, 0); template.endText(); template.restoreState(); }
From source file:org.geomajas.plugin.print.component.PdfContext.java
License:Open Source License
public void strokeRectangle(Rectangle rect, Color color, float linewidth, float[] dashArray) { template.saveState();//from w w w. j a v a 2s .com setStroke(color, linewidth, dashArray); template.rectangle(origX + rect.getLeft(), origY + rect.getBottom(), rect.getWidth(), rect.getHeight()); template.stroke(); template.restoreState(); }