Example usage for com.lowagie.text Rectangle setRight

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

Introduction

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

Prototype

public void setRight(float urx) 

Source Link

Document

Sets the upper right x-coordinate.

Usage

From source file:com.estate.pdf.Page.java

protected Rectangle toPage(float orgX, float orgY, Rectangle orgRect) {
    Rectangle rct = new Rectangle(orgRect);

    rct.setLeft(rct.getLeft() + orgX);/* w ww  .  j  a va 2 s  .  co  m*/
    rct.setRight(rct.getRight() + orgX);
    rct.setTop(rct.getTop() + orgY);
    rct.setBottom(rct.getBottom() + orgY);

    return rct;
}

From source file:com.estate.pdf.PageBorder.java

public void draw(Document doc, int iconNum, String pageNum, String toolName) {
    try {/*from   www  .  j  a  v a  2s  .  c o m*/
        PdfContentByte cb = writer.getDirectContentUnder();
        BaseFont fontBold = BaseFont.createFont(Locations.getFontLocation() + "timesbd.ttf", BaseFont.CP1252,
                BaseFont.EMBEDDED);
        BaseFont font = BaseFont.createFont(Locations.getFontLocation() + "times.ttf", BaseFont.CP1252,
                BaseFont.EMBEDDED);
        Rectangle rct = new Rectangle(doc.getPageSize());
        float iconBase = (1.25f * 72); // This is the base of the icons on
        // the page
        Image icon = Image.getInstance(Locations.getImageLocation() + icons[iconNum]);
        // Image box = Image.getInstance(Locations.ImageLocation() +
        // "blueBOX.png");
        icon.scalePercent(23);
        float scale = .23f;
        float iconLeft = (icon.getWidth() / 2) * scale;
        float boxSize = (.1875f * 72);

        // Adjust the top
        rct.setTop(rct.getTop() - (.5f * 72));

        // Place the Icon
        icon.setAbsolutePosition((1.25f * 72) - iconLeft, rct.getTop() - iconBase);
        doc.add(icon);

        // Set our line color
        cb.setRGBColorStroke(0, 72, 117);

        cb.setLineWidth(.75f);

        // do the bottom line
        cb.moveTo(1.25f * 72, (.5f * 72));
        cb.lineTo(rct.getRight() - (.5f * 72), (.5f * 72));

        cb.moveTo(1.25f * 72, (.5f * 72));
        cb.lineTo(1.25f * 72, rct.getTop());

        // stroke the lines
        cb.stroke();

        // Do the lower left box
        cb.rectangle((1.25f - 0.09375f) * 72, (.5f - 0.09375f) * 72, boxSize, boxSize);
        cb.setRGBColorFill(0, 72, 117);
        cb.closePathFillStroke();

        // Do the lower right box
        Rectangle pnRect = new Rectangle(0, 0);
        pnRect.setLeft(rct.getRight() - ((.5f + 0.09375f) * 72));
        pnRect.setTop((.5f - 0.09375f) * 72);
        pnRect.setRight(pnRect.getLeft() + boxSize);
        pnRect.setBottom(pnRect.getTop() - boxSize);

        // cb.rectangle(rct.getRight() - ((.5f + 0.09375f) * 72), (.5f -
        // 0.09375f) * 72, (.1875f * 72), (.1875f * 72));
        cb.rectangle(pnRect.getLeft(), pnRect.getTop(), boxSize, boxSize);
        cb.setRGBColorFill(0, 72, 117);
        cb.closePathFillStroke();

        // Now we do the page number if one is supplied.
        if (pageNum.length() > 0) {
            float pnHeight = fontBold.getAscentPoint(pageNum, 9) - fontBold.getDescentPoint(pageNum, 9);
            float pnWidth = fontBold.getWidthPoint(pageNum, 9);

            float l = pnRect.getLeft() + ((boxSize - pnWidth) / 2);
            float b = pnRect.getTop() + ((boxSize - pnHeight) / 2);

            cb.beginText();
            cb.setFontAndSize(fontBold, 9);
            cb.setRGBColorFill(255, 255, 255);
            cb.setTextMatrix(l, b);
            cb.showText(pageNum);
            cb.endText();

        }

        // Display the copyright
        SimpleDateFormat df = new SimpleDateFormat("yyyy");
        char cs = 0x00a9; // Unicode for the copyright symbol
        String copyRight = com.estate.constants.StringConstants.copyRight + cs + " " + df.format(new Date());
        float crWidth;
        float crLeft;

        crWidth = font.getWidthPoint(copyRight, 8);
        cb.beginText();

        cb.setFontAndSize(font, 8);
        cb.setRGBColorFill(0, 0, 0);

        crLeft = (doc.getPageSize().getRight() - crWidth) / 2;
        cb.setTextMatrix(crLeft, .375f * 72); // Place the base of the
        // copyright at 3/8" up from
        // the bottom
        cb.showText(copyRight);
        cb.endText();

        if (toolName.length() > 0) {
            cb.beginText();

            cb.setFontAndSize(font, 8);
            cb.setRGBColorFill(0, 0, 0);

            cb.setTextMatrix((1.25f * 72) + boxSize, .375f * 72);
            cb.showText(toolName);
            cb.endText();
        }

        // Fix a licensee at left
        cb.beginText();
        cb.setFontAndSize(font, 8);
        cb.setRGBColorFill(0, 0, 0);
        cb.showTextAligned(PdfContentByte.ALIGN_RIGHT, " Licensee: " + getLicense(), (10.2f * 72), .375f * 72,
                0);
        cb.endText();
    } catch (Exception e) {
        System.out.println(e.getMessage());
    }
}

