Example usage for com.lowagie.text Rectangle TOP

List of usage examples for com.lowagie.text Rectangle TOP

Introduction

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

Prototype

int TOP

To view the source code for com.lowagie.text Rectangle TOP.

Click Source Link

Document

This represents one side of the border of the Rectangle.

Usage

From source file:org.egov.works.web.actions.estimate.EstimatePDFGenerator.java

License:Open Source License

public void generatePDF() {
    try {/*from   w  ww.j  a  v  a 2  s .  c  o  m*/
        final Paragraph headerTextPara = new Paragraph(
                new Chunk(headerText, new Font(Font.UNDEFINED, LARGE_FONT, Font.BOLD)));
        String projectCode;
        final String oldEstNo = "";
        HeaderFooter hf;
        headerTextPara.setAlignment(Element.ALIGN_CENTER);
        document.add(headerTextPara);
        document.add(makePara("Executing Department:" + estimate.getExecutingDepartment().getName(),
                Element.ALIGN_LEFT));
        if (estimate.getUserDepartment() != null)
            document.add(
                    makePara("User Department:" + estimate.getUserDepartment().getName(), Element.ALIGN_LEFT));

        final CFinancialYear estimateFinancialYear = estimate.getMultiYearEstimates().get(0).getFinancialYear();
        addZoneYearHeader(estimate, estimateFinancialYear);

        document.add(makePara("Name of Work: " + estimate.getName(), Element.ALIGN_LEFT));
        document.add(makePara("Description: " + estimate.getDescription(), Element.ALIGN_LEFT));

        if (estimate.getProjectCode() != null) {
            projectCode = "Project Code : " + estimate.getProjectCode().getCode();
            document.add(makePara(projectCode, Element.ALIGN_LEFT));
            hf = new HeaderFooter(new Phrase("\t  \t  \t  \t \t \t  \t  \t  \t \t \t  \t  \t  \t \t"
                    + "\t  \t  \t  \t \t\t  \t  \t  \t \t\t  \t  \t  \t \t\t  \t  \t  "
                    + "\t  \t  \t  \t \t\t  \t  \t  \t \t"
                    + headerText.concat("\n")
                            .concat("\t  \t  \t  \t \t \t  \t  \t  \t \t"
                                    + "\t  \t  \t  \t \t\t  \t  \t  \t \t\t  \t  \t  \t \t\t  \t  \t  "
                                    + "\t  \t  \t  \t \t\t  \t  \t  \t \t ABSTRACT ESTIMATE")
                            .concat("\n\n").concat("Name of Work: " + estimate.getName()).concat("\n")
                            .concat("Description: " + estimate.getDescription()).concat("\n")
                            .concat("Estimate Number: " + estimate.getEstimateNumber()).concat(oldEstNo)
                            .concat("\n").concat(projectCode)),
                    false);
        } else
            hf = new HeaderFooter(new Phrase("\t  \t  \t  \t \t \t  \t  \t  \t \t \t  \t  \t  \t \t"
                    + "\t  \t  \t  \t \t\t  \t  \t  \t \t\t  \t  \t  \t \t\t  \t  \t  "
                    + "\t  \t  \t  \t \t\t  \t  \t  \t \t"
                    + headerText.concat("\n")
                            .concat("\t  \t  \t  \t \t \t  \t  \t  \t \t"
                                    + "\t  \t  \t  \t \t\t  \t  \t  \t \t\t  \t  \t  \t \t\t  \t  \t  "
                                    + "\t  \t  \t  \t \t\t  \t  \t  \t \t ABSTRACT ESTIMATE")
                            .concat("\n\n").concat("Name of Work: " + estimate.getName()).concat("\n")
                            .concat("Description: " + estimate.getDescription()).concat("\n")
                            .concat("Estimate Number: " + estimate.getEstimateNumber()).concat(oldEstNo)),
                    false);

        hf.disableBorderSide(Rectangle.TOP);
        hf.disableBorderSide(Rectangle.BOTTOM);
        hf.setLeft(Element.ALIGN_LEFT);
        document.setHeader(hf);
        final PdfPTable overheadsTable = createOverheadsTable(estimate);
        document.add(spacer());
        document.add(overheadsTable);
        document.add(spacer());
        final PdfPTable multiyearTable = createMultiYearTable(estimate);
        document.add(makePara("Year-wise Estimate"));
        document.add(spacer());
        document.add(multiyearTable);
        document.add(spacer());
        document.add(makePara("Estimate Created By: " + estimate.getCreatedBy().getName()));
        document.add(spacer());
        document.add(spacer());
        document.add(makePara("Checked By: "));
        document.newPage();
        addZoneYearHeaderWithOutEstimateNo(estimate, estimateFinancialYear);
        document.add(createActivitiesTable(estimate));
        document.add(spacer());

        final PdfPTable approvaldetailsTable = createApprovalDetailsTable(estimate);
        // TODO:Fixme - commented final out workflow history final details since ordering final of approval is final not
        // getting final listed properly
        /*
         * if (approvaldetailsTable.getRows().size() != 1) { document.add(makePara("Approval Details"));
         * document.add(spacer()); document.add(approvaldetailsTable); }
         */

        final String appropriationNumber = abstractEstimateService
                .getLatestEstimateAppropriationNumber(estimate);

        if (isSkipBudgetCheck()) {
            final PdfPTable depositWorksAppropriationTable = createDepositAppropriationTable(estimate,
                    appropriationNumber);
            if (depositWorksAppropriationTable.getRows().size() != 1)
                if (appropriationNumber != null) {
                    document.newPage();
                    document.add(spacer());
                    document.add(makePara("Deposit Code Appropriation Details"));
                    document.add(spacer());
                    document.add(depositWorksAppropriationTable);
                }
        } else {
            final PdfPTable BudgetaryAppropriationTable = createBudgetaryAppropriationTable(estimate,
                    appropriationNumber);
            final String estimateNumber = estimate.getEstimateNumber();
            if (BudgetaryAppropriationTable.getRows().size() != 1)
                if (!getBudgetDetailUsage(estimateNumber).isEmpty() && appropriationNumber != null) {
                    document.newPage();
                    document.add(spacer());
                    document.add(makePara("Budgetary Appropriation"));
                    document.add(spacer());
                    document.add(BudgetaryAppropriationTable);
                }
        }

        document.newPage();
        document.add(spacer());
        document.add(makePara(
                "EXECUTIVE ENGINEER'S OFFICE,  ZONE.......................................................................",
                Element.ALIGN_LEFT));
        document.add(spacer());
        document.add(makePara(
                "Est No.                                                Unit:                                                 Dept.",
                Element.ALIGN_LEFT));
        document.add(spacer());
        final Paragraph budgetheadTextPara = new Paragraph(
                new Chunk("BUDGET HEAD", new Font(Font.UNDEFINED, LARGE_FONT, Font.BOLD)));
        budgetheadTextPara.setAlignment(Element.ALIGN_CENTER);
        document.add(budgetheadTextPara);
        document.add(spacer());
        document.add(makePara("____________________________________________________________________________",
                Element.ALIGN_LEFT));
        document.add(makePara("Rs.                                            ", Element.ALIGN_LEFT));
        document.add(makePara("____________________________________________________________________________",
                Element.ALIGN_LEFT));
        document.add(makePara("Works:                                          ", Element.ALIGN_LEFT));
        document.add(spacer());
        document.add(spacer());
        final Paragraph memoTextPara = new Paragraph(
                new Chunk("MEMO", new Font(Font.UNDEFINED, LARGE_FONT, Font.BOLD)));
        memoTextPara.setAlignment(Element.ALIGN_CENTER);
        document.add(memoTextPara);
        document.add(makePara("Budget Grant                               ", Element.ALIGN_LEFT));
        document.add(makePara("Amount Appropriated:__________________________________________________________",
                Element.ALIGN_LEFT));
        document.add(makePara("Balance on Hand:                                ", Element.ALIGN_LEFT));
        document.add(
                makePara("Amount of this estimate_________________________________________________________",
                        Element.ALIGN_LEFT));
        document.add(makePara("Balance forward_______________________________________________________________",
                Element.ALIGN_LEFT));
        document.add(
                makePara("Submitted for favour of sanction                           ", Element.ALIGN_LEFT));
        document.add(spacer());
        document.add(spacer());
        document.add(
                makePara("A.E.E.Unit " + space1 + "\t  \t  \t  \t \t \t  \t  \t  \t \t \t \t \t \t \t \t \t \t"
                        + "Exe.Eng.Zone.....................", Element.ALIGN_LEFT));
        document.add(spacer());
        document.add(makePara("Sanctioned", Element.ALIGN_CENTER));
        document.add(spacer());
        document.add(spacer());
        document.add(makePara("DATE:" + space1
                + "\t  \t  \t  \t \t \t  \t  \t  \t \t \t \t\t  \t  \t  \t \t \t  \t  \t  \t \t \t \t"
                + "Asst.Commissioner Zone...............", Element.ALIGN_LEFT));
        document.add(spacer());
        document.add(makePara(
                space1 + "\t  \t  \t  \t \t \t  \t  \t  \t \t \t \t\t  \t  \t  \t \t \t  \t  \t  \t \t \t \t"
                        + "APPROPRIATION No.",
                Element.ALIGN_LEFT));
        document.add(makePara(space1 + "\t  \t  \t  \t \t \t  \t  \t  \t \t \t \t"
                + "\t  \t  \t  \t \t \t  \t  \t  \t \t \t \t \t \t \t" + "Date:", Element.ALIGN_LEFT));

        // WF for signature -----
        if (approvaldetailsTable.getRows().size() != 1)
            if (shouldShowApprovalNumber) {
                document.resetHeader();
                document.newPage();
                document.add(
                        makePara("\t  \t  \t  \t \t \t  \t  \t  \t \t \t  \t  \t  \t \t"
                                + "\t  \t  \t  \t \t\t  \t  \t  \t \t\t  \t  \t  \t \t\t  \t  \t  "
                                + "\t  \t  \t  \t \t\t  \t  \t  \t \t"
                                + headerText.concat("\n").concat("\t  \t  \t  \t \t \t  \t  \t  \t \t"
                                        + "\t  \t  \t  \t \t\t  \t  \t  \t \t\t  \t  \t  \t \t\t  \t  \t  "
                                        + "\t  \t  \t  \t \t\t  \t  \t  \t \t ABSTRACT ESTIMATE")
                                        .concat("\n\n")));
                document.add(
                        makePara(
                                "File Current Number :" + space1
                                        + "\t  \t  \t  \t \t \t  \t  \t  \t \t \t \t \t   " + "Date: \t \t",
                                Element.ALIGN_LEFT));
                document.add(makePara(space1
                        + "\t  \t  \t  \t \t \t  \t  \t  \t \t \t \t\t  \t  \t  \t \t \t \t \t  \t  \t  \t "
                        + "Department : ", Element.ALIGN_LEFT));
                document.add(spacer());
                final Paragraph headingPara1 = new Paragraph(
                        new Chunk("NOTE FOR ADMINISTRATIVE SANCTION AS PER RULE 78 OF ",
                                new Font(Font.UNDEFINED, LARGE_FONT, Font.BOLD)));
                headingPara1.setAlignment(Element.ALIGN_CENTER);
                document.add(headingPara1);
                final Paragraph headingPara2 = new Paragraph(
                        new Chunk("MCMC ACT 1919 ", new Font(Font.UNDEFINED, LARGE_FONT, Font.BOLD)));
                headingPara2.setAlignment(Element.ALIGN_CENTER);
                document.add(headingPara2);

                document.add(spacer());
                final PdfPTable estimateDetailsTable1 = createEstimateDetailsTable1(estimate);
                document.add(estimateDetailsTable1);
                final PdfPTable budgetDetailsTableFourCols = createBudgetDetailsForEstimateTable(estimate);
                document.add(budgetDetailsTableFourCols);
                final PdfPTable estimateDetailsTable2 = createBalanceAmtCalculationTable(estimate);
                document.add(estimateDetailsTable2);
                document.add(spacer());
                final Paragraph endTextPara = new Paragraph(
                        new Chunk("** END **", new Font(Font.UNDEFINED, LARGE_FONT, Font.BOLD)));
                endTextPara.setAlignment(Element.ALIGN_CENTER);
                document.add(endTextPara);
            }

        document.close();
    } catch (final DocumentException e) {
        throw new ApplicationRuntimeException("estimate.pdf.error", e);
    }
}

