Example usage for java.text NumberFormat setMaximumFractionDigits

List of usage examples for java.text NumberFormat setMaximumFractionDigits

Introduction

In this page you can find the example usage for java.text NumberFormat setMaximumFractionDigits.

Prototype

public void setMaximumFractionDigits(int newValue) 

Source Link

Document

Sets the maximum number of digits allowed in the fraction portion of a number.

Usage

From source file:ubic.gemma.apps.Blat.java

/**
 * Run a gfClient query, using a call to exec().
 * //from   ww  w . ja  v  a 2s  .c  o m
 * @param querySequenceFile
 * @param outputPath
 * @return
 */
private Collection<BlatResult> execGfClient(File querySequenceFile, String outputPath, int portToUse)
        throws IOException {
    final String cmd = gfClientExe + " -nohead -minScore=" + MIN_SCORE + " " + host + " " + portToUse + " "
            + seqDir + " " + querySequenceFile.getAbsolutePath() + " " + outputPath;
    log.info(cmd);

    final Process run = Runtime.getRuntime().exec(cmd);

    // to ensure that we aren't left waiting for these streams
    GenericStreamConsumer gscErr = new GenericStreamConsumer(run.getErrorStream());
    GenericStreamConsumer gscIn = new GenericStreamConsumer(run.getInputStream());
    gscErr.start();
    gscIn.start();

    try {

        int exitVal = Integer.MIN_VALUE;

        // wait...
        StopWatch overallWatch = new StopWatch();
        overallWatch.start();

        while (exitVal == Integer.MIN_VALUE) {
            try {
                exitVal = run.exitValue();
            } catch (IllegalThreadStateException e) {
                // okay, still
                // waiting.
            }
            Thread.sleep(BLAT_UPDATE_INTERVAL_MS);
            // I hope this is okay...
            synchronized (outputPath) {
                File outputFile = new File(outputPath);
                Long size = outputFile.length();
                NumberFormat nf = new DecimalFormat();
                nf.setMaximumFractionDigits(2);
                String minutes = TimeUtil.getMinutesElapsed(overallWatch);
                log.info("BLAT output so far: " + nf.format(size / 1024.0) + " kb (" + minutes
                        + " minutes elapsed)");
            }
        }

        overallWatch.stop();
        String minutes = TimeUtil.getMinutesElapsed(overallWatch);
        log.info("Blat took a total of " + minutes + " minutes");

        // int exitVal = run.waitFor();

        log.debug("blat exit value=" + exitVal);
    } catch (InterruptedException e) {
        throw new RuntimeException(e);
    }
    log.debug("GfClient Success");

    return processPsl(outputPath, null);
}

From source file:voldemort.store.readonly.fetcher.HdfsFetcher.java

/**
 * Function to copy a file from the given filesystem with a checksum of type
 * 'checkSumType' computed and returned. In case an error occurs during such
 * a copy, we do a retry for a maximum of NUM_RETRIES
 * /*from  w ww. j a v  a2 s.co  m*/
 * @param fs Filesystem used to copy the file
 * @param source Source path of the file to copy
 * @param dest Destination path of the file on the local machine
 * @param stats Stats for measuring the transfer progress
 * @param checkSumType Type of the Checksum to be computed for this file
 * @return A Checksum (generator) of type checkSumType which contains the
 *         computed checksum of the copied file
 * @throws IOException
 */
