Java 类com.lowagie.text.BadElementException 实例源码

项目:eid-applet    文件:PdfGenerator.java   
/**
 * Generate a Code128C barcode
 *
 * @param rrn
 *            unique Rijksregister number
 * @param cardNumber
 *            number of the card
 * @return Image containing barcode
 * @throws IOException
 * @throws BadElementException
 */
private Image createBarcodeImage(String rrn, String cardNumber) throws IOException, BadElementException {
    if (null == rrn || rrn.length() != 11 || null == cardNumber || cardNumber.length() < 9) {
        throw new IllegalArgumentException("Missing or invalid length for RRN or Card Number");
    }

    String lastDigits = cardNumber.substring(cardNumber.length() - 9);
    String code = rrn + lastDigits;

    Barcode128 barcode = new Barcode128();
    barcode.setCodeType(Barcode128.CODE_C);
    barcode.setCode(code);
    barcode.setFont(null);

    return Image.getInstance(barcode.createAwtImage(Color.BLACK, Color.WHITE), null, true);
}
项目:javamelody    文件:PdfJndiReport.java   
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(" ");
        phrase.add(name);
        addCell(phrase);
    } else {
        addCell(name);
    }
    addCell(className != null ? className : "");
    addCell(value != null ? value : "");
}
项目:javamelody    文件:PdfJavaInformationsReport.java   
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"));
        }
    }
}
项目:javamelody    文件:PdfJobInformationsReport.java   
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"));
    }
}
项目:gomall.la    文件:SimpleChinesePdfView.java   
/**
 * Generates the header cells, which persist on every page of the PDF
 * document.
 * 
 * @throws BadElementException
 *             IText exception
 */
protected void generateHeaders() throws BadElementException {
    Iterator iterator = this.model.getHeaderCellList().iterator();

    while (iterator.hasNext()) {
        HeaderCell headerCell = (HeaderCell) iterator.next();

        String columnHeader = headerCell.getTitle();

        if (columnHeader == null) {
            columnHeader = StringUtils.capitalize(headerCell.getBeanPropertyName());
        }

        Cell hdrCell = getCell(columnHeader);
        hdrCell.setGrayFill(0.9f);
        hdrCell.setHeader(true);
        tablePDF.addCell(hdrCell);

    }
}
项目:gomall.la    文件:SimpleChinesePdfView.java   
/**
 * Generates all the row cells.
 * 
 * @throws JspException
 *             for errors during value retrieving from the table model
 * @throws BadElementException
 *             errors while generating content
 */
protected void generateRows() throws JspException, BadElementException {
    // get the correct iterator (full or partial list according to the
    // exportFull field)
    RowIterator rowIterator = this.model.getRowIterator(this.exportFull);
    // iterator on rows
    while (rowIterator.hasNext()) {
        Row row = rowIterator.next();

        // iterator on columns
        ColumnIterator columnIterator = row.getColumnIterator(this.model.getHeaderCellList());

        while (columnIterator.hasNext()) {
            Column column = columnIterator.nextColumn();

            // Get the value to be displayed for the column
            Object value = column.getValue(this.decorated);

            Cell cell = getCell(ObjectUtils.toString(value));
            tablePDF.addCell(cell);
        }
    }
}
项目:kfs    文件:Coversheet.java   
/**
 * 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;
}
项目:kfs    文件:Coversheet.java   
/**
 * 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;
}
项目:kfs    文件:Coversheet.java   
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;
}
项目:primefaces-blueprints    文件:InvestmentSummaryController.java   
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 );
}
项目:primefaces-blueprints    文件:AccountSummaryController.java   
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 );
}
项目:primefaces-blueprints    文件:TransactionSummaryController.java   
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);
}
项目:netxilia    文件:SheetPdfProvider.java   
/**
 * Generates the header cells, which persist on every page of the PDF document.
 * 
 * @throws BadElementException
 *             IText exception
 * @throws NetxiliaBusinessException
 * @throws NetxiliaResourceException
 */
