Search in sources :

Example 11 with Paragraph

use of com.lowagie.text.Paragraph in project mdw-designer by CenturyLinkCloud.

the class ExportHelper method printNodePdf.

private void printNodePdf(Node node, Chapter chapter) throws Exception {
    Section section;
    String id = node.getDisplayId(nodeIdType);
    if (id == null || id.length() == 0)
        id = node.getId().toString();
    String tmp = ACTIVITY + id + ": \"" + node.getName().replace('\n', ' ') + "\n";
    Paragraph sTitle = new Paragraph(tmp, sectionFont);
    section = chapter.addSection(sTitle, options.contains(SECTION_NUMBER) ? 2 : 0);
    String summary = node.getAttribute(WorkAttributeConstant.DESCRIPTION);
    if (summary != null && summary.length() > 0) {
        printBoldParagraphsPdf(section, summary);
    }
    if (options.contains(DOCUMENTATION)) {
        String detail = node.getAttribute(WorkAttributeConstant.DOCUMENTATION);
        if (detail != null && detail.length() > 0) {
            printHtmlParagraphsPdf(section, detail, options.contains(SECTION_NUMBER) ? 2 : 0);
            section.add(new Paragraph("\n", FontFactory.getFont(FontFactory.TIMES, 4, Font.NORMAL, new Color(0, 0, 0))));
        }
    }
    if (options.contains(ATTRIBUTES) && !node.getAttributes().isEmpty()) {
        printAttributesPdf(section, node.getAttributes(), options.contains(SECTION_NUMBER) ? 2 : 0);
    }
    section.add(new Paragraph("\n", normalFont));
}
Also used : Color(java.awt.Color) Section(com.lowagie.text.Section) Paragraph(com.lowagie.text.Paragraph)

Example 12 with Paragraph

use of com.lowagie.text.Paragraph in project mdw-designer by CenturyLinkCloud.

the class ExportHelper method printVariablesPdf.

private void printVariablesPdf(Chapter chapter, List<VariableVO> variables, int parentLevel) {
    Paragraph sTitle = new Paragraph("Process Variables", sectionFont);
    Section section = chapter.addSection(sTitle, parentLevel == 0 ? 0 : (parentLevel + 1));
    com.lowagie.text.List list = new com.lowagie.text.List(false, false, 10.0f);
    for (VariableVO var : variables) {
        Phrase phrase = new Phrase();
        phrase.add(new Chunk(var.getVariableName(), fixedWidthFont));
        String v = var.getVariableType();
        if (var.getDescription() != null)
            v += " (" + var.getDescription() + ")";
        phrase.add(new Chunk(": " + v + "\n", normalFont));
        list.add(new ListItem(phrase));
    }
    section.add(list);
}
Also used : VariableVO(com.centurylink.mdw.model.value.variable.VariableVO) List(java.util.List) ArrayList(java.util.ArrayList) Phrase(com.lowagie.text.Phrase) ListItem(com.lowagie.text.ListItem) Chunk(com.lowagie.text.Chunk) Section(com.lowagie.text.Section) Paragraph(com.lowagie.text.Paragraph)

Example 13 with Paragraph

use of com.lowagie.text.Paragraph in project boxmaker by rahulbot.

the class Renderer method drawAllSides.

/**
 * Actually draw all the faces of the box
 * @param mmWidth			the width of the box in millimeters
 * @param mmHeight			the height of the box in millimeters
 * @param mmDepth			the depth of the box in millimeters
 * @param mmThickness		the thickness of the material in millimeters
 * @param mmCutWidth		the width of the laser beam
 * @param mmNotchLength		the length of the notch to use to hold the box together
 * @param drawBoundingBox 	draw an outer edge with a dimension (for easier DXF import)
 * @param specifiedInInches the user specified the box in inches?
 * @param fileName          the name of the file to write
 * @throws FileNotFoundException
 * @throws DocumentException
 */
