Example usage for com.lowagie.text Paragraph Paragraph

List of usage examples for com.lowagie.text Paragraph Paragraph

Introduction

In this page you can find the example usage for com.lowagie.text Paragraph Paragraph.

Prototype

public Paragraph(Phrase phrase) 

Source Link

Document

Constructs a Paragraph with a certain Phrase.

Usage

From source file:com.qcadoo.mes.genealogies.print.GenealogyForProductView.java

License:Open Source License

private void addTables(final Document document, final Entity entity, final Locale locale)
        throws DocumentException {
    List<String> orderHeader = new ArrayList<String>();
    orderHeader.add(translationService.translate("orders.order.number.label", locale));
    orderHeader.add(translationService.translate("orders.order.name.label", locale));
    orderHeader.add(translationService.translate("orders.order.dateFrom.label", locale));
    Paragraph productTitle = new Paragraph(new Phrase(
            translationService.translate("genealogies.genealogyForProduct.report.paragrah.product", locale),
            FontUtils.getDejavuBold11Light()));
    productTitle.setSpacingBefore(20);//from   w  w w.j  a  v  a  2 s  .c  o m
    document.add(productTitle);
    PdfPTable headerData = pdfHelper.createPanelTable(3);
    headerData.setSpacingBefore(7);
    Entity product = entity.getBelongsToField(ORDER_FIELD).getBelongsToField(PRODUCT_FIELD);
    pdfHelper.addTableCellAsOneColumnTable(headerData,
            translationService.translate("basic.product.number.label", locale), product.getField(NUMBER_FIELD));
    pdfHelper.addTableCellAsOneColumnTable(headerData,
            translationService.translate("basic.product.name.label", locale), product.getField(NAME_FIELD));
    pdfHelper.addTableCellAsOneColumnTable(headerData,
            translationService.translate("genealogies.genealogy.batch.label", locale),
            entity.getField(BATCH_FIELD));
    document.add(headerData);
    Paragraph orderTitle = new Paragraph(new Phrase(
            translationService.translate("genealogies.genealogyForProduct.report.paragrah.order", locale),
            FontUtils.getDejavuBold11Light()));
    orderTitle.setSpacingBefore(20);
    document.add(orderTitle);
    List<Entity> orders = getOrders(entity);
    Collections.sort(orders, new EntityNumberComparator());
    addOrderSeries(document, orders, orderHeader);
    if (pluginManager.isPluginEnabled(GENEALOGIES_FOR_COMPONENTS_PLUGIN)) {
        addComponentSeries(document, orders, locale);
    }
}

From source file:com.qcadoo.mes.genealogies.print.GenealogyForProductView.java

License:Open Source License

private void addComponentSeries(final Document document, final List<Entity> orders, final Locale locale)
        throws DocumentException {
    for (Entity order : orders) {
        document.add(Chunk.NEWLINE);//from  w  w w. j  ava 2 s .  c o  m
        Paragraph title = new Paragraph(new Phrase(
                translationService.translate("genealogies.genealogyForProduct.report.paragrah", locale),
                FontUtils.getDejavuBold11Light()));
        title.add(new Phrase(" " + order.getField(NUMBER_FIELD).toString(), FontUtils.getDejavuBold19Dark()));
        document.add(title);
        List<String> componentHeader = new ArrayList<String>();
        componentHeader.add(translationService.translate("basic.product.number.label", locale));
        componentHeader.add(translationService.translate("basic.product.name.label", locale));
        componentHeader.add(
                translationService.translate("genealogiesForComponents.productInBatch.batch.label", locale));
        PdfPTable table = pdfHelper.createTableWithHeader(3, componentHeader, false);

        List<Pair<String, Entity>> batchList = getBatchList(order);

        Collections.sort(batchList, new BatchOrderNrComparator());

        for (Pair<String, Entity> pair : batchList) {
            String batch = pair.getKey();
            Entity product = pair.getValue();
            table.addCell(
                    new Phrase(product.getField(NUMBER_FIELD).toString(), FontUtils.getDejavuRegular9Dark()));
            table.addCell(
                    new Phrase(product.getField(NAME_FIELD).toString(), FontUtils.getDejavuRegular9Dark()));
            table.addCell(new Phrase(batch, FontUtils.getDejavuRegular9Dark()));
        }
        document.add(table);

    }
}