protected void generateHeaders(ISheet sheet, Table tablePDF, Font font, int columnCount)
        throws BadElementException, NetxiliaResourceException, NetxiliaBusinessException {

    Cell hdrCell = getCell("", font, Element.ALIGN_CENTER, 50);
    hdrCell.setGrayFill(0.9f);
    hdrCell.setHeader(true);
    tablePDF.addCell(hdrCell);

    List<ColumnData> columnData = sheet.receiveColumns(Range.ALL).getNonBlocking();

    for (int i = 0; i < columnCount; ++i) {
        ColumnData column = i < columnData.size() ? columnData.get(i) : null;
        hdrCell = getCell(CellReference.columnLabel(i), font, Element.ALIGN_CENTER, column != null ? column
                .getWidth() : 120);
        hdrCell.setGrayFill(0.9f);
        hdrCell.setHeader(true);
        tablePDF.addCell(hdrCell);

    }
}
项目:totallicks-tuxguitar    文件:PDFWriter.java   
/**
 * Crea un com.lowagie.text.Image a partir de un org.eclipse.swt.graphics.ImageData
 * @param data
 * @return
 */
public static Image convertToIText(ImageData data){
    try {
        PaletteData palette = data.palette;
        int width = data.width;
        int height = data.height;

        byte bytes[] = new byte[(width * height * 3)];
        for (int y = 0; y < height; y++) {
            for (int x = 0; x < width; x++) {
                RGB rgb = palette.getRGB(data.getPixel(x, y));
                bytes[y * (width * 3) + (x * 3)] = (byte)rgb.red;
                bytes[y * (width * 3) + (x * 3) + 1] = (byte)rgb.green;
                bytes[y * (width * 3) + (x * 3) + 2] = (byte)rgb.blue;
            }
        }
        return Image.getInstance(width,height,3,8,bytes);
    } catch (BadElementException e) {
        e.printStackTrace();
    }
    return null;
}
项目:geomajas-project-server    文件:RasterLayerComponentImpl.java   
/**
 * 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");
}
项目:uis    文件:GradePDFView.java   
private Paragraph generateContent(Grade grade) throws BadElementException {
    Paragraph content = new Paragraph();
    Table table = createTable(grade);

    content.add(table);
    return content;
}
项目:jaffa-framework    文件:FormPrintEngineIText.java   
/** Print a java image */
private void printImage(java.awt.Image image, PdfContentByte cb, float x1, float y1, float x2, float y2, int alignment, int fitMethod, float rotate)
throws BadElementException, IOException, DocumentException {
    if(image!=null) {
        // Convert to an iText Image
        Image img = Image.getInstance(image, null);
        printImage(img,cb,x1,y1,x2,y2,alignment,fitMethod,rotate);
    }
}
项目:itext2    文件:BarcodeDatamatrix.java   
/** 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);
}
项目:itext2    文件:BmpImage.java   
/** 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);
    }
}
项目:itext2    文件:BmpImage.java   
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;
}
项目:itext2    文件:BmpImage.java   
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);
}
项目:camel-spring    文件:BarcodeQRCode.java   
/**
 * Gets an <CODE>Image</CODE> with the barcode.
 *
 * @return the barcode <CODE>Image</CODE>
 * @throws BadElementException on error
 */
public Image getImage() throws BadElementException {

    byte[] b = getBitMatrix();
    byte g4[] = CCITTG4Encoder.compress(b, bm.getWidth(), bm.getHeight());

    return Image.getInstance(bm.getWidth(), bm.getHeight(), false, Image.CCITTG4, Image.CCITT_BLACKIS1, g4, null);
}
项目:communote-server    文件:RtfNoteWriter.java   
/**
 * This message creates the footer element for the exported document.
 *
 * @param queryInstance
 *            The query instance to extract needed data from.
 * @param user
 *            The user.
 * @param resourcesManager
 *            The resources manager to retreive resources from.
 * @return An object to be used as a header.
 * @throws MalformedURLException
 *             {@link MalformedURLException}.
 * @throws BadElementException
 *             {@link BadElementException}.
 */