public void drawAllSides(double mmWidth, double mmHeight, double mmDepth, double mmThickness, double mmCutWidth, double mmNotchLength, boolean drawBoundingBox, boolean specifiedInInches, String fileName) throws FileNotFoundException, DocumentException {
    float width = (float) mmWidth;
    float height = (float) mmHeight;
    float depth = (float) mmDepth;
    float thickness = (float) mmThickness;
    float notchLength = (float) mmNotchLength;
    float cutwidth = (float) mmCutWidth;
    // enlarge the box to compensate for cut width
    width += cutwidth;
    height += cutwidth;
    depth += cutwidth;
    // figure out how many notches for each side, trying to make notches about the right length.
    int numNotchesW = closestOddTo(width / notchLength);
    int numNotchesH = closestOddTo(height / notchLength);
    int numNotchesD = closestOddTo(depth / notchLength);
    // compute exact notch lengths
    float notchLengthW = width / (numNotchesW);
    float notchLengthH = height / (numNotchesH);
    float notchLengthD = depth / (numNotchesD);
    // and compute the new width based on that (should be a NO-OP)
    float margin = 10 + cutwidth;
    width = numNotchesW * notchLengthW;
    height = numNotchesH * notchLengthH;
    depth = numNotchesD * notchLengthD;
    // initialize the eps file
    // based on layout of pieces
    float boxPiecesWidth = (depth * 2 + width);
    // based on layout of pieces
    float boxPiecesHeight = (height * 2 + depth * 2);
    openDoc((float) (boxPiecesWidth + margin * 4), (float) (boxPiecesHeight + margin * 5), fileName);
    if (specifiedInInches) {
        doc.add(new Paragraph("Width (in): " + width * INCH_PER_MM));
        doc.add(new Paragraph("Height (in): " + height * INCH_PER_MM));
        doc.add(new Paragraph("Depth (in): " + depth * INCH_PER_MM));
        doc.add(new Paragraph("Thickness (in): " + thickness * INCH_PER_MM));
        doc.add(new Paragraph("Notch Length (in): " + notchLength * INCH_PER_MM));
        doc.add(new Paragraph("Cut Width (in): " + cutwidth * INCH_PER_MM));
    } else {
        doc.add(new Paragraph("Width (mm): " + width));
        doc.add(new Paragraph("Height (mm): " + height));
        doc.add(new Paragraph("Depth (mm): " + depth));
        doc.add(new Paragraph("Thickness (mm): " + thickness));
        doc.add(new Paragraph("Notch Length (mm): " + notchLength));
        doc.add(new Paragraph("Cut Width (mm): " + cutwidth));
    }
    if (drawBoundingBox)
        drawBoundingBox(margin, boxPiecesWidth + margin * 2, boxPiecesHeight + margin * 3, specifiedInInches);
    // start the drawing phase
    float xOrig = 0;
    float yOrig = 0;
    // compensate for the cut width (in part) by increasing mwidth (eolson)
    // no, don't do that, because the cut widths cancel out. (eolson)
    // mwidth+=cutwidth/2;
    // 1. a W x H side (the back)
    xOrig = depth + margin * 2;
    yOrig = margin;
    // top
    drawHorizontalLine(xOrig, yOrig, notchLengthW, numNotchesW, thickness, cutwidth / 2, false, false);
    // bottom
    drawHorizontalLine(xOrig, yOrig + height - thickness, notchLengthW, numNotchesW, thickness, cutwidth / 2, true, false);
    // left
    drawVerticalLine(xOrig, yOrig, notchLengthH, numNotchesH, thickness, cutwidth / 2, false, false);
    // right
    drawVerticalLine(xOrig + width - thickness, yOrig, notchLengthH, numNotchesH, thickness, -cutwidth / 2, false, false);
    // 2. a D x H side (the left side)
    xOrig = margin;
    yOrig = height + margin * 2;
    // top
    drawHorizontalLine(xOrig, yOrig, notchLengthD, numNotchesD, thickness, cutwidth / 2, false, false);
    // bottom
    drawHorizontalLine(xOrig, yOrig + height - thickness, notchLengthD, numNotchesD, thickness, cutwidth / 2, true, false);
    // left
    drawVerticalLine(xOrig, yOrig, notchLengthH, numNotchesH, thickness, cutwidth / 2, false, false);
    // right
    drawVerticalLine(xOrig + depth - thickness, yOrig, notchLengthH, numNotchesH, thickness, -cutwidth / 2, false, false);
    // 3. a W x D side (the bottom)
    xOrig = depth + margin * 2;
    yOrig = height + margin * 2;
    // top
    drawHorizontalLine(xOrig, yOrig, notchLengthW, numNotchesW, thickness, -cutwidth / 2, true, true);
    // bottom
    drawHorizontalLine(xOrig, yOrig + depth - thickness, notchLengthW, numNotchesW, thickness, -cutwidth / 2, false, true);
    // left
    drawVerticalLine(xOrig, yOrig, notchLengthD, numNotchesD, thickness, -cutwidth / 2, true, true);
    // right
    drawVerticalLine(xOrig + width - thickness, yOrig, notchLengthD, numNotchesD, thickness, -cutwidth / 2, false, true);
    // 4. a D x H side (the right side)
    xOrig = depth + width + margin * 3;
    yOrig = height + margin * 2;
    // top
    drawHorizontalLine(xOrig, yOrig, notchLengthD, numNotchesD, thickness, cutwidth / 2, false, false);
    // bottom
    drawHorizontalLine(xOrig, yOrig + height - thickness, notchLengthD, numNotchesD, thickness, cutwidth / 2, true, false);
    // left
    drawVerticalLine(xOrig, yOrig, notchLengthH, numNotchesH, thickness, cutwidth / 2, false, false);
    // right
    drawVerticalLine(xOrig + depth - thickness, yOrig, notchLengthH, numNotchesH, thickness, -cutwidth / 2, false, false);
    // 5. a W x H side (the front)
    xOrig = depth + margin * 2;
    yOrig = height + depth + margin * 3;
    // top
    drawHorizontalLine(xOrig, yOrig, notchLengthW, numNotchesW, thickness, cutwidth / 2, false, false);
    // bottom
    drawHorizontalLine(xOrig, yOrig + height - thickness, notchLengthW, numNotchesW, thickness, cutwidth / 2, true, false);
    // left
    drawVerticalLine(xOrig, yOrig, notchLengthH, numNotchesH, thickness, cutwidth / 2, false, false);
    // right
    drawVerticalLine(xOrig + width - thickness, yOrig, notchLengthH, numNotchesH, thickness, -cutwidth / 2, false, false);
    // 3. a W x D side (the top)
    xOrig = depth + margin * 2;
    yOrig = height * 2 + depth + margin * 4;
    // top
    drawHorizontalLine(xOrig, yOrig, notchLengthW, numNotchesW, thickness, -cutwidth / 2, true, true);
    // bottom
    drawHorizontalLine(xOrig, yOrig + depth - thickness, notchLengthW, numNotchesW, thickness, -cutwidth / 2, false, true);
    // left
    drawVerticalLine(xOrig, yOrig, notchLengthD, numNotchesD, thickness, -cutwidth / 2, true, true);
    // right
    drawVerticalLine(xOrig + width - thickness, yOrig, notchLengthD, numNotchesD, thickness, -cutwidth / 2, false, true);
}
Also used : Paragraph(com.lowagie.text.Paragraph)