From source file:com.qcadoo.mes.genealogiesForComponents.GenealogyForComponentView.java

License:Open Source License

private void addTables(final Document document, final Entity entity, final Locale locale)
        throws DocumentException {
    List<String> orderHeader = new ArrayList<String>();
    orderHeader.add(translationService.translate("orders.order.number.label", locale));
    orderHeader.add(translationService.translate("orders.order.name.label", locale));
    orderHeader.add(translationService.translate("orders.order.product.label", locale));
    orderHeader.add(translationService//  w  w w  . j a  v  a  2 s . c o  m
            .translate("genealogiesForComponents.genealogyForComponent.report.productBatch", locale));
    Paragraph productTitle = new Paragraph(new Phrase(
            translationService.translate(
                    "genealogiesForComponents.genealogyForComponent.report.paragrah.product", locale),
            FontUtils.getDejavuBold11Light()));
    productTitle.setSpacingBefore(20);
    document.add(productTitle);
    PdfPTable headerData = pdfHelper.createPanelTable(3);
    headerData.setSpacingBefore(7);
    Entity product = entity.getBelongsToField("productInComponent").getBelongsToField("productInComponent")
            .getBelongsToField("product");
    pdfHelper.addTableCellAsOneColumnTable(headerData,
            translationService.translate("basic.product.number.label", locale), product.getField("number"));
    pdfHelper.addTableCellAsOneColumnTable(headerData,
            translationService.translate("basic.product.name.label", locale), product.getField("name"));
    pdfHelper.addTableCellAsOneColumnTable(headerData,
            translationService.translate("genealogiesForComponents.productInBatch.batch.label", locale),
            entity.getField(BATCH_FIELD));
    document.add(headerData);
    Paragraph orderTitle = new Paragraph(
            new Phrase(
                    translationService.translate(
                            "genealogiesForComponents.genealogyForComponent.report.paragrah.order", locale),
                    FontUtils.getDejavuBold11Light()));
    orderTitle.setSpacingBefore(20);
    document.add(orderTitle);
    addOrderSeries(document, entity, orderHeader);
}

From source file:com.qcadoo.mes.qualityControls.print.QualityControlsReportService.java

License:Open Source License

public final void addQualityControlReportHeader(final Document document, final Map<String, Object> model,
        final Locale locale) throws DocumentException {
    if (!model.containsKey(ENTITIES)) {
        Paragraph firstParagraphTitle = new Paragraph(new Phrase(
                translationService.translate("qualityControls.qualityControl.report.paragrah", locale),
                FontUtils.getDejavuBold11Light()));
        firstParagraphTitle.add(new Phrase(" " + model.get("dateFrom") + " - " + model.get("dateTo"),
                FontUtils.getDejavuBold11Light()));
        firstParagraphTitle.setSpacingBefore(20);
        document.add(firstParagraphTitle);

    }/*from www .  j a  va 2 s  . c om*/
    Paragraph secondParagraphTitle = new Paragraph(
            new Phrase(translationService.translate("qualityControls.qualityControl.report.paragrah2", locale),
                    FontUtils.getDejavuBold11Light()));
    secondParagraphTitle.setSpacingBefore(20);
    document.add(secondParagraphTitle);
}

From source file:com.qcadoo.mes.workPlans.pdf.document.WorkPlanPdfForDivision.java

License:Open Source License

