Example usage for com.lowagie.text Rectangle getTop

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

Introduction

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

Prototype

public float getTop() 

Source Link

Document

Returns the upper right y-coordinate.

Usage

From source file:ch.gpb.elexis.kgexporter.pdf.HeaderFooterPageEvent.java

License:Open Source License

public void onStartPage(PdfWriter writer, Document document) {
    Rectangle rect = writer.getBoxSize("art");

    ColumnText.showTextAligned(writer.getDirectContent(), Element.ALIGN_LEFT, new Phrase(sbHeader),
            rect.getLeft(), rect.getTop(), 0);

    ColumnText.showTextAligned(writer.getDirectContent(), Element.ALIGN_RIGHT, new Phrase(sDate),
            rect.getRight(), rect.getTop(), 0);

    PdfContentByte cb = writer.getDirectContentUnder();

    //cb.rectangle(document.left(), document.top(),
    //   document.right() - document.left(), document.top() - 25);
    /*/*  ww  w.  j  a  v  a2  s.c  o  m*/
    System.out.println("l: " + document.left());
    System.out.println("r: " + document.right());
    System.out.println("t: " + document.top());
    System.out.println("b: " + document.bottom());
    l: 36.0
    r: 559.0
    t: 806.0
    b: 36.0
    */

    //Rectangle rect2 = new Rectangle(document.top() - 36, document.top() - 36, 559, 1);

    /*
    float l = 36f;
    float r = 36f;
    float t = 559f;
    float b = 2f;
            
    Rectangle rect2 = new Rectangle(l, r, t, b);
            
    //Rectangle rect2 = new Rectangle(36, 36, 559, 1);
    rect2.setBorder(Rectangle.BOTTOM);
    rect2.setBorderWidth(0.5f);
    cb.rectangle(rect2);
            
    //cb.setColorStroke(Color.BLACK);
    */

    /*
    for (int i = 30; i > 0; i--) {
        System.err.println((float) i / 10);
        cb.setLineWidth((float) i / 10);
        cb.moveTo(36, 806 - (5 * i));
        cb.lineTo(400, 806 - (5 * i));
        cb.stroke();
    }
    cb.moveTo(10, 50);
    cb.lineTo(559, 50);
     */
    cb.setLineWidth(0.5f);
    cb.moveTo(30, 791);
    cb.lineTo(559, 791);

    cb.stroke();

}

From source file:classroom.filmfestival_c.Movies19.java

@SuppressWarnings("unchecked")
protected static void createSheet(Session session, Date date, PdfWriter writer) {
    Query q;/*ww w  . j a  v  a2s  . co m*/
    q = session.createQuery(
            "select distinct screening.id.place from FestivalScreening as screening where id.day=? order by screening.id.place");
    q.setDate(0, date);
    List<String> places = q.list();

    Rectangle art = writer.getBoxSize("art");
    // initialize the dimensions for this day
    float top = art.getTop();
    float row_height = art.getHeight() / places.size();
    if (row_height > 70) {
        row_height = 70;
    }
    float column_width = art.getWidth() / COLUMNS;
    float left = art.getLeft() + column_width;
    float minute = (2f * column_width) / 60f;

    // content
    drawGrid(writer, places, date.toString(), left, column_width, top, row_height);

    q = session.createQuery("from FestivalScreening where id.day=? order by id.time, id.place");
    q.setDate(0, date);
    List<FestivalScreening> screenings = q.list();
    for (FestivalScreening screening : screenings) {
        try {
            drawMovie(writer, screening, places, minute, left, top, row_height);
        } catch (DocumentException e) {
            LOGGER.error("DocumentException: ", e);
        }
    }
}

From source file:classroom.filmfestival_c.Movies19.java

