List of usage examples for com.lowagie.text Chunk Chunk
public Chunk(DrawInterface separator, float tabPosition)
From source file:com.jd.survey.web.pdf.StatisticsPdf.java
License:Open Source License
private void writeEntry(Document document, String label, double value) throws Exception { Paragraph questionParagraph = new Paragraph(); questionParagraph.setLeading(14, 0); questionParagraph.setIndentationLeft(18); questionParagraph.add(new Chunk(label.trim() + ": ", boldedFont)); questionParagraph.add(new Chunk( BigDecimalValidator.getInstance().format(value, LocaleContextHolder.getLocale()), normalFont)); document.add(questionParagraph);/* w w w. j av a 2 s . c om*/ }
From source file:com.jd.survey.web.pdf.StatisticsPdf.java
License:Open Source License
private void writeEntry(Document document, String label, Date value, String dateFormat) throws Exception { Paragraph questionParagraph = new Paragraph(); questionParagraph.setLeading(14, 0); questionParagraph.setIndentationLeft(18); questionParagraph.add(new Chunk(label.trim() + ": ", boldedFont)); questionParagraph.add(new Chunk(DateValidator.getInstance().format(value, dateFormat), normalFont)); document.add(questionParagraph);/*from www .j a v a2 s . c o m*/ }
From source file:com.jd.survey.web.pdf.StatisticsPdf.java
License:Open Source License
private void writeCurrencyEntry(Document document, String label, double value) throws Exception { Paragraph questionParagraph = new Paragraph(); questionParagraph.setLeading(14, 0); questionParagraph.setIndentationLeft(18); questionParagraph.add(new Chunk(label.trim() + ": ", boldedFont)); questionParagraph.add(new Chunk( CurrencyValidator.getInstance().format(value, LocaleContextHolder.getLocale()), normalFont)); document.add(questionParagraph);/* www.ja v a2 s . c om*/ }
From source file:com.jd.survey.web.pdf.SurveyPdf.java
License:Open Source License
private void writeAnswer(Document document, String questionText, boolean answerValue, String falseMessage, String trueMessage) throws Exception { //String falseString ="False"; //String trueString = "True"; Paragraph questionParagraph = new Paragraph(); questionParagraph.setLeading(14, 0); questionParagraph.add(new Chunk(questionText.trim() + ": ", boldedFont)); questionParagraph.add(new Chunk(answerValue ? trueMessage : falseMessage, normalFont)); document.add(questionParagraph);// w w w. j a v a 2s . c o m }
From source file:com.jd.survey.web.pdf.SurveyPdf.java
License:Open Source License
private void writeAnswer(Document document, String questionText, String answerValue) throws Exception { Paragraph questionParagraph = new Paragraph(); questionParagraph.setLeading(14, 0); questionParagraph.add(new Chunk(questionText.trim() + ": ", boldedFont)); questionParagraph.add(new Chunk(answerValue == null ? "" : answerValue.trim(), normalFont)); document.add(questionParagraph);//w ww. j a v a 2 s . c o m }
From source file:com.jd.survey.web.pdf.SurveyPdf.java
License:Open Source License
private void writeAnswersMatrix(Document document, Question question, Boolean[][] answerValuesMatrix, String falseMessage, String trueMessage) throws Exception { Table matrixTable;/* w ww.j a v a2 s. c o m*/ Cell cell; Paragraph questionParagraph = new Paragraph(); questionParagraph.add(new Chunk(question.getQuestionText().trim() + ": ", boldedFont)); document.add(questionParagraph); matrixTable = new Table(question.getColumnLabels().size() + 1); matrixTable.setPadding(2); matrixTable.setWidth(100); matrixTable.setDefaultCellBorder(0); matrixTable.setBorder(0); matrixTable.setOffset(4); matrixTable.setAutoFillEmptyCells(true); matrixTable.setCellsFitPage(true); matrixTable.setTableFitsPage(true); cell = new Cell(""); cell.setBackgroundColor(Color.LIGHT_GRAY); matrixTable.addCell(cell); for (QuestionColumnLabel questionColumnLabel : question.getColumnLabels()) { cell = new Cell(new Paragraph(questionColumnLabel.getLabel(), boldedFont)); cell.setBackgroundColor(Color.LIGHT_GRAY); matrixTable.addCell(cell); } int rowIndex = 0; for (QuestionRowLabel questionRowLabel : question.getRowLabels()) { int columnIndex = 0; questionParagraph = new Paragraph(questionRowLabel.getLabel(), boldedFont); questionParagraph.setLeading(12, 0); cell = new Cell(questionParagraph); if ((rowIndex % 2) == 1) { cell.setBackgroundColor(new Color(231, 238, 244)); } matrixTable.addCell(cell); for (QuestionColumnLabel questionColumnLabel : question.getColumnLabels()) { questionParagraph = new Paragraph( answerValuesMatrix[rowIndex][columnIndex] ? trueMessage : falseMessage, normalFont); questionParagraph.setLeading(12, 0); cell = new Cell(questionParagraph); if ((rowIndex % 2) == 1) { cell.setBackgroundColor(new Color(231, 238, 244)); } matrixTable.addCell(cell); columnIndex++; } rowIndex++; } document.add(matrixTable); }
From source file:com.jd.survey.web.pdf.SurveyPdf.java
License:Open Source License
private void writeAnswersMatrix(Document document, Question question, String[][] answerValuesMatrix) throws Exception { Table matrixTable;//from w w w .jav a2s. co m Cell cell; Paragraph questionParagraph = new Paragraph(); questionParagraph.add(new Chunk(question.getQuestionText().trim() + ": ", boldedFont)); document.add(questionParagraph); matrixTable = new Table(question.getColumnLabels().size() + 1); matrixTable.setPadding(2); matrixTable.setWidth(100); matrixTable.setDefaultCellBorder(0); matrixTable.setBorder(0); matrixTable.setOffset(4); matrixTable.setAutoFillEmptyCells(true); matrixTable.setCellsFitPage(true); matrixTable.setTableFitsPage(true); cell = new Cell(""); cell.setBackgroundColor(Color.LIGHT_GRAY); matrixTable.addCell(cell); for (QuestionColumnLabel questionColumnLabel : question.getColumnLabels()) { cell = new Cell(new Paragraph(questionColumnLabel.getLabel(), boldedFont)); cell.setBackgroundColor(Color.LIGHT_GRAY); matrixTable.addCell(cell); } int rowIndex = 0; for (QuestionRowLabel questionRowLabel : question.getRowLabels()) { int columnIndex = 0; questionParagraph = new Paragraph(questionRowLabel.getLabel(), boldedFont); questionParagraph.setLeading(12, 0); cell = new Cell(questionParagraph); if ((rowIndex % 2) == 1) { cell.setBackgroundColor(new Color(231, 238, 244)); } matrixTable.addCell(cell); for (QuestionColumnLabel questionColumnLabel : question.getColumnLabels()) { questionParagraph = new Paragraph(answerValuesMatrix[rowIndex][columnIndex] == null ? "" : answerValuesMatrix[rowIndex][columnIndex], normalFont); questionParagraph.setLeading(12, 0); cell = new Cell(questionParagraph); if ((rowIndex % 2) == 1) { cell.setBackgroundColor(new Color(231, 238, 244)); } matrixTable.addCell(cell); columnIndex++; } rowIndex++; } document.add(matrixTable); }
From source file:com.krawler.accounting.fontsetting.FontFamilySelector.java
License:Open Source License
public Phrase process(String text, FontContext context, Color color, Float size, Integer style) { int fsize = families.size(); if (fsize == 0) throw new IndexOutOfBoundsException("No font is defined."); if (text == null) text = ""; char cc[] = text.toCharArray(); int len = cc.length; StringBuffer sb = new StringBuffer(); Font font = null;/* w w w . ja va2 s . co m*/ int lastidx = -1; Phrase ret = new Phrase(); for (int k = 0; k < len; ++k) { char c = cc[k]; if (c == '\n' || c == '\r') { sb.append(c); continue; } if (Utilities.isSurrogatePair(cc, k)) { int u = Utilities.convertToUtf32(cc, k); for (int f = 0; f < fsize; ++f) { font = (Font) families.get(f).getPrimaryFont(); if (font.getBaseFont().charExists(u)) { if (lastidx != f) { if (sb.length() > 0 && lastidx != -1) { FontFamily fm = families.get(lastidx); Font fnt = fm.getFont(context); applyPropertiesToFont(fnt, color, size, style); Chunk ck = new Chunk(sb.toString(), fnt); ret.add(ck); sb.setLength(0); } lastidx = f; } sb.append(c); sb.append(cc[++k]); break; } } } else { for (int f = 0; f < fsize; ++f) { font = (Font) families.get(f).getPrimaryFont(); if (font.getBaseFont().charExists(c)) { if (lastidx != f) { if (sb.length() > 0 && lastidx != -1) { FontFamily fm = families.get(lastidx); Font fnt = fm.getFont(context); applyPropertiesToFont(fnt, color, size, style); Chunk ck = new Chunk(sb.toString(), fnt); ret.add(ck); sb.setLength(0); } lastidx = f; } sb.append(c); break; } } } } if (sb.length() > 0) { FontFamily fm = families.get(lastidx == -1 ? 0 : lastidx); Font fnt = fm.getFont(context); applyPropertiesToFont(fnt, color, size, style); Chunk ck = new Chunk(sb.toString(), fnt); ret.add(ck); } return ret; }
From source file:com.krawler.common.fontsettings.FontFamilySelector.java
License:Open Source License
public Phrase process(String text, FontContext context, Color color, Float size, Integer style) { int fsize = families.size(); if (fsize == 0) throw new IndexOutOfBoundsException("No font is defined."); if (text == null) text = ""; char cc[] = text.toCharArray(); int len = cc.length; StringBuffer sb = new StringBuffer(); Font font = null;/*www .j av a2s. com*/ int lastidx = -1; Phrase ret = new Phrase(); for (int k = 0; k < len; ++k) { char c = cc[k]; if (c == '\n' || c == '\r') { sb.append(c); continue; } if (Utilities.isSurrogatePair(cc, k)) { int u = Utilities.convertToUtf32(cc, k); for (int f = 0; f < fsize; ++f) { font = (Font) families.get(f).getPrimaryFont(); if (font.getBaseFont().charExists(u)) { if (lastidx != f) { if (sb.length() > 0 && lastidx != -1) { FontFamily fm = families.get(lastidx); Font fnt = fm.getFont(context); applyPropertiesToFont(fnt, color, size, style); Chunk ck = new Chunk(sb.toString(), fnt); ret.add(ck); sb.setLength(0); } lastidx = f; } sb.append(c); sb.append(cc[++k]); break; } } } else { for (int f = 0; f < fsize; ++f) { font = (Font) families.get(f).getPrimaryFont(); if (font.getBaseFont().charExists(c)) { if (lastidx != f) { if (sb.length() > 0 && lastidx != -1) { FontFamily fm = families.get(lastidx); Font fnt = fm.getFont(context); applyPropertiesToFont(fnt, color, size, style); Chunk ck = new Chunk(sb.toString(), fnt); ret.add(ck); sb.setLength(0); } lastidx = f; } sb.append(c); break; } } } } if (sb.length() > 0) { FontFamily fm = families.get(lastidx == -1 ? 0 : lastidx); Font fnt = fm.getFont(context); applyPropertiesToFont(fnt, color, size, style); Chunk ck = new Chunk(sb.toString(), fnt); ret.add(ck); } return ret; }
From source file:com.krawler.common.fontsettings.FontFamilySelector.java
License:Open Source License
public Chunk processChunk(String text, FontContext context, Color color, Float size, Integer style) { Chunk ck = null;/*from w w w.j a v a2 s . c o m*/ int fsize = families.size(); if (fsize == 0) throw new IndexOutOfBoundsException("No font is defined."); if (text == null) text = ""; char cc[] = text.toCharArray(); int len = cc.length; StringBuffer sb = new StringBuffer(); Font font = null; int lastidx = -1; for (int k = 0; k < len; ++k) { char c = cc[k]; if (c == '\n' || c == '\r') { sb.append(c); continue; } if (Utilities.isSurrogatePair(cc, k)) { int u = Utilities.convertToUtf32(cc, k); for (int f = 0; f < fsize; ++f) { font = (Font) families.get(f).getPrimaryFont(); if (font.getBaseFont().charExists(u)) { if (lastidx != f) { if (sb.length() > 0 && lastidx != -1) { FontFamily fm = families.get(lastidx); Font fnt = fm.getFont(context); applyPropertiesToFont(fnt, color, size, style); } lastidx = f; } sb.append(c); sb.append(cc[++k]); break; } } } else { for (int f = 0; f < fsize; ++f) { font = (Font) families.get(f).getPrimaryFont(); if (font.getBaseFont().charExists(c)) { if (lastidx != f) { if (sb.length() > 0 && lastidx != -1) { FontFamily fm = families.get(lastidx); Font fnt = fm.getFont(context); applyPropertiesToFont(fnt, color, size, style); } lastidx = f; } sb.append(c); break; } } } } if (sb.length() > 0) { FontFamily fm = families.get(lastidx == -1 ? 0 : lastidx); Font fnt = fm.getFont(context); applyPropertiesToFont(fnt, color, size, style); ck = new Chunk(sb.toString(), fnt); } return ck; }