private void addWorkPlanTitle(Document document, Entity workPlan, String title, Locale locale)
        throws DocumentException {

    PdfPTable headerTable = pdfHelper.createPanelTable(2);

    PdfPCell titleCell = new PdfPCell();
    titleCell.setBorder(Rectangle.NO_BORDER);
    Paragraph workPlanTitle = new Paragraph(
            new Phrase(getWorkPlanTitle(locale), FontUtils.getDejavuBold11Light()));
    workPlanTitle.add(new Phrase(" " + getWorkPlanName(workPlan), FontUtils.getDejavuBold11Dark()));
    titleCell.addElement(workPlanTitle);

    PdfPCell divisionCell = new PdfPCell();
    divisionCell.setBorder(Rectangle.NO_BORDER);
    Paragraph divisionTitle = new Paragraph(
            new Phrase(getDivisionTitle(locale), FontUtils.getDejavuBold11Light()));
    divisionTitle.add(new Phrase(" " + getDivisionFromTitle(title, locale), FontUtils.getDejavuBold11Dark()));
    divisionTitle.setAlignment(Element.ALIGN_RIGHT);
    divisionCell.addElement(divisionTitle);

    headerTable.getDefaultCell().setBorder(Rectangle.NO_BORDER);
    headerTable.setTableEvent(null);//ww  w  . j a v a 2s  . c  o  m
    headerTable.setSpacingAfter(4.0f);
    headerTable.addCell(titleCell);
    headerTable.addCell(divisionCell);
    document.add(headerTable);
}

From source file:com.qcadoo.mes.workPlans.pdf.document.WorkPlanPdfForDivision.java

License:Open Source License

private void addMainOrders(Document document, List<OrderOperationComponent> orderOperationComponents,
        Locale locale) throws DocumentException {
    List<Entity> orders = getMainOrdersForOperationComponents(orderOperationComponents);
    for (Entity order : orders) {
        Entity product = order.getBelongsToField(OrderFields.PRODUCT);
        Paragraph mainOrder = new Paragraph(
                new Phrase(prepareMainOrderSummary(order, product, locale), FontUtils.getDejavuBold9Dark()));
        mainOrder.setIndentationLeft(3f);
        document.add(mainOrder);/*from w w  w .  j  av a  2  s.  c om*/
    }
}

From source file:com.qcadoo.report.internal.PdfHelperImpl.java

License:Open Source License

@Override
public void addDocumentHeader(final Document document, final String name, final String documenTitle,
        final String documentAuthor, final Date date, final String username) throws DocumentException {
    SimpleDateFormat df = new SimpleDateFormat(DateUtils.L_DATE_TIME_FORMAT, getLocale());
    LineSeparator line = new LineSeparator(3, 100f, ColorUtils.getLineDarkColor(), Element.ALIGN_LEFT, 0);
    document.add(Chunk.NEWLINE);/* w  w  w .ja v  a  2  s.c o m*/
    Paragraph title = new Paragraph(new Phrase(documenTitle, FontUtils.getDejavuBold17Light()));
    title.add(new Phrase(" " + name, FontUtils.getDejavuBold17Dark()));
    title.setSpacingAfter(7f);
    document.add(title);
    document.add(line);
    PdfPTable userAndDate = new PdfPTable(2);
    userAndDate.setWidthPercentage(100f);
    userAndDate.setHorizontalAlignment(Element.ALIGN_LEFT);
    userAndDate.getDefaultCell().setBorderWidth(0);
    Paragraph userParagraph = new Paragraph(new Phrase(documentAuthor, FontUtils.getDejavuRegular9Light()));
    userParagraph.add(new Phrase(" " + username, FontUtils.getDejavuRegular9Dark()));
    Paragraph dateParagraph = new Paragraph(df.format(date), FontUtils.getDejavuRegular9Light());
    userAndDate.addCell(userParagraph);
    userAndDate.getDefaultCell().setHorizontalAlignment(Element.ALIGN_RIGHT);
    userAndDate.addCell(dateParagraph);
    userAndDate.setSpacingAfter(14f);
    document.add(userAndDate);
}

From source file:com.qcadoo.report.internal.PdfHelperImpl.java

License:Open Source License