From source file:com.estate.pdf.PageBorder.java

public void drawNoBorder(Document doc, String pageNum) {
    try {//from ww w .j ava2  s. co  m
        PdfContentByte cb = writer.getDirectContentUnder();
        BaseFont fontBold = BaseFont.createFont(Locations.getFontLocation() + "timesbd.ttf", BaseFont.CP1252,
                BaseFont.EMBEDDED);
        BaseFont font = BaseFont.createFont(Locations.getFontLocation() + "times.ttf", BaseFont.CP1252,
                BaseFont.EMBEDDED);
        Rectangle rct = new Rectangle(doc.getPageSize());
        float boxSize = (.1875f * 72);

        // Adjust the top
        rct.setTop(rct.getTop() - (.5f * 72));

        // Do the lower right box
        Rectangle pnRect = new Rectangle(0, 0);
        pnRect.setLeft(rct.getRight() - ((.5f + 0.09375f) * 72));
        pnRect.setTop(((.5f - 0.09375f) * 72) - 9);
        pnRect.setRight(pnRect.getLeft() + boxSize);
        pnRect.setBottom(pnRect.getTop() - boxSize);

        cb.rectangle(pnRect.getLeft(), pnRect.getTop(), boxSize, boxSize);
        cb.setRGBColorFill(0, 72, 117);
        cb.closePathFillStroke();

        // Now we do the page number if one is supplied.
        if (pageNum.length() > 0) {
            float pnHeight = fontBold.getAscentPoint(pageNum, 9) - fontBold.getDescentPoint(pageNum, 9) - 4.5f;
            float pnWidth = fontBold.getWidthPoint(pageNum, 9);

            float l = pnRect.getLeft() + ((boxSize - pnWidth) / 2);
            float b = pnRect.getTop() + ((boxSize - pnHeight) / 2) - 4.5f;

            cb.beginText();
            cb.setFontAndSize(fontBold, 9);
            cb.setRGBColorFill(255, 255, 255);
            cb.setTextMatrix(l, b);
            cb.showText(pageNum);
            cb.endText();
        }

        // Display the copyright
        SimpleDateFormat df = new SimpleDateFormat("yyyy");
        char cs = 0x00a9; // Unicode for the copyright symbol
        String copyRight = "Advanced Practice Network " + cs + " " + df.format(new Date());
        float crWidth;
        float crLeft;

        crWidth = font.getWidthPoint(copyRight, 8);
        cb.beginText();

        cb.setFontAndSize(font, 8);
        cb.setRGBColorFill(0, 0, 0);

        crLeft = (doc.getPageSize().getRight() - crWidth) / 2;
        cb.setTextMatrix(crLeft, .375f * 72); // Place the base of the
        // copyright at 3/8" up from
        // the bottom
        cb.showText(copyRight);
        cb.endText();

        if (license != null) {
            // Fix a licensee at left
            cb.beginText();
            cb.setFontAndSize(font, 8);
            cb.setRGBColorFill(0, 0, 0);
            cb.showTextAligned(PdfContentByte.ALIGN_RIGHT, " Licensee: " + getLicense(), (10.2f * 72),
                    .375f * 72, 0);
            cb.endText();
        }

    } catch (Exception e) {
        System.out.println(e.getMessage());
    }
}