private Element getFooter(NoteQueryParameters queryInstance, User user,
        ResourceBundleManager resourcesManager) throws MalformedURLException,
        BadElementException {
    Table table = new Table(2);
    table.setWidths(new float[] { 60, 40 });
    table.setWidth(100);
    table.setPadding(5);
    table.setBorder(Table.TOP);
    Cell serviceCell = new Cell();
    serviceCell.setBorder(Cell.TOP);
    serviceCell.add(RtfElementFactory.createChunk(
            resourcesManager.getText("export.post.footer.service", user.getLanguageLocale())
            + " ", null));
    serviceCell.add(RtfElementFactory.createChunk(resourcesManager.getText(
            "export.post.footer.service.provider", user.getLanguageLocale())));
    Cell pageNumberCell = new Cell();
    pageNumberCell.setHorizontalAlignment(Cell.ALIGN_RIGHT);
    pageNumberCell.setBorder(Cell.TOP);
    pageNumberCell.add(RtfElementFactory.createChunk(resourcesManager.getText(
            "export.post.footer.page", user.getLanguageLocale()) + " "));
    pageNumberCell.add(new RtfPageNumber());
    pageNumberCell
    .add(RtfElementFactory.createChunk(" "
            + resourcesManager.getText("export.post.footer.of",
                    user.getLanguageLocale()) + " "));
    pageNumberCell.add(new RtfTotalPageNumber());

    table.addCell(serviceCell);
    table.addCell(pageNumberCell);
    return table;
}
项目:javamelody    文件:PdfJndiReport.java   
private Image getFolderImage() throws BadElementException, IOException {
    if (folderImage == null) {
        folderImage = PdfDocumentFactory.getImage("folder.png");
        folderImage.scalePercent(40);
    }
    return folderImage;
}
项目:javamelody    文件:PdfJavaInformationsReport.java   
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("   ");
    }
    serverInfoPhrase.add(serverInfo);
    currentTable.addCell(serverInfoPhrase);
}
项目:javamelody    文件:PdfJavaInformationsReport.java   
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);
}
项目:javamelody    文件:PdfJavaInformationsReport.java   
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);
    }
}
项目:javamelody    文件:PdfSessionInformationsReport.java   
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);
        }
    }
}
项目:javamelody    文件:PdfSessionInformationsReport.java   
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)));
        }
    }
}
项目:javamelody    文件:PdfSessionInformationsReport.java   
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;
}
项目:javamelody    文件:PdfCounterReport.java   
private void writeRequest(CounterRequest request) throws BadElementException, IOException {
    getDefaultCell().setHorizontalAlignment(Element.ALIGN_LEFT);
    final String name = request.getName();
    if (name.length() > 1000) {
        // si la requête fait plus de 1000 caractères, on la coupe pour y voir quelque chose
        addCell(name.substring(0, 1000) + "...");
    } else {
        addCell(name);
    }
    if (includeGraph) {
        writeRequestGraph(request);
    }
    getDefaultCell().setHorizontalAlignment(Element.ALIGN_RIGHT);
    final CounterRequest globalRequest = counterRequestAggregation.getGlobalRequest();
    if (counterRequestAggregation.isTimesDisplayed()) {
        addPercentageCell(request.getDurationsSum(), globalRequest.getDurationsSum());
        addCell(integerFormat.format(request.getHits()));
        final int mean = request.getMean();
        addCell(new Phrase(integerFormat.format(mean), getSlaFont(mean)));
        addCell(integerFormat.format(request.getMaximum()));
        addCell(integerFormat.format(request.getStandardDeviation()));
    } else {
        addCell(integerFormat.format(request.getHits()));
    }
    if (counterRequestAggregation.isCpuTimesDisplayed()) {
        addPercentageCell(request.getCpuTimeSum(), globalRequest.getCpuTimeSum());
        final int cpuTimeMean = request.getCpuTimeMean();
        addCell(new Phrase(integerFormat.format(cpuTimeMean), getSlaFont(cpuTimeMean)));
    }
    if (!isErrorAndNotJobCounter()) {
        addCell(systemErrorFormat.format(request.getSystemErrorPercentage()));
    }
    if (counterRequestAggregation.isResponseSizeDisplayed()) {
        addCell(integerFormat.format(request.getResponseSizeMean() / 1024));
    }
    if (counterRequestAggregation.isChildHitsDisplayed()) {
        addCell(integerFormat.format(request.getChildHitsMean()));
        addCell(integerFormat.format(request.getChildDurationsMean()));
    }
}
项目:javamelody    文件:PdfCounterReport.java   
private void writeRequestGraph(CounterRequest request) throws BadElementException, IOException {
    final JRobin jrobin = collector.getJRobin(request.getId());
    if (jrobin == null) {
        addCell("");
    } else {
        final byte[] img = jrobin.graph(range, 100, 50);
        final Image image = Image.getInstance(img);
        image.scalePercent(50);
        addCell(image);
    }
}
项目:javamelody    文件:PdfJobInformationsReport.java   
private void writeJobTimes(JobInformations jobInformations, CounterRequest counterRequest)
        throws BadElementException, IOException {
    final long elapsedTime = jobInformations.getElapsedTime();
    if (elapsedTime >= 0) {
        final Phrase elapsedTimePhrase = new Phrase(durationFormat.format(elapsedTime),
                cellFont);
        final Image memoryImage = Image
                .getInstance(Bar.toBar(100d * elapsedTime / counterRequest.getMean()), null);
        memoryImage.scalePercent(47);
        elapsedTimePhrase.add("\n");
        elapsedTimePhrase.add(new Chunk(memoryImage, 0, 0));
        addCell(elapsedTimePhrase);
    } else {
        addCell("");
    }
    if (jobInformations.getPreviousFireTime() != null) {
        addCell(fireTimeFormat.format(jobInformations.getPreviousFireTime()));
    } else {
        addCell("");
    }
    if (jobInformations.getNextFireTime() != null) {
        addCell(fireTimeFormat.format(jobInformations.getNextFireTime()));
    } else {
        addCell("");
    }
    // on n'affiche pas la période si >= 1 jour car ce formateur ne saurait pas l'afficher
    if (jobInformations.getRepeatInterval() > 0
            && jobInformations.getRepeatInterval() < ONE_DAY_MILLIS) {
        addCell(durationFormat.format(new Date(jobInformations.getRepeatInterval())));
    } else if (jobInformations.getCronExpression() != null) {
        addCell(jobInformations.getCronExpression());
    } else {
        addCell("");
    }
}
项目:javamelody    文件:MPdfWriter.java   
/**
 * Effectue le rendu des headers.
 *
 * @param table
 *           MBasicTable
 * @param datatable
 *           Table
 * @throws BadElementException
 *            e
 */
