Java Code Examples for com.lowagie.text.BadElementException
The following examples show how to use
com.lowagie.text.BadElementException.
These examples are extracted from open source projects.
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source Project: Knowage-Server Author: KnowageLabs File: PdfCreator.java License: GNU Affero General Public License v3.0 | 6 votes |
Image cutImage(byte[] bytes, boolean cutImageHeight, boolean cutImageWidth, int tableHeight, int tableWidth, int imgWidth, int imgHeight) throws IOException, BadElementException { logger.debug("IN"); BufferedImage image = null; // Read from a file BufferedImage region = null; int pxWidthToCut = (cutImageWidth == true) ? tableWidth : imgWidth; int pxHeightToCut = (cutImageHeight == true) ? tableHeight : imgHeight; InputStream inputStream = new ByteArrayInputStream(bytes); image = ImageIO.read(inputStream); // Read from an input stream try { region = image.getSubimage(0, 0, pxWidthToCut, pxHeightToCut); } catch (Exception e) { e.printStackTrace(); } byte[] newBytes = getBytes(region); Image cutImg = Image.getInstance(newBytes); // ImageIO.write(region,"PNG",new File("C:/nuovaImmagine222.PNG")); logger.debug("OUT"); return cutImg; }
Example #2
Source Project: javamelody Author: javamelody File: PdfJndiReport.java License: Apache License 2.0 | 6 votes |
private void writeJndiBinding(JndiBinding jndiBinding) throws BadElementException, IOException { final PdfPCell defaultCell = getDefaultCell(); defaultCell.setHorizontalAlignment(Element.ALIGN_LEFT); final String name = jndiBinding.getName(); final String className = jndiBinding.getClassName(); final String contextPath = jndiBinding.getContextPath(); final String value = jndiBinding.getValue(); if (contextPath != null) { final Image image = getFolderImage(); final Phrase phrase = new Phrase("", cellFont); phrase.add(new Chunk(image, 0, 0)); phrase.add(new Chunk(" " + name)); addCell(phrase); } else { addCell(name); } addCell(className != null ? className : ""); addCell(value != null ? value : ""); }
Example #3
Source Project: javamelody Author: javamelody File: PdfJavaInformationsReport.java License: Apache License 2.0 | 6 votes |
private void writeMemoryInformations(MemoryInformations memoryInformations) throws BadElementException, IOException { addCell(memoryInformations.getMemoryDetails().replace(" Mo", ' ' + getString("Mo"))); final long usedPermGen = memoryInformations.getUsedPermGen(); if (usedPermGen > 0) { // perm gen est à 0 sous jrockit final long maxPermGen = memoryInformations.getMaxPermGen(); addCell(getString("Memoire_Perm_Gen") + ':'); if (maxPermGen > 0) { final Phrase permGenPhrase = new Phrase( integerFormat.format(usedPermGen / 1024 / 1024) + ' ' + getString("Mo") + DIVIDE + integerFormat.format(maxPermGen / 1024 / 1024) + ' ' + getString("Mo") + BAR_SEPARATOR, cellFont); final Image permGenImage = Image.getInstance( Bar.toBarWithAlert(memoryInformations.getUsedPermGenPercentage()), null); permGenImage.scalePercent(50); permGenPhrase.add(new Chunk(permGenImage, 0, 0)); currentTable.addCell(permGenPhrase); } else { addCell(integerFormat.format(usedPermGen / 1024 / 1024) + ' ' + getString("Mo")); } } }
Example #4
Source Project: javamelody Author: javamelody File: PdfJobInformationsReport.java License: Apache License 2.0 | 6 votes |
private void writeJobInformations(JobInformations jobInformations) throws BadElementException, IOException { final PdfPCell defaultCell = getDefaultCell(); defaultCell.setHorizontalAlignment(Element.ALIGN_LEFT); addCell(jobInformations.getGroup()); addCell(jobInformations.getName()); addCell(jobInformations.getJobClassName()); defaultCell.setHorizontalAlignment(Element.ALIGN_RIGHT); final CounterRequest counterRequest = getCounterRequest(jobInformations); // counterRequest ne peut pas être null ici if (counterRequest.getMean() >= 0) { addCell(formatDuration(counterRequest.getMean())); } else { addCell(""); } // rq: on n'affiche pas ici le nb d'exécutions, le maximum, l'écart-type // ou le pourcentage d'erreurs, uniquement car cela ferait trop de colonnes dans la page writeJobTimes(jobInformations, counterRequest); defaultCell.setHorizontalAlignment(Element.ALIGN_CENTER); if (jobInformations.isPaused()) { addCell(getString("oui")); } else { addCell(getString("non")); } }
Example #5
Source Project: kfs Author: kuali File: Coversheet.java License: GNU Affero General Public License v3.0 | 6 votes |
/** * Get the PDF Table containing trip information like trip id, date, and destination * * @returns {@link Table} used for a PDF */ protected Table getTripInfo() throws BadElementException { final Table retval = new Table(3); retval.setWidth(100f); retval.setBorder(NO_BORDER); retval.addCell(getHeaderCell("Trip/Event ID")); final Cell dateHeaderCell = getHeaderCell("Date"); retval.addCell(dateHeaderCell); retval.addCell(getHeaderCell("Destination/Event Name")); retval.endHeaders(); retval.addCell(getBorderlessCell(getTripId())); final Cell dateCell = getBorderlessCell(getDate()); retval.addCell(dateCell); retval.addCell(getBorderlessCell(getDestination())); return retval; }
Example #6
Source Project: kfs Author: kuali File: Coversheet.java License: GNU Affero General Public License v3.0 | 6 votes |
/** * Get the PDF Table with personal information about the initiator and traveler * * @returns {@link Table} used for a PDF */ protected Table getPersonalInfo() throws BadElementException { final Table retval = new Table(2); retval.setWidth(100f); retval.setBorder(NO_BORDER); retval.addCell(getHeaderCell("Traveler")); final Cell initiatorHeaderCell = getHeaderCell("Request Submitted By"); retval.addCell(initiatorHeaderCell); retval.endHeaders(); retval.addCell(getTravelerInfo()); final Cell initiatorCell = getInitiatorInfo(); retval.addCell(initiatorCell); return retval; }
Example #7
Source Project: kfs Author: kuali File: Coversheet.java License: GNU Affero General Public License v3.0 | 6 votes |
public Table getExpenses() throws BadElementException { final Table retval = new Table(3); retval.setWidth(100f); retval.setBorder(NO_BORDER); retval.addCell(getHeaderCell("Expenses")); retval.addCell(getHeaderCell("Amount")); retval.addCell(getHeaderCell("Receipt Required?")); retval.endHeaders(); for (final Map<String, String> expense : expenses) { retval.addCell(getBorderlessCell(expense.get("expenseType"))); retval.addCell(getBorderlessCell(expense.get("amount"))); retval.addCell(getBorderlessCell(expense.get("receipt"))); } return retval; }
Example #8
Source Project: primefaces-blueprints Author: sudheerj File: InvestmentSummaryController.java License: The Unlicense | 6 votes |
public void preProcessPDF(Object document) throws IOException, BadElementException, DocumentException { Document pdf = (Document) document; pdf.setPageSize(PageSize.A3); pdf.open(); ServletContext servletContext = (ServletContext) FacesContext.getCurrentInstance().getExternalContext().getContext(); String logo = servletContext.getRealPath("") + File.separator +"resources" + File.separator + "images" + File.separator +"logo" + File.separator + "logo.png"; Image image=Image.getInstance(logo); image.scaleAbsolute(100f, 50f); pdf.add(image); // add a couple of blank lines pdf.add( Chunk.NEWLINE ); pdf.add( Chunk.NEWLINE ); Font fontbold = FontFactory.getFont("Times-Roman", 16, Font.BOLD); fontbold.setColor(55, 55, 55);; pdf.add(new Paragraph("Investment Summary",fontbold)); // add a couple of blank lines pdf.add( Chunk.NEWLINE ); pdf.add( Chunk.NEWLINE ); }
Example #9
Source Project: primefaces-blueprints Author: sudheerj File: AccountSummaryController.java License: The Unlicense | 6 votes |
public void preProcessPDF(Object document) throws IOException, BadElementException, DocumentException { Document pdf = (Document) document; pdf.setPageSize(PageSize.A3); pdf.open(); ServletContext servletContext = (ServletContext) FacesContext.getCurrentInstance().getExternalContext().getContext(); String logo = servletContext.getRealPath("") + File.separator +"resources" + File.separator + "images" + File.separator +"logo" + File.separator + "logo.png"; Image image=Image.getInstance(logo); image.scaleAbsolute(100f, 50f); pdf.add(image); // add a couple of blank lines pdf.add( Chunk.NEWLINE ); pdf.add( Chunk.NEWLINE ); Font fontbold = FontFactory.getFont("Times-Roman", 16, Font.BOLD); fontbold.setColor(55, 55, 55);; pdf.add(new Paragraph("Account Summary",fontbold)); // add a couple of blank lines pdf.add( Chunk.NEWLINE ); pdf.add( Chunk.NEWLINE ); }
Example #10
Source Project: primefaces-blueprints Author: sudheerj File: TransactionSummaryController.java License: The Unlicense | 6 votes |
public void preProcessPDF(Object document) throws IOException, BadElementException, DocumentException { Document pdf = (Document) document; pdf.setPageSize(PageSize.A4); pdf.open(); ServletContext servletContext = (ServletContext) FacesContext .getCurrentInstance().getExternalContext().getContext(); String logo = servletContext.getRealPath("") + File.separator + "resources" + File.separator + "images" + File.separator + "logo" + File.separator + "logo.png"; Image image = Image.getInstance(logo); image.scaleAbsolute(100f, 50f); pdf.add(image); // add a couple of blank lines pdf.add(Chunk.NEWLINE); pdf.add(Chunk.NEWLINE); Font fontbold = FontFactory.getFont("Times-Roman", 16, Font.BOLD); fontbold.setColor(55, 55, 55); ; pdf.add(new Paragraph("Transaction Summary", fontbold)); // add a couple of blank lines pdf.add(Chunk.NEWLINE); pdf.add(Chunk.NEWLINE); }
Example #11
Source Project: pentaho-reporting Author: pentaho File: PatchRtfTableTest.java License: GNU Lesser General Public License v2.1 | 6 votes |
@Test public void testImportTableRemovesUnusedRow() throws BadElementException { Table table = Mockito.mock( Table.class ); Row row = Mockito.mock( Row.class ); RtfDocument rtfDocument = new RtfDocument(); List<Row> rows = new ArrayList<>( 5 ); for ( int i = 0; i < 5; i++ ) { rows.add( row ); } Iterator<Row> iterator = rows.iterator(); Mockito.when( table.iterator() ).thenReturn( iterator ); new PatchRtfTable( rtfDocument, table ); Assert.assertFalse( iterator.hasNext() ); Assert.assertEquals( 0, rows.size() ); }
Example #12
Source Project: geomajas-project-server Author: geomajas File: RasterLayerComponentImpl.java License: GNU Affero General Public License v3.0 | 6 votes |
/** * Add image in the document. * * @param context * PDF context * @param imageResult * image * @throws BadElementException * PDF construction problem * @throws IOException * PDF construction problem */ protected void addImage(PdfContext context, ImageResult imageResult) throws BadElementException, IOException { Bbox imageBounds = imageResult.getRasterImage().getBounds(); float scaleFactor = (float) (72 / getMap().getRasterResolution()); float width = (float) imageBounds.getWidth() * scaleFactor; float height = (float) imageBounds.getHeight() * scaleFactor; // subtract screen position of lower-left corner float x = (float) (imageBounds.getX() - rasterScale * bbox.getMinX()) * scaleFactor; // shift y to lowerleft corner, flip y to user space and subtract // screen position of lower-left // corner float y = (float) (-imageBounds.getY() - imageBounds.getHeight() - rasterScale * bbox.getMinY()) * scaleFactor; if (log.isDebugEnabled()) { log.debug("adding image, width=" + width + ",height=" + height + ",x=" + x + ",y=" + y); } // opacity log.debug("before drawImage"); context.drawImage(Image.getInstance(imageResult.getImage()), new Rectangle(x, y, x + width, y + height), getSize(), getOpacity()); log.debug("after drawImage"); }
Example #13
Source Project: gcs Author: richardwilkes File: BarcodeDatamatrix.java License: Mozilla Public License 2.0 | 5 votes |
/** * Gets an <CODE>Image</CODE> with the barcode. A successful call to the method * <CODE>generate()</CODE> before calling this method is required. * * @return the barcode <CODE>Image</CODE> * @throws BadElementException on error */ public Image createImage() throws BadElementException { if (image == null) { return null; } byte g4[] = CCITTG4Encoder.compress(image, width + 2 * ws, height + 2 * ws); return Image.getInstance(width + 2 * ws, height + 2 * ws, false, Element.CCITTG4, 0, g4, null); }
Example #14
Source Project: gcs Author: richardwilkes File: BmpImage.java License: Mozilla Public License 2.0 | 5 votes |
/** * Reads a BMP from a stream. The stream is not closed. The BMP may not have a header and be * considered as a plain DIB. * * @param is the stream * @param noHeader true to process a plain DIB * @param size the size of the DIB. Not used for a BMP * @throws IOException on error * @return the image */ public static Image getImage(InputStream is, boolean noHeader, int size) throws IOException { BmpImage bmp = new BmpImage(is, noHeader, size); try { Image img = bmp.getImage(); img.setDpi((int) (bmp.xPelsPerMeter * 0.0254d + 0.5d), (int) (bmp.yPelsPerMeter * 0.0254d + 0.5d)); img.setOriginalType(Image.ORIGINAL_BMP); return img; } catch (BadElementException be) { throw new ExceptionConverter(be); } }
Example #15
Source Project: gcs Author: richardwilkes File: BmpImage.java License: Mozilla Public License 2.0 | 5 votes |
private Image indexedModel(byte bdata[], int bpc, int paletteEntries) throws BadElementException { Image img = new ImgRaw(width, height, 1, bpc, bdata); PdfArray colorspace = new PdfArray(); colorspace.add(PdfName.INDEXED); colorspace.add(PdfName.DEVICERGB); byte np[] = getPalette(paletteEntries); int len = np.length; colorspace.add(new PdfNumber(len / 3 - 1)); colorspace.add(new PdfString(np)); PdfDictionary ad = new PdfDictionary(); ad.put(PdfName.COLORSPACE, colorspace); img.setAdditional(ad); return img; }
Example #16
Source Project: gcs Author: richardwilkes File: BmpImage.java License: Mozilla Public License 2.0 | 5 votes |
private Image read1Bit(int paletteEntries) throws IOException, BadElementException { byte bdata[] = new byte[(width + 7) / 8 * height]; int padding = 0; int bytesPerScanline = (int) Math.ceil(width / 8.0d); int remainder = bytesPerScanline % 4; if (remainder != 0) { padding = 4 - remainder; } int imSize = (bytesPerScanline + padding) * height; // Read till we have the whole image byte values[] = new byte[imSize]; int bytesRead = 0; while (bytesRead < imSize) { bytesRead += inputStream.read(values, bytesRead, imSize - bytesRead); } if (isBottomUp) { // Convert the bottom up image to a top down format by copying // one scanline from the bottom to the top at a time. for (int i = 0; i < height; i++) { System.arraycopy(values, imSize - (i + 1) * (bytesPerScanline + padding), bdata, i * bytesPerScanline, bytesPerScanline); } } else { for (int i = 0; i < height; i++) { System.arraycopy(values, i * (bytesPerScanline + padding), bdata, i * bytesPerScanline, bytesPerScanline); } } return indexedModel(bdata, 1, paletteEntries); }
Example #17
Source Project: gcs Author: richardwilkes File: BmpImage.java License: Mozilla Public License 2.0 | 5 votes |
private Image read4Bit(int paletteEntries) throws IOException, BadElementException { byte bdata[] = new byte[(width + 1) / 2 * height]; // Padding bytes at the end of each scanline int padding = 0; int bytesPerScanline = (int) Math.ceil(width / 2.0d); int remainder = bytesPerScanline % 4; if (remainder != 0) { padding = 4 - remainder; } int imSize = (bytesPerScanline + padding) * height; // Read till we have the whole image byte values[] = new byte[imSize]; int bytesRead = 0; while (bytesRead < imSize) { bytesRead += inputStream.read(values, bytesRead, imSize - bytesRead); } if (isBottomUp) { // Convert the bottom up image to a top down format by copying // one scanline from the bottom to the top at a time. for (int i = 0; i < height; i++) { System.arraycopy(values, imSize - (i + 1) * (bytesPerScanline + padding), bdata, i * bytesPerScanline, bytesPerScanline); } } else { for (int i = 0; i < height; i++) { System.arraycopy(values, i * (bytesPerScanline + padding), bdata, i * bytesPerScanline, bytesPerScanline); } } return indexedModel(bdata, 4, paletteEntries); }
Example #18
Source Project: gcs Author: richardwilkes File: BmpImage.java License: Mozilla Public License 2.0 | 5 votes |
private Image read8Bit(int paletteEntries) throws IOException, BadElementException { byte bdata[] = new byte[width * height]; // Padding bytes at the end of each scanline int padding = 0; // width * bitsPerPixel should be divisible by 32 int bitsPerScanline = width * 8; if (bitsPerScanline % 32 != 0) { padding = (bitsPerScanline / 32 + 1) * 32 - bitsPerScanline; padding = (int) Math.ceil(padding / 8.0); } int imSize = (width + padding) * height; // Read till we have the whole image byte values[] = new byte[imSize]; int bytesRead = 0; while (bytesRead < imSize) { bytesRead += inputStream.read(values, bytesRead, imSize - bytesRead); } if (isBottomUp) { // Convert the bottom up image to a top down format by copying // one scanline from the bottom to the top at a time. for (int i = 0; i < height; i++) { System.arraycopy(values, imSize - (i + 1) * (width + padding), bdata, i * width, width); } } else { for (int i = 0; i < height; i++) { System.arraycopy(values, i * (width + padding), bdata, i * width, width); } } return indexedModel(bdata, 8, paletteEntries); }
Example #19
Source Project: gcs Author: richardwilkes File: BmpImage.java License: Mozilla Public License 2.0 | 5 votes |
private Image readRLE8() throws IOException, BadElementException { // If imageSize field is not provided, calculate it. int imSize = (int) imageSize; if (imSize == 0) { imSize = (int) (bitmapFileSize - bitmapOffset); } // Read till we have the whole image byte values[] = new byte[imSize]; int bytesRead = 0; while (bytesRead < imSize) { bytesRead += inputStream.read(values, bytesRead, imSize - bytesRead); } // Since data is compressed, decompress it byte val[] = decodeRLE(true, values); // Uncompressed data does not have any padding imSize = width * height; if (isBottomUp) { // Convert the bottom up image to a top down format by copying // one scanline from the bottom to the top at a time. // int bytesPerScanline = (int)Math.ceil((double)width/8.0); byte temp[] = new byte[val.length]; int bytesPerScanline = width; for (int i = 0; i < height; i++) { System.arraycopy(val, imSize - (i + 1) * bytesPerScanline, temp, i * bytesPerScanline, bytesPerScanline); } val = temp; } return indexedModel(val, 8, 4); }
Example #20
Source Project: itext2 Author: albfernandez File: BarcodeDatamatrix.java License: GNU Lesser General Public License v3.0 | 5 votes |
/** Gets an <CODE>Image</CODE> with the barcode. A successful call to the method <CODE>generate()</CODE> * before calling this method is required. * @return the barcode <CODE>Image</CODE> * @throws BadElementException on error */ public Image createImage() throws BadElementException { if (image == null) return null; byte g4[] = CCITTG4Encoder.compress(image, width + 2 * ws, height + 2 * ws); return Image.getInstance(width + 2 * ws, height + 2 * ws, false, Image.CCITTG4, 0, g4, null); }
Example #21
Source Project: itext2 Author: albfernandez File: BmpImage.java License: GNU Lesser General Public License v3.0 | 5 votes |
/** Reads a BMP from a stream. The stream is not closed. * The BMP may not have a header and be considered as a plain DIB. * @param is the stream * @param noHeader true to process a plain DIB * @param size the size of the DIB. Not used for a BMP * @throws IOException on error * @return the image */ public static Image getImage(InputStream is, boolean noHeader, int size) throws IOException { BmpImage bmp = new BmpImage(is, noHeader, size); try { Image img = bmp.getImage(); img.setDpi((int)(bmp.xPelsPerMeter * 0.0254d + 0.5d), (int)(bmp.yPelsPerMeter * 0.0254d + 0.5d)); img.setOriginalType(Image.ORIGINAL_BMP); return img; } catch (BadElementException be) { throw new ExceptionConverter(be); } }
Example #22
Source Project: itext2 Author: albfernandez File: BmpImage.java License: GNU Lesser General Public License v3.0 | 5 votes |
private Image indexedModel(byte bdata[], int bpc, int paletteEntries) throws BadElementException { Image img = new ImgRaw(width, height, 1, bpc, bdata); PdfArray colorspace = new PdfArray(); colorspace.add(PdfName.INDEXED); colorspace.add(PdfName.DEVICERGB); byte np[] = getPalette(paletteEntries); int len = np.length; colorspace.add(new PdfNumber(len / 3 - 1)); colorspace.add(new PdfString(np)); PdfDictionary ad = new PdfDictionary(); ad.put(PdfName.COLORSPACE, colorspace); img.setAdditional(ad); return img; }
Example #23
Source Project: itext2 Author: albfernandez File: BmpImage.java License: GNU Lesser General Public License v3.0 | 5 votes |
private Image readRLE8() throws IOException, BadElementException { // If imageSize field is not provided, calculate it. int imSize = (int)imageSize; if (imSize == 0) { imSize = (int)(bitmapFileSize - bitmapOffset); } // Read till we have the whole image byte values[] = new byte[imSize]; int bytesRead = 0; while (bytesRead < imSize) { bytesRead += inputStream.read(values, bytesRead, imSize - bytesRead); } // Since data is compressed, decompress it byte val[] = decodeRLE(true, values); // Uncompressed data does not have any padding imSize = width * height; if (isBottomUp) { // Convert the bottom up image to a top down format by copying // one scanline from the bottom to the top at a time. // int bytesPerScanline = (int)Math.ceil((double)width/8.0); byte temp[] = new byte[val.length]; int bytesPerScanline = width; for (int i=0; i<height; i++) { System.arraycopy(val, imSize - (i+1)*(bytesPerScanline), temp, i*bytesPerScanline, bytesPerScanline); } val = temp; } return indexedModel(val, 8, 4); }
Example #24
Source Project: javamelody Author: javamelody File: PdfJndiReport.java License: Apache License 2.0 | 5 votes |
private Image getFolderImage() throws BadElementException, IOException { if (folderImage == null) { folderImage = PdfDocumentFactory.getImage("folder.png"); folderImage.scalePercent(40); } return folderImage; }
Example #25
Source Project: javamelody Author: javamelody File: PdfJavaInformationsReport.java License: Apache License 2.0 | 5 votes |
private void writeServerInfo(String serverInfo) throws BadElementException, IOException { addCell(getString("Serveur") + ':'); final Phrase serverInfoPhrase = new Phrase("", cellFont); final String applicationServerIconName = HtmlJavaInformationsReport .getApplicationServerIconName(serverInfo); if (applicationServerIconName != null) { final Image applicationServerImage = PdfDocumentFactory .getImage("servers/" + applicationServerIconName); applicationServerImage.scalePercent(40); serverInfoPhrase.add(new Chunk(applicationServerImage, 0, 0)); serverInfoPhrase.add(new Chunk(" ")); } serverInfoPhrase.add(new Chunk(serverInfo)); currentTable.addCell(serverInfoPhrase); }
Example #26
Source Project: javamelody Author: javamelody File: PdfJavaInformationsReport.java License: Apache License 2.0 | 5 votes |
private void writeFileDescriptorCounts(JavaInformations javaInformations) throws BadElementException, IOException { final long unixOpenFileDescriptorCount = javaInformations.getUnixOpenFileDescriptorCount(); final long unixMaxFileDescriptorCount = javaInformations.getUnixMaxFileDescriptorCount(); addCell(getString("nb_fichiers") + ':'); final Phrase fileDescriptorCountPhrase = new Phrase( integerFormat.format(unixOpenFileDescriptorCount) + DIVIDE + integerFormat.format(unixMaxFileDescriptorCount) + BAR_SEPARATOR, cellFont); final Image fileDescriptorCountImage = Image.getInstance( Bar.toBarWithAlert(javaInformations.getUnixOpenFileDescriptorPercentage()), null); fileDescriptorCountImage.scalePercent(50); fileDescriptorCountPhrase.add(new Chunk(fileDescriptorCountImage, 0, 0)); currentTable.addCell(fileDescriptorCountPhrase); }
Example #27
Source Project: javamelody Author: javamelody File: PdfJavaInformationsReport.java License: Apache License 2.0 | 5 votes |
private void writeTomcatInformations(List<TomcatInformations> tomcatInformationsList) throws BadElementException, IOException { for (final TomcatInformations tomcatInformations : tomcatInformationsList) { if (tomcatInformations.getRequestCount() <= 0) { continue; } addCell("Tomcat " + tomcatInformations.getName() + ':'); // rq: on n'affiche pas pour l'instant getCurrentThreadCount final int currentThreadsBusy = tomcatInformations.getCurrentThreadsBusy(); final String equal = " = "; final Phrase phrase = new Phrase(getString("busyThreads") + equal + integerFormat.format(currentThreadsBusy) + DIVIDE + integerFormat.format(tomcatInformations.getMaxThreads()) + BAR_SEPARATOR, cellFont); final Image threadsImage = Image.getInstance(Bar.toBarWithAlert( 100d * currentThreadsBusy / tomcatInformations.getMaxThreads()), null); threadsImage.scalePercent(50); phrase.add(new Chunk(threadsImage, 0, 0)); phrase.add(new Chunk('\n' + getString("bytesReceived") + equal + integerFormat.format(tomcatInformations.getBytesReceived()) + '\n' + getString("bytesSent") + equal + integerFormat.format(tomcatInformations.getBytesSent()) + '\n' + getString("requestCount") + equal + integerFormat.format(tomcatInformations.getRequestCount()) + '\n' + getString("errorCount") + equal + integerFormat.format(tomcatInformations.getErrorCount()) + '\n' + getString("processingTime") + equal + integerFormat.format(tomcatInformations.getProcessingTime()) + '\n' + getString("maxProcessingTime") + equal + integerFormat.format(tomcatInformations.getMaxTime()))); currentTable.addCell(phrase); } }
Example #28
Source Project: javamelody Author: javamelody File: PdfSessionInformationsReport.java License: Apache License 2.0 | 5 votes |
private void writeSession(SessionInformations session) throws IOException, BadElementException { final PdfPCell defaultCell = getDefaultCell(); defaultCell.setHorizontalAlignment(Element.ALIGN_LEFT); addCell(session.getId()); defaultCell.setHorizontalAlignment(Element.ALIGN_RIGHT); addCell(durationFormat.format(session.getLastAccess())); addCell(durationFormat.format(session.getAge())); addCell(expiryFormat.format(session.getExpirationDate())); addCell(integerFormat.format(session.getAttributeCount())); defaultCell.setHorizontalAlignment(Element.ALIGN_CENTER); if (session.isSerializable()) { addCell(getString("oui")); } else { final Phrase non = new Phrase(getString("non"), severeCellFont); addCell(non); } defaultCell.setHorizontalAlignment(Element.ALIGN_RIGHT); addCell(integerFormat.format(session.getSerializedSize())); defaultCell.setHorizontalAlignment(Element.ALIGN_LEFT); final String remoteAddr = session.getRemoteAddr(); if (remoteAddr == null) { addCell(""); } else { addCell(remoteAddr); } defaultCell.setHorizontalAlignment(Element.ALIGN_CENTER); writeCountry(session); writeBrowserAndOs(session); if (displayUser) { defaultCell.setHorizontalAlignment(Element.ALIGN_LEFT); final String remoteUser = session.getRemoteUser(); if (remoteUser == null) { addCell(""); } else { addCell(remoteUser); } } }
Example #29
Source Project: javamelody Author: javamelody File: PdfSessionInformationsReport.java License: Apache License 2.0 | 5 votes |
private void writeCountry(SessionInformations session) throws IOException, BadElementException { final String country = session.getCountry(); if (country == null) { addCell(""); } else { final String fileName = "flags/" + country + ".gif"; final Image image = getImageByFileName(fileName); if (image == null) { addCell(country); } else { addCell(new Phrase(new Chunk(image, 0, 0))); } } }
Example #30
Source Project: javamelody Author: javamelody File: PdfSessionInformationsReport.java License: Apache License 2.0 | 5 votes |
private Image getImageByFileName(String fileName) throws BadElementException, IOException { assert fileName != null; Image image = imagesByFileName.get(fileName); if (image == null) { if (getClass().getResource(Parameters.getResourcePath(fileName)) == null) { return null; } image = PdfDocumentFactory.getImage(fileName); image.scalePercent(40); imagesByFileName.put(fileName, image); } return image; }