From source file:com.estate.report.Scenario.java

public Rectangle placeHeading() {
    Rectangle rect = new Rectangle(document.getPageSize());
    BaseFont font = PageUtils.LoadFont("GARA.TTF");
    rect.setBottom(rect.getTop() - (72 * .6f));
    HeadingText ht = new HeadingText(this.writer);
    rect.setBottom(rect.getBottom() - (72 * .33f));
    ht.setColor(57, 57, 57);//from  ww w  . ja v  a2 s.c  o m
    ht.setCapsColor(98, 98, 98);
    if (sc1)
        ht.display(rect, 12f, font, 3f, heading, HeadingText.DHT_CENTER);
    else
        ht.display(rect, 12f, font, 3f, heading2, 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));

    try {
        Rectangle rct = new Rectangle(document.getPageSize());
        float iconBase = (.75f * 72); // This is the base of the icons on
        // the page
        Image icon = Image.getInstance(Locations.getImageLocation() + "pawn.png");
        //    Image box = Image.getInstance(Locations.ImageLocation() +
        //    "blueBOX.png");
        icon.scalePercent(23);
        float scale = .23f;
        float iconLeft = (icon.getWidth() / 2) * scale;

        // Adjust the top
        rct.setTop(rct.getTop());

        // Place the Icon
        icon.setAbsolutePosition((.5f * 72) - iconLeft, rct.getTop() - iconBase);
        document.add(icon);
    } catch (Exception e) {
        System.err.println(e.getMessage());
    }

    drawLifeExp();

    return rect;
}

From source file:com.estate.report.Scenario.java

public void page1() {
    float tallest = 0;
    int colCount = MAX_COLS;
    CFRow continueRow = null;/*from www.j  ava  2  s. co m*/
    float baseWidths[] = initWidths(colCount - 1);
    float widths[] = calcWidths(baseWidths, 11f * 72);
    drawHeader(userInfo.getClientHeading(), "");

    Rectangle agt = placeHeading();
    Rectangle rct = new Rectangle(prctFull);
    rct.setLeft(_1_4TH);
    rct.setRight(rct.getLeft() + 756);
    Rectangle r = doRow(leList(), widths, agt, 17);
    rct.setTop(r.getBottom());
    r = doRow(agesList(), widths, rct, 17);
    rct.setTop(r.getBottom());
    r = doRow(fiscalYearList(), widths, rct, 17);
    rct.setTop(r.getBottom());

    tallest = tallest < r.getHeight() ? r.getHeight() : tallest;

    for (CFRow row : rowList) {
        boolean flag = false;
        if (row.getColNumber() == 0 && row.getIndentLevel() == 0) {
            continueRow = row;
        }

        do {
            flag = false;
            String pdfRow[] = buildRow(row, colCount);
            if (row.isNewPage()) {
                newPage();
                drawHeader(userInfo.getClientHeading(), "");

                agt = placeHeading();
                //rct = new Rectangle(prctFull);
                rct.setLeft(_1_4TH);
                rct.setRight(rct.getLeft() + 756);
                r = doRow(leList(), widths, agt, 17);
                rct.setTop(r.getBottom());
                r = doRow(agesList(), widths, rct, 17);
                rct.setTop(r.getBottom());
                r = doRow(fiscalYearList(), widths, rct, 17);
                rct.setTop(r.getBottom());

                tallest = tallest < r.getHeight() ? r.getHeight() : tallest;
                if (continueRow != null) {
                    if (!row.equals(continueRow)) {
                        row = continueRow;
                        row.setHeader(row.getHeader() + " (cont.)");
                        flag = true;
                    }
                }
            }

            r = doRow(pdfRow, widths, rct, colCount - 1);
            rct.setTop(r.getBottom());
            tallest = tallest < r.getHeight() ? r.getHeight() : tallest;

        } while (flag == true);
    }
}

From source file:com.estate.report.Scenario.java