From source file:org.kuali.kfs.fp.document.service.impl.CashReceiptCoverSheetServiceImpl.java

License:Open Source License

/**
 * Responsible for creating a new PDF page and workspace through <code>{@link PdfContentByte}</code> for direct writing to the
 * PDF.//from  ww  w  .j av a  2  s. c  om
 *
 * @param writer The PDF writer used to write to the new page with.
 * @param reader The PDF reader used to read information from the PDF file.
 * @param pageNumber The current number of pages in the PDF file, which will be incremented by one inside this method.
 *
 * @return The PDFContentByte used to access the new PDF page.
 * @exception DocumentException
 * @exception IOException
 */
protected PdfContentByte startNewPage(PdfWriter writer, PdfReader reader, ModifiableInteger pageNumber)
        throws DocumentException, IOException {
    PdfContentByte retval;
    PdfContentByte under;
    Rectangle pageSize;
    Document pdfDoc;
    PdfImportedPage newPage;

    pageNumber.increment();
    pageSize = reader.getPageSize(FRONT_PAGE);
    retval = writer.getDirectContent();
    // under = writer.getDirectContentUnder();

    if (pageNumber.getInt() > FRONT_PAGE) {
        newPage = writer.getImportedPage(reader, CHECK_PAGE_NORMAL);
        setCurrentRenderingYPosition(pageSize.top(TOP_MARGIN + CHECK_DETAIL_HEADING_HEIGHT));
    } else {
        newPage = writer.getImportedPage(reader, FRONT_PAGE);
        setCurrentRenderingYPosition(pageSize.top(TOP_FIRST_PAGE));
    }

    pdfDoc = retval.getPdfDocument();
    pdfDoc.newPage();
    retval.addTemplate(newPage, 0, 0);
    retval.setFontAndSize(getTextFont(), 8);

    return retval;
}

