List of usage examples for com.itextpdf.text.pdf PdfPCell setHorizontalAlignment
public void setHorizontalAlignment(int horizontalAlignment)
From source file:org.totschnig.myexpenses.model.Account.java
License:Open Source License
private void addTransactionList(Document document, Cursor transactionCursor, PdfHelper helper, WhereFilter filter) throws DocumentException, IOException { String selection;/*from w w w. j a v a 2s .c o m*/ String[] selectionArgs; if (!filter.isEmpty()) { selection = filter.getSelectionForParts(DatabaseConstants.VIEW_EXTENDED);//GROUP query uses extended view selectionArgs = filter.getSelectionArgs(true); } else { selection = null; selectionArgs = null; } Builder builder = Transaction.CONTENT_URI.buildUpon(); builder.appendPath(TransactionProvider.URI_SEGMENT_GROUPS).appendPath(grouping.name()); if (getId() < 0) { builder.appendQueryParameter(KEY_CURRENCY, currency.getCurrencyCode()); } else { builder.appendQueryParameter(KEY_ACCOUNTID, String.valueOf(getId())); } Cursor groupCursor = cr().query(builder.build(), null, selection, selectionArgs, KEY_YEAR + " ASC," + KEY_SECOND_GROUP + " ASC"); MyApplication ctx = MyApplication.getInstance(); int columnIndexGroupSumIncome = groupCursor.getColumnIndex(KEY_SUM_INCOME); int columnIndexGroupSumExpense = groupCursor.getColumnIndex(KEY_SUM_EXPENSES); int columnIndexGroupSumTransfer = groupCursor.getColumnIndex(KEY_SUM_TRANSFERS); int columIndexGroupSumInterim = groupCursor.getColumnIndex(KEY_INTERIM_BALANCE); int columnIndexRowId = transactionCursor.getColumnIndex(KEY_ROWID); int columnIndexYear = transactionCursor.getColumnIndex(KEY_YEAR); int columnIndexYearOfWeekStart = transactionCursor.getColumnIndex(KEY_YEAR_OF_WEEK_START); int columnIndexMonth = transactionCursor.getColumnIndex(KEY_MONTH); int columnIndexWeek = transactionCursor.getColumnIndex(KEY_WEEK); int columnIndexDay = transactionCursor.getColumnIndex(KEY_DAY); int columnIndexAmount = transactionCursor.getColumnIndex(KEY_AMOUNT); int columnIndexLabelSub = transactionCursor.getColumnIndex(KEY_LABEL_SUB); int columnIndexLabelMain = transactionCursor.getColumnIndex(KEY_LABEL_MAIN); int columnIndexComment = transactionCursor.getColumnIndex(KEY_COMMENT); int columnIndexReferenceNumber = transactionCursor.getColumnIndex(KEY_REFERENCE_NUMBER); int columnIndexPayee = transactionCursor.getColumnIndex(KEY_PAYEE_NAME); int columnIndexTransferPeer = transactionCursor.getColumnIndex(KEY_TRANSFER_PEER); int columnIndexDate = transactionCursor.getColumnIndex(KEY_DATE); DateFormat itemDateFormat; switch (grouping) { case DAY: itemDateFormat = android.text.format.DateFormat.getTimeFormat(ctx); break; case MONTH: itemDateFormat = new SimpleDateFormat("dd"); break; case WEEK: itemDateFormat = new SimpleDateFormat("EEE"); break; default: itemDateFormat = Utils.localizedYearlessDateFormat(); } PdfPTable table = null; int prevHeaderId = 0, currentHeaderId; transactionCursor.moveToFirst(); groupCursor.moveToFirst(); while (transactionCursor.getPosition() < transactionCursor.getCount()) { int year = transactionCursor .getInt(grouping.equals(Grouping.WEEK) ? columnIndexYearOfWeekStart : columnIndexYear); int month = transactionCursor.getInt(columnIndexMonth); int week = transactionCursor.getInt(columnIndexWeek); int day = transactionCursor.getInt(columnIndexDay); int second = -1; switch (grouping) { case DAY: currentHeaderId = year * 1000 + day; break; case WEEK: currentHeaderId = year * 1000 + week; break; case MONTH: currentHeaderId = year * 1000 + month; break; case YEAR: currentHeaderId = year * 1000; break; default: currentHeaderId = 1; } if (currentHeaderId != prevHeaderId) { if (table != null) { document.add(table); } switch (grouping) { case DAY: second = transactionCursor.getInt(columnIndexDay); break; case MONTH: second = transactionCursor.getInt(columnIndexMonth); break; case WEEK: second = transactionCursor.getInt(columnIndexWeek); break; } table = helper.newTable(2); table.setWidthPercentage(100f); PdfPCell cell = helper.printToCell(grouping.getDisplayTitle(ctx, year, second, transactionCursor), FontType.HEADER); table.addCell(cell); Long sumExpense = DbUtils.getLongOr0L(groupCursor, columnIndexGroupSumExpense); Long sumIncome = DbUtils.getLongOr0L(groupCursor, columnIndexGroupSumIncome); Long sumTransfer = DbUtils.getLongOr0L(groupCursor, columnIndexGroupSumTransfer); Long delta = sumIncome - sumExpense + sumTransfer; Long interimBalance = DbUtils.getLongOr0L(groupCursor, columIndexGroupSumInterim); Long previousBalance = interimBalance - delta; cell = helper.printToCell(String.format("%s %s %s = %s", Utils.convAmount(previousBalance, currency), Long.signum(delta) > -1 ? "+" : "-", Utils.convAmount(Math.abs(delta), currency), Utils.convAmount(interimBalance, currency)), FontType.HEADER); cell.setHorizontalAlignment(Element.ALIGN_RIGHT); table.addCell(cell); document.add(table); table = helper.newTable(3); table.setWidthPercentage(100f); cell = helper.printToCell("+ " + Utils.convAmount(sumIncome, currency), FontType.NORMAL); cell.setHorizontalAlignment(Element.ALIGN_CENTER); table.addCell(cell); cell = helper.printToCell("- " + Utils.convAmount(sumExpense, currency), FontType.NORMAL); cell.setHorizontalAlignment(Element.ALIGN_CENTER); table.addCell(cell); cell = helper.printToCell("<-> " + Utils.convAmount(DbUtils.getLongOr0L(groupCursor, columnIndexGroupSumTransfer), currency), FontType.NORMAL); cell.setHorizontalAlignment(Element.ALIGN_CENTER); table.addCell(cell); table.setSpacingAfter(2f); document.add(table); LineSeparator sep = new LineSeparator(); document.add(sep); table = helper.newTable(4); table.setWidths(new int[] { 1, 5, 3, 2 }); table.setSpacingBefore(2f); table.setSpacingAfter(2f); table.setWidthPercentage(100f); prevHeaderId = currentHeaderId; groupCursor.moveToNext(); } long amount = transactionCursor.getLong(columnIndexAmount); String catText = transactionCursor.getString(columnIndexLabelMain); PdfPCell cell = helper.printToCell( Utils.convDateTime(transactionCursor.getString(columnIndexDate), itemDateFormat), FontType.NORMAL); table.addCell(cell); if (DbUtils.getLongOrNull(transactionCursor, columnIndexTransferPeer) != null) { catText = ((amount < 0) ? "=> " : "<= ") + catText; } else { Long catId = DbUtils.getLongOrNull(transactionCursor, KEY_CATID); if (SPLIT_CATID.equals(catId)) { Cursor splits = cr().query(Transaction.CONTENT_URI, null, KEY_PARENTID + " = " + transactionCursor.getLong(columnIndexRowId), null, null); splits.moveToFirst(); catText = ""; while (splits.getPosition() < splits.getCount()) { String splitText = DbUtils.getString(splits, KEY_LABEL_MAIN); if (splitText.length() > 0) { if (DbUtils.getLongOrNull(splits, KEY_TRANSFER_PEER) != null) { splitText = "[" + splitText + "]"; } else { String label_sub = DbUtils.getString(splits, KEY_LABEL_SUB); if (label_sub.length() > 0) splitText += TransactionList.CATEGORY_SEPARATOR + label_sub; } } else { splitText = ctx.getString(R.string.no_category_assigned); } splitText += " " + Utils .convAmount(splits.getLong(splits.getColumnIndexOrThrow(KEY_AMOUNT)), currency); String splitComment = DbUtils.getString(splits, KEY_COMMENT); if (splitComment != null && splitComment.length() > 0) { splitText += " (" + splitComment + ")"; } catText += splitText; if (splits.getPosition() != splits.getCount() - 1) { catText += "; "; } splits.moveToNext(); } splits.close(); } else if (catId == null) { catText = ctx.getString(R.string.no_category_assigned); } else { String label_sub = transactionCursor.getString(columnIndexLabelSub); if (label_sub != null && label_sub.length() > 0) { catText = catText + TransactionList.CATEGORY_SEPARATOR + label_sub; } } } String referenceNumber = transactionCursor.getString(columnIndexReferenceNumber); if (referenceNumber != null && referenceNumber.length() > 0) catText = "(" + referenceNumber + ") " + catText; cell = helper.printToCell(catText, FontType.NORMAL); String payee = transactionCursor.getString(columnIndexPayee); if (payee == null || payee.length() == 0) { cell.setColspan(2); } table.addCell(cell); if (payee != null && payee.length() > 0) { table.addCell(helper.printToCell(payee, FontType.UNDERLINE)); } FontType t = amount < 0 ? FontType.EXPENSE : FontType.INCOME; cell = helper.printToCell(Utils.convAmount(amount, currency), t); cell.setHorizontalAlignment(Element.ALIGN_RIGHT); table.addCell(cell); String comment = transactionCursor.getString(columnIndexComment); if (comment != null && comment.length() > 0) { cell = helper.printToCell(comment, FontType.ITALIC); cell.setColspan(2); table.addCell(helper.emptyCell()); table.addCell(cell); table.addCell(helper.emptyCell()); } transactionCursor.moveToNext(); } // now add all this to the document document.add(table); groupCursor.close(); }
From source file:org.tvd.thptty.management.report.Report.java
private PdfPTable createSubjectPointTable() throws BadElementException { int countCell = cellTitles.length; PdfPTable table = new PdfPTable(countCell); table.setWidthPercentage(100);//from w ww .ja v a 2s . com for (int i = 0; i < countCell; i++) { Phrase phrase = new Phrase(cellTitles[i], tahomaFont); PdfPCell cx = new PdfPCell(phrase); cx.setHorizontalAlignment(Element.ALIGN_CENTER); table.addCell(cx); } table.setHeaderRows(1); Phrase phrase = null; java.util.List<TYStudent> students = ActionUtil.getStudentsInClass(courses, tyClass.getClassId()); for (int i = 0; i < students.size(); i++) { //index phrase = new Phrase(String.valueOf(i + 1), tahomaFont); table.addCell(phrase); //student full name TYStudent student = students.get(i); student.setFullName(student.getStudentFirstName() + " " + student.getStudentLastName()); phrase = new Phrase(student.getFullName(), tahomaFont); table.addCell(phrase); //speak point float points[] = TYServiceUtil.getPointStudentByPTPF(courses, semester, student.getStudentId(), tySubject.getSubjectId(), WebKeys.SPEAK_POINT, 1); String pointString = TYServiceUtil.floatsToPointString(points); phrase = new Phrase(pointString, smallBold); table.addCell(phrase); //15' point points = TYServiceUtil.getPointStudentByPTPF(courses, semester, student.getStudentId(), tySubject.getSubjectId(), WebKeys.WRITE_POINT, 1); pointString = TYServiceUtil.floatsToPointString(points); phrase = new Phrase(pointString, smallBold); table.addCell(phrase); //45' point points = TYServiceUtil.getPointStudentByPTPF(courses, semester, student.getStudentId(), tySubject.getSubjectId(), WebKeys.WRITE_POINT, 2); pointString = TYServiceUtil.floatsToPointString(points); phrase = new Phrase(pointString, smallBold); table.addCell(phrase); //90' point points = TYServiceUtil.getPointStudentByPTPF(courses, semester, student.getStudentId(), tySubject.getSubjectId(), WebKeys.WRITE_POINT, 3); pointString = TYServiceUtil.floatsToPointString(points); phrase = new Phrase(pointString, smallBold); table.addCell(phrase); //avg point TYStudentPoint studentPointSubject = TYServiceUtil.getStudentAVGPointBySubject(courses, semester, student.getStudentId(), tySubject.getSubjectId()); float avgPointSubject = 0; if (studentPointSubject != null) avgPointSubject = TYServiceUtil.getCutFloat(studentPointSubject.getPoint(), 1); pointString = "" + avgPointSubject; phrase = new Phrase(pointString, smallBold); table.addCell(phrase); } float totalWidth = PageSize.A4.getWidth(); float columnWidths[] = { (float) (0.05 * totalWidth), (float) (0.35 * totalWidth), (float) (0.1 * totalWidth), (float) (0.2 * totalWidth), (float) (0.1 * totalWidth), (float) (0.1 * totalWidth), (float) (0.1 * totalWidth) }; try { table.setWidthPercentage(columnWidths, PageSize.A4); } catch (DocumentException e) { e.printStackTrace(); } return table; }
From source file:org.tvd.thptty.management.report.Report.java
private PdfPTable createStatisticsStudentPointTable() throws BadElementException { PdfPTable table = new PdfPTable(15); table.setWidthPercentage(100);/*from w w w .ja v a 2 s. c o m*/ for (int i = 0; i < 3; i++) { Phrase phrase = new Phrase(cellTitles[i], tahomaBoldFont); PdfPCell cx = new PdfPCell(phrase); cx.setHorizontalAlignment(Element.ALIGN_CENTER); cx.setVerticalAlignment(Element.ALIGN_MIDDLE); cx.setRowspan(3); table.addCell(cx); } for (int i = 3; i < 5; i++) { Phrase phrase = new Phrase(cellTitles[i], tahomaBoldFont); PdfPCell cx = new PdfPCell(phrase); cx.setHorizontalAlignment(Element.ALIGN_CENTER); cx.setVerticalAlignment(Element.ALIGN_MIDDLE); cx.setColspan(6); table.addCell(cx); } for (int i = 5; i < 11; i++) { Phrase phrase = new Phrase(cellTitles[i], tahomaBoldFont); PdfPCell cx = new PdfPCell(phrase); cx.setHorizontalAlignment(Element.ALIGN_CENTER); cx.setVerticalAlignment(Element.ALIGN_MIDDLE); cx.setColspan(2); table.addCell(cx); } for (int i = 11; i < 23; i++) { Phrase phrase = new Phrase(cellTitles[i], tahomaBoldFont); PdfPCell cx = new PdfPCell(phrase); cx.setHorizontalAlignment(Element.ALIGN_CENTER); cx.setVerticalAlignment(Element.ALIGN_MIDDLE); table.addCell(cx); } table.setHeaderRows(3); Phrase phrase = null; for (int i = 0; rows != null && i < rows.size(); i++) { for (int k = 0; k < rows.get(i).getListCells().size(); k++) { phrase = new Phrase(rows.get(i).getListCells().get(k).getCellName(), tahomaSmallFont); PdfPCell cx = new PdfPCell(phrase); cx.setHorizontalAlignment(Element.ALIGN_CENTER); cx.setVerticalAlignment(Element.ALIGN_MIDDLE); table.addCell(cx); } } float totalWidth = PageSize.A4.getWidth(); float columnWidths[] = new float[15]; for (int i = 0; i < columnWidths.length; i++) { columnWidths[i] = (float) (1.0 / 15) * totalWidth; } try { table.setWidthPercentage(columnWidths, PageSize.A4); } catch (DocumentException e) { e.printStackTrace(); } return table; }
From source file:org.tvd.thptty.management.util.Report.java
private PdfPTable createTable(Section subCatPart) throws BadElementException { int countCell = cellTitles.length; PdfPTable table = new PdfPTable(countCell); for (int i = 0; i < countCell; i++) { PdfPCell cx = new PdfPCell(new Phrase(cellTitles[i])); cx.setHorizontalAlignment(Element.ALIGN_CENTER); table.addCell(cx);/*from ww w . jav a 2s . c o m*/ } table.setHeaderRows(1); java.util.List<TYStudent> students = ActionUtil.getStudentsInClass(courses, tyClass.getClassId()); for (int i = 0; i < students.size(); i++) { TYStudent student = students.get(i); student.setFullName(student.getStudentFirstName() + " " + student.getStudentLastName()); table.addCell(student.getFullName()); System.out.println("\n" + student.getFullName() + "\n"); float points[] = TYServiceUtil.getPointStudentByPTPF(courses, semester, student.getStudentId(), tySubject.getSubjectId(), WebKeys.SPEAK_POINT, 1); String pointString = TYServiceUtil.floatsToPointString(points); table.addCell(pointString); points = TYServiceUtil.getPointStudentByPTPF(courses, semester, student.getStudentId(), tySubject.getSubjectId(), WebKeys.WRITE_POINT, 1); pointString = TYServiceUtil.floatsToPointString(points); table.addCell(pointString); points = TYServiceUtil.getPointStudentByPTPF(courses, semester, student.getStudentId(), tySubject.getSubjectId(), WebKeys.WRITE_POINT, 2); pointString = TYServiceUtil.floatsToPointString(points); table.addCell(pointString); points = TYServiceUtil.getPointStudentByPTPF(courses, semester, student.getStudentId(), tySubject.getSubjectId(), WebKeys.WRITE_POINT, 3); pointString = TYServiceUtil.floatsToPointString(points); table.addCell(pointString); java.util.List<TYStudentPoint> studentPointSubjects = TYServiceUtil.getStudentAVGPointBySubject(courses, semester, student.getStudentId(), tySubject.getSubjectId()); float avgPointSubject = 0; if (studentPointSubjects.size() > 0) avgPointSubject = TYServiceUtil.getCutFloat(studentPointSubjects.get(0).getPoint(), 2); pointString = "" + avgPointSubject; table.addCell(pointString); } subCatPart.add(table); return table; }
From source file:others.pdfWriter.java
public static void createTableExercicios(Document document, java.util.List<Exercicios> exercicios) throws BadElementException, DocumentException { PdfPTable table = new PdfPTable(3); // t.setBorderColor(BaseColor.GRAY); // t.setPadding(4); // t.setSpacing(4); // t.setBorderWidth(1); PdfPCell c1 = new PdfPCell(new Phrase("Exercicio")); c1.setHorizontalAlignment(Element.ALIGN_CENTER); table.addCell(c1);/*from w w w . j av a2s. c om*/ c1 = new PdfPCell(new Phrase("Descrio")); c1.setHorizontalAlignment(Element.ALIGN_CENTER); table.addCell(c1); c1 = new PdfPCell(new Phrase("Musculo")); c1.setHorizontalAlignment(Element.ALIGN_CENTER); table.addCell(c1); table.setHeaderRows(1); if (exercicios.size() < 1) { table.addCell("Adicione Exercicios"); table.addCell("Adicione Exercicios"); table.addCell("Adicione Exercicios"); } for (Exercicios exercicio : exercicios) { table.addCell(exercicio.getNome()); table.addCell(exercicio.getDescricao()); table.addCell(exercicio.getMusculo()); } document.add(table); }
From source file:others.pdfWriter.java
public static void createTableGeral(Document document, java.util.List<Aluno> alunos) throws BadElementException, DocumentException { PdfPTable table = new PdfPTable(3); // t.setBorderColor(BaseColor.GRAY); // t.setPadding(4); // t.setSpacing(4); // t.setBorderWidth(1); PdfPCell c1 = new PdfPCell(new Phrase("Aluno")); c1.setHorizontalAlignment(Element.ALIGN_CENTER); table.addCell(c1);//from ww w . j a v a2s.c o m c1 = new PdfPCell(new Phrase("Email Aluno")); c1.setHorizontalAlignment(Element.ALIGN_CENTER); table.addCell(c1); c1 = new PdfPCell(new Phrase("Professor")); c1.setHorizontalAlignment(Element.ALIGN_CENTER); table.addCell(c1); table.setHeaderRows(1); if (alunos.size() < 1) { table.addCell("Nada consta"); table.addCell("Nada consta"); table.addCell("Nada consta"); } for (Aluno aluno : alunos) { table.addCell(aluno.getNome()); table.addCell(aluno.getEmail()); if (aluno.getInstrutor() != null) { table.addCell(aluno.getInstrutor().getNome()); } else { table.addCell("Aguarda aceitao"); } } document.add(table); }
From source file:others.pdfWriter.java
public static void createTableAlunos(Document document, java.util.List<Aluno> alunos) throws BadElementException, DocumentException { PdfPTable table = new PdfPTable(2); // t.setBorderColor(BaseColor.GRAY); // t.setPadding(4); // t.setSpacing(4); // t.setBorderWidth(1); PdfPCell c1 = new PdfPCell(new Phrase("Aluno")); c1.setHorizontalAlignment(Element.ALIGN_CENTER); table.addCell(c1);// w w w . ja v a2s .co m c1 = new PdfPCell(new Phrase("Email")); c1.setHorizontalAlignment(Element.ALIGN_CENTER); table.addCell(c1); table.setHeaderRows(1); if (alunos.size() < 1) { table.addCell("Adicione Alunos"); table.addCell("Adicione Alunos"); } for (Aluno aluno : alunos) { table.addCell(aluno.getNome()); table.addCell(aluno.getEmail()); } document.add(table); }
From source file:our.isaacmayur.expensemanager.GenerateReport.java
private static void createTable(Section catPart) throws BadElementException { PdfPTable table = new PdfPTable(4); // t.setBorderColor(BaseColor.GRAY); // t.setPadding(4); // t.setSpacing(4); // t.setBorderWidth(1); for (int i = 0; i < category.size(); i++) { Log.e("category...", category.get(i)); Log.e("mode...", mode.get(i)); Log.e("amt...", "amt" + amount.get(i)); Log.e("date2...", "date" + date.get(i)); }//ww w . j a v a 2 s. c om PdfPCell c1 = new PdfPCell(new Phrase("Category Name")); c1.setHorizontalAlignment(Element.ALIGN_CENTER); table.addCell(c1); c1 = new PdfPCell(new Phrase("Amount Spent (Rs)")); c1.setHorizontalAlignment(Element.ALIGN_CENTER); table.addCell(c1); c1 = new PdfPCell(new Phrase("Date")); c1.setHorizontalAlignment(Element.ALIGN_CENTER); table.addCell(c1); c1 = new PdfPCell(new Phrase("Payment Mode")); c1.setHorizontalAlignment(Element.ALIGN_CENTER); table.addCell(c1); table.setHeaderRows(1); /* * table.addCell("pay"); table.addCell("hell"); table.addCell("to"); * table.addCell("to"); table.addCell("to"); * * table.addCell("2.1"); table.addCell("2.2"); table.addCell("2.3"); */ // code to add rows dynamically...remember the multiple for (int i = 0; i < category.size(); i++) { table.addCell(category.get(i)); table.addCell(amount.get(i) + ""); table.addCell(date.get(i)); table.addCell(mode.get(i)); } catPart.add(table); Log.e("meta", "table"); }
From source file:PDF.GenerateReportActivities.java
private PdfPTable TablaDatos() throws Exception { PdfPTable Datos_prof = new PdfPTable(5); Datos_prof.setWidths(new int[] { 2, 3, 2, 2, 2 }); PdfPCell Titulo_tabla = new PdfPCell(new Phrase("Datos generales del Profesor", encabezadost)); PdfPCell Nombre = new PdfPCell(new Phrase("Nombre del Profesor")); PdfPCell Matricula = new PdfPCell(new Phrase("No. de Empleado")); PdfPCell UA = new PdfPCell(new Phrase("Unidad Acadmica")); PdfPCell Puntos = new PdfPCell(new Phrase("Puntos obtenidos")); PdfPCell Nivel = new PdfPCell(new Phrase("Nivel de Beca")); Titulo_tabla.setHorizontalAlignment(Element.ALIGN_CENTER); Titulo_tabla.setVerticalAlignment(Element.ALIGN_MIDDLE); Titulo_tabla.setBackgroundColor(new BaseColor(153, 0, 76)); Titulo_tabla.setColspan(5);//from w w w .j av a2 s.com Titulo_tabla.setExtraParagraphSpace(15f); Datos_prof.addCell(Titulo_tabla); Nombre.setHorizontalAlignment(Element.ALIGN_CENTER); Datos_prof.addCell(Nombre); Matricula.setHorizontalAlignment(Element.ALIGN_CENTER); Datos_prof.addCell(Matricula); UA.setHorizontalAlignment(Element.ALIGN_CENTER); Datos_prof.addCell(UA); Puntos.setHorizontalAlignment(Element.ALIGN_CENTER); Datos_prof.addCell(Puntos); Nivel.setHorizontalAlignment(Element.ALIGN_CENTER); Datos_prof.addCell(Nivel); /*Aqui van las consultas de los datos del profesor*/ ResultSet rn, rt; String nom_usuario = null, id_usuario = null, u_a = null, puntaje_final = null, nivel = null; //Datos_prof.addCell("Hola"); ResultSet rp = lb.executeQuery("SELECT * FROM usuario WHERE id_usuario = " + username); while (rp.next()) { nom_usuario = rp.getString("nom_usuario"); id_usuario = rp.getString("id_usuario"); u_a = rp.getString("u_a"); } System.out.println(getUsername()); rn = lb.executeQuery( "SELECT * FROM evaluador_evalua_profesor WHERE id_usuario_prof = '" + getUsername() + "'"); while (rn.next()) { puntaje_final = rn.getString("puntaje_final"); //Datos_prof.addCell(rn.getString("puntaje_final")); } rt = lb.executeQuery("SELECT * FROM profesor WHERE id_usuario = '" + getUsername() + "'"); while (rt.next()) { nivel = rt.getString("nivel"); } Datos_prof.addCell(nom_usuario); Datos_prof.addCell(id_usuario); Datos_prof.addCell(u_a); Datos_prof.addCell(puntaje_final); Datos_prof.addCell(nivel); return Datos_prof; }
From source file:PDF.GenerateReportActivities.java
private PdfPTable dospuntouno() throws Exception { PdfPTable Dos_uno = new PdfPTable(6); Dos_uno.setWidths(new int[] { 2, 2, 3, 2, 2, 2 }); PdfPCell Titulo_tabla = new PdfPCell(new Phrase( "Actividad 2.1" + " - Formacin de Recursos Humanos para la Investigacin", encabezadost)); PdfPCell Nom_Proyecto = new PdfPCell(new Phrase("Nmero de proyecto SIP")); PdfPCell Num_Actividad = new PdfPCell(new Phrase("Nmero de Actividad")); PdfPCell Tipo_Actividad = new PdfPCell(new Phrase("Tipo de Actividad")); PdfPCell Ruta_alm = new PdfPCell(new Phrase("Evidencia")); PdfPCell Puntos = new PdfPCell(new Phrase("Puntos obtenidos")); PdfPCell Observaciones = new PdfPCell(new Phrase("Observaciones")); //PdfPCell celda=new PdfPCell(); Titulo_tabla.setHorizontalAlignment(Element.ALIGN_CENTER); Titulo_tabla.setVerticalAlignment(Element.ALIGN_MIDDLE); Titulo_tabla.setBackgroundColor(new BaseColor(153, 0, 76)); Titulo_tabla.setColspan(6);// w ww . j a v a 2 s . c o m Titulo_tabla.setExtraParagraphSpace(15f); Dos_uno.addCell(Titulo_tabla); Nom_Proyecto.setHorizontalAlignment(Element.ALIGN_CENTER); Nom_Proyecto.setVerticalAlignment(Element.ALIGN_MIDDLE); Dos_uno.addCell(Nom_Proyecto); Num_Actividad.setHorizontalAlignment(Element.ALIGN_CENTER); Num_Actividad.setVerticalAlignment(Element.ALIGN_MIDDLE); Dos_uno.addCell(Num_Actividad); Tipo_Actividad.setHorizontalAlignment(Element.ALIGN_CENTER); Tipo_Actividad.setVerticalAlignment(Element.ALIGN_MIDDLE); Dos_uno.addCell(Tipo_Actividad); Ruta_alm.setHorizontalAlignment(Element.ALIGN_CENTER); Ruta_alm.setVerticalAlignment(Element.ALIGN_MIDDLE); Dos_uno.addCell(Ruta_alm); Puntos.setHorizontalAlignment(Element.ALIGN_CENTER); Puntos.setVerticalAlignment(Element.ALIGN_MIDDLE); Dos_uno.addCell(Puntos); Observaciones.setHorizontalAlignment(Element.ALIGN_CENTER); Observaciones.setVerticalAlignment(Element.ALIGN_MIDDLE); Dos_uno.addCell(Observaciones); /*Aqui van las consultas de las Actividades del profesor*/ /**Get actual period***/ int periodo = 0; ResultSet rperiodo = lb.executeQuery("SELECT * FROM profesor WHERE id_usuario = " + getUsername()); if (rperiodo.next()) periodo = rperiodo.getInt("periodo"); /**Get actual period***/ String id_al = null, tipo_alumno = null, puntaje = null, comen = null, nom_proyecto = null; ResultSet rb = lb .executeQuery("SELECT * FROM profesor_tiene_proyecto WHERE " + "id_usuario = " + getUsername() + " AND (validado_alumno = 1 OR validado_alumno = 0) AND " + "periodo = " + periodo); while (rb.next()) { nom_proyecto = rb.getString("id_proyecto"); Dos_uno.addCell(nom_proyecto); id_al = rb.getString("id_alumno"); Dos_uno.addCell(id_al); tipo_alumno = rb.getString("tipo_alumno"); Dos_uno.addCell(tipo_alumno); Anchor anchor = new Anchor("Constancia"); //anchor.setReference("file:///"+rb.getString("ruta_alm")); anchor.setReference(rb.getString("ruta_alumno")); Dos_uno.addCell(anchor); puntaje = rb.getString("puntaje_alumno"); Dos_uno.addCell(puntaje); comen = rb.getString("comentarios"); Dos_uno.addCell(comen); } return Dos_uno; }