private CheckSum copyFileWithCheckSum(FileSystem fs, Path source, File dest, CopyStats stats,
        CheckSumType checkSumType) throws Throwable {
    CheckSum fileCheckSumGenerator = null;
    logger.debug("Starting copy of " + source + " to " + dest);
    FSDataInputStream input = null;
    OutputStream output = null;

    for (int attempt = 0; attempt < maxAttempts; attempt++) {
        boolean success = true;
        long totalBytesRead = 0;
        boolean fsOpened = false;
        try {

            // Create a per file checksum generator
            if (checkSumType != null) {
                fileCheckSumGenerator = CheckSum.getInstance(checkSumType);
            }

            logger.info("Attempt " + attempt + " at copy of " + source + " to " + dest);

            input = fs.open(source);
            fsOpened = true;

            output = new BufferedOutputStream(new FileOutputStream(dest));
            byte[] buffer = new byte[bufferSize];
            while (true) {
                int read = input.read(buffer);
                if (read < 0) {
                    break;
                } else {
                    output.write(buffer, 0, read);
                }

                // Update the per file checksum
                if (fileCheckSumGenerator != null) {
                    fileCheckSumGenerator.update(buffer, 0, read);
                }

                // Check if we need to throttle the fetch
                if (throttler != null) {
                    throttler.maybeThrottle(read);
                }

                stats.recordBytes(read);
                totalBytesRead += read;
                if (stats.getBytesSinceLastReport() > reportingIntervalBytes) {
                    NumberFormat format = NumberFormat.getNumberInstance();
                    format.setMaximumFractionDigits(2);
                    logger.info(stats.getTotalBytesCopied() / (1024 * 1024) + " MB copied at "
                            + format.format(stats.getBytesPerSecond() / (1024 * 1024)) + " MB/sec - "
                            + format.format(stats.getPercentCopied()) + " % complete, destination:" + dest);
                    if (this.status != null) {
                        this.status.setStatus(stats.getTotalBytesCopied() / (1024 * 1024) + " MB copied at "
                                + format.format(stats.getBytesPerSecond() / (1024 * 1024)) + " MB/sec - "
                                + format.format(stats.getPercentCopied()) + " % complete, destination:" + dest);
                    }
                    stats.reset();
                }
            }
            logger.info("Completed copy of " + source + " to " + dest);

        } catch (Throwable te) {
            success = false;
            if (!fsOpened) {
                logger.error("Error while opening the file stream to " + source, te);
            } else {
                logger.error("Error while copying file " + source + " after " + totalBytesRead + " bytes.", te);
            }
            if (te.getCause() != null) {
                logger.error("Cause of error ", te.getCause());
            }
            te.printStackTrace();

            if (attempt < maxAttempts - 1) {
                logger.info("Will retry copying after " + retryDelayMs + " ms");
                sleepForRetryDelayMs();
            } else {
                logger.info("Fetcher giving up copy after " + maxAttempts + " attempts");
                throw te;
            }
        } finally {
            IOUtils.closeQuietly(output);
            IOUtils.closeQuietly(input);
            if (success) {
                break;
            }
        }
        logger.debug("Completed copy of " + source + " to " + dest);
    }
    return fileCheckSumGenerator;
}

From source file:net.fabiszewski.ulogger.MainActivity.java

/**
 * Called when the user clicks the track text view
 * @param view View//from   ww  w . java 2  s. c  o  m
 */
public void trackSummary(@SuppressWarnings("UnusedParameters") View view) {
    final TrackSummary summary = db.getTrackSummary();
    if (summary == null) {
        showToast(getString(R.string.no_positions));
        return;
    }

    @SuppressLint("InflateParams")
    View summaryView = getLayoutInflater().inflate(R.layout.summary, null, false);
    AlertDialog alertDialog = new AlertDialog.Builder(MainActivity.this).create();
    alertDialog.setTitle(getString(R.string.track_summary));
    alertDialog.setView(summaryView);
    alertDialog.setIcon(R.drawable.ic_equalizer_white_24dp);
    alertDialog.setButton(AlertDialog.BUTTON_NEUTRAL, getString(R.string.ok),
            new DialogInterface.OnClickListener() {
                public void onClick(DialogInterface dialog, int which) {
                    dialog.dismiss();
                }
            });
    alertDialog.show();

    final TextView summaryDistance = (TextView) alertDialog.findViewById(R.id.summary_distance);
    final TextView summaryDuration = (TextView) alertDialog.findViewById(R.id.summary_duration);
    final TextView summaryPositions = (TextView) alertDialog.findViewById(R.id.summary_positions);
    double distance = (double) summary.getDistance() / 1000;
    String unitName = getString(R.string.unit_kilometer);
    if (pref_units.equals(getString(R.string.pref_units_imperial))) {
        distance *= KM_MILE;
        unitName = getString(R.string.unit_mile);
    }
    final NumberFormat nf = NumberFormat.getInstance();
    nf.setMaximumFractionDigits(2);
    final String distanceString = nf.format(distance);
    summaryDistance.setText(getString(R.string.summary_distance, distanceString, unitName));
    final long h = summary.getDuration() / 3600;
    final long m = summary.getDuration() % 3600 / 60;
    summaryDuration.setText(getString(R.string.summary_duration, h, m));
    int positionsCount = (int) summary.getPositionsCount();
    if (needsPluralFewHack(positionsCount)) {
        summaryPositions.setText(getResources().getString(R.string.summary_positions_few, positionsCount));
    } else {
        summaryPositions.setText(
                getResources().getQuantityString(R.plurals.summary_positions, positionsCount, positionsCount));
    }
}