From source file:org.pentaho.reporting.engine.classic.core.modules.output.table.rtf.itext.PatchRtfBorderGroup.java

License:Open Source License

/**
 * Adds borders to the PatchRtfBorderGroup
 *
 * @param bordersToAdd/* ww  w . j a  va  2  s.  c  o m*/
 *          The borders to add (Rectangle.LEFT, Rectangle.RIGHT, Rectangle.TOP, Rectangle.BOTTOM, Rectangle.BOX)
 * @param borderStyle
 *          The style of border to add (from PatchRtfBorder)
 * @param borderWidth
 *          The border width to use
 * @param borderColor
 *          The border color to use
 */
public void addBorder(int bordersToAdd, int borderStyle, float borderWidth, Color borderColor) {
    if ((bordersToAdd & Rectangle.LEFT) == Rectangle.LEFT) {
        setBorder(PatchRtfBorder.LEFT_BORDER, borderStyle, borderWidth, borderColor);
    }
    if ((bordersToAdd & Rectangle.TOP) == Rectangle.TOP) {
        setBorder(PatchRtfBorder.TOP_BORDER, borderStyle, borderWidth, borderColor);
    }
    if ((bordersToAdd & Rectangle.RIGHT) == Rectangle.RIGHT) {
        setBorder(PatchRtfBorder.RIGHT_BORDER, borderStyle, borderWidth, borderColor);
    }
    if ((bordersToAdd & Rectangle.BOTTOM) == Rectangle.BOTTOM) {
        setBorder(PatchRtfBorder.BOTTOM_BORDER, borderStyle, borderWidth, borderColor);
    }
    if ((bordersToAdd & Rectangle.BOX) == Rectangle.BOX && this.borderType == PatchRtfBorder.ROW_BORDER) {
        setBorder(PatchRtfBorder.VERTICAL_BORDER, borderStyle, borderWidth, borderColor);
        setBorder(PatchRtfBorder.HORIZONTAL_BORDER, borderStyle, borderWidth, borderColor);
    }
}

From source file:org.pentaho.reporting.engine.classic.core.modules.output.table.rtf.itext.PatchRtfBorderGroup.java

License:Open Source License

