use of com.lowagie.text.Paragraph in project OpenClinica by OpenClinica.
the class DownloadDiscrepancyNote method createTableThreadHeader.
private Table createTableThreadHeader(DiscrepancyNoteThread discNoteThread) throws BadElementException {
Table table = new Table(2);
table.setTableFitsPage(true);
table.setCellsFitPage(true);
table.setBorderWidth(1);
table.setBorderColor(new java.awt.Color(0, 0, 0));
table.setPadding(4);
table.setSpacing(4);
if (discNoteThread == null || discNoteThread.getLinkedNoteList().isEmpty()) {
return table;
}
// Get information for the header; the resolution status, however, has to be the latest
// resolution status for the DN thread
DiscrepancyNoteBean dnBean = discNoteThread.getLinkedNoteList().getFirst();
DiscrepancyNoteUtil discUtil = new DiscrepancyNoteUtil();
String latestResolutionStatus = discUtil.getResolutionStatusName(discNoteThread.getLinkedNoteList().getFirst().getResolutionStatusId());
StringBuilder content = new StringBuilder("");
if (dnBean != null) {
if (!"".equalsIgnoreCase(dnBean.getEntityName())) {
content.append("Item field name/value: ");
content.append(dnBean.getEntityName());
if (!"".equalsIgnoreCase(dnBean.getEntityValue())) {
content.append(" = ");
content.append(dnBean.getEntityValue());
}
}
Paragraph para = new Paragraph(content.toString(), new Font(Font.HELVETICA, 14, Font.BOLD, new Color(0, 0, 0)));
Cell cell = new Cell(para);
cell.setHeader(true);
cell.setHorizontalAlignment(Element.ALIGN_LEFT);
cell.setColspan(2);
table.addCell(cell);
table.endHeaders();
// Add at least three more rows of data -- dnBean.getSubjectName()
// row 1
cell = createCell("Study Subject", dnBean.getSubjectName());
table.addCell(cell);
cell = createCell("Study Event", dnBean.getEventName());
table.addCell(cell);
// row 2
cell = createCell("Study Event Date", dnBean.getEventStart() + "");
table.addCell(cell);
StringBuilder tmpStrBuilder = new StringBuilder("CRF: ");
tmpStrBuilder.append(dnBean.getCrfName());
tmpStrBuilder.append("\n");
tmpStrBuilder.append("Status: ");
tmpStrBuilder.append(dnBean.getCrfStatus());
content.append(dnBean.getCrfName());
cell = new Cell(new Paragraph(tmpStrBuilder.toString(), new Font(Font.HELVETICA, 14, Font.BOLD, new Color(0, 0, 0))));
table.addCell(cell);
// row 3
cell = createCell("Type", discUtil.getResolutionStatusTypeName(dnBean.getDiscrepancyNoteTypeId()));
table.addCell(cell);
cell = createCell("Resolution Status", latestResolutionStatus);
table.addCell(cell);
cell = createCell("Number of notes", discNoteThread.getLinkedNoteList().size() + "");
table.addCell(cell);
cell = createCell("Discrepancy Note ID", dnBean.getId() + "");
table.addCell(cell);
cell = createCell("Days Open", dnBean.getAge() + "");
table.addCell(cell);
String daysSinceUpdated = escapeQuotesInCSV(dnBean.getDays() + "");
cell = createCell("Days Since Updated", daysSinceUpdated.equals("0") ? "" : daysSinceUpdated + "");
table.addCell(cell);
}
return table;
}
use of com.lowagie.text.Paragraph in project OpenClinica by OpenClinica.
the class DownloadDiscrepancyNote method serializeListToPDF.
public void serializeListToPDF(String content, OutputStream stream) {
ServletOutputStream servletStream = (ServletOutputStream) stream;
Document pdfDoc = new Document();
try {
PdfWriter.getInstance(pdfDoc, servletStream);
pdfDoc.open();
pdfDoc.add(new Paragraph(content));
} catch (DocumentException e) {
e.printStackTrace();
}
pdfDoc.close();
}
use of com.lowagie.text.Paragraph in project vcell by virtualcell.
the class PDFWriter method writeHorizontalLine.
/**
* PDF implementation.
*/
protected void writeHorizontalLine() throws DocumentException {
document.add(new Paragraph("\n"));
Graphic graphic = new Graphic();
graphic.setHorizontalLine(1, 75);
document.add(graphic);
document.add(new Paragraph("\n"));
}
use of com.lowagie.text.Paragraph 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()));
}
}
use of com.lowagie.text.Paragraph in project vcell by virtualcell.
the class ITextWriter method writeGeom.
// Section used can be a chapter or a section of one, based on the document type.
protected void writeGeom(Section container, Geometry geom, GeometryContext geomCont) throws Exception {
try {
Section geomSection = container.addSection("Geometry: " + geom.getName(), container.numberDepth() + 1);
if (geom.getDimension() == 0) {
Paragraph p = new Paragraph(new Phrase("Non spatial geometry."));
p.setAlignment(Paragraph.ALIGN_CENTER);
geomSection.add(p);
return;
}
ByteArrayOutputStream bos = generateGeometryImage(geom);
com.lowagie.text.Image geomImage = com.lowagie.text.Image.getInstance(java.awt.Toolkit.getDefaultToolkit().createImage(bos.toByteArray()), null);
geomImage.setAlignment(Table.ALIGN_LEFT);
geomSection.add(geomImage);
// addImage(geomSection, bos);
Table geomTable = getTable(2, 50, 1, 2, 2);
geomTable.setAlignment(Table.ALIGN_LEFT);
Extent extent = geom.getExtent();
String extentStr = "(" + extent.getX() + ", " + extent.getY() + ", " + extent.getZ() + ")";
Origin origin = geom.getOrigin();
String originStr = "(" + origin.getX() + ", " + origin.getY() + ", " + origin.getZ() + ")";
geomTable.addCell(createCell("Size", getFont()));
geomTable.addCell(createCell(extentStr, getFont()));
geomTable.addCell(createCell("Origin", getFont()));
geomTable.addCell(createCell(originStr, getFont()));
geomSection.add(geomTable);
} catch (Exception e) {
System.err.println("Unable to add geometry image to report.");
e.printStackTrace();
}
}
Aggregations