From source file:org.jivesoftware.openfire.reporting.graph.GraphEngine.java

/**
 * Generates a generic Time Bar Chart./*from w  w  w.  j  a  va 2 s.c  o m*/
 *
 * @param title      the title of the Chart.
 * @param valueLabel the X Axis Label.
 * @param data       the data to populate with.
 * @return the generated Chart.
 */
private JFreeChart createTimeBarChart(String title, String color, String valueLabel, XYDataset data) {
    PlotOrientation orientation = PlotOrientation.VERTICAL;
    DateAxis xAxis = generateTimeAxis();

    NumberAxis yAxis = new NumberAxis(valueLabel);
    NumberFormat formatter = NumberFormat.getNumberInstance(JiveGlobals.getLocale());
    formatter.setMaximumFractionDigits(2);
    formatter.setMinimumFractionDigits(0);
    yAxis.setNumberFormatOverride(formatter);
    yAxis.setAutoRangeIncludesZero(true);

    return createChart(title, data, xAxis, yAxis, orientation, new XYBarRenderer(),
            GraphDefinition.getDefinition(color));
}

From source file:org.jivesoftware.openfire.reporting.graph.GraphEngine.java

/**
 * Generates a generic Time Area Chart.//from   www .ja va 2  s  . c o  m
 *
 * @param title      the title of the Chart.
 * @param valueLabel the Y Axis label.
 * @param data       the data to populate with.
 * @return the generated Chart.
 */
private JFreeChart createTimeAreaChart(String title, String color, String valueLabel, XYDataset data) {
    PlotOrientation orientation = PlotOrientation.VERTICAL;

    DateAxis xAxis = generateTimeAxis();

    NumberAxis yAxis = new NumberAxis(valueLabel);

    NumberFormat formatter = NumberFormat.getNumberInstance(JiveGlobals.getLocale());
    formatter.setMaximumFractionDigits(2);
    formatter.setMinimumFractionDigits(0);
    yAxis.setNumberFormatOverride(formatter);

    XYAreaRenderer renderer = new XYAreaRenderer(XYAreaRenderer.AREA);
    renderer.setOutline(true);

    return createChart(title, data, xAxis, yAxis, orientation, renderer, GraphDefinition.getDefinition(color));
}

From source file:com.jd.survey.web.pdf.StatisticsPdf.java

private void writeDateMatrixQuestionStatistics(Document document, Question question,
        List<QuestionStatistic> questionStatistics, String minimumLabel, String maximumLabel, String dateFormat)
        throws Exception {

    NumberFormat percentFormat = NumberFormat.getPercentInstance();
    percentFormat.setMaximumFractionDigits(1);

    Table statsTable;/* w  w w.  j av  a  2s.c o m*/
    Cell cell;

    statsTable = new Table(question.getColumnLabels().size() + 1);
    statsTable.setWidth(94);
    statsTable.setBorder(0);
    statsTable.setOffset(5);
    statsTable.setPadding(2);
    statsTable.setDefaultCellBorder(0);

    //header
    cell = new Cell();
    cell.setBorder(Cell.BOTTOM);
    statsTable.addCell(cell);
    for (QuestionColumnLabel columnLabel : question.getColumnLabels()) {
        cell = new Cell(new Paragraph(columnLabel.getLabel(), boldedFont));
        cell.setBorder(Cell.BOTTOM);
        statsTable.addCell(cell);
    }
    int rowIndex = 1;
    for (QuestionRowLabel rowLabel : question.getRowLabels()) {
        cell = new Cell(new Paragraph(rowLabel.getLabel(), boldedFont));
        cell.setBorder(Cell.RIGHT);
        if ((rowIndex % 2) == 1) {
            cell.setBackgroundColor(new Color(244, 244, 244));
        }
        statsTable.addCell(cell);
        for (QuestionColumnLabel columnLabel : question.getColumnLabels()) {
            boolean found = false;
            cell = new Cell();
            if ((rowIndex % 2) == 1) {
                cell.setBackgroundColor(new Color(244, 244, 244));
            }
            for (QuestionStatistic questionStatistic : questionStatistics) {
                if (questionStatistic.getRowOrder().equals(rowLabel.getOrder())
                        && questionStatistic.getColumnOrder().equals(columnLabel.getOrder())) {
                    cell.add(new Paragraph(minimumLabel + ": "
                            + DateValidator.getInstance().format(questionStatistic.getMinDate(), dateFormat),
                            normalFont));
                    cell.add(new Paragraph(maximumLabel + ": "
                            + DateValidator.getInstance().format(questionStatistic.getMaxDate(), dateFormat),
                            normalFont));
                    break;
                }
            }
            if (!found) {
            }

            statsTable.addCell(cell);
        }
        rowIndex++;
    }

    document.add(statsTable);

}