/**
 * Removes borders from the list of borders
 *
 * @param bordersToRemove/*w w  w .jav a 2 s  .  c o m*/
 *          The borders to remove (from Rectangle)
 */
public void removeBorder(int bordersToRemove) {
    if ((bordersToRemove & Rectangle.LEFT) == Rectangle.LEFT) {
        this.borders.remove(new Integer(PatchRtfBorder.LEFT_BORDER));
    }
    if ((bordersToRemove & Rectangle.TOP) == Rectangle.TOP) {
        this.borders.remove(new Integer(PatchRtfBorder.TOP_BORDER));
    }
    if ((bordersToRemove & Rectangle.RIGHT) == Rectangle.RIGHT) {
        this.borders.remove(new Integer(PatchRtfBorder.RIGHT_BORDER));
    }
    if ((bordersToRemove & Rectangle.BOTTOM) == Rectangle.BOTTOM) {
        this.borders.remove(new Integer(PatchRtfBorder.BOTTOM_BORDER));
    }
    if ((bordersToRemove & Rectangle.BOX) == Rectangle.BOX && this.borderType == PatchRtfBorder.ROW_BORDER) {
        this.borders.remove(new Integer(PatchRtfBorder.VERTICAL_BORDER));
        this.borders.remove(new Integer(PatchRtfBorder.HORIZONTAL_BORDER));
    }
}

From source file:org.revager.export.PDFExporter.java

License:Open Source License

/**
 * Creates an empty PdfPTable cell with a defined height and colspan.
 * //  w w  w.java  2s.  co  m
 * @param height
 *            the height of the created cell
 * @param colspan
 *            the colspan
 * 
 * @return Empty cell with defined minimum height
 */
protected PdfPCell createVerticalStrut(float height, int colspan) {
    PdfPCell fill = new PdfPCell();

    fill.setColspan(colspan);
    fill.setMinimumHeight(height);
    fill.disableBorderSide(Rectangle.LEFT | Rectangle.RIGHT | Rectangle.TOP | Rectangle.BOTTOM);

    return fill;
}

From source file:org.unitime.timetable.export.PDFPrinter.java

License:Open Source License

@Override
public void printLine(String... fields) {
    PdfPCellEvent setLineDashEvent = new PdfPCellEvent() {
        @Override/*from ww  w.j av  a 2  s .  c  o m*/
        public void cellLayout(PdfPCell cell, Rectangle rect, PdfContentByte[] canvas) {
            PdfContentByte cb = canvas[PdfPTable.LINECANVAS];
            cb.setLineDash(new float[] { 2, 2 }, 0);
        }
    };

    for (int idx = 0; idx < fields.length; idx++) {
        if (iHiddenColumns.contains(idx))
            continue;
        String f = fields[idx];
        if (f == null || f.isEmpty() || (iCheckLast
                && f.equals(iLastLine == null || idx >= iLastLine.length ? null : iLastLine[idx])))
            f = "";

        boolean number = sNumber.matcher(f).matches();

        Font font = PdfFont.getFont();
        Phrase p = new Phrase(f, PdfFont.getSmallFont());

        PdfPCell cell = new PdfPCell(p);
        cell.setBorder(iLastLine == null ? Rectangle.TOP : Rectangle.NO_BORDER);
        cell.setVerticalAlignment(Element.ALIGN_TOP);
        cell.setHorizontalAlignment(number ? Element.ALIGN_RIGHT : Element.ALIGN_LEFT);
        cell.setPaddingBottom(4f);
        cell.setCellEvent(setLineDashEvent);
        if (number)
            cell.setPaddingRight(10f);
        iTable.addCell(cell);

        float width = 0;
        if (f.indexOf('\n') >= 0) {
            for (StringTokenizer s = new StringTokenizer(f, "\n"); s.hasMoreTokens();)
                width = Math.max(width, font.getBaseFont().getWidthPoint(s.nextToken(), font.getSize()));
        } else
            width = Math.max(width, font.getBaseFont().getWidthPoint(f, font.getSize()));
        iMaxWidth[idx] = Math.max(iMaxWidth[idx], width + (number ? 10 : 0));
    }
    iLastLine = fields;
}

From source file:ro.nextreports.engine.exporter.RtfExporter.java

License:Apache License

