List of usage examples for com.itextpdf.text.pdf PdfPCell setRowspan
public void setRowspan(int rowspan)
From source file:com.softwaremagico.tm.pdf.small.SmallCharacterSheet.java
License:Open Source License
protected PdfPTable createCharacterContent(CharacterPlayer characterPlayer) throws Exception { float[] widths = { 2.2f, 1f }; PdfPTable mainTable = new PdfPTable(widths); BaseElement.setTablePropierties(mainTable); mainTable.getDefaultCell().setPadding(0); PdfPTable infoTable = CharacterBasicsReducedTableFactory.getCharacterBasicsTable(characterPlayer); PdfPCell infoCell = new PdfPCell(infoTable); infoCell.setBorderWidthTop(0);//from ww w .ja va 2s . co m infoCell.setBorderWidthLeft(0); infoCell.setBorderWidthBottom(1); mainTable.addCell(infoCell); PdfPTable learnedSkillsTable = LearnedSkillsTable.getSkillsTable(characterPlayer, getLanguage()); PdfPCell learnedSkillsCell = new PdfPCell(learnedSkillsTable); learnedSkillsCell.setColspan(2); learnedSkillsCell.setRowspan(3); learnedSkillsCell.setBorderWidthTop(0); learnedSkillsCell.setBorderWidthRight(0); mainTable.addCell(learnedSkillsCell); PdfPTable basicTable = new PdfPTable(new float[] { 5f, 4f }); BaseElement.setTablePropierties(basicTable); basicTable.getDefaultCell().setBorder(0); PdfPTable characteristicsTable = CharacteristicsTableFactory.getCharacteristicsBasicsTable(characterPlayer); PdfPCell characteristicCell = new PdfPCell(characteristicsTable); characteristicCell.setBorderWidthLeft(0); basicTable.addCell(characteristicCell); PdfPTable naturalSkillsTable = NaturalSkillsTable.getSkillsTable(characterPlayer, getLanguage()); PdfPCell naturalSkillsCell = new PdfPCell(naturalSkillsTable); naturalSkillsCell.setBorderWidthRight(0); basicTable.addCell(naturalSkillsCell); PdfPCell basicComposedCell = new PdfPCell(basicTable); basicComposedCell.setBorder(0); mainTable.addCell(basicComposedCell); PdfPTable composedTable = new PdfPTable(new float[] { 5f, 2f }); PdfPTable blessingsTable = new BlessingTable(characterPlayer); PdfPCell blessingsCell = new PdfPCell(blessingsTable); blessingsCell.setBorderWidthLeft(0); blessingsCell.setBorderWidthBottom(1); composedTable.addCell(blessingsCell); PdfPTable beneficesTable = new BeneficesTable(characterPlayer); PdfPCell beneficesCell = new PdfPCell(beneficesTable); beneficesCell.setBorderWidthBottom(1); composedTable.addCell(beneficesCell); PdfPCell composedCell = new PdfPCell(composedTable); composedCell.setRowspan(2); composedCell.setBorder(0); mainTable.addCell(composedCell); PdfPTable armourTable = new ArmourTable(characterPlayer); PdfPCell armourCell = new PdfPCell(armourTable); armourCell.setBorderWidthRight(0); armourCell.setBorderWidthBottom(1); mainTable.addCell(armourCell); PdfPTable fightTable = new PdfPTable(new float[] { 3f, 5f, 1f }); if (characterPlayer != null && (characterPlayer.getSelectedPowers().isEmpty() && !characterPlayer.getCybernetics().isEmpty())) { PdfPTable cyberneticsTable = new CyberneticsTable(characterPlayer); PdfPCell cyberneticsCell = new PdfPCell(cyberneticsTable); cyberneticsCell.setBorderWidthLeft(0); fightTable.addCell(cyberneticsCell); } else { PdfPTable occultismTable = new OccultismTable(characterPlayer, getLanguage()); PdfPCell occultismCell = new PdfPCell(occultismTable); occultismCell.setBorderWidthLeft(0); fightTable.addCell(occultismCell); } PdfPTable weaponsTable = new WeaponsTable(characterPlayer); fightTable.addCell(weaponsTable); PdfPCell victoryPointsCell = new PdfPCell(new VerticalVictoryPointsTable()); victoryPointsCell.setPadding(0); victoryPointsCell.setRowspan(3); fightTable.addCell(victoryPointsCell); PdfPTable vitalityTable = new VitalityTable(characterPlayer); PdfPCell vitalityCell = new PdfPCell(vitalityTable); vitalityCell.setColspan(2); vitalityCell.setBorderWidth(1); fightTable.addCell(vitalityCell); PdfPTable wyrdTable = new WyrdTable(characterPlayer); PdfPCell wyrdCell = new PdfPCell(wyrdTable); wyrdCell.setBorderWidth(1); wyrdCell.setColspan(2); fightTable.addCell(wyrdCell); PdfPCell fightCell = new PdfPCell(fightTable); fightCell.setBorder(0); fightCell.setColspan(2); mainTable.addCell(fightCell); return mainTable; }
From source file:com.tomasz.drag.triballocommanderro.controller.MakerPDF.java
public static PdfPTable createTable(Person person, EventGig event) throws DocumentException, IOException { int a = 0;/* w w w . j av a 2 s . co m*/ if (person.getZaladunekScenaDachWyplata() > 0) { a++; } if (person.getZaladunekTechnikiWyplata() > 0) { a++; } if (person.getMontazDachuWyplata() > 0) { a++; } if (person.getMontazDzwiekuWyplata() > 0) { a++; } if (person.getMontazScenyWyplata() > 0) { a++; } if (person.getMontazSwiatlaWyplata() > 0) { a++; } if (person.getMontazTechnikiWyplata() > 0) { a++; } if (person.getDemontazDachuWyplata() > 0) { a++; } if (person.getDemontazDzwiekuWyplata() > 0) { a++; } if (person.getDemontazScenyWyplata() > 0) { a++; } if (person.getDemontazSwiatlaWyplata() > 0) { a++; } if (person.getDemontazTechnikiWyplata() > 0) { a++; } if (person.getRozladunekScenaDachWyplata() > 0) { a++; } if (person.getRozladunekTechnikiWyplata() > 0) { a++; } if (person.getDyzurWyplata() > 0) { a++; } if (person.getTechnikScenyWyplata() > 0) { a++; } if (person.getRealizacjaFOHWyplata() > 0) { a++; } if (person.getRealizacjaMONWyplata() > 0) { a++; } if (person.getRealizacjaSwiatlaWyplata() > 0) { a++; } if (person.getPremia() > 0) { a++; } System.out.println(a); BaseFont bf; bf = BaseFont.createFont("src\\main\\resources\\font\\arialuni.ttf", BaseFont.IDENTITY_H, BaseFont.EMBEDDED); // bf = BaseFont.createFont("arialuni.ttf", BaseFont.IDENTITY_H, BaseFont.EMBEDDED); com.itextpdf.text.Font ft = new com.itextpdf.text.Font(bf); PdfPTable table = new PdfPTable(2); table.setTotalWidth(new float[] { 90, 190 }); table.setLockedWidth(true); PdfPCell cell; cell = new PdfPCell(new Phrase(person.getName() + " " + person.getSurName(), ft)); cell.setColspan(1); table.addCell(cell); cell = new PdfPCell(new Phrase(event.getName() + " " + event.getData(), ft)); cell.setColspan(2); table.addCell(cell); cell = new PdfPCell(new Phrase("")); cell.setRowspan(a); table.addCell(cell); if (person.getZaladunekScenaDachWyplata() > 0) { table.addCell(new Phrase("Zaadunek Scena/Dach", ft)); } if (person.getZaladunekTechnikiWyplata() > 0) { table.addCell(new Phrase("Zaadunek Techniki", ft)); } if (person.getMontazDachuWyplata() > 0) { table.addCell(new Phrase("Monta Dachu", ft)); } if (person.getMontazDzwiekuWyplata() > 0) { table.addCell(new Phrase("Monta Dwieku", ft)); } if (person.getMontazScenyWyplata() > 0) { table.addCell(new Phrase("Monta Sceny", ft)); } if (person.getMontazSwiatlaWyplata() > 0) { table.addCell(new Phrase("Monta wiata", ft)); } if (person.getMontazTechnikiWyplata() > 0) { table.addCell(new Phrase("Monta Techniki", ft)); } if (person.getDemontazDachuWyplata() > 0) { table.addCell(new Phrase("Demonta Dachu", ft)); } if (person.getDemontazDzwiekuWyplata() > 0) { table.addCell(new Phrase("Demonta Dwieku", ft)); } if (person.getDemontazScenyWyplata() > 0) { table.addCell(new Phrase("Demonta Sceny", ft)); } if (person.getDemontazSwiatlaWyplata() > 0) { table.addCell(new Phrase("Demonta wiata", ft)); } if (person.getDemontazTechnikiWyplata() > 0) { table.addCell(new Phrase("Demonta Techniki", ft)); } if (person.getRozladunekScenaDachWyplata() > 0) { table.addCell(new Phrase("Rozadunek Scena/Dach", ft)); } if (person.getRozladunekTechnikiWyplata() > 0) { table.addCell(new Phrase("Rozadunek Techniki", ft)); } if (person.getDyzurWyplata() > 0) { table.addCell(new Phrase("Dyur", ft)); } if (person.getTechnikScenyWyplata() > 0) { table.addCell(new Phrase("Technik Sceny", ft)); } if (person.getRealizacjaFOHWyplata() > 0) { table.addCell(new Phrase("Realizacja FOH", ft)); } if (person.getRealizacjaMONWyplata() > 0) { table.addCell(new Phrase("Realizacja MON", ft)); } if (person.getRealizacjaSwiatlaWyplata() > 0) { table.addCell(new Phrase("Realizacja wiata", ft)); } if (person.getPremia() > 0) { table.addCell(new Phrase("Premia", ft)); } cell = new PdfPCell(new Phrase("Suma: ")); cell.setColspan(1); table.addCell(cell); //cell = new PdfPCell(new Phrase(Double.toString(person.getSumaWyplata())));//String.format("%.2f", tempPerson.getRealizacjaSwiatlaWyplata()) cell = new PdfPCell(new Phrase(String.format("%.2f", person.getSumaWyplata()) + " z", ft));//String.format("%.2f", tempPerson.getRealizacjaSwiatlaWyplata()) table.addCell(cell); cell = new PdfPCell(new Phrase(" ")); cell.setColspan(1); cell.setBorder(Rectangle.NO_BORDER); table.addCell(cell); //cell = new PdfPCell(new Phrase(Double.toString(person.getSumaWyplata())));//String.format("%.2f", tempPerson.getRealizacjaSwiatlaWyplata()) cell = new PdfPCell(new Phrase(" "));//String.format("%.2f", tempPerson.getRealizacjaSwiatlaWyplata()) cell.setBorder(Rectangle.NO_BORDER); table.addCell(cell); table.setBreakPoints(2 + a); return table; }
From source file:com.vectorprint.report.itext.style.stylers.ColRowSpan.java
License:Open Source License
@Override public <E> E style(E text, Object data) throws VectorPrintException { PdfPCell cell = (PdfPCell) text; cell.setColspan(getValue(COLSPAN_PARAM, Integer.class)); cell.setRowspan(getValue(ROWSPAN_PARAM, Integer.class)); return text;//from w ww.j av a 2 s. c om }
From source file:com.wabacus.system.component.application.report.abstractreport.AbsReportType.java
License:Open Source License
protected void addDataHeaderCell(Object configbean, String value, int rowspan, int colspan, int align) { if (dataheadFont == null) { int dataheaderfontsize = 0; if (this.pdfbean != null) dataheaderfontsize = this.pdfbean.getDataheaderfontsize(); if (dataheaderfontsize <= 0) dataheaderfontsize = 6;// w w w . j a v a 2s.c o m dataheadFont = new Font(PdfAssistant.getInstance().getBfChinese(), dataheaderfontsize, Font.BOLD);//?? } PdfPCell cell = new PdfPCell(new Paragraph(value, dataheadFont)); cell.setColspan(colspan); cell.setRowspan(rowspan); // cell.setImage(img); // cell.addElement(new Paragraph(value+"2222",dataheadFont)); cell.setBackgroundColor(BaseColor.LIGHT_GRAY); cell.setHorizontalAlignment(align); cell.setVerticalAlignment(Element.ALIGN_MIDDLE); if (pdfbean != null && pdfbean.getInterceptorObj() != null) { pdfbean.getInterceptorObj().displayPerColDataWithoutTemplate(this, configbean, -1, value, cell); } pdfDataTable.addCell(cell); }
From source file:com.wabacus.system.component.application.report.abstractreport.AbsReportType.java
License:Open Source License
protected void addDataCell(Object configbean, String value, int rowspan, int colspan, int align) { if (dataFont == null) { int datafontsize = 0; if (this.pdfbean != null) datafontsize = this.pdfbean.getDatafontsize(); if (datafontsize <= 0) datafontsize = 6;/* ww w . j ava 2 s.c om*/ dataFont = new Font(PdfAssistant.getInstance().getBfChinese(), datafontsize, Font.NORMAL); } PdfPCell cell = new PdfPCell(new Paragraph(value, dataFont)); cell.setColspan(colspan);//?? cell.setRowspan(rowspan); // }catch(Exception e) cell.setHorizontalAlignment(align);//?? cell.setVerticalAlignment(Element.ALIGN_MIDDLE); if (pdfbean != null && pdfbean.getInterceptorObj() != null) { pdfbean.getInterceptorObj().displayPerColDataWithoutTemplate(this, configbean, rowspan, value, cell); } pdfDataTable.addCell(cell); }
From source file:ControleurClients.ControleurClients.java
private void pageCommandes(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException, DocumentException { request.setAttribute("attente", commandef.getAttente(clientConnect)); request.setAttribute("cours", commandef.getCours(clientConnect)); request.setAttribute("effectuee", commandef.getEffectuee(clientConnect)); List<Commande> attente = commandef.getAttente(); List<Commande> cours = commandef.getCours(); List<Commande> effectue = commandef.getEffectuee(); if (!attente.isEmpty()) { for (Commande c : attente) { Document document1 = new Document(); PdfWriter.getInstance(document1, new FileOutputStream("/home/aymeric/Commerce/Commerce/Commerce-war/web/pdf/attente" + c.getId().toString() + ".pdf")); document1.open();// w w w. j av a 2s . c o m Paragraph text = new Paragraph(); text.add(new Paragraph("Grenoble Dvd", new Font(Font.FontFamily.TIMES_ROMAN, 24, Font.BOLD))); text.add(new Paragraph(" ")); text.add(new Paragraph(" ")); text.add(new Paragraph(" ")); text.add(new Paragraph(" ")); text.add(new Paragraph("Facture", new Font(Font.FontFamily.TIMES_ROMAN, 24, Font.BOLD))); text.add(new Paragraph(" ")); text.add(new Paragraph(" ")); text.add(new Paragraph(" ")); text.add(new Paragraph(" ")); text.add(new Paragraph("En attente : Commande n" + c.getId().toString(), new Font(Font.FontFamily.TIMES_ROMAN, 18, Font.BOLD))); text.add(new Paragraph(" ")); text.add(new Paragraph(" ")); document1.add(text); Paragraph p = new Paragraph(c.getDate(), new Font(Font.FontFamily.TIMES_ROMAN, 14, Font.ITALIC)); p.setAlignment(Element.ALIGN_RIGHT); p.add(new Paragraph(" ")); p.add(new Paragraph(" ")); document1.add(p); Paragraph text1 = new Paragraph(); text1.add(new Paragraph( "Mr " + c.getClient().getNom().substring(0, 1).toUpperCase() + c.getClient().getNom().substring(1) + " " + c.getClient().getPrenom().substring(0, 1).toUpperCase() + c.getClient().getPrenom().substring(1), new Font(Font.FontFamily.TIMES_ROMAN, 14, Font.ITALIC))); text1.add(new Paragraph("Email: " + c.getClient().getEmail(), new Font(Font.FontFamily.TIMES_ROMAN, 14, Font.ITALIC))); text1.add(new Paragraph(" ")); text1.add(new Paragraph(" ")); text1.add(new Paragraph(" ")); text1.add(new Paragraph(" ")); text1.add(new Paragraph(" ")); document1.add(text1); PdfPTable table = new PdfPTable(3); //On crer l'objet cellule. PdfPCell cell; cell = new PdfPCell(new Phrase("Facture")); cell.setColspan(3); table.addCell(cell); cell = new PdfPCell(new Phrase("Nom du Dvd")); cell.setRowspan(1); table.addCell(cell); //contenu du tableau. table.addCell("Quantit"); table.addCell("Prix"); for (Entry<Dvd, Integer> entry : c.getDvds().entrySet()) { Dvd dvd = (Dvd) entry.getKey(); Object value = entry.getValue(); //Image dvdimage = Image.getInstance(dvd.getImage()); //On crer un objet table dans lequel on intialise a taille. cell = new PdfPCell(new Phrase(dvd.getTitre())); cell.setRowspan(1); table.addCell(cell); table.addCell(String.valueOf(value)); table.addCell(String.valueOf(dvd.getPrix())); } cell = new PdfPCell(new Phrase("Total: " + String.valueOf(c.getMontant()) + " ")); cell.setColspan(3); table.addCell(cell); document1.add(table); Paragraph p1 = new Paragraph(); p1.add(new Paragraph(" ")); p1.add(new Paragraph(" ")); p1.add(new Paragraph(" ")); p1.add(new Paragraph(" ")); p1.add(new Paragraph(" Grenoble Dvd: 12 avenue des ensimag 38000 Grenoble", new Font(Font.FontFamily.TIMES_ROMAN, 14, Font.ITALIC))); p1.setAlignment(Element.ALIGN_RIGHT); document1.add(p1); document1.close(); } } if (!cours.isEmpty()) { for (Commande c : cours) { Document document1 = new Document(); PdfWriter.getInstance(document1, new FileOutputStream("/home/aymeric/Commerce/Commerce/Commerce-war/web/pdf/cours" + c.getId().toString() + ".pdf")); document1.open(); Paragraph text = new Paragraph(); text.add(new Paragraph("Grenoble Dvd", new Font(Font.FontFamily.TIMES_ROMAN, 24, Font.BOLD))); text.add(new Paragraph(" ")); text.add(new Paragraph(" ")); text.add(new Paragraph(" ")); text.add(new Paragraph(" ")); text.add(new Paragraph("Facture", new Font(Font.FontFamily.TIMES_ROMAN, 24, Font.BOLD))); text.add(new Paragraph(" ")); text.add(new Paragraph(" ")); text.add(new Paragraph(" ")); text.add(new Paragraph(" ")); text.add(new Paragraph("En cours : Commande n" + c.getId().toString(), new Font(Font.FontFamily.TIMES_ROMAN, 18, Font.BOLD))); text.add(new Paragraph(" ")); text.add(new Paragraph(" ")); document1.add(text); Paragraph p = new Paragraph(c.getDate(), new Font(Font.FontFamily.TIMES_ROMAN, 14, Font.ITALIC)); p.setAlignment(Element.ALIGN_RIGHT); p.add(new Paragraph(" ")); p.add(new Paragraph(" ")); document1.add(p); Paragraph text1 = new Paragraph(); text1.add(new Paragraph( "Mr " + c.getClient().getNom().substring(0, 1).toUpperCase() + c.getClient().getNom().substring(1) + " " + c.getClient().getPrenom().substring(0, 1).toUpperCase() + c.getClient().getPrenom().substring(1), new Font(Font.FontFamily.TIMES_ROMAN, 14, Font.ITALIC))); text1.add(new Paragraph("Email: " + c.getClient().getEmail(), new Font(Font.FontFamily.TIMES_ROMAN, 14, Font.ITALIC))); text1.add(new Paragraph(" ")); text1.add(new Paragraph(" ")); text1.add(new Paragraph(" ")); text1.add(new Paragraph(" ")); text1.add(new Paragraph(" ")); document1.add(text1); PdfPTable table = new PdfPTable(3); //On crer l'objet cellule. PdfPCell cell; cell = new PdfPCell(new Phrase("Facture")); cell.setColspan(3); table.addCell(cell); cell = new PdfPCell(new Phrase("Nom du Dvd")); cell.setRowspan(1); table.addCell(cell); //contenu du tableau. table.addCell("Quantit"); table.addCell("Prix"); for (Entry<Dvd, Integer> entry : c.getDvds().entrySet()) { Dvd dvd = (Dvd) entry.getKey(); Object value = entry.getValue(); //Image dvdimage = Image.getInstance(dvd.getImage()); //On crer un objet table dans lequel on intialise a taille. cell = new PdfPCell(new Phrase(dvd.getTitre())); cell.setRowspan(1); table.addCell(cell); table.addCell(String.valueOf(value)); table.addCell(String.valueOf(dvd.getPrix())); } cell = new PdfPCell(new Phrase("Total : " + String.valueOf(c.getMontant()) + " ")); cell.setColspan(3); table.addCell(cell); document1.add(table); Paragraph p1 = new Paragraph(); p1.add(new Paragraph(" ")); p1.add(new Paragraph(" ")); p1.add(new Paragraph(" ")); p1.add(new Paragraph(" ")); p1.add(new Paragraph(" Grenoble Dvd: 12 avenue des ensimag 38000 Grenoble", new Font(Font.FontFamily.TIMES_ROMAN, 14, Font.ITALIC))); p1.setAlignment(Element.ALIGN_RIGHT); document1.add(p1); document1.close(); } } if (!effectue.isEmpty()) { for (Commande c : effectue) { new File("/home/aymeric/Commerce/Commerce/Commerce-war/web/pdf/attente" + c.getId().toString() + ".pdf").delete(); new File("/home/aymeric/Commerce/Commerce/Commerce-war/web/pdf/cours" + c.getId().toString() + ".pdf").delete(); Document document1 = new Document(); PdfWriter.getInstance(document1, new FileOutputStream("/home/aymeric/Commerce/Commerce/Commerce-war/web/pdf/effectue" + c.getId().toString() + ".pdf")); document1.open(); Paragraph text = new Paragraph(); text.add(new Paragraph("Grenoble Dvd", new Font(Font.FontFamily.TIMES_ROMAN, 24, Font.BOLD))); text.add(new Paragraph(" ")); text.add(new Paragraph(" ")); text.add(new Paragraph(" ")); text.add(new Paragraph(" ")); text.add(new Paragraph("Facture", new Font(Font.FontFamily.TIMES_ROMAN, 24, Font.BOLD))); text.add(new Paragraph(" ")); text.add(new Paragraph(" ")); text.add(new Paragraph(" ")); text.add(new Paragraph(" ")); text.add(new Paragraph("Effectue : Commande n" + c.getId().toString(), new Font(Font.FontFamily.TIMES_ROMAN, 18, Font.BOLD))); text.add(new Paragraph(" ")); text.add(new Paragraph(" ")); document1.add(text); Paragraph p = new Paragraph(c.getDate(), new Font(Font.FontFamily.TIMES_ROMAN, 14, Font.ITALIC)); p.setAlignment(Element.ALIGN_RIGHT); p.add(new Paragraph(" ")); p.add(new Paragraph(" ")); document1.add(p); Paragraph text1 = new Paragraph(); text1.add(new Paragraph( "Mr " + c.getClient().getNom().substring(0, 1).toUpperCase() + c.getClient().getNom().substring(1) + " " + c.getClient().getPrenom().substring(0, 1).toUpperCase() + c.getClient().getPrenom().substring(1), new Font(Font.FontFamily.TIMES_ROMAN, 14, Font.ITALIC))); text1.add(new Paragraph("Email: " + c.getClient().getEmail(), new Font(Font.FontFamily.TIMES_ROMAN, 14, Font.ITALIC))); text1.add(new Paragraph(" ")); text1.add(new Paragraph(" ")); text1.add(new Paragraph(" ")); text1.add(new Paragraph(" ")); text1.add(new Paragraph(" ")); document1.add(text1); PdfPTable table = new PdfPTable(3); //On crer l'objet cellule. PdfPCell cell; cell = new PdfPCell(new Phrase("Facture")); cell.setColspan(3); table.addCell(cell); cell = new PdfPCell(new Phrase("Nom du Dvd")); cell.setRowspan(1); table.addCell(cell); //contenu du tableau. table.addCell("Quantit"); table.addCell("Prix"); for (Entry<Dvd, Integer> entry : c.getDvds().entrySet()) { Dvd dvd = (Dvd) entry.getKey(); Object value = entry.getValue(); //Image dvdimage = Image.getInstance(dvd.getImage()); //On crer un objet table dans lequel on intialise a taille. cell = new PdfPCell(new Phrase(dvd.getTitre())); cell.setRowspan(1); table.addCell(cell); table.addCell(String.valueOf(value)); table.addCell(String.valueOf(dvd.getPrix())); } cell = new PdfPCell(new Phrase("Total : " + String.valueOf(c.getMontant()) + " ")); cell.setColspan(3); table.addCell(cell); document1.add(table); Paragraph p1 = new Paragraph(); p1.add(new Paragraph(" ")); p1.add(new Paragraph(" ")); p1.add(new Paragraph(" ")); p1.add(new Paragraph(" ")); p1.add(new Paragraph(" Grenoble Dvd: 12 avenue des ensimag 38000 Grenoble", new Font(Font.FontFamily.TIMES_ROMAN, 14, Font.ITALIC))); p1.setAlignment(Element.ALIGN_RIGHT); document1.add(p1); document1.close(); } } getServletContext().getRequestDispatcher("/WEB-INF/Commande.jsp").forward(request, response); }
From source file:domain.Pdfmaker.java
public void makePdf() { Document doc = new Document(); doc.setPageSize(PageSize.A4);//from ww w. j a v a2 s . c om try { PdfWriter writer = PdfWriter.getInstance(doc, new FileOutputStream(test.getTitle() + ".pdf")); writer.setPdfVersion(PdfWriter.VERSION_1_7); doc.open(); Font f = new Font(Font.FontFamily.TIMES_ROMAN, 15, Font.BOLD, new BaseColor(0, 0, 0)); Paragraph title = new Paragraph("TEST TITLE", f); title.setAlignment(Element.ALIGN_CENTER); doc.addCreator("Arne De Bremme"); //make table PdfPTable table = new PdfPTable(4); table.setTotalWidth(550f); table.setLockedWidth(true); table.setHeaderRows(1); Paragraph p = new Paragraph(test.getTitle()); p.setAlignment(Element.ALIGN_CENTER); PdfPCell cell = new PdfPCell(p); cell.setGrayFill(0.7f); cell.setColspan(4); table.addCell(cell); table.addCell(test.getClassGroup().getGroupName()); PdfPCell cell2 = new PdfPCell(new Paragraph(test.getDescription())); cell2.setColspan(2); cell2.setRowspan(2); table.addCell(cell2); PdfPCell cell3 = new PdfPCell(new Paragraph("DD " + test.getStartDate().getDay() + "/" + test.getStartDate().getMonth() + "/" + test.getStartDate().getYear())); cell3.setRowspan(2); table.addCell(cell3); table.addCell(new Paragraph("Test " + test.getTestId())); doc.add(table); doc.add(Chunk.NEWLINE); for (Exercise e : ex) { Paragraph par = new Paragraph(); par.add("Vraag " + counter); par.add(Chunk.TABBING); par.add(Chunk.TABBING); par.add(Chunk.TABBING); par.add(Chunk.TABBING); par.add(e.getPunten() + "/"); doc.add(par); doc.add(new Paragraph("Klimatogram " + e.getClimateChart().getLocation() + " " + e.getPunten())); Robot r = new Robot(); Desktop.getDesktop().browse(new URI( "http://climatechart.azurewebsites.net/ClimateChart/ShowExercises?selectedYear=1&continentId=" + e.getClimateChart().getCountry().getContinent().getId() + "&countryId=" + e.getClimateChart().getCountry().getContinent().getId() + "&climateId=" + e.getClimateChart().getId())); TimeUnit.SECONDS.sleep(6); BufferedImage bi = r.createScreenCapture( new Rectangle(Toolkit.getDefaultToolkit().getScreenSize().width * 7 / 10, Toolkit.getDefaultToolkit().getScreenSize().width * 8 / 14)); File file = new File("screenCapture" + counter + ".jpg"); ImageIO.write(bi, "jpg", file); Image img = Image.getInstance("screenCapture.jpg"); img.scaleAbsolute(400, 300); doc.add(img); doc.add(Chunk.NEWLINE); doc.add(new Paragraph(e.getNaam())); doc.add(Chunk.NEXTPAGE); counter++; } doc.close(); File filz = new File(test.getTitle() + ".pdf"); Desktop.getDesktop().open(filz); } catch (Exception e) { } }
From source file:eu.aniketos.wp1.ststool.report.pdfgenerator.ReportContentFactory.java
License:Open Source License
private void buildSectionGoalDelegations(Section section) { String sectionIntro = "Stakeholders interact with others to achieve some of their goals by means of goal delegations. Goal delegations are graphically represented as a relation that starts from a delegator actor to a delegatee actor (following the direction of the arrow), having a rounded corner rectangle representing the goal being delegated. Security needs are graphically specified as labels that appear below the delegated goal " + socialDiagRef() + "."; section.add(createParagraph(sectionIntro)); List<Actor> selActor = getGoalDelegationsActors(); List<Paragraph> phrases = new ArrayList<Paragraph>(); for (Actor a : selActor) { for (Delegation d : a.getOutgoingDelegations()) { Paragraph par = createParagraph("%b" + a.getName() + "% delegates goal %i" + d.getSourceGoal().getName() + "% to %b" + d.getTarget().getName() + "%."); List<String> secNeeds = buildDelegationSecNeedList(d); if (secNeeds.size() > 0) { par.add(new Phrase(" The following security needs apply to this delegation:")); par.add(Chunk.NEWLINE);/*from www . jav a 2 s.co m*/ par.add(new Phrase(separateListOfString(secNeeds) + ".")); } phrases.add(par); } /* * StringBuilder sbInc = new StringBuilder(); sbInc.append("%b" + * a.getName() + "% is delegated by "); * * int incCount = 0; for (Delegation d : a.getIncomingDelegations()) * { if (incCount > 0) sbInc.append(", and is delegated by "); * sbInc.append("%i" + d.getSource().getName() + "% goal %i" + * d.getSourceGoal().getName() + "%"); List<String> secNeed1 = * buildSecNeedString(d, false, 'i'); List<String> secNeed2 = * buildSecNeedString(d, true, 'i'); * * if (secNeed2.size() > 0) { switch (secNeed2.size()) { case 1: * sbInc.append(" and is required to comply with the " + * separateListOfString(secNeed2) + " security need"); break; * default: sbInc.append(" and is required to comply with the " + * separateListOfString(secNeed2) + " security needs"); break; } } * if (secNeed1.size() > 0) { switch (secNeed1.size()) { case 1: * sbInc.append(" and requires it to comply with the " + * separateListOfString(secNeed1) + " security need"); break; * default: sbInc.append(" and requires it to comply with the " + * separateListOfString(secNeed1) + " security needs"); break; } * * } List<String> parmSecNeed = buildParamterizedSecNeedString(d, * 'i'); if (parmSecNeed.size() > 0) { * sbInc.append(" and is required for a level of " + * separateListOfString(parmSecNeed)); } if (secNeed1.size() == 0 && * secNeed2.size() == 0 && parmSecNeed.size() == 0) { * sbInc.append(": no security need is speccified"); } incCount++; } * * * StringBuilder sbOut = new StringBuilder(); int outCount = 0; for * (Delegation d : a.getOutgoingDelegations()) { if (outCount > 0) * sbOut.append(", and delegates to "); sbOut.append("%i" + * d.getTarget().getName() + "% goal %i" + * d.getSourceGoal().getName() + "%"); List<String> secNeed1 = * buildSecNeedString(d, true, 'i'); List<String> secNeed2 = * buildSecNeedString(d, false, 'i'); * * if (secNeed1.size() > 0) { switch (secNeed1.size()) { case 1: * sbOut.append(" and requires it to comply with the " + * separateListOfString(secNeed1) + " security need"); break; * default: sbOut.append(" and requires it to comply with the " + * separateListOfString(secNeed1) + " security needs"); break; } } * if (secNeed2.size() > 0) { switch (secNeed2.size()) { case 1: * sbOut.append(" and is required to comply with the " + * separateListOfString(secNeed2) + " security need"); break; * default: sbOut.append(" and is required to comply with the " + * separateListOfString(secNeed2) + " security needs"); break; } } * List<String> parmSecNeed = buildParamterizedSecNeedString(d, * 'i'); if (parmSecNeed.size() > 0) { * sbOut.append(" and requires a level of " + * separateListOfString(parmSecNeed)); } if (secNeed1.size() == 0 && * secNeed2.size() == 0 && parmSecNeed.size() == 0) { * sbOut.append(": no security need is speccified"); } * * outCount++; } * * StringBuilder sb = new StringBuilder(); if (incCount > 0) { if * (outCount > 0) { sb.append(sbInc.toString() + * " while it delegates to " + sbOut.toString() + "."); } else { * sb.append(sbInc.toString() + "."); } } else { if (outCount > 0) { * sb.append("%b" + a.getName() + "% delegates to " + * sbOut.toString() + "."); } } if (sb.length() > 0) { * phrases.add(createParagraph(sb.toString())); } */ } if (phrases.size() != 0) { sectionIntro = "The following description enlists all the delegations from one role/agent to the others. When applicable, security needs expressed over the delegations are enumerated."; section.add(createParagraph(sectionIntro)); String t = "In the " + getProjectName() + " project" + socialDiagRef() + ", we have the following goal delegations:"; section.add(createParagraph(t)); section.add(listParagraphs(phrases)); section.add(createParagraph(ftc.getTable(FigureConstant.DELEGATION_TABLE) + " summarises %igoal delegations%, together with the eventual %isecurity needs%, and the possible %ipreconditions% and %ipostconditions%, which determine when the delegation can take place, and the expected outcome of the delegation, respectively.")); List<String[]> headers = new ArrayList<String[]>(); headers.add(new String[] { "Delegator" }); headers.add(new String[] { "Goal" }); headers.add(new String[] { "Delegatee" }); headers.add(new String[] { "Security", "Needs" }); headers.add(new String[] { "Delegation", "Description" }); headers.add(new String[] { "Pre-", "conditions" }); headers.add(new String[] { "Post-", "conditions" }); PdfPTable table = createTable(headers); for (Actor a : selActor) { if (a.getOutgoingDelegations().size() > 0) { PdfPCell cell = getContentCell(); cell.setPhrase(new Phrase(a.getName(), TABLE_CONTENT)); cell.setRowspan(a.getOutgoingDelegations().size()); table.addCell(cell); for (Delegation d : a.getOutgoingDelegations()) { table.addCell(getContentCell(d.getSourceGoal().getName())); table.addCell(getContentCell(d.getTarget().getName())); List<String> sn = buildDelegationSecNeedList(d); Phrase p = null; for (int i = 0; i < sn.size(); i++) { if (i == 0) p = new Phrase(sn.get(i), TABLE_CONTENT_SMALL); else { p.add(Chunk.NEWLINE); p.add(new Phrase(sn.get(i), TABLE_CONTENT_SMALL)); } } PdfPCell c = getContentCell(); c.addElement(p); table.addCell(c); table.addCell(getContentCell(d.getDescription())); table.addCell(getContentCell(d.getPreConditions())); table.addCell(getContentCell(d.getPostConditions())); } } } addTableCaption(table, ftc.getTable(FigureConstant.DELEGATION_TABLE) + " - Goal Delegations and Security Needs"); section.add(table); table.setComplete(true); } else { section.add(createParagraph("In the " + getProjectName() + " project there are no goal delegations taking place for the given agents/roles.")); } section.setComplete(true); }
From source file:eu.aniketos.wp1.ststool.report.pdfgenerator.ReportContentFactory.java
License:Open Source License
private void buildSectionDocumentProvisions(Section section) { String sectionIntro = "Stakeholders exchange information by means of documents with other stakeholders. The following description enlists all the provisions from one role/agent representing the stakeholder, to other roles/agents. %iDocument provision% is represented as an arrow from the provider to the providee, with a rectangle representing the document. The security needs expressed over the provisions are described, if applicable. Security needs are specified with the help of labels that appear below the document."; section.add(createParagraph(sectionIntro)); List<Actor> selActor = getDocumentProvisionsActors(); List<Paragraph> phrases = new ArrayList<Paragraph>(); for (Actor a : selActor) { for (Provision p : a.getOutgoingProvisions()) { Paragraph par = createParagraph("%b" + a.getName() + "% provides document %i" + p.getSourceResource().getName() + "% to %b" + p.getTarget().getName() + "%."); List<String> secNeeds = buildProvisionSecNeedList(p); if (secNeeds.size() > 0) { par.add(new Phrase(" The following security needs apply to this provision:")); par.add(Chunk.NEWLINE);//from w w w . jav a2 s . co m par.add(new Phrase(separateListOfString(secNeeds) + ".")); } phrases.add(par); } } /* * for (Actor a : selActor) { StringBuilder sbInc = new StringBuilder(); * sbInc.append("%b" + a.getName() + "% is provided by "); int incCount * = 0; for (Provision p : a.getIncomingProvisions()) { if (incCount > * 0) sbInc.append(", and is provided by "); sbInc.append("%i" + * p.getSource().getName() + "% document %i" + * p.getSourceResource().getName() + "%"); if (p.isIntegrity()) { * sbInc.append(" and requires %b" + p.getSource().getName() + * "% to ensure %iintegrity of transmission% over the provision of this document" * ); } * * incCount++; } * * StringBuilder sbOut = new StringBuilder(); int outCount = 0; for * (Provision p : a.getOutgoingProvisions()) { if (outCount > 0) * sbOut.append(", and it provides to "); sbOut.append("%i" + * p.getTarget().getName() + "% document %i" + * p.getSourceResource().getName() + "%"); if (p.isIntegrity()) { * sbInc.append(" and requires %iAvailability% level of " + * p.getAvailabilityValue() + "%"); } outCount++; } * * StringBuilder sb = new StringBuilder(); if (incCount > 0) { if * (outCount > 0) { sb.append(sbInc.toString() + * " while it provides to " + sbOut.toString() + "."); } else { * sb.append(sbInc.toString() + "."); } } else { if (outCount > 0) { * sb.append("%b" + a.getName() + "% provides to " + sbOut.toString() + * "."); } } * * if (sb.length() > 0) { phrases.add(createParagraph(sb.toString())); } * } */ if (phrases.size() != 0) { String s = "In the " + getProjectName() + " project " + socialDiagRef() + ", we have the following %idocument provisions%:"; section.add(createParagraph(s)); section.add(listParagraphs(phrases)); section.add(createParagraph(ftc.getTable(FigureConstant.PROVISION_TABLE) + " summarises the %idocument provisions% for the " + getProjectName() + " project.")); List<String[]> headers = new ArrayList<String[]>(); headers.add(new String[] { "Providor" }); headers.add(new String[] { "Document" }); headers.add(new String[] { "Providee" }); headers.add(new String[] { "Security", "Needs" }); headers.add(new String[] { "Provision", "Descr." }); PdfPTable table = createTable(headers); for (Actor a : selActor) { if (a.getOutgoingProvisions().size() > 0) { PdfPCell cell = getContentCell(); cell.setPhrase(new Phrase(a.getName(), TABLE_CONTENT)); cell.setRowspan(a.getOutgoingProvisions().size()); table.addCell(cell); for (Provision p : a.getOutgoingProvisions()) { table.addCell(getContentCell(p.getSourceResource().getName())); table.addCell(getContentCell(p.getTarget().getName())); List<String> sn = buildProvisionSecNeedList(p); Phrase pr = null; for (int i = 0; i < sn.size(); i++) { if (i == 0) pr = new Phrase(sn.get(i), TABLE_CONTENT_SMALL); else { pr.add(Chunk.NEWLINE); pr.add(new Phrase(sn.get(i), TABLE_CONTENT_SMALL)); } } PdfPCell c = getContentCell(); c.addElement(pr); table.addCell(c); table.addCell(getContentCell(p.getDescription())); } } } addTableCaption(table, ftc.getTable(FigureConstant.PROVISION_TABLE) + " - Document Provisions"); section.add(table); table.setComplete(true); } else { section.add(createParagraph("In the " + getProjectName() + " project there are no document provisions taking place for the given agents/roles.")); } section.setComplete(true); }
From source file:eu.aniketos.wp1.ststool.report.pdfgenerator.ReportContentFactory.java
License:Open Source License
private void buildSectionGoalAnalysis(Section section) { String sectionIntro = "Stakeholders have goals to achieve. Goals are represented within the rationale (round compartment attached to the role/agent" + socialDiagRef(", see ", "") + ") of the role/agent representing the stakeholder. They achieve their goals by further refining them into finer-grained goals (subgoals) by means of AND/OR-decompositions. AND-decompositions structurally refine a goal into multiple subgoals (all AND subgoals need to be achieved for the goal to be achieved), while OR-decompositions represent alternative ways for achieving a goal (at least one of the subgoals in the OR-decomposition needs to be achieved for the goal to be achieved)."; section.add(createParagraph(sectionIntro)); List<Actor> selActor = getGoalAnalysisActors(); List<Paragraph> phrases = new ArrayList<Paragraph>(); for (Actor a : selActor) { if (a.getGoals().size() != 0) { StringBuilder sb = new StringBuilder(); List<String> goalS = new ArrayList<String>(); List<Goal> goalDecomposed = new ArrayList<Goal>(); for (Goal g : a.getGoals()) { if (g.getIncomingDecompositions() == null) { goalS.add("goal %i" + g.getName() + "%"); }//ww w. jav a 2 s . c o m if (g.getOutgoingDecompositions().size() > 0) { goalDecomposed.add(g); } } if (goalS.size() > 0) { sb.append("%b" + a.getName() + "% " + " has to achieve " + separateListOfString(goalS) + "."); if (goalDecomposed.size() > 0) { for (Goal g : goalDecomposed) { sb.append(" To achieve %i" + g.getName() + "%, " + g.getActorOwner().getName() + " should achieve "); if (g.getOutgoingDecompositions().get(0) instanceof GoalDecompositionAND) { List<String> list = new ArrayList<String>(); for (GoalDecomposition gd : g.getOutgoingDecompositions()) { if (gd.getTarget() != null) list.add("goal %i" + gd.getTarget().getName() + "%"); } sb.append(separateListOfString(list)); } else { List<String> list = new ArrayList<String>(); for (GoalDecomposition gd : g.getOutgoingDecompositions()) { if (gd.getTarget() != null) list.add("goal %i" + gd.getTarget().getName() + "%"); } sb.append("either " + separateListOfString(list, ", ", " or ")); } sb.append("."); } } } if (sb.length() > 0) { phrases.add(createParagraph(sb.toString())); } } } if (phrases.size() != 0) { String s = "In the " + getProjectName() + " project" + socialDiagRef() + " we have:"; section.add(createParagraph(s)); section.add(listParagraphs(phrases)); section.add(createParagraph( ftc.getTable(FigureConstant.GOAL_DEC_TABLE) + " summarises the goals of each agent/role in the " + getProjectName() + " project and how they are decomposed, when applicable.")); List<String[]> headers = new ArrayList<String[]>(); headers.add(new String[] { "Agent/Role" }); headers.add(new String[] { "Goal" }); headers.add(new String[] { "Dec. Type" }); headers.add(new String[] { "Subgoals" }); PdfPTable table = createTable(headers); for (Actor a : selActor) { List<Goal> validGoals = new ArrayList<Goal>(); for (Goal g : a.getGoals()) { if (g.getIncomingDecompositions() == null) { validGoals.add(g); } // remove goal of decompostion } if (validGoals.size() > 0) { PdfPCell actorCell = getContentCell(a.getName()); int rowspan = 0; for (Goal g : validGoals) { if (g.getOutgoingDecompositions().size() > 0) rowspan += g.getOutgoingDecompositions().size(); else ++rowspan; } actorCell.setRowspan(rowspan); table.addCell(actorCell); for (Goal g : validGoals) { PdfPCell goalCell = getContentCell(g.getName()); if (g.getOutgoingDecompositions().size() > 0) { String decType = ""; if (g.getOutgoingDecompositions().get(0) instanceof GoalDecompositionAND) { decType = "AND"; } else { decType = "OR"; } PdfPCell decTypeCell = getContentCell(decType); List<String> decomp = new ArrayList<String>(); for (GoalDecomposition gd : g.getOutgoingDecompositions()) { if (gd.getTarget() != null) decomp.add(gd.getTarget().getName()); } if (decomp.size() > 1) { rowspan = decomp.size(); goalCell.setRowspan(rowspan); decTypeCell.setRowspan(rowspan); } table.addCell(goalCell); table.addCell(decTypeCell); for (String stri : decomp) { table.addCell(getContentCell(stri)); } } else { table.addCell(goalCell); table.addCell(getContentCell("-")); table.addCell(getContentCell()); } } } } section.add(table); addTableCaption(table, ftc.getTable(FigureConstant.GOAL_DEC_TABLE) + " - Goal Decompositions"); table.setComplete(true); } else { section.add(createParagraph("In the " + getProjectName() + " project there are no decomposition relations taking place for the given agents/roles.")); } section.setComplete(true); }