List of usage examples for com.lowagie.text Paragraph setLeading
public void setLeading(float fixedLeading)
From source file:airportpainter.util.AirportPainter.java
License:Open Source License
private Paragraph createTinyParagraph(String title, String data) { Paragraph p = new Paragraph(); p.setLeading((p.leading() / 2) + 2); p.add(new Chunk(title, new com.lowagie.text.Font(com.lowagie.text.Font.TIMES_ROMAN, 8, com.lowagie.text.Font.NORMAL))); p.add(new Chunk(data, new com.lowagie.text.Font(com.lowagie.text.Font.TIMES_ROMAN, 10, com.lowagie.text.Font.BOLD))); return p;/*from w w w. j a v a 2 s.c o m*/ }
From source file:airportpainter.util.AirportPainter.java
License:Open Source License
private void createSheetsFakeShops(Airport airport, Document document) { // FREQs Nearest Navaid notifyAction("createSheetsFakeShops"); PdfPTable table = new PdfPTable(1); {//from w w w .j av a 2s . c o m PdfPCell cell = new PdfPCell(); cell.setVerticalAlignment(Element.ALIGN_TOP); cell.setMinimumHeight(20); boolean addWorker = false; for (final Runway runway : airport.getRunways()) { if (runway.getLength() > 1200 / FEET_PER_METER) { addWorker = true; } } boolean addFork = (airport.hasTower()); Paragraph p = new Paragraph(); p.setLeading((p.leading() / 2) + 4); if (addWorker) { try { p.add(new Chunk(" ")); p.add(new Chunk(Image.getInstance(getClass().getResource(Main.imgFolder + "avail_work.png")), 0, -3)); } catch (BadElementException ex) { Logger.getLogger(AirportPainter.class.getName()).log(Level.SEVERE, null, ex); } catch (IOException ex) { Logger.getLogger(AirportPainter.class.getName()).log(Level.SEVERE, null, ex); } } if (addFork) { try { p.add(new Chunk(" ")); p.add(new Chunk(Image.getInstance(getClass().getResource(Main.imgFolder + "avail_fork.png")), 0, -3)); } catch (BadElementException ex) { Logger.getLogger(AirportPainter.class.getName()).log(Level.SEVERE, null, ex); } catch (IOException ex) { Logger.getLogger(AirportPainter.class.getName()).log(Level.SEVERE, null, ex); } } cell.addElement(p); //cell.setBorder(com.lowagie.text.Rectangle.NO_BORDER); cell.setBorderWidth(borderWidth); cell.setVerticalAlignment(Element.ALIGN_TOP); table.addCell(cell); } table.setWidthPercentage(100); try { document.add(table); } catch (DocumentException ex) { Logger.getLogger(AirportPainter.class.getName()).log(Level.SEVERE, null, ex); } }
From source file:airportpainter.util.AirportPainter.java
License:Open Source License
private void createSheetsLights(Airport airport, Document document) { // FREQs Nearest Navaid notifyAction("createSheetsLights"); PdfPTable table = new PdfPTable(1); {/* ww w . j a v a2s .c o m*/ PdfPCell cell = new PdfPCell(); cell.setVerticalAlignment(Element.ALIGN_TOP); cell.setMinimumHeight(20); Paragraph p = new Paragraph(); p.setLeading((p.leading() / 2) + 4); com.lowagie.text.Font font = new com.lowagie.text.Font(com.lowagie.text.Font.TIMES_ROMAN, 10, com.lowagie.text.Font.NORMAL); oneLightDone = false; try { p.add(new Chunk(" ", font)); p.add(new Chunk(Image.getInstance(getClass().getResource(Main.imgFolder + "light.png")), 0, 0)); p.add(new Chunk(" ", font)); } catch (BadElementException ex) { Logger.getLogger(AirportPainter.class.getName()).log(Level.SEVERE, null, ex); } catch (IOException ex) { Logger.getLogger(AirportPainter.class.getName()).log(Level.SEVERE, null, ex); } boolean addABN = airport.hasBeacon(); if (addABN) { p.add(addOneLight("ABN", font)); } boolean addALS = false; boolean addPAPI = false; for (final Runway runway : airport.getRunways()) { if ((runway.hasALSF_I(false) || runway.hasALSF_I(true)) || (runway.hasALSF_II(false) || runway.hasALSF_II(true))) { addALS = true; } if ((runway.hasPapi(false) || runway.hasPapi(true))) { addPAPI = true; } } if (addALS) { p.add(addOneLight("ALS", font)); } if (addPAPI) { p.add(addOneLight("PAPI ", font)); String separ = ""; for (final Runway runway : airport.getRunways()) { if (runway.hasPapi(false)) { p.add(new Chunk(separ + runway.getNumber() + " (3.5)" + degrees + " ", font)); separ = ", "; } if (runway.hasPapi(true)) { p.add(new Chunk(separ + runway.getOppositeNumber() + " (3.5)" + degrees + " ", font)); separ = ", "; } } } cell.addElement(p); //cell.setBorder(com.lowagie.text.Rectangle.NO_BORDER); cell.setBorderWidth(borderWidth); cell.setVerticalAlignment(Element.ALIGN_CENTER); table.addCell(cell); } table.setWidthPercentage(100); try { document.add(table); } catch (DocumentException ex) { Logger.getLogger(AirportPainter.class.getName()).log(Level.SEVERE, null, ex); } }
From source file:airportpainter.util.AirportPainter.java
License:Open Source License
private void createSheetsRunways(Airport airport, Document document) { notifyAction("createSheetsRunways"); PdfPTable table = new PdfPTable(6); // titles/*from ww w. j ava2 s. c om*/ com.lowagie.text.Font fontTitle = new com.lowagie.text.Font(com.lowagie.text.Font.TIMES_ROMAN, 8, com.lowagie.text.Font.NORMAL); { PdfPCell cell = new PdfPCell(); cell.setVerticalAlignment(Element.ALIGN_CENTER); cell.setBorderWidthTop(borderWidth); cell.setBorderWidthBottom(borderWidthThin); cell.setBorderWidthRight(borderWidthThin); cell.setBorderWidthLeft(borderWidth); Paragraph p = new Paragraph("RWY N" + degrees, fontTitle); p.setLeading((p.leading() / 2) + 2); p.setAlignment(Element.ALIGN_CENTER); cell.addElement(p); table.addCell(cell); } { PdfPCell cell = new PdfPCell(); cell.setVerticalAlignment(Element.ALIGN_CENTER); cell.setBorderWidthTop(borderWidth); cell.setBorderWidthBottom(borderWidthThin); cell.setBorderWidthRight(borderWidthThin); cell.setBorderWidthLeft(borderWidthThin); Paragraph p = new Paragraph("Dimension (ft) - Surface", fontTitle); p.setLeading((p.leading() / 2) + 2); p.setAlignment(Element.ALIGN_CENTER); cell.addElement(p); table.addCell(cell); } { PdfPCell cell = new PdfPCell(); cell.setVerticalAlignment(Element.ALIGN_CENTER); cell.setBorderWidthTop(borderWidth); cell.setBorderWidthBottom(borderWidthThin); cell.setBorderWidthRight(borderWidthThin); cell.setBorderWidthLeft(borderWidthThin); Paragraph p = new Paragraph("TORA (ft)", fontTitle); p.setLeading((p.leading() / 2) + 2); p.setAlignment(Element.ALIGN_CENTER); cell.addElement(p); table.addCell(cell); } { PdfPCell cell = new PdfPCell(); cell.setVerticalAlignment(Element.ALIGN_CENTER); cell.setBorderWidthTop(borderWidth); cell.setBorderWidthBottom(borderWidthThin); cell.setBorderWidthRight(borderWidthThin); cell.setBorderWidthLeft(borderWidthThin); Paragraph p = new Paragraph("LDA (ft)", fontTitle); p.setLeading((p.leading() / 2) + 2); p.setAlignment(Element.ALIGN_CENTER); cell.addElement(p); table.addCell(cell); } { PdfPCell cell = new PdfPCell(); cell.setVerticalAlignment(Element.ALIGN_CENTER); cell.setBorderWidthTop(borderWidth); cell.setBorderWidthBottom(borderWidthThin); cell.setBorderWidthRight(borderWidthThin); cell.setBorderWidthLeft(borderWidthThin); Paragraph p = new Paragraph("Strength", fontTitle); p.setLeading((p.leading() / 2) + 2); p.setAlignment(Element.ALIGN_CENTER); cell.addElement(p); table.addCell(cell); } { PdfPCell cell = new PdfPCell(); cell.setVerticalAlignment(Element.ALIGN_CENTER); cell.setBorderWidthTop(borderWidth); cell.setBorderWidthBottom(borderWidthThin); cell.setBorderWidthRight(borderWidth); cell.setBorderWidthLeft(borderWidthThin); Paragraph p = new Paragraph("Lights", fontTitle); p.setLeading((p.leading() / 2) + 2); p.setAlignment(Element.ALIGN_CENTER); cell.addElement(p); table.addCell(cell); } // data com.lowagie.text.Font fontData = new com.lowagie.text.Font(com.lowagie.text.Font.TIMES_ROMAN, 10, com.lowagie.text.Font.NORMAL); int rc = 0; for (final Runway runway : airport.getRunways()) { { PdfPCell cell = new PdfPCell(); cell.setVerticalAlignment(Element.ALIGN_CENTER); cell.setBorderWidthLeft(borderWidth); if (rc < airport.getRunways().size() - 1) { // thin bottom if not last runway cell.setBorderWidthBottom(borderWidthThin); } else { cell.setBorderWidthBottom(borderWidth); } cell.setBorderWidthRight(borderWidthThin); Paragraph p = new Paragraph(runway.getNumber() + "\r\n" + runway.getOppositeNumber(), fontData); p.setLeading((p.leading() / 2) + 2); p.setAlignment(Element.ALIGN_CENTER); cell.addElement(p); table.addCell(cell); } { PdfPCell cell = new PdfPCell(); cell.setVerticalAlignment(Element.ALIGN_CENTER); cell.setBorderWidthLeft(borderWidthThin); if (rc < airport.getRunways().size() - 1) { // thin bottom if not last runway cell.setBorderWidthBottom(borderWidthThin); } else { cell.setBorderWidthBottom(borderWidth); } cell.setBorderWidthRight(borderWidthThin); String runwayLength = new Integer(runway.getLength()).toString() + " x " + new Integer(runway.getWidth()).toString() + " " + runway.getSurfaceName(); Paragraph p = new Paragraph(runwayLength, fontData); p.setLeading((p.leading() / 2) + 2); p.setAlignment(Element.ALIGN_CENTER); cell.addElement(p); table.addCell(cell); } { PdfPCell cell = new PdfPCell(); cell.setVerticalAlignment(Element.ALIGN_CENTER); cell.setBorderWidthLeft(borderWidthThin); if (rc < airport.getRunways().size() - 1) { // thin bottom if not last runway cell.setBorderWidthBottom(borderWidthThin); } else { cell.setBorderWidthBottom(borderWidth); } cell.setBorderWidthRight(borderWidthThin); Paragraph p = new Paragraph(runway.getLength() + "\r\n" + runway.getLength(), fontData); p.setLeading((p.leading() / 2) + 2); p.setAlignment(Element.ALIGN_CENTER); cell.addElement(p); table.addCell(cell); } { PdfPCell cell = new PdfPCell(); cell.setVerticalAlignment(Element.ALIGN_CENTER); cell.setBorderWidthLeft(borderWidthThin); if (rc < airport.getRunways().size() - 1) { // thin bottom if not last runway cell.setBorderWidthBottom(borderWidthThin); } else { cell.setBorderWidthBottom(borderWidth); } cell.setBorderWidthRight(borderWidthThin); Paragraph p = new Paragraph((runway.getLength() - runway.getDisplacement()) + "\r\n" + (runway.getLength() - runway.getDisplacementOpposite()), fontData); p.setLeading((p.leading() / 2) + 2); p.setAlignment(Element.ALIGN_CENTER); cell.addElement(p); table.addCell(cell); } { PdfPCell cell = new PdfPCell(); cell.setVerticalAlignment(Element.ALIGN_CENTER); cell.setBorderWidthLeft(borderWidthThin); if (rc < airport.getRunways().size() - 1) { // thin bottom if not last runway cell.setBorderWidthBottom(borderWidthThin); } else { cell.setBorderWidthBottom(borderWidth); } cell.setBorderWidthRight(borderWidthThin); Paragraph p = new Paragraph("to do...", fontData); p.setLeading((p.leading() / 2) + 2); p.setAlignment(Element.ALIGN_CENTER); cell.addElement(p); table.addCell(cell); } { PdfPCell cell = new PdfPCell(); cell.setVerticalAlignment(Element.ALIGN_CENTER); cell.setBorderWidthLeft(borderWidthThin); cell.setBorderWidthRight(borderWidth); if (rc < airport.getRunways().size() - 1) { // thin bottom if not last runway cell.setBorderWidthBottom(borderWidthThin); } else { cell.setBorderWidthBottom(borderWidth); } Paragraph p = new Paragraph(); p.setLeading((p.leading() / 2) + 2); p.setAlignment(Element.ALIGN_CENTER); try { if (runway.hasALSF_I(true) || runway.hasALSF_I(false) || runway.hasALSF_II(true) || runway.hasALSF_II(false) || runway.hasPapi(true) || runway.hasPapi(false) || runway.hasSALSF(true) || runway.hasSALSF(false) || runway.hasSSLP(true) || runway.hasSSLP(false) || runway.hasVasi(true) || runway.hasVasi(false)) { p.add(new Chunk(Image.getInstance(getClass().getResource(Main.imgFolder + "light.png")), 0, 0)); } else { p.add(new Chunk("--", fontData)); } } catch (BadElementException ex) { Logger.getLogger(AirportPainter.class.getName()).log(Level.SEVERE, null, ex); } catch (IOException ex) { Logger.getLogger(AirportPainter.class.getName()).log(Level.SEVERE, null, ex); } cell.addElement(p); table.addCell(cell); } rc++; } float[] widths2 = { 1f, 2f, 1f, 1f, 2f, 1f }; try { table.setWidths(widths2); } catch (DocumentException ex) { Logger.getLogger(AirportPainter.class.getName()).log(Level.SEVERE, null, ex); } table.setWidthPercentage(100); try { document.add(table); } catch (DocumentException ex) { Logger.getLogger(AirportPainter.class.getName()).log(Level.SEVERE, null, ex); } }
From source file:airportpainter.util.AirportPainter.java
License:Open Source License
private void createSheets2ILS(Airport airport, Document document) { // FREQs Nearest Navaid notifyAction("createSheets2ILS"); PdfPTable table = new PdfPTable(2); {// w w w. ja v a 2s. com PdfPCell cell = new PdfPCell(); { Paragraph p = new Paragraph("(TWR)", new com.lowagie.text.Font(com.lowagie.text.Font.TIMES_ROMAN, 8, com.lowagie.text.Font.NORMAL)); p.setLeading((p.leading() / 2) + 2); cell.addElement(p); } List<ATCFreq> tempFreqsTwr = _airport.getATCFreqs("54"); List<ATCFreq> tempFreqsGnd = _airport.getATCFreqs("53"); if (tempFreqsTwr.size() > 0 || tempFreqsGnd.size() > 0) { if (tempFreqsTwr.size() > 0) { Paragraph p = new Paragraph(); p.setLeading((p.leading() / 2) + 6); Chunk c = new Chunk(airport.getName().toUpperCase() + " APPROACH ", new com.lowagie.text.Font( com.lowagie.text.Font.TIMES_ROMAN, 8, com.lowagie.text.Font.NORMAL)); p.add(c); for (final ATCFreq tower : tempFreqsTwr) { Chunk c2 = new Chunk((tower.getFreq() + " ").substring(0, 9) + " ", new com.lowagie.text.Font(com.lowagie.text.Font.TIMES_ROMAN, 8, com.lowagie.text.Font.BOLD)); p.add(c2); } cell.addElement(p); } if (tempFreqsGnd.size() > 0) { Paragraph p = new Paragraph(); p.setLeading((p.leading() / 2) + 6); Chunk c = new Chunk("GROUND ", new com.lowagie.text.Font(com.lowagie.text.Font.TIMES_ROMAN, 8, com.lowagie.text.Font.NORMAL)); p.add(c); for (final ATCFreq tower : tempFreqsGnd) { Chunk c2 = new Chunk((tower.getFreq() + " ").substring(0, 9) + " ", new com.lowagie.text.Font(com.lowagie.text.Font.TIMES_ROMAN, 8, com.lowagie.text.Font.BOLD)); p.add(c2); } cell.addElement(p); } } cell.setBorderWidth(borderWidth); cell.setBorderWidthTop(borderWidthThin); cell.setBorderWidthRight(borderWidthThin); //cell.setHorizontalAlignment(Element.ALIGN_RIGHT); cell.setVerticalAlignment(Element.ALIGN_TOP); table.addCell(cell); } { com.lowagie.text.Font font = new com.lowagie.text.Font(com.lowagie.text.Font.TIMES_ROMAN, com.lowagie.text.Font.DEFAULTSIZE, com.lowagie.text.Font.NORMAL); PdfPCell cell = new PdfPCell(); Paragraph p = new Paragraph(); p.setLeading((p.leading()) + 6); Chunk c = new Chunk("ATIS ", new com.lowagie.text.Font(com.lowagie.text.Font.TIMES_ROMAN, 8, com.lowagie.text.Font.NORMAL)); p.add(c); for (final Atis atis : _airport.getAtises()) { Chunk c2 = new Chunk((atis.getFreq() + " ").substring(0, 9) + " ", new com.lowagie.text.Font( com.lowagie.text.Font.TIMES_ROMAN, 8, com.lowagie.text.Font.BOLD)); p.add(c2); } cell.addElement(p); /// ILS table { height1 = 0; PdfPTable tableILS = new PdfPTable(4); tableILS.setWidthPercentage(100); // titles com.lowagie.text.Font fontTitle = new com.lowagie.text.Font(com.lowagie.text.Font.TIMES_ROMAN, 8, com.lowagie.text.Font.NORMAL); { PdfPCell cellTitle = new PdfPCell(); cellTitle.setVerticalAlignment(Element.ALIGN_CENTER); cellTitle.setBorderWidth(borderWidthThin); Paragraph pt = new Paragraph("RWY", fontTitle); pt.setLeading((pt.leading() / 2) + 2); pt.setAlignment(Element.ALIGN_CENTER); cellTitle.addElement(pt); tableILS.addCell(cellTitle); } { PdfPCell cellTitle = new PdfPCell(); cellTitle.setVerticalAlignment(Element.ALIGN_CENTER); cellTitle.setBorderWidth(borderWidthThin); Paragraph pt = new Paragraph("ILS", fontTitle); pt.setLeading((pt.leading() / 2) + 2); pt.setAlignment(Element.ALIGN_CENTER); cellTitle.addElement(pt); tableILS.addCell(cellTitle); } { PdfPCell cellTitle = new PdfPCell(); cellTitle.setVerticalAlignment(Element.ALIGN_CENTER); cellTitle.setBorderWidth(borderWidthThin); Paragraph pt = new Paragraph("RWY", fontTitle); pt.setLeading((pt.leading() / 2) + 2); pt.setAlignment(Element.ALIGN_CENTER); cellTitle.addElement(pt); tableILS.addCell(cellTitle); } { PdfPCell cellTitle = new PdfPCell(); cellTitle.setVerticalAlignment(Element.ALIGN_CENTER); cellTitle.setBorderWidth(borderWidthThin); Paragraph pt = new Paragraph("ILS", fontTitle); pt.setLeading((pt.leading() / 2) + 2); pt.setAlignment(Element.ALIGN_CENTER); cellTitle.addElement(pt); tableILS.addCell(cellTitle); } int pos = 0; int rs = airport.getRunways().size(); for (final Runway runway : airport.getRunways()) { if (runway.getIlsFreq() != 0) { height1 = height1 + 10; { PdfPCell cellFreq = new PdfPCell(); cellFreq.setVerticalAlignment(Element.ALIGN_CENTER); cellFreq.setBorderWidth(borderWidthThin); if (pos > 0) { cellFreq.setBorderWidthTop(0); } if (pos < rs - 1) { cellFreq.setBorderWidthBottom(0); } Paragraph pt = new Paragraph(runway.getNumber(), fontTitle); pt.setLeading((pt.leading() / 2) + 2); pt.setAlignment(Element.ALIGN_CENTER); cellFreq.addElement(pt); tableILS.addCell(cellFreq); } { PdfPCell cellFreq = new PdfPCell(); cellFreq.setVerticalAlignment(Element.ALIGN_CENTER); cellFreq.setBorderWidth(borderWidthThin); if (pos > 0) { cellFreq.setBorderWidthTop(0); } if (pos < rs - 1) { cellFreq.setBorderWidthBottom(0); } Paragraph pt = new Paragraph( runway.getIlsFreq() + " " + "... " + new Integer((int) runway.getHeading()).toString() + degrees, fontTitle); pt.setLeading((pt.leading() / 2) + 2); pt.setAlignment(Element.ALIGN_CENTER); cellFreq.addElement(pt); tableILS.addCell(cellFreq); } } /*else { { PdfPCell cellFreq = new PdfPCell(); cellFreq.setVerticalAlignment(Element.ALIGN_CENTER); cellFreq.setBorderWidth(borderWidthThin); if (pos>0) { cellFreq.setBorderWidthTop(0); } if (pos<rs-1) { cellFreq.setBorderWidthBottom(0); } Paragraph pt=new Paragraph( "",fontTitle); pt.setLeading((pt.leading()/2)+2); pt.setAlignment(Element.ALIGN_CENTER); cellFreq.addElement(pt); tableILS.addCell(cellFreq); } { PdfPCell cellFreq = new PdfPCell(); cellFreq.setVerticalAlignment(Element.ALIGN_CENTER); cellFreq.setBorderWidth(borderWidthThin); if (pos>0) { cellFreq.setBorderWidthTop(0); } if (pos<rs-1) { cellFreq.setBorderWidthBottom(0); } Paragraph pt=new Paragraph( "",fontTitle); pt.setLeading((pt.leading()/2)+2); pt.setAlignment(Element.ALIGN_CENTER); cellFreq.addElement(pt); tableILS.addCell(cellFreq); } }*/ if (runway.getIlsOppositeFreq() != 0) { { PdfPCell cellFreq = new PdfPCell(); cellFreq.setVerticalAlignment(Element.ALIGN_CENTER); cellFreq.setBorderWidth(borderWidthThin); if (pos > 0) { cellFreq.setBorderWidthTop(0); } if (pos < rs - 1) { cellFreq.setBorderWidthBottom(0); } Paragraph pt = new Paragraph(runway.getOppositeNumber(), fontTitle); pt.setLeading((pt.leading() / 2) + 2); pt.setAlignment(Element.ALIGN_CENTER); cellFreq.addElement(pt); tableILS.addCell(cellFreq); } { PdfPCell cellFreq = new PdfPCell(); cellFreq.setVerticalAlignment(Element.ALIGN_CENTER); cellFreq.setBorderWidth(borderWidthThin); if (pos > 0) { cellFreq.setBorderWidthTop(0); } if (pos < rs - 1) { cellFreq.setBorderWidthBottom(0); } Paragraph pt = new Paragraph(runway.getIlsOppositeFreq() + " " + "... " + new Integer((int) (runway.getHeading() + 180) % 180).toString() + degrees, fontTitle); pt.setLeading((pt.leading() / 2) + 2); pt.setAlignment(Element.ALIGN_CENTER); cellFreq.addElement(pt); tableILS.addCell(cellFreq); } } else { { PdfPCell cellFreq = new PdfPCell(); cellFreq.setVerticalAlignment(Element.ALIGN_CENTER); cellFreq.setBorderWidth(borderWidthThin); if (pos > 0) { cellFreq.setBorderWidthTop(0); } if (pos < rs - 1) { cellFreq.setBorderWidthBottom(0); } Paragraph pt = new Paragraph("", fontTitle); pt.setLeading((pt.leading() / 2) + 2); pt.setAlignment(Element.ALIGN_CENTER); cellFreq.addElement(pt); tableILS.addCell(cellFreq); } { PdfPCell cellFreq = new PdfPCell(); cellFreq.setVerticalAlignment(Element.ALIGN_CENTER); cellFreq.setBorderWidth(borderWidthThin); if (pos > 0) { cellFreq.setBorderWidthTop(0); } if (pos < rs - 1) { cellFreq.setBorderWidthBottom(0); } Paragraph pt = new Paragraph("", fontTitle); pt.setLeading((pt.leading() / 2) + 2); pt.setAlignment(Element.ALIGN_CENTER); cellFreq.addElement(pt); tableILS.addCell(cellFreq); } } pos++; } float[] widths2 = { 1f, 3f, 1f, 3f }; try { tableILS.setWidths(widths2); } catch (DocumentException ex) { Logger.getLogger(AirportPainter.class.getName()).log(Level.SEVERE, null, ex); } cell.addElement(tableILS); } cell.setBorderWidth(borderWidth); cell.setVerticalAlignment(Element.ALIGN_TOP); table.addCell(cell); } table.setWidthPercentage(100); try { document.add(table); } catch (DocumentException ex) { Logger.getLogger(AirportPainter.class.getName()).log(Level.SEVERE, null, ex); } }
From source file:classroom.filmfestival_c.Movies17.java
protected static Element fullTitle(FestivalScreening screening) throws DocumentException { FilmTitle movie = screening.getFilmTitle(); // a table with 3 cells PdfPTable table = new PdfPTable(3); table.setWidths(INNER);//from w w w .j av a 2 s .c o m table.setWidthPercentage(100); // the title(s) Paragraph p = new Paragraph(); p.add(new Phrase(movie.getTitle(), BOLD)); p.setLeading(16); // maybe an alternative title if (movie.getATitle().trim().length() > 0) { p.add(new Phrase(" (" + movie.getATitle() + ")")); } PdfPCell cell = new PdfPCell(); cell.addElement(p); cell.setBorder(PdfPCell.NO_BORDER); cell.setUseAscender(true); cell.setUseDescender(true); table.addCell(cell); // eXploreZone? cell = new PdfPCell(); cell.setBorder(PdfPCell.NO_BORDER); if (isExploreZone(movie)) { cell.setBackgroundColor(WHITE); cell.setUseAscender(true); cell.setUseDescender(true); cell.addElement(new Paragraph("eXplore")); } table.addCell(cell); // Duration / shortfilm cell = new PdfPCell(); cell.setBorder(PdfPCell.NO_BORDER); cell.setBackgroundColor(WHITE); cell.setUseAscender(true); cell.setUseDescender(true); StringBuffer buf = new StringBuffer(); buf.append(movie.getDuration()); buf.append('\''); if (getExtra(screening) > 0) { buf.append(" + KF"); buf.append(getExtra(screening)); buf.append('\''); } p = new Paragraph(buf.toString()); p.setAlignment(Element.ALIGN_CENTER); cell.addElement(p); table.addCell(cell); return table; }
From source file:classroom.filmfestival_c.Movies17.java
@SuppressWarnings("unchecked") protected static Element directors(FilmTitle movie) { Set<DirectorName> directors = movie.getDirectorNames(); if (directors.size() == 0) { Paragraph p = new Paragraph("various directors"); p.setLeading(16); return p; }/*from w w w . j a v a2 s . c om*/ if (directors.size() == 1) { DirectorName name = directors.iterator().next(); Paragraph p = new Paragraph(name.getName()); p.setLeading(16); return p; } List list = new List(List.UNORDERED, 10); ListItem li; for (DirectorName director : directors) { li = new ListItem(director.getName()); li.setLeading(16); list.add(li); } return list; }
From source file:classroom.filmfestival_c.Movies17.java
@SuppressWarnings({ "unchecked", "deprecation" }) protected static Element screenings(FestivalScreening screening) { // the specific screening Paragraph p = getScreening(screening, BOLDSMALL); p.setLeading(16); FilmTitle movie = screening.getFilmTitle(); Set<FestivalScreening> screenings = movie.getFestivalScreenings(); if (screenings.size() == 1) { return p; }/* www. java2s.c om*/ // the alternative screenings List list = new List(List.UNORDERED, 10); list.add(new ListItem(p)); ListItem li; for (FestivalScreening ascreening : screenings) { if (ascreening.getId().equals(screening.getId())) continue; GregorianCalendar gc = new GregorianCalendar(); gc.setTime(ascreening.getId().getDay()); if (gc.get(GregorianCalendar.YEAR) != YEAR) continue; li = new ListItem(getScreening(ascreening, SMALL)); li.setLeading(12); list.add(li); } return list; }
From source file:com.aryjr.nheengatu.pdf.PDFTable.java
License:Open Source License
private static void createTableRow(final PDFTable table, final Tag row, final ArrayList suggestedCellWidths) { final TagsManager tm = TagsManager.getInstance(); final Iterator cells = row.tags(); Tag htmlCell;//from w w w. j a v a 2s .c o m PdfPCell cell; Paragraph pCell; try { int inc = 0; // TODO suggested cell widths only without rowspan while (cells.hasNext()) { htmlCell = (Tag) cells.next(); htmlCell.setPropertyValue(PDFTable.CELLSPACING, row.getPropertyValue(PDFTable.CELLSPACING)); htmlCell.setPropertyValue(PDFTable.CELLPADDING, row.getPropertyValue(PDFTable.CELLPADDING)); cell = PDFTable.createCell(htmlCell); tm.checkTag(htmlCell); pCell = new Paragraph(); // TODO Cell heights problem solved!!! Waiting for a iText // solution. pCell.setLeading((pCell.getLeading() / 2) + 2); //pCell.setLeading((pCell.leading() / 2)); cell.addElement(pCell); if (htmlCell.getPropertyValue("itext-padding") != null) { cell.setPadding(Float.valueOf(htmlCell.getPropertyValue("itext-padding")).floatValue()); } if (htmlCell.getPropertyValue("cellpadding") != null) { cell.setPadding(Float.valueOf(htmlCell.getPropertyValue("cellpadding")).floatValue()); } if (htmlCell.getPropertyValue("cellspacing") != null) { cell.setBorderWidth(Float.valueOf(htmlCell.getPropertyValue("cellspacing")).floatValue()); } final float cellWidth = PDFTable.extractVisibleComponents(htmlCell, cell, pCell, 0f); // TODO compare the size of anothers widths suggestedCellWidths.add(new Float(cellWidth)); tm.back(); table.addCell(cell); inc++; } } catch (final Exception e) { e.printStackTrace(); } }
From source file:com.aryjr.nheengatu.pdf.PDFText.java
License:Open Source License
public static Paragraph createParagraph(final Text htmlText, TagsManager tm) { if (tm == null) tm = TagsManager.getInstance();/*from ww w. j av a 2 s .com*/ final Paragraph text = new Paragraph(htmlText != null ? htmlText.getText() : null, tm.getFont()); text.setAlignment(tm.getAlign()); text.setKeepTogether(true); // float b = tm.getSpacingBefore(); // float a = tm.getSpacingAfter(); text.setSpacingBefore(tm.getSpacingBefore()); text.setSpacingAfter(tm.getSpacingAfter()); text.setFirstLineIndent(tm.getTextIndent()); text.setIndentationLeft(tm.getMarginLeft()); // text.setFirstLineIndent(20f); text.setLeading(tm.getFont().getSize() * 1.5f); return text; }