private void setCellStyle(Font fnt, Map<String, Object> style, RtfCell cell) {
    if (style != null) {
        updateFont(fnt, style);//from  w ww  . j  a va2 s .co m
        if (style.containsKey(StyleFormatConstants.BACKGROUND_COLOR)) {
            Color val = (Color) style.get(StyleFormatConstants.BACKGROUND_COLOR);
            cell.setBackgroundColor(val);
        }
        if (style.containsKey(StyleFormatConstants.HORIZONTAL_ALIGN_KEY)) {
            if (StyleFormatConstants.HORIZONTAL_ALIGN_LEFT
                    .equals(style.get(StyleFormatConstants.HORIZONTAL_ALIGN_KEY))) {
                cell.setHorizontalAlignment(Element.ALIGN_LEFT);
            }
            if (StyleFormatConstants.HORIZONTAL_ALIGN_RIGHT
                    .equals(style.get(StyleFormatConstants.HORIZONTAL_ALIGN_KEY))) {
                cell.setHorizontalAlignment(Element.ALIGN_RIGHT);
            }
            if (StyleFormatConstants.HORIZONTAL_ALIGN_CENTER
                    .equals(style.get(StyleFormatConstants.HORIZONTAL_ALIGN_KEY))) {
                cell.setHorizontalAlignment(Element.ALIGN_CENTER);
            }
        }

        if (style.containsKey(StyleFormatConstants.VERTICAL_ALIGN_KEY)) {
            if (StyleFormatConstants.VERTICAL_ALIGN_TOP
                    .equals(style.get(StyleFormatConstants.VERTICAL_ALIGN_KEY))) {
                cell.setVerticalAlignment(Element.ALIGN_TOP);
            }
            if (StyleFormatConstants.VERTICAL_ALIGN_MIDDLE
                    .equals(style.get(StyleFormatConstants.VERTICAL_ALIGN_KEY))) {
                cell.setVerticalAlignment(Element.ALIGN_MIDDLE);
            }
            if (StyleFormatConstants.VERTICAL_ALIGN_BOTTOM
                    .equals(style.get(StyleFormatConstants.VERTICAL_ALIGN_KEY))) {
                cell.setVerticalAlignment(Element.ALIGN_BOTTOM);
            }
        }
        // if (style.containsKey(StyleFormatConstants.PADDING_LEFT)) {
        // Float val = (Float) style.get(StyleFormatConstants.PADDING_LEFT);
        // cell.setPaddingLeft(val);
        // }
        // if (style.containsKey(StyleFormatConstants.PADDING_RIGHT)) {
        // Float val = (Float)
        // style.get(StyleFormatConstants.PADDING_RIGHT);
        // cell.setPaddingRight(val);
        // }
        // if (style.containsKey(StyleFormatConstants.PADDING_TOP)) {
        // Float val = (Float) style.get(StyleFormatConstants.PADDING_TOP);
        // cell.setPaddingTop(val);
        // }
        // if (style.containsKey(StyleFormatConstants.PADDING_BOTTOM)) {
        // Float val = (Float)
        // style.get(StyleFormatConstants.PADDING_BOTTOM);
        // cell.setPaddingBottom(val);
        // }
        cell.setBorderWidth(0);

        Float val = Float.valueOf(1);
        RtfBorderGroup bg = new RtfBorderGroup();
        if (style.containsKey(StyleFormatConstants.BORDER_LEFT)) {
            val = (Float) style.get(StyleFormatConstants.BORDER_LEFT);
            Color color = (Color) style.get(StyleFormatConstants.BORDER_LEFT_COLOR);
            bg.addBorder(Rectangle.LEFT, RtfBorder.BORDER_SINGLE, val, color);
        }
        if (style.containsKey(StyleFormatConstants.BORDER_RIGHT)) {
            val = (Float) style.get(StyleFormatConstants.BORDER_RIGHT);
            Color color = (Color) style.get(StyleFormatConstants.BORDER_RIGHT_COLOR);
            bg.addBorder(Rectangle.RIGHT, RtfBorder.BORDER_SINGLE, val, color);
        }
        if (style.containsKey(StyleFormatConstants.BORDER_TOP)) {
            val = (Float) style.get(StyleFormatConstants.BORDER_TOP);
            Color color = (Color) style.get(StyleFormatConstants.BORDER_TOP_COLOR);
            bg.addBorder(Rectangle.TOP, RtfBorder.BORDER_SINGLE, val, color);
        }
        if (style.containsKey(StyleFormatConstants.BORDER_BOTTOM)) {
            val = (Float) style.get(StyleFormatConstants.BORDER_BOTTOM);
            Color color = (Color) style.get(StyleFormatConstants.BORDER_BOTTOM_COLOR);
            bg.addBorder(Rectangle.BOTTOM, RtfBorder.BORDER_SINGLE, val, color);
        }
        cell.setBorders(bg);

        // cell.setNoWrap(true);
        // if (bandElement != null) {
        // if (bandElement.isWrapText()) {
        // cell.setNoWrap(false);
        // }
        // }
    }
}

From source file:s2s.luna.reports.Report_LIS_INR_MAN_AZL.java

License:GNU General Public License

