Example usage for com.lowagie.text Rectangle getLeft

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

Introduction

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

Prototype

public float getLeft() 

Source Link

Document

Returns the lower left x-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);
    /*//from  w w w.  j  a  v  a  2 s.  com
    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:ch.gpb.elexis.kgexporter.pdf.HeaderFooterPageEvent.java

License:Open Source License

public void onEndPage(PdfWriter writer, Document document) {
    Rectangle rect = writer.getBoxSize("art");
    ColumnText.showTextAligned(writer.getDirectContent(), Element.ALIGN_LEFT, new Phrase(this.sbFooter),
            rect.getLeft(), rect.getBottom(), 0);

    /*/*from w w w.  j  a va  2  s .co m*/
    ColumnText.showTextAligned(writer.getDirectContent(), Element.ALIGN_CENTER, new Phrase("Bottom Right"),
       rect.getRight(), rect.getBottom(), 0);
    */
    PdfContentByte cb = writer.getDirectContentUnder();

    cb.setLineWidth(0.5f);

    cb.moveTo(30, 50);
    cb.lineTo(559, 50);
    cb.stroke();

}

From source file:classroom.filmfestival_c.Movies19.java

@SuppressWarnings("unchecked")
protected static void createSheet(Session session, Date date, PdfWriter writer) {
    Query q;//from  w  w  w  .j  a  v a  2 s.  c  o 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//from  w ww  .  j  a  v a 2s .  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 Rectangle adjustPlacement(Rectangle rctIn) {
    Rectangle rctOut = new Rectangle(rctIn);

    rctOut.setLeft(rctOut.getLeft() - _1_4TH);
    rctOut.setBottom(rctOut.getBottom() - _1_4TH);
    return rctOut;
}

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

protected void drawFilledRect(Rectangle rct, Color color) {
    PdfContentByte cb = writer.getDirectContentUnder();
    // Do the lower left box
    cb.setLineWidth(0);//from  w  w  w .  j  a  v a 2 s.  c  o  m
    cb.setRGBColorStroke(255, 255, 255);
    cb.rectangle(rct.getLeft(), rct.getBottom(), rct.getWidth(), rct.getHeight());
    cb.setColorFill(color);
    cb.closePathFillStroke();
}

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 Rectangle toPage(float orgX, float orgY, Rectangle orgRect) {
    Rectangle rct = new Rectangle(orgRect);

    rct.setLeft(rct.getLeft() + orgX);
    rct.setRight(rct.getRight() + orgX);
    rct.setTop(rct.getTop() + orgY);/*  w  ww.j av a2 s  .  co m*/
    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 {/*www.  j  a va2s  .c  om*/
        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());
    }
}