List of usage examples for com.lowagie.text.pdf PdfPCell addElement
public void addElement(Element element)
From source file:displayStructureAsPDFTable.java
License:Open Source License
public void drawStructure(IAtomContainer mol, int cnt) { mol = addHeteroHydrogens(mol);//from w ww . j ava 2 s . c o m // do aromaticity detection try { CDKHueckelAromaticityDetector.detectAromaticity(mol); } catch (CDKException cdke) { cdke.printStackTrace(); } r2dm = new Renderer2DModel(); renderer = new Renderer2D(r2dm); Dimension screenSize = new Dimension(this.width, this.height); setPreferredSize(screenSize); r2dm.setBackgroundDimension(screenSize); // make sure it is synched with the JPanel size setBackground(r2dm.getBackColor()); try { StructureDiagramGenerator sdg = new StructureDiagramGenerator(); sdg.setMolecule((IMolecule) mol); sdg.generateCoordinates(); this.mol = sdg.getMolecule(); r2dm.setDrawNumbers(false); r2dm.setUseAntiAliasing(true); r2dm.setColorAtomsByType(doColor); r2dm.setShowExplicitHydrogens(withH); r2dm.setShowImplicitHydrogens(true); r2dm.setShowAromaticity(true); r2dm.setShowReactionBoxes(false); r2dm.setKekuleStructure(false); GeometryTools.translateAllPositive(this.mol); GeometryTools.scaleMolecule(this.mol, getPreferredSize(), this.scale); GeometryTools.center(this.mol, getPreferredSize()); } catch (Exception exc) { exc.printStackTrace(); } this.frame.getContentPane().add(this); this.frame.pack(); Rectangle pageSize = new Rectangle(this.getSize().width, this.getSize().height); try { StringBuffer comment = new StringBuffer(); PdfPCell cell = new PdfPCell(); Phrase phrase = new Phrase(); addTitle(mol, phrase); if (props) { Map<Object, Object> propertyMap = mol.getProperties(); for (Object key : propertyMap.keySet()) { if (key.equals("AllRings")) continue; if (key.equals("SmallestRings")) continue; if (key.equals(CDKConstants.TITLE)) continue; addProperty(key, mol, phrase); } } cell.addElement(phrase); table.addCell(cell); Image awtImage = createImage(this.getSize().width, this.getSize().height); Graphics snapGraphics = awtImage.getGraphics(); paint(snapGraphics); com.lowagie.text.Image pdfImage = com.lowagie.text.Image.getInstance(awtImage, null); pdfImage.setAbsolutePosition(0, 0); table.addCell(pdfImage); } catch (DocumentException de) { System.err.println(de.getMessage()); } catch (IOException ioe) { System.err.println(ioe.getMessage()); } }
From source file:airportpainter.util.AirportPainter.java
License:Open Source License
private void createSheetsFreqs(Airport airport, Document document) { // FREQs Nearest Navaid notifyAction("createSheetsFreqs"); PdfPTable table = new PdfPTable(2); {/*from w w w. j a v a 2 s. c om*/ PdfPCell cell = new PdfPCell(); cell.setVerticalAlignment(Element.ALIGN_TOP); { if (_airport.getAtises().size() > 0) { String freq = ""; for (final Atis atis : _airport.getAtises()) { freq = freq + new Double(atis.getFreq()).toString() + " "; } Paragraph p = createTinyParagraph("ATIS ", freq); cell.addElement(p); } } { String[] reqs = { "50", "51", "52", "53", "54", "55", "56" }; for (String req : reqs) { List<ATCFreq> tempFreqs = _airport.getATCFreqs(req); if (tempFreqs.size() > 0) { String freq = ""; for (final ATCFreq tower : tempFreqs) { freq = freq + tower.getFreq() + " "; } Paragraph p = createTinyParagraph(ATCFreq.typeNames.get(req) + " ", freq); cell.addElement(p); } } } //cell.setBorder(com.lowagie.text.Rectangle.NO_BORDER); cell.setBorderWidth(borderWidth); cell.setVerticalAlignment(Element.ALIGN_TOP); table.addCell(cell); } { PdfPCell cell = new PdfPCell(); { Paragraph p = new Paragraph("Nearest Navaid:", new com.lowagie.text.Font( com.lowagie.text.Font.TIMES_ROMAN, 8, com.lowagie.text.Font.NORMAL)); cell.addElement(p); } { Paragraph p = new Paragraph(getNEarestBeaconString(airport), new com.lowagie.text.Font( com.lowagie.text.Font.TIMES_ROMAN, 10, com.lowagie.text.Font.NORMAL)); cell.addElement(p); } cell.setBorderWidth(borderWidth); //cell.setHorizontalAlignment(Element.ALIGN_RIGHT); 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 createSheetsAddSvg(Airport airport, PdfWriter writer, Document document, String imageFileName) { // FREQs Nearest Navaid notifyAction("createSheetsAddSvg"); PdfPTable table = new PdfPTable(1); {//from w ww . j ava2 s. c o m PdfPCell cell = new PdfPCell(); cell.setMinimumHeight(height); { Paragraph p = new Paragraph(); com.lowagie.text.Font fontWarning = new com.lowagie.text.Font(com.lowagie.text.Font.TIMES_ROMAN, com.lowagie.text.Font.DEFAULTSIZE, com.lowagie.text.Font.BOLD); p.add(new Chunk(" ", fontWarning)); cell.addElement(p); } 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 createSheetsFakeShops(Airport airport, Document document) { // FREQs Nearest Navaid notifyAction("createSheetsFakeShops"); PdfPTable table = new PdfPTable(1); {// w ww.j a v a 2 s .c om 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); {/*from www.ja v a 2s . co 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 a va 2 s. c o m 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 createSheetsNotes(Airport airport, Document document) { // FREQs Nearest Navaid notifyAction("createSheetsNotes"); PdfPTable table = new PdfPTable(1); {/* w w w . jav a 2s .co m*/ PdfPCell cell = new PdfPCell(); cell.setVerticalAlignment(Element.ALIGN_CENTER); { Paragraph p = new Paragraph(); com.lowagie.text.Font fontWarning = new com.lowagie.text.Font(com.lowagie.text.Font.TIMES_ROMAN, com.lowagie.text.Font.DEFAULTSIZE, com.lowagie.text.Font.BOLD); p.add(new Chunk("Warning !", fontWarning)); cell.addElement(p); } { Paragraph p = new Paragraph(); com.lowagie.text.Font fontText = new com.lowagie.text.Font(com.lowagie.text.Font.TIMES_ROMAN, com.lowagie.text.Font.DEFAULTSIZE, com.lowagie.text.Font.NORMAL); p.add(new Chunk( "Do not use this chart in real life, this is a chart suitable to be used only for FlightGear !!!", fontText)); cell.addElement(p); } 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 createSheets2Freqs(Airport airport, Document document) { // FREQs Nearest Navaid notifyAction("createSheets2Freqs"); PdfPTable table = new PdfPTable(2); {// w ww . j av a 2 s .com PdfPCell cell = new PdfPCell(); { Paragraph p = new Paragraph("Within Airspace:", new com.lowagie.text.Font( com.lowagie.text.Font.TIMES_ROMAN, 8, com.lowagie.text.Font.NORMAL)); cell.addElement(p); } cell.setBorderWidth(borderWidth); cell.setBorderWidthBottom(borderWidthThin); //cell.setHorizontalAlignment(Element.ALIGN_RIGHT); cell.setVerticalAlignment(Element.ALIGN_TOP); table.addCell(cell); } { PdfPCell cell = new PdfPCell(); com.lowagie.text.Font fontBold = new com.lowagie.text.Font(com.lowagie.text.Font.TIMES_ROMAN, com.lowagie.text.Font.DEFAULTSIZE, com.lowagie.text.Font.BOLD); 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); { Paragraph p = new Paragraph(airport.getId(), fontBold); cell.addElement(p); } { Paragraph p = new Paragraph(); p.add(new Chunk("Elev ", font)); int feets = (int) (airport.getElevation()); p.add(new Chunk(new Integer(feets).toString() + "'", fontBold)); int meters = (int) (feets / FEET_PER_METER); p.add(new Chunk("/" + new Integer(meters).toString() + "m", font)); cell.addElement(p); } { Paragraph p = new Paragraph(); p.add(new Chunk(airport.getLatitudeString1(airport.getLat(), "N", "S", 2, false) + "\r\n" + airport.getLatitudeString1(airport.getLong(), "W", "E", 3, true), font)); cell.addElement(p); } cell.setBorder(com.lowagie.text.Rectangle.NO_BORDER); cell.setVerticalAlignment(Element.ALIGN_BOTTOM); 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 createSheets2ILS(Airport airport, Document document) { // FREQs Nearest Navaid notifyAction("createSheets2ILS"); PdfPTable table = new PdfPTable(2); {//w w w. j av a2 s. 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:ambit.data.qmrf.Qmrf_Xml_Pdf.java
License:Open Source License
public void headerTable(Document pdfdoc, org.w3c.dom.Document xmldoc) { try {//ww w . j av a 2 s.c o m int header_font_size = 10; Image png_left = Image .getInstance(Qmrf_Xml_Pdf.class.getClassLoader().getResource("ambit/data/qmrf/logo.png")); Image png_right = Image .getInstance(Qmrf_Xml_Pdf.class.getClassLoader().getResource("ambit/data/qmrf/logo.png")); png_left.setAlignment(Image.LEFT); png_right.setAlignment(Image.RIGHT); png_left.scalePercent(60); png_right.scalePercent(60); //png.scaleAbsolute(76, 67); //png.setAlignment(Image.MIDDLE); PdfPCell cell; float[] widths = { 1f, 5f, 1f }; float[] widths1 = { 1f }; PdfPTable table = new PdfPTable(widths); PdfPTable table1 = new PdfPTable(widths1); table.setWidthPercentage(100); cell = new PdfPCell(); cell.setMinimumHeight(70); cell.addElement(new Chunk(png_left, +14, -40)); table.addCell(cell); String Text = ""; try { Text = findNodeValue(xml_QMRF_number, xmldoc); Chunk ident_title = new Chunk("QMRF identifier (JRC Inventory):"); Chunk ident_text = new Chunk(Text); Font bi_font = new Font(baseFont, header_font_size, Font.BOLDITALIC); Font i_font = new Font(baseFont, header_font_size, Font.ITALIC); ident_title.setFont(bi_font); ident_text.setFont(i_font); Paragraph p = new Paragraph(); p.add(ident_title); p.add(ident_text); cell = new PdfPCell(p); cell.setHorizontalAlignment(Element.ALIGN_LEFT); table1.addCell(cell); ident_title = new Chunk("QMRF Title:"); Phrase textPhrase = new Phrase(); createNodePhrase("QSAR_title", xmldoc, textPhrase, i_font); ident_title.setFont(bi_font); p = new Paragraph(); p.add(ident_title); p.add(textPhrase); cell = new PdfPCell(p); cell.setHorizontalAlignment(Element.ALIGN_LEFT); table1.addCell(cell); java.util.Date now = new java.util.Date(); java.text.DateFormat df = java.text.DateFormat.getDateInstance(); String date = df.format(now); ident_title = new Chunk("Printing Date:"); ident_text = new Chunk(date); ident_title.setFont(bi_font); ident_text.setFont(i_font); p = new Paragraph(); p.add(ident_title); p.add(ident_text); cell = new PdfPCell(p); cell.setHorizontalAlignment(Element.ALIGN_LEFT); table1.addCell(cell); p = new Paragraph(""); cell = new PdfPCell(p); cell.setHorizontalAlignment(Element.ALIGN_LEFT); table1.addCell(cell); cell = new PdfPCell(table1); cell.setPadding(0f); table.addCell(cell); } catch (Throwable x) { x.printStackTrace(); } //table.addCell(new PdfPCell(png, true)); cell.addElement(new Chunk(png_right, +14, -40)); table.addCell(cell); pdfdoc.add(table); pdfdoc.add(new Paragraph(16)); } catch (Exception x) { x.printStackTrace(); } }