@Override
public void doReport() throws DocumentException, IOException, BadElementException, Exception { //----------------------------------------------------------------------

    IAziendaHome home = (IAziendaHome) PseudoContext.lookup("AziendaBean");
    IAzienda bean_az = home.findByPrimaryKey(new Long(lCOD_AZL));

    IAttivitaLavorativeHome h = (IAttivitaLavorativeHome) PseudoContext.lookup("AttivitaLavorativeBean");
    IRischioHome home_rs = (IRischioHome) PseudoContext.lookup("RischioBean");
    IMisurePreventiveHome home_mp = (IMisurePreventiveHome) PseudoContext.lookup("MisurePreventiveBean");

    this.bRotate = true;
    initDocument("the doc", null,
            ApplicationConfigurator.LanguageManager.getString("LISTA.DEGLI.INTERVENTI.AZIENDALI"),
            bean_az.getRAG_SCL_AZL(), null);
    AddImage();//w  ww .java2 s. c  o  m
    {
        CenterMiddleTable tbl = new CenterMiddleTable(1);
        tbl.setOffset(0);
        tbl.addHeaderCellB(ApplicationConfigurator.LanguageManager.getString("Azienda/Ente"));
        tbl.addCell(bean_az.getRAG_SCL_AZL());
        tbl.addHeaderCellB(
                ApplicationConfigurator.LanguageManager.getString("LISTA.DEGLI.INTERVENTI.AZIENDALI"));
        m_document.add(tbl);
    }
    writeIndent();
    {
        CenterMiddleTable tbl = null;
        if (!bShowSito) {
            tbl = new CenterMiddleTable(8);
            int width[] = { 5, 6, 12, 5, 25, 15, 7, 10 };
            tbl.setWidths(width);
        } else {
            tbl = new CenterMiddleTable(9);
            int width[] = { 5, 5, 6, 12, 5, 25, 15, 7, 10 };
            tbl.setWidths(width);
        }

        tbl.toLeft();
        tbl.setDefaultCellBorder(Rectangle.BOTTOM | Rectangle.TOP | Rectangle.LEFT | Rectangle.RIGHT);

        if (!bShowSito) {
            Iterator it = h.getAttivitaLavorative_Name_View(lCOD_AZL).iterator();
            while (it.hasNext()) {
                AttivitaLavorative_Name_View w = (AttivitaLavorative_Name_View) it.next();
                drawLuogoFisico(home_rs, home_mp, tbl, w.NOM_MAN, w.COD_MAN, bShowSito);
            }
        } else {
            ISitaAziendeHome home_sa = (ISitaAziendeHome) PseudoContext.lookup("SitaAziendeBean");
            Iterator it = home_sa.getNonEmptySiteAziendaleByAZLID_View(lCOD_AZL).iterator();
            while (it.hasNext()) {
                SiteAziendaleByAZLID_View w = (SiteAziendaleByAZLID_View) it.next();
                tbl.setDefaultCellBorder(Rectangle.BOTTOM | Rectangle.TOP | Rectangle.LEFT | Rectangle.RIGHT);
                tbl.addHeaderCellB(ApplicationConfigurator.LanguageManager.getString("Sito.aziendale"), 9);
                tbl.addHeaderCellI(w.NOM_SIT_AZL, 9);

                Iterator it2 = h.getAttivitaLavorative_Name_ViewBySito(w.COD_SIT_AZL).iterator();

                while (it2.hasNext()) {
                    AttivitaLavorative_Name_View ww = (AttivitaLavorative_Name_View) it2.next();
                    drawLuogoFisico(home_rs, home_mp, tbl, ww.NOM_MAN, ww.COD_MAN, bShowSito);
                }

            }
        }
        m_document.add(tbl);
    }
    closeDocument();
}

From source file:s2s.luna.reports.Report_LIS_INR_MAN_AZL.java

License:GNU General Public License

public void drawLuogoFisico(IRischioHome home_rs, IMisurePreventiveHome home_mp, CenterMiddleTable tbl,
        String strName, long lCOD_MAN, boolean bShowSito) throws BadElementException {

    int iTmp = bShowSito ? 1 : 0;
    tbl.setDefaultCellBorder(Rectangle.BOTTOM | Rectangle.TOP | Rectangle.LEFT | Rectangle.RIGHT);
    if (bShowSito) {
        tbl.setDefaultCellBorder(0);//from w ww .  j a  v a  2  s  . c o m
        tbl.addCell("", 0, 1);
        tbl.setDefaultCellBorder(Rectangle.BOTTOM | Rectangle.TOP | Rectangle.LEFT | Rectangle.RIGHT);
    }
    tbl.addHeaderCellB(ApplicationConfigurator.LanguageManager.getString("Attivit.lavorativa"), 8);
    if (bShowSito) {
        tbl.setDefaultCellBorder(0);
        tbl.addCell("", 0, 1);
        tbl.setDefaultCellBorder(Rectangle.BOTTOM | Rectangle.TOP | Rectangle.LEFT | Rectangle.RIGHT);
    }
    tbl.addHeaderCellI(strName, 8);
    tbl.setDefaultCellBorder(0);
    {
        Iterator it2 = home_rs.getReportRischioByMAN_Name_View(lCOD_AZL, lCOD_MAN).iterator();
        while (it2.hasNext()) {
            ReportRischio_Name_View ww = (ReportRischio_Name_View) it2.next();
            tbl.addCell("", 0, 1 + iTmp);
            tbl.addCellB(ApplicationConfigurator.LanguageManager.getString("Rischio") + ":", 0, 1);
            tbl.addCell(Formatter.format(ww.strNOM_RSO), 0, 4);
            tbl.toRight();
            tbl.addCellB(ApplicationConfigurator.LanguageManager.getString("PxD") + ":", 0, 1);
            tbl.toLeft();
            tbl.addCell(Formatter.format(ww.lSTM_NUM_RSO));
            {
                Iterator it3 = home_mp.getReportMisurePreventive_View(ww.lCOD_RSO_MAN).iterator();
                while (it3.hasNext()) {
                    ReportMisurePreventive_View www = (ReportMisurePreventive_View) it3.next();
                    tbl.addCell("", 0, 2 + iTmp);
                    tbl.addCellB(ApplicationConfigurator.LanguageManager.getString("Misure") + ":", 0, 1);
                    tbl.addCell(www.strNOM_MIS_PET + "\n" + www.strDES_MIS_PET, 0, 3);
                    tbl.toRight();
                    tbl.addCellB(ApplicationConfigurator.LanguageManager.getString("Dt.Comp.") + ":", 0, 1);
                    tbl.toLeft();
                    tbl.addCell(Formatter.format(www.dtDAT_CMP));
                    //tbl.setDefaultColspan(7);
                    {
                        CenterMiddleTable tb = tbl;//new CenterMiddleTable(4);
                        //tb.toLeft();
                        tbl.addCell("", 0, 2 + iTmp);
                        tb.addCellB(
                                ApplicationConfigurator.LanguageManager.getString("Data.pianificazione") + ":",
                                0, 2);
                        tb.addCellB(
                                ApplicationConfigurator.LanguageManager.getString("Referente.dell'intervento")
                                        + ":",
                                0, 1);
                        tb.addCellB(ApplicationConfigurator.LanguageManager.getString("Data.bonifica") + ":", 0,
                                1);
                        tb.addCellB(ApplicationConfigurator.LanguageManager.getString("Costo.intervento") + ":",
                                0, 2);

                        tbl.addCell("", 0, 2 + iTmp);
                        tb.addCell(".... / .... / ....", 0, 2);
                        tb.addCell(".............................................");
                        tb.addCell(".... / .... / ....");
                        tb.addCell(".................................", 0, 2);
                        //tbl.insertTable(tb);
                    }
                    //tbl.setDefaultColspan(1);
                }
            }
        }
    }

}