@Override
public void addDocumentHeader(final Document document, final String name, final String documenTitle,
        final String documentAuthor, final Date date) throws DocumentException {
    SimpleDateFormat df = new SimpleDateFormat(DateUtils.L_DATE_TIME_FORMAT, getLocale());
    LineSeparator line = new LineSeparator(2, 100f, ColorUtils.getLineDarkColor(), Element.ALIGN_LEFT, 0);
    document.add(Chunk.NEWLINE);/*  ww w . j av  a2  s .c  o m*/
    Paragraph title = new Paragraph(new Phrase(documenTitle, FontUtils.getDejavuBold17Light()));
    title.add(new Phrase(" " + name, FontUtils.getDejavuBold17Dark()));
    title.setSpacingAfter(7f);
    document.add(title);
    document.add(line);
    PdfPTable userAndDate = new PdfPTable(2);
    userAndDate.setWidthPercentage(100f);
    userAndDate.setHorizontalAlignment(Element.ALIGN_LEFT);
    userAndDate.getDefaultCell().setBorderWidth(0);
    Paragraph userParagraph = new Paragraph(new Phrase(documentAuthor, FontUtils.getDejavuRegular9Light()));
    userParagraph.add(new Phrase(" " + getDocumentAuthor(), FontUtils.getDejavuRegular9Dark()));
    Paragraph dateParagraph = new Paragraph(df.format(date), FontUtils.getDejavuRegular9Light());
    userAndDate.addCell(userParagraph);
    userAndDate.getDefaultCell().setHorizontalAlignment(Element.ALIGN_RIGHT);
    userAndDate.addCell(dateParagraph);
    userAndDate.setSpacingAfter(14f);
    document.add(userAndDate);
}

From source file:com.qcadoo.report.internal.PdfHelperImpl.java

License:Open Source License

@Override
public void addDocumentHeaderThin(final Document document, final String name, final String documentTitle,
        final String documentAuthor, final Date date) throws DocumentException {
    SimpleDateFormat df = new SimpleDateFormat(DateUtils.L_DATE_TIME_FORMAT, getLocale());
    LineSeparator line = new LineSeparator(2, 100f, ColorUtils.getLineDarkColor(), Element.ALIGN_LEFT, 0);
    Paragraph title = new Paragraph(new Phrase(documentTitle, FontUtils.getDejavuBold14Light()));
    title.add(new Phrase(" " + name, FontUtils.getDejavuBold14Dark()));
    title.setSpacingAfter(7f);//  w ww.  j a v  a2  s.  c  o m
    document.add(title);
    document.add(line);
    PdfPTable userAndDate = new PdfPTable(2);
    userAndDate.setWidthPercentage(100f);
    userAndDate.setHorizontalAlignment(Element.ALIGN_LEFT);
    userAndDate.getDefaultCell().setBorderWidth(0);
    Paragraph userParagraph = new Paragraph(new Phrase(documentAuthor, FontUtils.getDejavuRegular9Light()));
    userParagraph.add(new Phrase(" " + getDocumentAuthor(), FontUtils.getDejavuRegular9Dark()));
    Paragraph dateParagraph = new Paragraph(df.format(date), FontUtils.getDejavuRegular9Light());
    userAndDate.addCell(userParagraph);
    userAndDate.getDefaultCell().setHorizontalAlignment(Element.ALIGN_RIGHT);
    userAndDate.addCell(dateParagraph);
    userAndDate.setSpacingAfter(10f);
    document.add(userAndDate);
}

From source file:com.senacor.wbs.web.project.ProjectListPanel.java

License:Apache License