From source file:com.jd.survey.web.pdf.StatisticsPdf.java

private void writeBooleanQuestionStatistics(Document document, Question question,
        List<QuestionStatistic> questionStatistics, String optionLabel, String optionFrequencyLabel,
        String trueLabel, String falseLabel) throws Exception {

    NumberFormat percentFormat = NumberFormat.getPercentInstance();
    percentFormat.setMaximumFractionDigits(1);

    Table statsTable = createOptionsQuestionStatisticsTableHeader(optionLabel, optionFrequencyLabel);
    Cell cell;//w  ww.  j  ava 2 s  .  c o m
    Boolean foundOption = false;

    cell = new Cell(new Paragraph(trueLabel, normalFont));
    statsTable.addCell(cell);
    if (questionStatistics != null && questionStatistics.size() > 0) {
        for (QuestionStatistic questionStatistic : questionStatistics) {
            if (questionStatistic.getEntry().equals("1")) {
                foundOption = true;
                cell = new Cell(
                        new Paragraph(percentFormat.format(questionStatistic.getFrequency()), normalFont));
                statsTable.addCell(cell);

                cell = new Cell();
                Image img = Image.getInstance(this.getClass().getResource("/chartbar.png"));
                cell.setColspan(5);
                img.scaleAbsolute((float) (questionStatistic.getFrequency() * 210), 10f);
                cell.addElement(img);
                cell.setVerticalAlignment(Cell.ALIGN_BOTTOM);
                statsTable.addCell(cell);
                break;
            }
        }
    }
    if (!foundOption) {
        cell = new Cell(new Paragraph(percentFormat.format(0), normalFont));
        statsTable.addCell(cell);

        cell = new Cell();
        cell.setColspan(5);
        statsTable.addCell(cell);
    }

    foundOption = false;
    cell = new Cell(new Paragraph(falseLabel, normalFont));
    statsTable.addCell(cell);
    if (questionStatistics != null && questionStatistics.size() > 0) {
        for (QuestionStatistic questionStatistic : questionStatistics) {
            if (questionStatistic.getEntry().equals("0")) {
                foundOption = true;
                cell = new Cell(
                        new Paragraph(percentFormat.format(questionStatistic.getFrequency()), normalFont));
                statsTable.addCell(cell);

                cell = new Cell();
                Image img = Image.getInstance(this.getClass().getResource("/chartbar.png"));
                cell.setColspan(5);
                img.scaleAbsolute((float) (questionStatistic.getFrequency() * 210), 10f);
                cell.addElement(img);
                cell.setVerticalAlignment(Cell.ALIGN_BOTTOM);
                statsTable.addCell(cell);
                break;
            }
        }
    }
    if (!foundOption) {
        cell = new Cell(new Paragraph(percentFormat.format(0), normalFont));
        statsTable.addCell(cell);

        cell = new Cell();
        cell.setColspan(5);
        statsTable.addCell(cell);
    }
    document.add(statsTable);

}

From source file:com.jd.survey.web.pdf.StatisticsPdf.java