From source file:s2s.luna.reports.Report_REP_AZL_GSE.java

License:GNU General Public License

@Override
public void doReport() throws DocumentException, IOException, BadElementException, Exception {
    String strTemp = "";
    IAziendaHome home = (IAziendaHome) PseudoContext.lookup("AziendaBean");
    IAzienda bean = home.findByPrimaryKey(new Long(lCOD_AZL));

    initDocument("the doc", null,
            IncludeLogo ? ApplicationConfigurator.LanguageManager.getString("SCHEDA.AZIENDALE")
                    : ApplicationConfigurator.LanguageManager.getString("Informazioni.preliminari"),
            bean.getRAG_SCL_AZL(), null);
    if (IncludeLogo) {
        AddImage();//from   w  w w  . ja  v a  2  s .  c om
    }
    // writeIndent();
    {
        CenterMiddleTable tbl = new CenterMiddleTable(1);
        tbl.addHeaderCellB(IncludeLogo ? ApplicationConfigurator.LanguageManager.getString("SCHEDA.AZIENDALE")
                : ApplicationConfigurator.LanguageManager.getString("Informazioni.preliminari"));
        tbl.addTitleCell(bean.getRAG_SCL_AZL());
        m_document.add(tbl);
    }
    {// Dati anagrafici
        writeParagraph1(ApplicationConfigurator.LanguageManager.getString("Dati.anagrafici"));
        CenterMiddleTable tbl = new CenterMiddleTable(2);
        tbl.toLeft();
        int width[] = { 30, 79 };
        tbl.setWidths(width);

        tbl.addCell(ApplicationConfigurator.LanguageManager.getString("Attivit.svolta")); //ok
        tbl.addCell(bean.getDES_ATI_SVO_AZL());
        tbl.addCell(ApplicationConfigurator.LanguageManager.getString("Indirizzo.n.civico"));// ok
        tbl.addCell(bean.getIDZ_AZL() + ", " + bean.getNUM_CIC_AZL());
        tbl.addCell(ApplicationConfigurator.LanguageManager.getString("Citt.C.A.P."));// ok
        if (bean.getCAP_AZL() != null) {
            tbl.addCell(bean.getCIT_AZL() + " - " + bean.getCAP_AZL());
        } else {
            tbl.addCell(bean.getCIT_AZL());
        }
        tbl.addCell(ApplicationConfigurator.LanguageManager.getString("Provincia"));// ok
        tbl.addCell(bean.getPRV_AZL());
        tbl.addCell(ApplicationConfigurator.LanguageManager.getString("Nazionalit"));// ok
        strTemp = "";
        INazionalitaHome h = (INazionalitaHome) PseudoContext.lookup("NazionalitaBean");
        INazionalita b = h.findByPrimaryKey(new Long(bean.getCOD_STA()));
        tbl.addCell(b.getNOM_STA());
        m_document.add(tbl);
    }
    {// Dati sulla sicurezza
        writeParagraph1(ApplicationConfigurator.LanguageManager.getString("Dati.sulla.sicurezza"));
        CenterMiddleTable tbl = new CenterMiddleTable(2);
        tbl.toLeft();
        int width[] = { 30, 79 };
        tbl.setWidths(width);

        tbl.addCell(ApplicationConfigurator.LanguageManager.getString("Datore.di.lavoro"));// ok
        tbl.addCell(bean.getNOM_RSP_AZL());
        tbl.addCell(ApplicationConfigurator.LanguageManager.getString("Qualifica.del.datore.lavoro"));//ok
        tbl.addCell(bean.getQLF_RSP_AZL());

        tbl.addCell(ApplicationConfigurator.LanguageManager.getString("Resp.aziendale.SPP"));// ok
        tbl.addCell(bean.getNOM_RSP_SPP_AZL());
        tbl.addCell(ApplicationConfigurator.LanguageManager.getString("Medico.competente"));// ok
        tbl.addCell(bean.getNOM_MED_AZL());
        m_document.add(tbl);
    }
    {// Altro
        writeParagraph1(ApplicationConfigurator.LanguageManager.getString("Altro"));
        CenterMiddleTable tbl = new CenterMiddleTable(2);
        tbl.toLeft();
        int width[] = { 30, 79 };
        tbl.setWidths(width);

        tbl.addCell(ApplicationConfigurator.LanguageManager.getString("E-mail.aziendale"));// ok
        tbl.addCell(bean.getIDZ_PSA_ELT_RSP_AZL());
        tbl.addCell(ApplicationConfigurator.LanguageManager.getString("Sito.internet.aziendale"));// ok
        tbl.addCell(bean.getSIT_INT_AZL());
        tbl.addCell(ApplicationConfigurator.LanguageManager.getString("Azienda.associata"));
        if (bean.getCOD_AZL_ASC() == 0) {
            tbl.addCell("");
        } else {
            strTemp = "";
            IAziendaHome h = (IAziendaHome) PseudoContext.lookup("AziendaBean");
            IAzienda b = h.findByPrimaryKey(new Long(bean.getCOD_AZL_ASC()));

            tbl.addCell(b.getRAG_SCL_AZL());
        }
        tbl.addCell(ApplicationConfigurator.LanguageManager.getString("Codice.ISTAT"));//ok
        tbl.addCell(bean.getCOD_IST_TAT_AZL());
        tbl.addCell(ApplicationConfigurator.LanguageManager.getString("Telefoni.utili"));//ok
        strTemp = "";
        IAziendaTelefonoHome h = (IAziendaTelefonoHome) PseudoContext.lookup("AziendaTelefonoBean");
        Iterator it = h.getAziendaTelefoniByAZLID_View(lCOD_AZL).iterator();
        while (it.hasNext()) {
            AziendaTelefoniByAZLID_View w = (AziendaTelefoniByAZLID_View) it.next();
            strTemp += w.NUM_TEL;
            if (it.hasNext()) {
                strTemp += ", ";
            }
        }
        tbl.addCell(strTemp);
        m_document.add(tbl);
    }
    {// Rappresentanti dei lavoratori
        writeParagraph1(ApplicationConfigurator.LanguageManager.getString("Rappresentanti.dei.lavoratori"));
        CenterMiddleTable tbl = new CenterMiddleTable(2);
        tbl.toLeft();
        int width[] = { 30, 79 };
        tbl.setWidths(width);

        Cell rlsCell = new Cell(ApplicationConfigurator.LanguageManager.getString("R.L.S."));
        rlsCell.setVerticalAlignment(Element.ALIGN_TOP);
        tbl.addCell(rlsCell);//ok
        strTemp = "";
        IDipendenteHome home_dpd = (IDipendenteHome) PseudoContext.lookup("DipendenteBean");
        java.util.Iterator it_dip = home_dpd.getDipendentiByAZLID_RLS_View(lCOD_AZL).iterator();
        while (it_dip.hasNext()) {
            DipendentiByAZLID_View dt = (DipendentiByAZLID_View) it_dip.next();
            strTemp += Formatter.format(dt.COG_DPD);
            strTemp += " " + Formatter.format(dt.NOM_DPD);
            if (it_dip.hasNext()) {
                strTemp += "\n";
            }
        }
        tbl.addCell(strTemp);
        m_document.add(tbl);
    }
    {// Siti aziendali
        writeParagraph1(ApplicationConfigurator.LanguageManager.getString("Sedi"));
        CenterMiddleTable tbl = new CenterMiddleTable(5);
        tbl.toLeft();
        int width[] = { 22, 25, 25, 20, 8 };
        tbl.setWidths(width);

        tbl.addHeaderCellB(ApplicationConfigurator.LanguageManager.getString("Sede"));// ok
        tbl.addHeaderCellB(ApplicationConfigurator.LanguageManager.getString("Immobile"));// ok
        tbl.addHeaderCellB(ApplicationConfigurator.LanguageManager.getString("Indirizzo"));
        tbl.addHeaderCellB(ApplicationConfigurator.LanguageManager.getString("Citt.C.A.P."));
        tbl.addHeaderCellB(ApplicationConfigurator.LanguageManager.getString("Prov."));
        tbl.endHeaders();

        IImmobili3lvHome imm3lv = (IImmobili3lvHome) PseudoContext.lookup("Immobili3lvBean");
        Iterator imm3lv_it = imm3lv.findEx(lCOD_AZL, null, null, null, null, null, null, null, null, 0)
                .iterator();
        String previousNOM_SIT_AZL = "";
        while (imm3lv_it.hasNext()) {
            Immobili3liv_View immobile3lv = (Immobili3liv_View) imm3lv_it.next();
            Cell nomSitAzlCell = null;
            // Cambio sede
            if (previousNOM_SIT_AZL.equals(immobile3lv.NOM_SIT_AZL) == false) {
                nomSitAzlCell = new Cell(immobile3lv.NOM_SIT_AZL);
                if (imm3lv_it.hasNext()) {
                    nomSitAzlCell.setBorder(Rectangle.TOP | Rectangle.LEFT | Rectangle.RIGHT);
                }
                // Sede uguale alle precedente
            } else {
                nomSitAzlCell = new Cell("");
                if (imm3lv_it.hasNext()) {
                    nomSitAzlCell.setBorder(Rectangle.LEFT | Rectangle.RIGHT);
                } else {
                    nomSitAzlCell.setBorder(Rectangle.LEFT | Rectangle.RIGHT | Rectangle.BOTTOM);
                }
            }
            tbl.addCell(nomSitAzlCell);
            previousNOM_SIT_AZL = immobile3lv.NOM_SIT_AZL;
            tbl.addCell(Formatter.format(immobile3lv.NOM_IMM));
            tbl.addCell(Formatter.format(immobile3lv.IND_IMM)
                    + (StringManager.isNotEmpty(immobile3lv.IND_IMM)
                            && StringManager.isNotEmpty(immobile3lv.NUM_CIV_IMM) ? ", " : "")
                    + Formatter.format(immobile3lv.NUM_CIV_IMM));
            tbl.addCell(Formatter.format(immobile3lv.CIT_IMM)
                    + (StringManager.isNotEmpty(immobile3lv.CIT_IMM)
                            && StringManager.isNotEmpty(immobile3lv.CAP_IMM) ? " - " : "")
                    + Formatter.format(immobile3lv.CAP_IMM));
            tbl.addCell(Formatter.format(immobile3lv.PRO_IMM));
        }
        m_document.add(tbl);
    }
    closeDocument();
}