public Rectangle nextPage(float[] widths) {
    newPage();/* ww w  . ja va 2s.c o m*/
    String user = userInfo.getClientHeading();
    drawHeader(user, "");
    Rectangle agt = placeHeading();
    Rectangle rct = new Rectangle(prctFull);
    rct.setLeft(_1_4TH);
    rct.setRight(rct.getLeft() + 756);
    Rectangle r = null;
    r = doRow(leList(), widths, agt, 17);
    rct.setTop(r.getBottom());
    r = doRow(agesList(), widths, rct, 17);
    rct.setTop(r.getBottom());
    rct.setTop(r.getBottom());
    r = doRow(fiscalYearList(), widths, rct, 17);
    rct.setTop(r.getBottom());
    return rct;
}

From source file:com.teag.reports.CashFlows.java

private void page1() {
    CashFlowTable cft = new CashFlowTable();
    ClientBean cb = new ClientBean();
    CFRow row;//from  w  ww  .  j  av  a 2  s  .  co m
    CFRow continueRow = null;
    float tallest = 0;

    cb.setPrimaryId(clientID);

    cft.setCb(cb);
    cft.init();
    cft.genTable();

    cft.reset();
    int colCount = MAX_ROWS;

    drawHeader(userInfo.getClientHeading(), "");
    Rectangle agt = placeHeading();

    float baseWidths[] = this.initWidths(colCount - 1);
    float widths[] = this.calcWidths(baseWidths, 11.f * 72);

    Rectangle rct = new Rectangle(prctFull);
    rct.setLeft(_1_4TH);
    rct.setRight(rct.getLeft() + 756);

    Rectangle r = doRow(leList(), widths, agt, 17);
    rct.setTop(r.getBottom());
    r = doRow(agesList(), widths, rct, 17);

    rct.setTop(r.getBottom());

    r = doRow(fiscalYearList(), widths, rct, 17);
    rct.setTop(r.getBottom());

    tallest = tallest < r.getHeight() ? r.getHeight() : tallest;

    while ((row = cft.getRow()) != null) {
        boolean flag;
        if (row.getColNumber() == 0 && row.getIndentLevel() == 0) {
            continueRow = row;
        }

        do {
            flag = false;
            boolean nPage = false;
            String pdfRow[] = buildRow(row, colCount);
            if (row.getHeader().startsWith("III.") && !row.getHeader().endsWith("(cont.)")) {
                nPage = true;
            }
            if (row.getHeader().startsWith("IV.") && !row.getHeader().endsWith("(cont.)")) {
                nPage = true;
            }

            // Rectangle r = doSimpleRow(pdfRow, rct);
            if (nPage) {
                // need to span to a new page
                newPage();
                drawHeader(client, "");
                agt = placeHeading();
                rct.setLeft(_1_4TH);
                rct.setRight(rct.getLeft() + 756);

                r = doRow(leList(), widths, agt, 17);
                rct.setTop(r.getBottom());
                r = doRow(agesList(), widths, rct, 17);
                rct.setTop(r.getBottom());
                r = doRow(fiscalYearList(), widths, rct, 17);
                rct.setTop(r.getBottom());
                tallest = tallest < r.getHeight() ? r.getHeight() : tallest;
                if (continueRow != null) {
                    if (!row.equals(continueRow)) {
                        row = continueRow;
                        row.setHeader(row.getHeader() + " (cont.)");
                        flag = true;

                    }
                }
                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, "");
                agt = placeHeading();

                rct.setLeft(_1_4TH);
                rct.setRight(rct.getLeft() + 756);

                r = doRow(leList(), widths, agt, 17);
                rct.setTop(r.getBottom());
                r = doRow(agesList(), widths, rct, 17);
                rct.setTop(r.getBottom());
                r = doRow(fiscalYearList(), widths, rct, 17);
                rct.setTop(r.getBottom());
                tallest = tallest < r.getHeight() ? r.getHeight() : tallest;

                if (continueRow != null) {
                    if (!row.equals(continueRow)) {
                        row = continueRow;
                        row.setHeader(row.getHeader() + " (cont.)");
                        flag = true;
                    }
                }
            }
        } while (flag == true);
    }
    cft.cleanUp();
}

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);//  w  w w  .  j a  v a  2s  . c  o 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.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;//  w  w w .j  a va2s . com
    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);/*from   www  .j  ava 2  s.  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.0f * 72);
    drawHeader(client, "");
    PageBorder pb = new PageBorder(writer);
    pb.setLicense(userInfo.getPlannerFirstName() + " " + userInfo.getPlannerLastName());
    pb.drawNoBorder(document, Integer.toString(pageNum));
    drawLifeExp();

    return (rect);
}