protected void renderHeaders(final MBasicTable table, final Table datatable)
        throws BadElementException {
    final int columnCount = table.getColumnCount();
    final TableColumnModel columnModel = table.getColumnModel();
    // size of columns
    float totalWidth = 0;
    for (int i = 0; i < columnCount; i++) {
        totalWidth += columnModel.getColumn(i).getWidth();
    }
    final float[] headerwidths = new float[columnCount];
    for (int i = 0; i < columnCount; i++) {
        headerwidths[i] = 100f * columnModel.getColumn(i).getWidth() / totalWidth;
    }
    datatable.setWidths(headerwidths);
    datatable.setWidth(100f);

    // table header
    final Font font = FontFactory.getFont(FontFactory.HELVETICA, 12, Font.BOLD);
    datatable.getDefaultCell().setBorderWidth(2);
    datatable.getDefaultCell().setHorizontalAlignment(Element.ALIGN_CENTER);
    // datatable.setDefaultCellGrayFill(0.75f);

    String text;
    Object value;
    for (int i = 0; i < columnCount; i++) {
        value = columnModel.getColumn(i).getHeaderValue();
        text = value != null ? value.toString() : "";
        datatable.addCell(new Phrase(text, font));
    }
    // end of the table header
    datatable.endHeaders();
}
项目:javamelody    文件:MPdfWriter.java   
/**
 * Effectue le rendu de la liste.
 *
 * @param table
 *           MBasicTable
 * @param datatable
 *           Table
 * @throws BadElementException
 *            e
 */
