Search in sources :

Example 11 with Chunk

use of com.lowagie.text.Chunk in project vcell by virtualcell.

the class ITextWriter method writeStructure.

protected void writeStructure(Model model, Structure struct, Table structTable) throws DocumentException {
    // If this structure has any reactions in it, add its name as a hyperlink to the reactions' list.
    if (hasReactions(model, struct)) {
        Paragraph linkParagraph = new Paragraph();
        Font linkFont;
        try {
            BaseFont fontBaseFont = BaseFont.createFont(BaseFont.HELVETICA, BaseFont.CP1252, BaseFont.NOT_EMBEDDED);
            linkFont = new Font(fontBaseFont, DEF_FONT_SIZE, Font.NORMAL, new java.awt.Color(0, 0, 255));
        } catch (Exception e) {
            linkFont = getFont();
            e.printStackTrace();
        }
        linkParagraph.add(new Chunk(struct.getName(), linkFont).setLocalGoto(struct.getName()));
        Cell structLinkCell = new Cell(linkParagraph);
        structLinkCell.setBorderWidth(1);
        structLinkCell.setHorizontalAlignment(Element.ALIGN_LEFT);
        structTable.addCell(structLinkCell);
    } else {
        structTable.addCell(createCell(struct.getName(), getFont()));
    }
    StructureTopology structTopology = model.getStructureTopology();
    if (struct instanceof Membrane) {
        structTable.addCell(createCell("Membrane", getFont()));
        Feature outsideFeature = structTopology.getOutsideFeature((Membrane) struct);
        Feature insideFeature = structTopology.getInsideFeature((Membrane) struct);
        structTable.addCell(createCell((insideFeature != null ? insideFeature.getName() : "N/A"), getFont()));
        structTable.addCell(createCell((outsideFeature != null ? outsideFeature.getName() : "N/A"), getFont()));
    } else {
        structTable.addCell(createCell("Feature", getFont()));
        String outsideStr = "N/A", insideStr = "N/A";
        Membrane enclosingMem = (Membrane) structTopology.getParentStructure(struct);
        if (enclosingMem != null) {
            outsideStr = enclosingMem.getName();
        }
        // To do:  retrieve the 'child' membrane here...
        structTable.addCell(createCell(insideStr, getFont()));
        structTable.addCell(createCell(outsideStr, getFont()));
    }
}
Also used : StructureTopology(cbit.vcell.model.Model.StructureTopology) Color(java.awt.Color) BaseFont(com.lowagie.text.pdf.BaseFont) Membrane(cbit.vcell.model.Membrane) Chunk(com.lowagie.text.Chunk) Cell(com.lowagie.text.Cell) Feature(cbit.vcell.model.Feature) BaseFont(com.lowagie.text.pdf.BaseFont) Font(com.lowagie.text.Font) DocumentException(com.lowagie.text.DocumentException) ExpressionException(cbit.vcell.parser.ExpressionException) Paragraph(com.lowagie.text.Paragraph)

Example 12 with Chunk

use of com.lowagie.text.Chunk in project charts by vaadin.

the class PdfExportDemo method writePdfContent.

private void writePdfContent() throws DocumentException, IOException {
    Paragraph caption = new Paragraph();
    caption.add(new Chunk("Vaadin Charts Export Demo PDF", captionFont));
    document.add(caption);
    Paragraph br = new Paragraph(Chunk.NEWLINE);
    document.add(br);
    Paragraph paragraph = new Paragraph();
    paragraph.add(new Chunk("This PDF is rendered with iText 2.1.7.", normalFont));
    document.add(paragraph);
    paragraph = new Paragraph();
    paragraph.add(new Chunk("Chart below is originally an SVG image created with Vaadin Charts and rendered with help of Batik SVG Toolkit.", normalFont));
    document.add(paragraph);
    document.add(createSvgImage(writer.getDirectContent(), 400, 400));
    document.add(createExampleTable());
}
Also used : Chunk(com.lowagie.text.Chunk) Paragraph(com.lowagie.text.Paragraph)

Example 13 with Chunk

use of com.lowagie.text.Chunk in project charts by vaadin.

the class PdfExportDemo method createCell.

private PdfPCell createCell(String value) throws BadElementException {
    PdfPCell cell = new PdfPCell(new Phrase(new Chunk(value, normalFont)));
    cell.setBorder(0);
    cell.setHorizontalAlignment(PdfPCell.ALIGN_LEFT);
    return cell;
}
Also used : PdfPCell(com.lowagie.text.pdf.PdfPCell) Phrase(com.lowagie.text.Phrase) Chunk(com.lowagie.text.Chunk)

Example 14 with Chunk

use of com.lowagie.text.Chunk in project activityinfo by bedatadriven.

the class ItextMapRenderer method addPieChartDescription.

private void addPieChartDescription(MapReportElement element, Cell descriptionCell, PiechartMapLayer layer) throws BadElementException, IOException {
    for (Slice slice : layer.getSlices()) {
        IndicatorDTO indicator = element.getContent().getIndicatorById(slice.getIndicatorId());
        Color color = ColorUtil.colorFromString(slice.getColor());
        ItextGraphic sliceImage = renderSlice(imageCreator, color, 10);
        Chunk box = new Chunk(sliceImage.toItextImage(), 0, 0);
        Chunk description = new Chunk(indicator.getName());
        Phrase phrase = new Phrase();
        phrase.add(box);
        phrase.add(description);
        Paragraph paragraph = new Paragraph(phrase);
        descriptionCell.add(paragraph);
    }
}
Also used : IndicatorDTO(org.activityinfo.shared.dto.IndicatorDTO) Slice(org.activityinfo.shared.report.model.layers.PiechartMapLayer.Slice) Color(com.google.code.appengine.awt.Color) Phrase(com.lowagie.text.Phrase) Chunk(com.lowagie.text.Chunk) ItextGraphic(org.activityinfo.server.report.renderer.image.ItextGraphic) Paragraph(com.lowagie.text.Paragraph)

Aggregations

Chunk (com.lowagie.text.Chunk)14 Paragraph (com.lowagie.text.Paragraph)12 DocumentException (com.lowagie.text.DocumentException)5 ListItem (com.lowagie.text.ListItem)5 Color (java.awt.Color)5 List (java.util.List)5 Cell (com.lowagie.text.Cell)4 Phrase (com.lowagie.text.Phrase)4 Section (com.lowagie.text.Section)4 ArrayList (java.util.ArrayList)4 Document (com.lowagie.text.Document)3 Font (com.lowagie.text.Font)3 Table (com.lowagie.text.Table)3 PdfPCell (com.lowagie.text.pdf.PdfPCell)3 ExpressionException (cbit.vcell.parser.ExpressionException)2 DocxTable (com.centurylink.mdw.designer.utils.DocxBuilder.DocxTable)2 BadElementException (com.lowagie.text.BadElementException)2 ByteArrayOutputStream (java.io.ByteArrayOutputStream)2 BadLocationException (javax.swing.text.BadLocationException)2 HTMLDocument (javax.swing.text.html.HTMLDocument)2