private void writeNumericMatrixQuestionStatistics(Document document, Question question,
        List<QuestionStatistic> questionStatistics, String minimumLabel, String maximumLabel,
        String averageLabel, String standardDeviationLabel) throws Exception {

    NumberFormat percentFormat = NumberFormat.getPercentInstance();
    percentFormat.setMaximumFractionDigits(1);

    Table statsTable;//from w  ww.  j a va  2s.  c  o m
    Cell cell;

    statsTable = new Table(question.getColumnLabels().size() + 1);
    statsTable.setWidth(94);
    statsTable.setBorder(0);
    statsTable.setOffset(5);
    statsTable.setPadding(2);
    statsTable.setDefaultCellBorder(0);

    //header
    cell = new Cell();
    cell.setBorder(Cell.BOTTOM);
    statsTable.addCell(cell);
    for (QuestionColumnLabel columnLabel : question.getColumnLabels()) {
        cell = new Cell(new Paragraph(columnLabel.getLabel(), boldedFont));
        cell.setBorder(Cell.BOTTOM);
        statsTable.addCell(cell);
    }
    int rowIndex = 1;
    for (QuestionRowLabel rowLabel : question.getRowLabels()) {
        cell = new Cell(new Paragraph(rowLabel.getLabel(), boldedFont));
        cell.setBorder(Cell.RIGHT);
        if ((rowIndex % 2) == 1) {
            cell.setBackgroundColor(new Color(244, 244, 244));
        }
        statsTable.addCell(cell);
        for (QuestionColumnLabel columnLabel : question.getColumnLabels()) {
            boolean found = false;
            cell = new Cell();
            if ((rowIndex % 2) == 1) {
                cell.setBackgroundColor(new Color(244, 244, 244));
            }
            for (QuestionStatistic questionStatistic : questionStatistics) {
                if (questionStatistic.getRowOrder().equals(rowLabel.getOrder())
                        && questionStatistic.getColumnOrder().equals(columnLabel.getOrder())) {
                    cell.add(new Paragraph(
                            minimumLabel + ": " + BigDecimalValidator.getInstance()
                                    .format(questionStatistic.getMin(), LocaleContextHolder.getLocale()),
                            normalFont));
                    cell.add(new Paragraph(
                            maximumLabel + ": " + BigDecimalValidator.getInstance()
                                    .format(questionStatistic.getMax(), LocaleContextHolder.getLocale()),
                            normalFont));
                    cell.add(new Paragraph(
                            averageLabel + ": " + BigDecimalValidator.getInstance()
                                    .format(questionStatistic.getAverage(), LocaleContextHolder.getLocale()),
                            normalFont));
                    cell.add(new Paragraph(standardDeviationLabel + ": "
                            + BigDecimalValidator.getInstance().format(
                                    questionStatistic.getSampleStandardDeviation(),
                                    LocaleContextHolder.getLocale()),
                            normalFont));

                    break;
                }
            }
            if (!found) {
            }

            statsTable.addCell(cell);
        }
        rowIndex++;
    }

    document.add(statsTable);

}

From source file:com.jd.survey.web.pdf.StatisticsPdf.java

private void writeCurrencyMatrixQuestionStatistics(Document document, Question question,
        List<QuestionStatistic> questionStatistics, String minimumLabel, String maximumLabel,
        String averageLabel, String standardDeviationLabel) throws Exception {

    NumberFormat percentFormat = NumberFormat.getPercentInstance();
    percentFormat.setMaximumFractionDigits(1);

    Table statsTable;/* www  . ja  v a 2 s .  c  o m*/
    Cell cell;

    statsTable = new Table(question.getColumnLabels().size() + 1);
    statsTable.setWidth(94);
    statsTable.setBorder(0);
    statsTable.setOffset(5);
    statsTable.setPadding(2);
    statsTable.setDefaultCellBorder(0);

    //header
    cell = new Cell();
    cell.setBorder(Cell.BOTTOM);
    statsTable.addCell(cell);
    for (QuestionColumnLabel columnLabel : question.getColumnLabels()) {
        cell = new Cell(new Paragraph(columnLabel.getLabel(), boldedFont));
        cell.setBorder(Cell.BOTTOM);
        statsTable.addCell(cell);
    }
    int rowIndex = 1;
    for (QuestionRowLabel rowLabel : question.getRowLabels()) {
        cell = new Cell(new Paragraph(rowLabel.getLabel(), boldedFont));
        cell.setBorder(Cell.RIGHT);
        if ((rowIndex % 2) == 1) {
            cell.setBackgroundColor(new Color(244, 244, 244));
        }
        statsTable.addCell(cell);
        for (QuestionColumnLabel columnLabel : question.getColumnLabels()) {
            boolean found = false;
            cell = new Cell();
            if ((rowIndex % 2) == 1) {
                cell.setBackgroundColor(new Color(244, 244, 244));
            }
            for (QuestionStatistic questionStatistic : questionStatistics) {
                if (questionStatistic.getRowOrder().equals(rowLabel.getOrder())
                        && questionStatistic.getColumnOrder().equals(columnLabel.getOrder())) {
                    cell.add(new Paragraph(
                            minimumLabel + ": " + CurrencyValidator.getInstance()
                                    .format(questionStatistic.getMin(), LocaleContextHolder.getLocale()),
                            normalFont));
                    cell.add(new Paragraph(
                            maximumLabel + ": " + CurrencyValidator.getInstance()
                                    .format(questionStatistic.getMax(), LocaleContextHolder.getLocale()),
                            normalFont));
                    cell.add(new Paragraph(
                            averageLabel + ": " + CurrencyValidator.getInstance()
                                    .format(questionStatistic.getAverage(), LocaleContextHolder.getLocale()),
                            normalFont));
                    cell.add(new Paragraph(standardDeviationLabel + ": "
                            + CurrencyValidator.getInstance().format(
                                    questionStatistic.getSampleStandardDeviation(),
                                    LocaleContextHolder.getLocale()),
                            normalFont));

                    break;
                }
            }
            if (!found) {
            }

            statsTable.addCell(cell);
        }
        rowIndex++;
    }

    document.add(statsTable);

}