protected void renderList(final MBasicTable table, final Table datatable)
        throws BadElementException {
    final int columnCount = table.getColumnCount();
    final int rowCount = table.getRowCount();
    // data rows
    final Font font = FontFactory.getFont(FontFactory.HELVETICA, 10, Font.NORMAL);
    datatable.getDefaultCell().setBorderWidth(1);
    datatable.getDefaultCell().setHorizontalAlignment(Element.ALIGN_LEFT);
    // datatable.setDefaultCellGrayFill(0);
    Object value;
    String text;
    int horizontalAlignment;
    for (int k = 0; k < rowCount; k++) {
        for (int i = 0; i < columnCount; i++) {
            value = getValueAt(table, k, i);
            if (value instanceof Number || value instanceof Date) {
                horizontalAlignment = Element.ALIGN_RIGHT;
            } else if (value instanceof Boolean) {
                horizontalAlignment = Element.ALIGN_CENTER;
            } else {
                horizontalAlignment = Element.ALIGN_LEFT;
            }
            datatable.getDefaultCell().setHorizontalAlignment(horizontalAlignment);
            text = getTextAt(table, k, i);
            datatable.addCell(new Phrase(8, text != null ? text : "", font));
        }
    }
}
项目:sakai    文件:SpreadsheetDataFileWriterPdf.java   
private Cell getHeaderCell(String headerTxt) throws BadElementException{
    //set header cells:                             
    Cell c = new Cell(new Chunk(headerTxt, getBoldFont()));
    c.setHeader(true);
    c.setBackgroundColor(Color.LIGHT_GRAY);

    return c;
}
项目:gomall.la    文件:SimpleChinesePdfView.java   
/**
 * Initialize the main info holder table.
 * 
 * @throws BadElementException
 *             for errors during table initialization
 */
protected void initTable() throws BadElementException {
    tablePDF = new Table(this.model.getNumberOfColumns());
    tablePDF.setDefaultVerticalAlignment(Element.ALIGN_TOP);
    tablePDF.setCellsFitPage(true);
    tablePDF.setWidth(100);

    tablePDF.setPadding(2);
    tablePDF.setSpacing(0);

    // smallFont = FontFactory.getFont(FontFactory.HELVETICA, 7,
    // Font.NORMAL, new Color(0, 0, 0));
    smallFont = FontFactory.getFont("STSong-Light", "UniGB-UCS2-H", Font.DEFAULTSIZE);
}
项目:PDFReporter    文件:Page.java   
private Image getImage(IImage image) throws BadElementException, IOException {
        if (image!=null) {
            return  Image.getInstance((Image)image.getPeer());
        }
        return null;
//      Image pdfImage = Image.getInstance((Image)image.getPeer());
//      return  Image.getInstance(pdfImage);
    }
项目:PDFReporter    文件:Page.java   
private Image getImage(IImage image) throws BadElementException, IOException {
        if (image!=null) {
            return  Image.getInstance((Image)image.getPeer());
        }
        return null;
//      Image pdfImage = Image.getInstance((Image)image.getPeer());
//      return  Image.getInstance(pdfImage);
    }
项目:kfs    文件:Coversheet.java   
/**
 * Information about the person that initiated the {@link TravelReimbursementDocument}
 */
protected Cell getInitiatorInfo() throws BadElementException {
    final StringBuilder strBuilder = new StringBuilder();
    strBuilder.append(getInitiatorName()).append("\n")
        .append(getInitiatorPrincipalName()).append("\n")
        .append(getInitiatorPhone()).append("\n")
        .append(getInitiatorEmail()).append("\n");
    final Cell retval = getBorderlessCell(strBuilder.toString());
    return retval;
}