List of usage examples for com.lowagie.text.pdf PdfPCell setBorderColor
public void setBorderColor(Color borderColor)
From source file:it.eng.spagobi.engines.qbe.crosstable.exporter.CrosstabPDFExporter.java
License:Mozilla Public License
/** * Builds the row headers. This method performs a depth first visit * of the row headers tree//from w ww . j a va 2s.com * @param siblings: a level (L) of headers * @return the cells from level L to the leafs * @throws JSONException * @throws BadElementException */ private List<PdfPCell> buildRowsHeaders(JSONArray siblings) throws JSONException, BadElementException { JSONArray childs; List<PdfPCell> rowNodes = new ArrayList<PdfPCell>(); //For every node of the level.. for (int i = 0; i < siblings.length(); i++) { JSONObject aNode = (JSONObject) siblings.get(i); String text = (String) aNode.opt(Node.CROSSTAB_NODE_JSON_DESCRIPTION); if (text == null) { // in case of calculated fields text = (String) aNode.get(CrossTab.CROSSTAB_NODE_JSON_KEY); } int descendants = aNode.getInt(CrosstabExporterUtility.CROSSTAB_JSON_DESCENDANTS_NUMBER); PdfPCell cell = new PdfPCell(new Phrase(text, cellFont)); cell.setBackgroundColor(headersBackgroundColor); cell.setBorderColor(cellsBorderColor); if (descendants > 1) { cell.setRowspan(descendants); } //1) add the node name rowNodes.add(cell); //2) add the child node names childs = aNode.optJSONArray(CrossTab.CROSSTAB_NODE_JSON_CHILDS); if (childs != null && childs.length() > 0) { rowNodes.addAll(buildRowsHeaders(childs)); } else { rowNodes.addAll(dataMatrix.remove(0)); } } return rowNodes; }
From source file:it.eng.spagobi.engines.qbe.crosstable.exporter.CrosstabPDFExporter.java
License:Mozilla Public License
/** * Builds cells for the column headers/*from w w w. j ava 2 s .c om*/ * @param siblings the top level * @return * @throws JSONException * @throws BadElementException */ private List<PdfPCell> buildColumnsHeader(JSONArray siblings, JSONArray rowHeadersDescription, int dataColumnNumber) throws JSONException, BadElementException { List<PdfPCell> cells = new ArrayList<PdfPCell>(); List<JSONObject> columnNodes = getAllNodes(siblings); for (int i = 0; i < columnNodes.size(); i++) { //adds the row headers if (rowHeadersDescription != null && i == columnNodes.size() - dataColumnNumber) { for (int y = 0; y < rowHeadersDescription.length(); y++) { String text = rowHeadersDescription.getString(y); PdfPCell cell = new PdfPCell(new Phrase(text, cellFont)); cell.setBorderColor(cellsBorderColor); cell.setBackgroundColor(headersBackgroundColor); cells.add(cell); } } JSONObject aNode = (JSONObject) columnNodes.get(i); String text = (String) aNode.get(Node.CROSSTAB_NODE_JSON_DESCRIPTION); int descendants = aNode.getInt(CrosstabExporterUtility.CROSSTAB_JSON_DESCENDANTS_NUMBER); PdfPCell cell = new PdfPCell(new Phrase(text, cellFont)); cell.setBorderColor(cellsBorderColor); cell.setBackgroundColor(headersBackgroundColor); if (descendants > 1) { cell.setColspan(descendants); } cells.add(cell); } return cells; }
From source file:it.eng.spagobi.engines.worksheet.exporter.DataSourceTablePDFExporter.java
License:Mozilla Public License
/** * Builds the header of the table../*from w w w . j ava2s .c o m*/ * It creates also the object table.. * @param dataStore * @return the table object * @throws BadElementException */ public PdfPTable buildTableHeader(IDataStore dataStore) throws BadElementException { logger.debug("IN: building the headers of the table"); IMetaData dataStoreMetaData = dataStore.getMetaData(); int colunum = dataStoreMetaData.getFieldCount(); List<String> columnsName = new ArrayList<String>(); //reads the names of the visible table columns for (int j = 0; j < colunum; j++) { String fieldName = dataStoreMetaData.getFieldAlias(j); IFieldMetaData fieldMetaData = dataStoreMetaData.getFieldMeta(j); // String format = (String) fieldMetaData.getProperty("format"); String alias = (String) fieldMetaData.getAlias(); if (alias != null && !alias.equals("")) { columnsName.add(alias); } else { columnsName.add(fieldName); } } PdfPTable table = new PdfPTable(colunum); //For each column builds a cell PdfPCell d = table.getDefaultCell(); if (colunum < 4) { table.setWidthPercentage(colunum * 25); } else { table.setWidthPercentage(100); } for (int j = 0; j < colunum; j++) { PdfPCell cell = new PdfPCell(new Phrase(columnsName.get(j))); //cell.setHeader(true); cell.setBorderColor(cellsBorderColor); cell.setBackgroundColor(headerbackgroundColor); table.addCell(cell); } table.setHeaderRows(1); logger.debug("Out: built the headers of the table"); return table; }
From source file:it.eng.spagobi.engines.worksheet.exporter.DataSourceTablePDFExporter.java
License:Mozilla Public License
/** * Build the content of the table//from w w w . j a v a 2 s . co m * @param dataStore * @param table the table with the headers * @throws BadElementException */ public void buildTableContent(IDataStore dataStore, PdfPTable table) throws BadElementException { logger.debug("IN: building the conetent of the table"); boolean oddRows = true; PdfPCell cell; Iterator it = dataStore.iterator(); IMetaData d = dataStore.getMetaData(); while (it.hasNext()) {//for each record IRecord record = (IRecord) it.next(); List fields = record.getFields(); int length = fields.size(); //build the row for (int fieldIndex = 0; fieldIndex < length; fieldIndex++) { IField f = (IField) fields.get(fieldIndex); IFieldMetaData fieldMetaData = d.getFieldMeta(fieldIndex); String decimalPrecision = (String) fieldMetaData.getProperty(IFieldMetaData.DECIMALPRECISION); if (f == null || f.getValue() == null) { cell = new PdfPCell(new Phrase("")); } else { Class c = d.getFieldType(fieldIndex); cell = new PdfPCell(new Phrase(formatPDFCell(c, f, decimalPrecision))); if (oddRows) { cell.setBackgroundColor(oddrowsBackgroundColor); } else { cell.setBackgroundColor(evenrowsBackgroundColor); } } cell.setBorderColor(cellsBorderColor); table.addCell(cell); } oddRows = !oddRows; } logger.debug("Out: built the conetent of the table"); }
From source file:jdbreport.model.io.pdf.itext2.PdfWriter.java
License:Apache License
private void assignBorders(CellStyle style, PdfPCell pdfCell) { pdfCell.setBorderWidth(0);//from ww w. j a va 2 s . com if (pdfCell.getBackgroundColor() != Color.WHITE) { pdfCell.setBorderColor(pdfCell.getBackgroundColor()); } Border border = style.getBorders(Border.LINE_LEFT); if (border != null) { pdfCell.setBorderWidthLeft(border.getLineWidth()); pdfCell.setBorderColorLeft(border.getColor()); } border = style.getBorders(Border.LINE_RIGHT); if (border != null) { pdfCell.setBorderWidthRight(border.getLineWidth()); pdfCell.setBorderColorRight(border.getColor()); } if (pdfCell.getBackgroundColor() != Color.WHITE) { pdfCell.setBorderWidthRight(0.5f); } border = style.getBorders(Border.LINE_TOP); if (border != null) { pdfCell.setBorderWidthTop(border.getLineWidth()); pdfCell.setBorderColorTop(border.getColor()); } border = style.getBorders(Border.LINE_BOTTOM); if (border != null) { pdfCell.setBorderWidthBottom(border.getLineWidth()); pdfCell.setBorderColorBottom(border.getColor()); } if (pdfCell.getBackgroundColor() != Color.WHITE) { pdfCell.setBorderWidthBottom(0.5f); } }
From source file:jm.web.Addons.java
License:GNU General Public License
public static PdfPCell setCeldaPDF(String texto, int tipo, int tamanio, int estilo, int alineacion, int borde) { PdfPCell celda = new PdfPCell(new Paragraph(texto, new Font(tipo, tamanio, estilo))); celda.setHorizontalAlignment(alineacion); celda.setVerticalAlignment(Element.ALIGN_TOP); celda.setBorderColor(Color.LIGHT_GRAY); celda.setBorderWidth(borde);//from w w w .ja v a 2 s. c om return celda; }
From source file:jm.web.Addons.java
License:GNU General Public License
public static PdfPCell setCeldaPDF(String texto, int tipo, int tamanio, int estilo, int alineacion, int borde, int padding) { PdfPCell celda = new PdfPCell(new Paragraph(texto, new Font(tipo, tamanio, estilo))); celda.setHorizontalAlignment(alineacion); celda.setVerticalAlignment(Element.ALIGN_TOP); celda.setBorderColor(Color.LIGHT_GRAY); celda.setBorderWidth(borde);// w w w .j a va 2 s. c om celda.setPadding(padding); return celda; }
From source file:jm.web.Addons.java
License:GNU General Public License
public static PdfPCell setCeldaPDFBottom(String texto, int tipo, int tamanio, int estilo, int alineacion, int borde, int padding, int colspan) { PdfPCell celda = new PdfPCell(new Paragraph(texto, new Font(tipo, tamanio, estilo, Color.WHITE))); celda.setHorizontalAlignment(alineacion); celda.setVerticalAlignment(Element.ALIGN_TOP); celda.setBorderColor(Color.WHITE); celda.setColspan(colspan);/*w w w .j a v a 2 s.c o m*/ celda.setBorder(borde); celda.setPadding(padding); return celda; }
From source file:jm.web.Addons.java
License:GNU General Public License
public static PdfPCell setCeldaPDFCarnetOpciones(String texto, int tipo, int tamanio, int estilo, int alineacion, int borde, int padding, int colspan, Color color) { PdfPCell celda = new PdfPCell(new Paragraph(texto, new Font(tipo, tamanio, estilo, Color.WHITE))); celda.setHorizontalAlignment(alineacion); celda.setVerticalAlignment(Element.ALIGN_TOP); celda.setBorderColor(Color.black); celda.setBackgroundColor(color);//from w w w . ja v a 2 s . com celda.setColspan(colspan); celda.setBorderWidth(borde); celda.setPadding(0); celda.setPaddingBottom(padding); return celda; }
From source file:jm.web.Addons.java
License:GNU General Public License
public static PdfPCell setCeldaPDFCarnet(String texto, int tipo, int tamanio, int estilo, int alineacion, int borde, int padding, int colspan) { PdfPCell celda = new PdfPCell(new Paragraph(texto, new Font(tipo, tamanio, estilo, Color.WHITE))); celda.setHorizontalAlignment(alineacion); celda.setVerticalAlignment(Element.ALIGN_TOP); celda.setBorderColor(Color.WHITE); celda.setColspan(colspan);//from w ww. j a va 2 s . c o m celda.setBorderWidth(0); celda.setBorderWidthBottom(borde); celda.setPadding(0); celda.setPaddingBottom(padding); return celda; }