public ProjectListPanel(final String id, final List<Project> projects) {
    super(id);// w  w w .  j a va2s . c om
    this.locale = getLocale();
    SortableListDataProvider<Project> projectProvider = new SortableListDataProvider<Project>(projects) {
        @Override
        protected Locale getLocale() {
            return ProjectListPanel.this.getLocale();
        }

        public IModel model(final Object object) {
            return new CompoundPropertyModel(object);
        }
    };
    projectProvider.setSort("name", true);
    dataView = new DataView("projects", projectProvider, 4) {
        @Override
        protected void populateItem(final Item item) {
            Project project = (Project) item.getModelObject();
            PageParameters pageParameters = new PageParameters();
            pageParameters.put("projectId", project.getId());
            item.add(new BookmarkablePageLink("tasks", ProjectDetailsPage.class, pageParameters)
                    .add(new Label("id")));
            item.add(new Label("kuerzel"));
            item.add(new Label("titel", project.getName()));
            item.add(new Label("budget"));
            item.add(new Label("costPerHour"));
            item.add(new Label("start"));
            item.add(new Label("ende"));
            item.add(new Label("state"));
            // Alternieren der Farbe zwischen geraden und
            // ungeraden Zeilen
            item.add(new AttributeModifier("class", true, new AbstractReadOnlyModel() {
                @Override
                public Object getObject() {
                    return (item.getIndex() % 2 == 1) ? "even" : "odd";
                }
            }));
        }
    };
    add(dataView);
    Form localeForm = new Form("localeForm");
    ImageButton deButton = new ImageButton("langde", new ResourceReference(BaseWBSPage.class, "de.png")) {
        @Override
        public void onSubmit() {
            ProjectListPanel.this.locale = Locale.GERMANY;
        }
    };
    localeForm.add(deButton);
    ImageButton usButton = new ImageButton("langus", new ResourceReference(BaseWBSPage.class, "us.png")) {
        @Override
        public void onSubmit() {
            ProjectListPanel.this.locale = Locale.US;
        }
    };
    localeForm.add(usButton);
    add(localeForm);
    final IResourceStream pdfResourceStream = new AbstractResourceStreamWriter() {
        public void write(final OutputStream output) {
            Document document = new Document();
            try {
                PdfWriter.getInstance(document, output);
                document.open();
                // document.add(new
                // Paragraph("WBS-Projektliste"));
                // document.add(new Paragraph(""));
                PdfPTable table = new PdfPTable(new float[] { 1f, 1f, 2f, 1f });
                PdfPCell cell = new PdfPCell(new Paragraph("WBS-Projektliste"));
                cell.setColspan(4);
                cell.setGrayFill(0.8f);
                table.addCell(cell);
                table.addCell("ID");
                table.addCell("Krzel");
                table.addCell("Titel");
                table.addCell("Budget in PT");
                for (Project project : projects) {
                    table.addCell("" + project.getId());
                    table.addCell(project.getKuerzel());
                    table.addCell(project.getName());
                    table.addCell("" + project.getBudget());
                }
                document.add(table);
                document.close();
            } catch (DocumentException e) {
                throw new RuntimeException(e);
            }
        }

        public String getContentType() {
            return "application/pdf";
        }
    };
    WebResource projectsResource = new WebResource() {
        {
            setCacheable(false);
        }

        @Override
        public IResourceStream getResourceStream() {
            return pdfResourceStream;
        }

        @Override
        protected void setHeaders(final WebResponse response) {
            super.setHeaders(response);
            // response.setAttachmentHeader("projekte.pdf");
        }
    };
    WebResource projectsResourceDL = new WebResource() {
        {
            setCacheable(false);
        }

        @Override
        public IResourceStream getResourceStream() {
            return pdfResourceStream;
        }

        @Override
        protected void setHeaders(final WebResponse response) {
            super.setHeaders(response);
            response.setAttachmentHeader("projekte.pdf");
        }
    };
    ResourceLink pdfDownload = new ResourceLink("pdfDownload", projectsResourceDL);
    ResourceLink pdfPopup = new ResourceLink("pdfPopup", projectsResource);
    PopupSettings popupSettings = new PopupSettings(PopupSettings.STATUS_BAR);
    popupSettings.setWidth(500);
    popupSettings.setHeight(700);
    pdfPopup.setPopupSettings(popupSettings);
    Link pdfReqTarget = new Link("pdfReqTarget") {
        @Override
        public void onClick() {
            RequestCycle.get()
                    .setRequestTarget(new ResourceStreamRequestTarget(pdfResourceStream, "projekte.pdf"));
        }
    };
    add(pdfReqTarget);
    add(pdfDownload);
    add(pdfPopup);
    add(new OrderByBorder("orderByKuerzel", "kuerzel", projectProvider));
    add(new OrderByBorder("orderByName", "name", projectProvider));
    add(new OrderByBorder("orderByBudget", "budget", projectProvider));
    add(new OrderByBorder("orderByCostPerHour", "costPerHour", projectProvider));
    add(new OrderByBorder("orderByStart", "start", projectProvider));
    add(new OrderByBorder("orderByEnde", "ende", projectProvider));
    add(new OrderByBorder("orderByState", "state", projectProvider));
    add(new PagingNavigator("projectsNavigator", dataView));
}