protected static void drawGrid(PdfWriter writer, List<String> places, String day, float left,
        float column_width, float top, float row_height) {

    // CANVAS//w w  w . ja v  a 2  s . co  m
    PdfContentByte directcontent = writer.getDirectContent();
    Rectangle art = writer.getBoxSize("art");

    // LINES

    directcontent.setLineWidth(1);
    float bottom = art.getTop();

    // rows
    int rows = places.size();
    for (int i = 0; i <= rows; i++) {
        directcontent.moveTo(art.getLeft(), art.getTop() - (i * row_height));
        directcontent.lineTo(art.getRight(), art.getTop() - (i * row_height));
        bottom = art.getTop() - (i * row_height);
    }

    // Rectangle
    directcontent.moveTo(art.getLeft(), art.getTop());
    directcontent.lineTo(art.getLeft(), bottom);
    directcontent.moveTo(left, art.getTop());
    directcontent.lineTo(left, bottom);
    directcontent.moveTo(art.getLeft() + (COLUMNS * column_width), art.getTop());
    directcontent.lineTo(art.getLeft() + (COLUMNS * column_width), bottom);
    directcontent.stroke();

    // columns
    directcontent.saveState();
    directcontent.setLineWidth(0.3f);
    directcontent.setColorStroke(SILVER);
    directcontent.setLineDash(3, 1);
    for (int i = 2; i < COLUMNS; i++) {
        directcontent.moveTo(art.getLeft() + (i * column_width), art.getTop());
        directcontent.lineTo(art.getLeft() + (i * column_width), bottom);
    }
    directcontent.stroke();
    directcontent.restoreState();

    // TEXT

    // date
    directcontent.beginText();
    directcontent.setFontAndSize(FONT, 12);
    directcontent.showTextAligned(Element.ALIGN_RIGHT, day, art.getLeft() - 5, art.getTop(), 90);
    directcontent.endText();

    // time
    for (int i = 1; i < COLUMNS; i++) {
        directcontent.beginText();
        directcontent.setFontAndSize(FONT, 8);
        directcontent.showTextAligned(Element.ALIGN_LEFT, TIME[i - 1], art.getLeft() + (i * column_width) + 5,
                top + 5, 90);
        directcontent.endText();
    }

    // places
    for (int i = 0; i < rows; i++) {
        directcontent.beginText();
        directcontent.setFontAndSize(FONT, 12);
        directcontent.showTextAligned(Element.ALIGN_CENTER, places.get(i), art.getLeft() + 16,
                art.getTop() - ((i + 0.5f) * row_height), 90);
        directcontent.endText();
    }
}

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

protected void drawRectangle(Rectangle rct, Color color) {
    drawLine(rct.getLeft(), rct.getTop(), rct.getLeft(), rct.getBottom(), color); // Left
    drawLine(rct.getLeft(), rct.getTop(), rct.getRight(), rct.getTop(), color); // Top
    drawLine(rct.getRight(), rct.getTop(), rct.getRight(), rct.getBottom(), color); // right
    drawLine(rct.getLeft(), rct.getBottom(), rct.getRight(), rct.getBottom(), color); // Bottom

}

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

protected void drawSpacingGrid(Rectangle rct, float spacing, Color color) {
    PdfContentByte cb = writer.getDirectContentUnder();

    cb.setLineWidth(.25f);//from   w  w  w .j  a  v  a 2s.c om
    cb.setColorStroke(color);
    for (float x = 0; x < rct.getRight(); x += spacing) {
        cb.moveTo(x, 0);
        cb.lineTo(x, rct.getTop());
    }

    for (float y = 0; y < rct.getTop(); y += spacing) {
        cb.moveTo(0, y);
        cb.lineTo(rct.getRight(), y);
    }

    cb.stroke();

}

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);//ww  w  .ja v a 2  s  . com
    rct.setRight(rct.getRight() + orgX);
    rct.setTop(rct.getTop() + orgY);
    rct.setBottom(rct.getBottom() + orgY);

    return rct;
}

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

protected Rectangle translateRect(Rectangle rct) {
    Rectangle rctPage = new Rectangle(document.getPageSize());

    rct = new Rectangle(rct.getLeft(), rctPage.getTop() - rct.getBottom(), rct.getRight(),
            rctPage.getTop() - rct.getTop());
    return (rct);
}

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

public void draw(Document doc, int iconNum, String pageNum, String toolName) {
    try {/*from   ww w .java2s . 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 w  ww . java  2  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);// w  w  w  . j  a  v a  2s .  com
    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;
}