From source file:com.jd.survey.web.pdf.StatisticsPdf.java

private void writeOptionsQuestionStatistics(Document document, Question question,
        List<QuestionStatistic> questionStatistics, String optionLabel, String optionFrequencyLabel)
        throws Exception {

    NumberFormat percentFormat = NumberFormat.getPercentInstance();
    percentFormat.setMaximumFractionDigits(1);

    Table statsTable = createOptionsQuestionStatisticsTableHeader(optionLabel, optionFrequencyLabel);
    Cell cell;//from w ww.j  a v  a2  s  .  c o  m

    int rowIndex = 0;
    for (QuestionOption option : question.getOptions()) {
        Boolean foundOption = false;
        cell = new Cell(new Paragraph(option.getText(), normalFont));
        //if ((rowIndex % 2) == 1) {cell.setBackgroundColor(new Color(244,244,244));}
        statsTable.addCell(cell);

        if (questionStatistics != null && questionStatistics.size() > 0) {
            for (QuestionStatistic questionStatistic : questionStatistics) {
                if (question.getType().getIsMultipleValue()) {
                    //multiple value question (checkboxes) match on order
                    if (questionStatistic.getOptionOrder().equals(option.getOrder())) {
                        foundOption = true;

                        cell = new Cell(new Paragraph(percentFormat.format(questionStatistic.getFrequency()),
                                normalFont));
                        statsTable.addCell(cell);

                        cell = new Cell();
                        Image img = Image.getInstance(this.getClass().getResource("/chartbar.png"));
                        cell.setColspan(5);
                        img.scaleAbsolute((float) (questionStatistic.getFrequency() * 210), 10f);
                        cell.addElement(img);
                        cell.setVerticalAlignment(Cell.ALIGN_BOTTOM);
                        statsTable.addCell(cell);
                        break;
                    }
                } else {
                    //single value question match on value
                    if (questionStatistic.getEntry() != null
                            && questionStatistic.getEntry().equals(option.getValue())) {
                        foundOption = true;
                        cell = new Cell(new Paragraph(percentFormat.format(questionStatistic.getFrequency()),
                                normalFont));
                        //if ((rowIndex % 2) == 1) {cell.setBackgroundColor(new Color(244,244,244));}
                        statsTable.addCell(cell);

                        cell = new Cell();
                        //if ((rowIndex % 2) == 1) {cell.setBackgroundColor(new Color(244,244,244));}
                        Image img = Image.getInstance(this.getClass().getResource("/chartbar.png"));
                        cell.setColspan(5);
                        img.scaleAbsolute((float) (questionStatistic.getFrequency() * 210), 10f);
                        cell.addElement(img);
                        cell.setVerticalAlignment(Cell.ALIGN_BOTTOM);
                        statsTable.addCell(cell);
                        break;
                    }

                }
            }
        }

        if (!foundOption) {

            cell = new Cell(new Paragraph(percentFormat.format(0), normalFont));
            //if ((rowIndex % 2) == 1) {cell.setBackgroundColor(new Color(244,244,244));}
            statsTable.addCell(cell);

            cell = new Cell();
            //if ((rowIndex % 2) == 1) {cell.setBackgroundColor(new Color(244,244,244));}
            cell.setColspan(5);
            statsTable.addCell(cell);
        }
        rowIndex++;
    }
    document.add(statsTable);

}