Example 14 with Paragraph

use of com.lowagie.text.Paragraph in project OpenClinica by OpenClinica.

the class DownloadDiscrepancyNote method createCell.

private Cell createCell(String propertyName, String propertyValue) throws BadElementException {
    StringBuilder content = new StringBuilder(propertyName + ": ");
    content.append(propertyValue);
    Paragraph para = new Paragraph(content.toString(), new Font(Font.HELVETICA, 14, Font.BOLD, new Color(0, 0, 0)));
    return new Cell(para);
}
Also used : Color(java.awt.Color) Cell(com.lowagie.text.Cell) Font(com.lowagie.text.Font) Paragraph(com.lowagie.text.Paragraph)

Example 15 with Paragraph

use of com.lowagie.text.Paragraph in project drools by kiegroup.

the class EndPage method createFirstPage.

public static void createFirstPage(Document document, String currentDate, DrlPackageParser packageData) throws DocumentException {
    Paragraph title = new Paragraph("\n\n\n\n\n" + packageData.getName().toUpperCase(), RULE_PACKAGE_TITLE);
    title.setAlignment(Element.ALIGN_CENTER);
    document.add(title);
    Paragraph date = new Paragraph("Documentation created: " + currentDate, BODY_TEXT);
    date.setAlignment(Element.ALIGN_CENTER);
    document.add(date);
    document.add(new Paragraph("\n\n\n\n\n" + packageData.getDescription(), BODY_TEXT));
    document.add(newTable("Metadata ", packageData.getMetadata()));
    document.add(newTable("Globals ", packageData.getGlobals()));
    createOtherItems(document, packageData.getOtherInformation());
}
Also used : Paragraph(com.lowagie.text.Paragraph)

Aggregations

Paragraph (com.lowagie.text.Paragraph)43 Font (com.lowagie.text.Font)14 DocumentException (com.lowagie.text.DocumentException)13 Color (java.awt.Color)13 Document (com.lowagie.text.Document)12 Chunk (com.lowagie.text.Chunk)11 Cell (com.lowagie.text.Cell)9 Phrase (com.lowagie.text.Phrase)7 Section (com.lowagie.text.Section)7 PdfPCell (com.lowagie.text.pdf.PdfPCell)7 ByteArrayOutputStream (java.io.ByteArrayOutputStream)7 List (java.util.List)7 ArrayList (java.util.ArrayList)6 Table (com.lowagie.text.Table)5 DiscrepancyNoteBean (org.akaza.openclinica.bean.managestudy.DiscrepancyNoteBean)5 ListItem (com.lowagie.text.ListItem)4 PdfPTable (com.lowagie.text.pdf.PdfPTable)4 IOException (java.io.IOException)4 ServletOutputStream (javax.servlet.ServletOutputStream)4 ExpressionException (cbit.vcell.parser.ExpressionException)3