Example usage for com.lowagie.text Table setBorderWidth

List of usage examples for com.lowagie.text Table setBorderWidth

Introduction

In this page you can find the example usage for com.lowagie.text Table setBorderWidth.

Prototype

public void setBorderWidth(float borderWidth) 

Source Link

Document

Sets the borderwidth of the table.

Usage

From source file:include.nseer_cookie.MakePdf.java

License:Open Source License

public void make(String database, String tablename, String sql1, String sql2, String filename, int everypage,
        HttpSession session) {//from w w  w  . j a  va  2  s  .  c o m
    try {

        nseer_db aaa = new nseer_db(database);
        nseer_db demo_db = new nseer_db(database);

        ServletContext context = session.getServletContext();
        String path = context.getRealPath("/");

        Masking reader = new Masking(configFile);
        Vector columnNames = new Vector();
        Vector tables = reader.getTableNicks();
        Iterator loop = tables.iterator();
        while (loop.hasNext()) {
            String tablenick = (String) loop.next();
            columnNames = reader.getColumnNames(tablenick);
        }

        int cpage = 1; //? 

        int spage = 1;
        int ipage = everypage;
        String pagesql = sql1;

        //? 
        ResultSet pagers = demo_db.executeQuery(pagesql);
        pagers.next();
        int allCol = pagers.getInt("A");

        allpage = (int) Math.ceil((allCol + ipage - 1) / ipage);
        //
        for (int m = 1; m <= allpage; m++) {
            spage = (m - 1) * ipage;
            String sql = sql2 + " limit " + spage + "," + ipage;

            ResultSet bbb = aaa.executeQuery(sql);
            //ResultSetMetaData tt=bbb.getMetaData();       //
            int b = columnNames.size(); //
            int a = 0;
            while (bbb.next()) {
                a++;
            } //
            bbb.first(); //    ??
            Rectangle rectPageSize = new Rectangle(PageSize.A4);// 
            rectPageSize = rectPageSize.rotate();
            Document document = new Document(rectPageSize, 20, 20, 20, 20); //? Document
            PdfWriter writer = PdfWriter.getInstance(document,
                    new FileOutputStream(path + filename + m + ".pdf")); //?PDF??
            document.open(); //
            BaseFont bfChinese = BaseFont.createFont("STSong-Light", "UniGB-UCS2-H", BaseFont.NOT_EMBEDDED); //?
            com.lowagie.text.Font FontChinese = new com.lowagie.text.Font(bfChinese, 8,
                    com.lowagie.text.Font.NORMAL); //

            Paragraph title1 = new Paragraph("nseer ERP",
                    FontFactory.getFont(FontFactory.HELVETICA, 18, Font.BOLDITALIC));
            Chapter chapter1 = new Chapter(title1, 1); // ? 
            chapter1.setNumberDepth(0);

            Paragraph title11 = new Paragraph(tablename,
                    FontFactory.getFont(FontFactory.HELVETICA, 16, Font.BOLD));
            Section section1 = chapter1.addSection(title11); //?                                                                                            

            Table t = new Table(b, a); // ? 
            t.setPadding(1); //  
            t.setSpacing(0); //  ?
            t.setBorderWidth(1); //

            do { //
                 //
                for (int k = 0; k < b; k++) { //
                    Cell cell = new Cell(
                            new Paragraph(bbb.getString((String) columnNames.elementAt(k)), FontChinese)); //?                                    //
                    t.addCell(cell); //   ?
                    //
                } //
            } while (bbb.next()); //

            section1.add(t); //
            document.add(chapter1); // 
            document.close();

        } // ?
    } catch (Exception pp) {
        pp.printStackTrace();
    }
}

From source file:ispyb.client.mx.collection.PdfRtfExporter.java

License:Open Source License

/**
 * set a table for a sessionDataObject/*from w ww .  jav a  2s. c  o  m*/
 * 
 * @param document
 * @param sessionDataObject
 * @param mRequest
 */
private void setDetailSessionObjectTable(Document document, SessionDataObjectInformation sessionDataObject,
        HttpServletRequest mRequest) {
    try {
        int nbCol = 6;
        int nbRows = 5;
        List<Param> listParam = sessionDataObject.getListParameters();
        int idParam = 0;
        int nbParam = listParam.size();
        nbRows = Math.max(nbRows, nbParam);
        boolean secondGraph = sessionDataObject.getGraph2Path() != null
                && !sessionDataObject.getGraph2Path().isEmpty();
        if (secondGraph)
            nbCol += 1;

        Table table = new Table(nbCol);

        int l = 0;

        int[] headersWidth = new int[nbCol];

        headersWidth[l++] = 10; // def
        headersWidth[l++] = 6; // parameters title
        headersWidth[l++] = 6; // parameters value
        headersWidth[l++] = 12; // Thumbnail
        headersWidth[l++] = 12; // Snapshot
        headersWidth[l++] = 22; // Graph
        if (secondGraph)
            headersWidth[l++] = 22; // Graph2
        table.setWidths(headersWidth);

        table.setWidth(100); // percentage
        table.setPadding(1);
        table.setCellsFitPage(true);
        table.setTableFitsPage(true);
        table.setBorderWidth(1);
        table.getDefaultCell().setHorizontalAlignment(Element.ALIGN_CENTER);
        // no header
        // first Row
        // firstCell: def : date
        SimpleDateFormat formatter = new SimpleDateFormat("dd/MM/yyyy HH:mm:ss");
        String collectTime = formatter.format(sessionDataObject.getDataTime());
        Cell c = getCellValue(collectTime);
        c.setBorderWidthBottom(0);
        table.addCell(c);
        // second Cell param
        setCellParam(table, listParam, idParam++, 1);
        // third Cell : thumbnail
        Cell cellThumbnail = getCellImage(sessionDataObject.getImageThumbnailPath());
        cellThumbnail.setRowspan(nbRows);
        cellThumbnail.setBorderWidth(0);
        table.addCell(cellThumbnail);
        // 4 Cell : snapshot
        Cell cellSnapshot = getCellImage(sessionDataObject.getCrystalSnapshotPath());
        cellSnapshot.setRowspan(nbRows);
        cellSnapshot.setBorderWidth(0);
        table.addCell(cellSnapshot);
        // 5 Cell : graph
        Cell cellGraph = getCellGraph(sessionDataObject);
        cellGraph.setRowspan(nbRows);
        cellGraph.setBorderWidth(0);
        table.addCell(cellGraph);
        // 6 Cell : graph2
        if (secondGraph) {
            Cell cellGraph2 = getCellImage(sessionDataObject.getGraph2Path());
            cellGraph2.setRowspan(nbRows);
            cellGraph2.setBorderWidth(0);
            table.addCell(cellGraph2);
        }

        // second row
        Cell c2 = getCellValue(sessionDataObject.getImagePrefix() + " " + sessionDataObject.getRunNumber());
        c2.setBorderWidth(0);
        table.addCell(c2);
        // param2
        setCellParam(table, listParam, idParam++, 1);

        // third row
        Cell c3 = getCellValue(sessionDataObject.getExperimentType());
        c3.setBorderWidth(0);
        table.addCell(c3);
        // param3
        setCellParam(table, listParam, idParam++, 1);

        // 4 row
        Cell c4 = getCellValue(sessionDataObject.getSampleNameProtein());
        c4.setBorderWidth(0);
        table.addCell(c4);
        // param4
        setCellParam(table, listParam, idParam++, 1);

        // 5 row
        Cell c5 = new Cell();
        c5.setHorizontalAlignment(Element.ALIGN_LEFT);
        c5.add(new Paragraph(sessionDataObject.getComments(), FONT_DOC_ITALIC));
        c5.setBorderWidth(0);
        c5.setRowspan(nbRows - 4);
        table.addCell(c5);
        // param4
        setCellParam(table, listParam, idParam++, 1);

        for (int i = 5; i < nbRows; i++) {
            setCellParam(table, listParam, idParam++, 1);
        }

        // results
        // workflow result status
        if (sessionDataObject.isWorkflow()) {
            Cell resultCell = getWorkflowResult(sessionDataObject.getWorkflow(), mRequest);
            resultCell.setHorizontalAlignment(Element.ALIGN_LEFT);
            resultCell.setColspan(nbCol);
            table.addCell(resultCell);
        }
        // collect OSC
        if ((sessionDataObject.isDataCollection()
                && !sessionDataObject.getDataCollection().getDataCollectionGroupVO().getExperimentType()
                        .equals(Constants.EXPERIMENT_TYPE_CHARACTERIZATION))) {
            DataCollectionExporter dcExporter = new DataCollectionExporter(df2, df3, proposalCode,
                    proposalNumber, mRequest);
            DataCollection3VO dataCollection = sessionDataObject.getDataCollection();
            DataCollectionInformation dcInfo = dcExporter.getDataCollectionInformation(dataCollection,
                    getSampleRankingVO(dataCollection.getDataCollectionId()),
                    getAutoProcRankingVO(dataCollection.getDataCollectionId()));
            Cell resultCell = getAutoProcResultStatus(dcInfo);
            resultCell.setColspan(nbCol);
            resultCell.setHorizontalAlignment(Element.ALIGN_LEFT);
            table.addCell(resultCell);
            document.add(table);
            document.add(new Paragraph(" ", VERY_SMALL_FONT));

            setAutoProcResultsTable(document, dcInfo);
        } else if (sessionDataObject.isWorkflow() && sessionDataObject.getWorkflow().isMXPressEOIA()) { // MXPRESS
            // wf
            DataCollectionExporter dcExporter = new DataCollectionExporter(df2, df3, proposalCode,
                    proposalNumber, mRequest);
            DataCollection3VO dataCollection = sessionDataObject.getListDataCollection().get(0);
            DataCollectionInformation dcInfo = dcExporter.getDataCollectionInformation(dataCollection,
                    getSampleRankingVO(dataCollection.getDataCollectionId()),
                    getAutoProcRankingVO(dataCollection.getDataCollectionId()));
            Cell resultCell = getAutoProcResultStatus(dcInfo);
            resultCell.setHorizontalAlignment(Element.ALIGN_LEFT);
            resultCell.setColspan(nbCol);
            table.addCell(resultCell);

            document.add(table);
            document.add(new Paragraph(" ", VERY_SMALL_FONT));

            setAutoProcResultsTable(document, dcInfo);
        } else if ((sessionDataObject.isDataCollection()
                && sessionDataObject.getDataCollection().getDataCollectionGroupVO().getExperimentType()
                        .equals(Constants.EXPERIMENT_TYPE_CHARACTERIZATION))) { // Characterization
            DataCollectionExporter dcExporter = new DataCollectionExporter(df2, df3, proposalCode,
                    proposalNumber, mRequest);
            DataCollection3VO dataCollection = sessionDataObject.getDataCollection();
            DataCollectionInformation dcInfo = dcExporter.getDataCollectionInformation(dataCollection,
                    getSampleRankingVO(dataCollection.getDataCollectionId()),
                    getAutoProcRankingVO(dataCollection.getDataCollectionId()));
            Cell resultCell = getCharacterizationResultStatus(dcInfo, mRequest);
            resultCell.setColspan(nbCol);
            resultCell.setHorizontalAlignment(Element.ALIGN_LEFT);
            table.addCell(resultCell);
            document.add(table);
            document.add(new Paragraph(" ", VERY_SMALL_FONT));

            setStrategyTable2(document, dcInfo);
        } else {
            List<Param> listResults = sessionDataObject.getListResults();
            if (listResults != null) {
                int nbResults = listResults.size();
                for (int j = 0; j < nbResults; j++) {
                    setCellParam(table, listResults, j, 2);
                    Cell eCell = getEmptyCell(nbCol - 3);
                    eCell.setBorderWidth(0);
                    table.addCell(eCell);
                }
            }
            document.add(table);
            document.add(new Paragraph(" ", FONT_SPACE));
        }

    } catch (Exception e) {
        e.printStackTrace();
    }
}

From source file:ispyb.client.mx.collection.PdfRtfExporter.java

License:Open Source License

/**
 * sets the date and if it is a SCREEN or a COLLECT and indexing status
 * //from w w w  .  j a  va2s.c  o m
 * @param document
 * @param dcValue
 * @param date
 * @throws Exception
 */
private void setDataCollectionGeneralInfo(Document document, DataCollection3VO dcValue,
        DataCollectionInformation dcInfo) throws Exception {
    String collect = "Collect";
    if (DataCollectionExporter.isDataCollectionScreening(dcValue)) {
        collect = "Screen";
    }
    String date = dcInfo.getDataCollectionDate();
    String screeningSuccess = dcInfo.getScreeningSuccess();
    String screeningFailure = dcInfo.getScreeningFailure();
    String screeningNotDone = dcInfo.getScreeningNotDone();
    Table aTable = new Table(3);
    aTable.setWidth(100); // percentage
    aTable.setPadding(3);
    aTable.setCellsFitPage(true);
    aTable.getDefaultCell().setBorderWidth(0);
    aTable.setBorderWidth(0);
    aTable.getDefaultCell().setHorizontalAlignment(Element.ALIGN_LEFT);
    aTable.addCell(new Paragraph(date, FONT_DOC));
    aTable.addCell(new Paragraph(collect, FONT_DOC));
    // no indexing availabe
    if (screeningNotDone != null && !screeningNotDone.equals("")) {
        aTable.addCell(new Paragraph(screeningNotDone, FONT_INDEXING_NOTDONE));
    } else if (screeningFailure != null && !screeningFailure.equals("")) { // indexing
        // failed
        aTable.addCell(new Paragraph(screeningFailure, FONT_INDEXING_FAILED));
    } else if (screeningSuccess != null && !screeningSuccess.equals("")) { // indexing
        // successful
        aTable.addCell(new Paragraph(screeningSuccess, FONT_INDEXING_SUCCESS));
    } else {
        aTable.addCell(new Paragraph(" "));
    }
    document.add(aTable);
    document.add(new Paragraph(" ", VERY_SMALL_FONT));
}

From source file:ispyb.client.mx.collection.PdfRtfExporter.java

License:Open Source License

private void setImagesTable(Document document, DataCollectionInformation dcInfo) throws Exception {
    String imgCrystal = dcInfo.getPathjpgCrystal();
    String imgDiff1 = dcInfo.getPathDiffractionImg1();
    String imgDiff2 = dcInfo.getPathDiffractionImg2();
    int nbCol = 0;
    if (imgCrystal != null && !imgCrystal.equals("")) {
        nbCol++;// w  ww  .j  a  v  a 2  s.c o m
    }
    if (imgDiff1 != null && !imgDiff1.equals("")) {
        nbCol++;
    }
    if (imgDiff2 != null && !imgDiff2.equals("")) {
        nbCol++;
    }
    if (nbCol > 0) {
        Table tableImage = new Table(nbCol);
        tableImage.setCellsFitPage(true);
        tableImage.setWidth(100); // percentage
        tableImage.getDefaultCell().setBorderWidth(0);
        tableImage.setBorderWidth(0);
        tableImage.getDefaultCell().setHorizontalAlignment(Element.ALIGN_CENTER);
        // ------------------------------------- Insert crystal image
        // ----------------------------
        if (imgCrystal != null && !imgCrystal.equals("")) {
            try {
                Image jpgCrystal = Image.getInstance(imgCrystal);
                jpgCrystal.scaleAbsolute(CRYSTAL_IMAGE_WIDTH, CRYSTAL_IMAGE_HEIGHT);
                Cell cellCrystalImage = new Cell(jpgCrystal);
                cellCrystalImage.setLeading(0);
                cellCrystalImage.setBorderWidth(0);
                cellCrystalImage.setHorizontalAlignment(Element.ALIGN_CENTER);
                tableImage.addCell(cellCrystalImage);
            } catch (IOException e) {
                tableImage.addCell(new Paragraph(imgCrystal + " not found", FONT_DOC));
            }
        }
        // --- Image 1
        if (imgDiff1 != null && !imgDiff1.equals("")) {
            try {
                Image jpg1 = Image.getInstance(imgDiff1);
                jpg1.scaleAbsolute(DIFF_IMAGE_WIDTH, DIFF_IMAGE_HEIGHT);
                Cell cellDiffractionThumbnail1 = new Cell(jpg1);
                cellDiffractionThumbnail1.setLeading(0);
                cellDiffractionThumbnail1.setBorderWidth(0);
                cellDiffractionThumbnail1.setHorizontalAlignment(Element.ALIGN_CENTER);
                tableImage.addCell(cellDiffractionThumbnail1);
            } catch (IOException e) {
                tableImage.addCell(new Paragraph(imgDiff1 + " not found", FONT_DOC));
            }
        }
        // --- Image 2
        if (imgDiff2 != null && !imgDiff2.equals("")) {
            try {
                Image jpg2 = Image.getInstance(imgDiff2);
                jpg2.scaleAbsolute(DIFF_IMAGE_WIDTH, DIFF_IMAGE_HEIGHT);
                Cell cellDiffractionThumbnail2 = new Cell(jpg2);
                cellDiffractionThumbnail2.setLeading(0);
                cellDiffractionThumbnail2.setBorderWidth(0);
                cellDiffractionThumbnail2.setHorizontalAlignment(Element.ALIGN_CENTER);
                tableImage.addCell(cellDiffractionThumbnail2);
            } catch (IOException e) {
                tableImage.addCell(new Paragraph(imgDiff2 + " not found", FONT_DOC));
            }
        }
        //
        document.add(tableImage);
        document.add(new Paragraph(" ", VERY_SMALL_FONT));
    }
}

From source file:ispyb.client.mx.collection.PdfRtfExporter.java

License:Open Source License

/**
 * set the strategy table and wedge & subwedge strategy tables
 * // w w  w .j a  v a  2  s.c  o m
 * @param document
 * @param dcInfo
 * @throws Exception
 */
private void setStrategyTable(Document document, DataCollectionInformation dcInfo) throws Exception {
    // ------------------------------------------- Strategy Wedge
    // ------------------------------------------------
    List<StrategyWedgeInformation> strategyWedgeInformationList = dcInfo.getListStrategyWedgeInformation();
    for (Iterator<StrategyWedgeInformation> i = strategyWedgeInformationList.iterator(); i.hasNext();) {
        document.add(new Paragraph(" ", VERY_SMALL_FONT));
        StrategyWedgeInformation swi = i.next();
        Table strategyWedgeTable = new Table(10);
        int headerStrategyWedge[] = { 8, 10, 10, 10, 10, 10, 10, 10, 10, 20 }; // percentage
        strategyWedgeTable.setWidths(headerStrategyWedge);
        strategyWedgeTable.setWidth(100);
        strategyWedgeTable.setCellsFitPage(true);
        strategyWedgeTable.setTableFitsPage(true);
        strategyWedgeTable.setPadding(0);
        strategyWedgeTable.getDefaultCell().setBorderWidth(0);
        strategyWedgeTable.setBorderWidth(0);
        strategyWedgeTable.getDefaultCell().setBackgroundColor(WEDGE_COLOR);

        strategyWedgeTable.addCell(new Paragraph("Wedge number", FONT_DOC_BOLD));
        strategyWedgeTable.addCell(new Paragraph("Resolution\n(" + Constants.ANGSTROM + ")", FONT_DOC_BOLD));
        strategyWedgeTable.addCell(new Paragraph("Completeness", FONT_DOC_BOLD));
        strategyWedgeTable.addCell(new Paragraph("Multiplicity", FONT_DOC_BOLD));
        strategyWedgeTable.addCell(new Paragraph("Total dose", FONT_DOC_BOLD));
        strategyWedgeTable.addCell(new Paragraph("Number of Images", FONT_DOC_BOLD));
        strategyWedgeTable.addCell(new Paragraph("Phi\n(" + Constants.DEGREE + ")", FONT_DOC_BOLD));
        strategyWedgeTable.addCell(new Paragraph("Kappa\n(" + Constants.DEGREE + ")", FONT_DOC_BOLD));
        strategyWedgeTable.addCell(new Paragraph("Wavelength", FONT_DOC_BOLD));
        strategyWedgeTable.addCell(new Paragraph("Comments", FONT_DOC_BOLD));

        strategyWedgeTable.getDefaultCell().setBackgroundColor(WHITE_COLOR);
        // rows
        strategyWedgeTable.addCell(new Paragraph(swi.getWedgeNumber(), FONT_DOC));
        strategyWedgeTable.addCell(new Paragraph(swi.getResolution(), FONT_DOC));
        strategyWedgeTable.addCell(new Paragraph(swi.getCompleteness(), FONT_DOC));
        strategyWedgeTable.addCell(new Paragraph(swi.getMultiplicity(), FONT_DOC));
        strategyWedgeTable.addCell(new Paragraph(swi.getDoseTotal(), FONT_DOC));
        strategyWedgeTable.addCell(new Paragraph(swi.getNumberOfImages(), FONT_DOC));
        strategyWedgeTable.addCell(new Paragraph(swi.getPhi(), FONT_DOC));
        strategyWedgeTable.addCell(new Paragraph(swi.getKappa(), FONT_DOC));
        strategyWedgeTable.addCell(new Paragraph(swi.getWavelength(), FONT_DOC));
        strategyWedgeTable.addCell(new Paragraph(swi.getComments(), FONT_DOC));

        document.add(strategyWedgeTable);

        // --- strategy sub wedge
        if (swi.getListStrategySubWedgeInformation().size() > 0) {
            document.add(new Paragraph(" ", VERY_SMALL_FONT));

            Table strategySubWedgeTable = new Table(12);
            int headerStrategySubWedge[] = { 8, 15, 10, 10, 10, 10, 10, 10, 10, 8, 8, 20 }; // percentage
            strategySubWedgeTable.setWidths(headerStrategySubWedge);
            strategySubWedgeTable.setWidth(80);
            strategySubWedgeTable.setCellsFitPage(true);
            strategySubWedgeTable.setTableFitsPage(true);
            strategySubWedgeTable.setPadding(0);
            strategySubWedgeTable.getDefaultCell().setBorderWidth(0);
            strategySubWedgeTable.setBorderWidth(0);
            strategySubWedgeTable.getDefaultCell().setBackgroundColor(SUBWEDGE_COLOR);

            strategySubWedgeTable.addCell(new Paragraph("Sub Wedge number", FONT_DOC_BOLD));
            strategySubWedgeTable.addCell(new Paragraph("Rotation axis", FONT_DOC_BOLD));
            strategySubWedgeTable.addCell(new Paragraph("Axis start", FONT_DOC_BOLD));
            strategySubWedgeTable.addCell(new Paragraph("Axis end", FONT_DOC_BOLD));
            strategySubWedgeTable.addCell(new Paragraph("Exposure time", FONT_DOC_BOLD));
            strategySubWedgeTable.addCell(new Paragraph("Transmission", FONT_DOC_BOLD));
            strategySubWedgeTable.addCell(new Paragraph("Oscillation Range", FONT_DOC_BOLD));
            strategySubWedgeTable.addCell(new Paragraph("Completeness", FONT_DOC_BOLD));
            strategySubWedgeTable.addCell(new Paragraph("Multiplicity", FONT_DOC_BOLD));
            strategySubWedgeTable.addCell(new Paragraph("Total dose", FONT_DOC_BOLD));
            strategySubWedgeTable.addCell(new Paragraph("Number of images", FONT_DOC_BOLD));
            strategySubWedgeTable.addCell(new Paragraph("Comments", FONT_DOC_BOLD));

            strategySubWedgeTable.getDefaultCell().setBackgroundColor(WHITE_COLOR);
            // rows
            for (Iterator<StrategySubWedgeInformation> s = swi.getListStrategySubWedgeInformation()
                    .iterator(); s.hasNext();) {
                StrategySubWedgeInformation sswi = s.next();
                strategySubWedgeTable.addCell(new Paragraph(sswi.getSubWedgeNumber(), FONT_DOC));
                strategySubWedgeTable.addCell(new Paragraph(sswi.getRotationAxis(), FONT_DOC));
                strategySubWedgeTable.addCell(new Paragraph(sswi.getAxisStart(), FONT_DOC));
                strategySubWedgeTable.addCell(new Paragraph(sswi.getAxisEnd(), FONT_DOC));
                strategySubWedgeTable.addCell(new Paragraph(sswi.getExposureTime(), FONT_DOC));
                strategySubWedgeTable.addCell(new Paragraph(sswi.getTransmission(), FONT_DOC));
                strategySubWedgeTable.addCell(new Paragraph(sswi.getOscillationRange(), FONT_DOC));
                strategySubWedgeTable.addCell(new Paragraph(sswi.getCompleteness(), FONT_DOC));
                strategySubWedgeTable.addCell(new Paragraph(sswi.getMultiplicity(), FONT_DOC));
                strategySubWedgeTable.addCell(new Paragraph(sswi.getDoseTotal(), FONT_DOC));
                strategySubWedgeTable.addCell(new Paragraph(sswi.getNumberOfImages(), FONT_DOC));
                strategySubWedgeTable.addCell(new Paragraph(sswi.getComments(), FONT_DOC));
            }
            document.add(strategySubWedgeTable);
        }
    }
    document.add(new Paragraph(" ", VERY_SMALL_FONT));
}

From source file:ispyb.client.mx.collection.PdfRtfExporter.java

License:Open Source License

/**
 * set the strategy table and wedge & subwedge strategy tables copy from
 * setStrategyTable, waiting for feedback that we can remove the old reports
 * and the first method//  www . j a v  a  2  s . c  o m
 * 
 * @param document
 * @param dcInfo
 * @throws Exception
 */
private void setStrategyTable2(Document document, DataCollectionInformation dcInfo) throws Exception {
    // ------------------------------------------- Strategy Wedge
    // ------------------------------------------------
    List<StrategyWedgeInformation> strategyWedgeInformationList = dcInfo.getListStrategyWedgeInformation();
    for (Iterator<StrategyWedgeInformation> i = strategyWedgeInformationList.iterator(); i.hasNext();) {
        document.add(new Paragraph(" ", VERY_SMALL_FONT));
        StrategyWedgeInformation swi = i.next();
        Table strategyWedgeTable = new Table(10);
        int headerStrategyWedge[] = { 8, 10, 10, 10, 10, 10, 10, 10, 10, 20 }; // percentage
        strategyWedgeTable.setWidths(headerStrategyWedge);
        strategyWedgeTable.setWidth(100);
        strategyWedgeTable.setCellsFitPage(true);
        strategyWedgeTable.setTableFitsPage(true);
        strategyWedgeTable.setPadding(1);
        strategyWedgeTable.getDefaultCell().setBorderWidth(1);
        strategyWedgeTable.setBorderWidth(1);
        strategyWedgeTable.getDefaultCell().setBackgroundColor(LIGHT_GREY_COLOR);
        strategyWedgeTable.getDefaultCell().setHorizontalAlignment(Element.ALIGN_CENTER);

        strategyWedgeTable.addCell(new Paragraph("Wedge number", FONT_DOC_BOLD));
        strategyWedgeTable.addCell(new Paragraph("Resolution (" + Constants.ANGSTROM + ")", FONT_DOC_BOLD));
        strategyWedgeTable.addCell(new Paragraph("Completeness", FONT_DOC_BOLD));
        strategyWedgeTable.addCell(new Paragraph("Multiplicity", FONT_DOC_BOLD));
        strategyWedgeTable.addCell(new Paragraph("Total dose", FONT_DOC_BOLD));
        strategyWedgeTable.addCell(new Paragraph("Number of Images", FONT_DOC_BOLD));
        strategyWedgeTable.addCell(new Paragraph("Phi (" + Constants.DEGREE + ")", FONT_DOC_BOLD));
        strategyWedgeTable.addCell(new Paragraph("Kappa (" + Constants.DEGREE + ")", FONT_DOC_BOLD));
        strategyWedgeTable.addCell(new Paragraph("Wavelength", FONT_DOC_BOLD));
        strategyWedgeTable.addCell(new Paragraph("Comments", FONT_DOC_BOLD));

        strategyWedgeTable.getDefaultCell().setBackgroundColor(WHITE_COLOR);
        // rows
        strategyWedgeTable.addCell(new Paragraph(swi.getWedgeNumber(), FONT_DOC));
        strategyWedgeTable.addCell(new Paragraph(swi.getResolution(), FONT_DOC));
        strategyWedgeTable.addCell(new Paragraph(swi.getCompleteness(), FONT_DOC));
        strategyWedgeTable.addCell(new Paragraph(swi.getMultiplicity(), FONT_DOC));
        strategyWedgeTable.addCell(new Paragraph(swi.getDoseTotal(), FONT_DOC));
        strategyWedgeTable.addCell(new Paragraph(swi.getNumberOfImages(), FONT_DOC));
        strategyWedgeTable.addCell(new Paragraph(swi.getPhi(), FONT_DOC));
        strategyWedgeTable.addCell(new Paragraph(swi.getKappa(), FONT_DOC));
        strategyWedgeTable.addCell(new Paragraph(swi.getWavelength(), FONT_DOC));
        strategyWedgeTable.addCell(new Paragraph(swi.getComments(), FONT_DOC));

        document.add(strategyWedgeTable);

        // --- strategy sub wedge
        if (swi.getListStrategySubWedgeInformation().size() > 0) {
            document.add(new Paragraph(" ", VERY_SMALL_FONT));

            Table strategySubWedgeTable = new Table(12);
            int headerStrategySubWedge[] = { 8, 15, 10, 10, 10, 10, 10, 10, 10, 8, 8, 20 }; // percentage
            strategySubWedgeTable.setWidths(headerStrategySubWedge);
            strategySubWedgeTable.setWidth(97);
            strategySubWedgeTable.setCellsFitPage(true);
            strategySubWedgeTable.setTableFitsPage(true);
            strategySubWedgeTable.setPadding(1);
            strategySubWedgeTable.getDefaultCell().setBorderWidth(1);
            strategySubWedgeTable.setBorderWidth(1);
            strategySubWedgeTable.getDefaultCell().setBackgroundColor(LIGHT_GREY_COLOR);
            strategySubWedgeTable.getDefaultCell().setHorizontalAlignment(Element.ALIGN_CENTER);

            strategySubWedgeTable.addCell(new Paragraph("Sub Wedge number", FONT_DOC_BOLD));
            strategySubWedgeTable.addCell(new Paragraph("Rotation axis", FONT_DOC_BOLD));
            strategySubWedgeTable.addCell(new Paragraph("Axis start", FONT_DOC_BOLD));
            strategySubWedgeTable.addCell(new Paragraph("Axis end", FONT_DOC_BOLD));
            strategySubWedgeTable.addCell(new Paragraph("Exposure time", FONT_DOC_BOLD));
            strategySubWedgeTable.addCell(new Paragraph("Transmission", FONT_DOC_BOLD));
            strategySubWedgeTable.addCell(new Paragraph("Oscillation Range", FONT_DOC_BOLD));
            strategySubWedgeTable.addCell(new Paragraph("Completeness", FONT_DOC_BOLD));
            strategySubWedgeTable.addCell(new Paragraph("Multiplicity", FONT_DOC_BOLD));
            strategySubWedgeTable.addCell(new Paragraph("Total dose", FONT_DOC_BOLD));
            strategySubWedgeTable.addCell(new Paragraph("Number of images", FONT_DOC_BOLD));
            strategySubWedgeTable.addCell(new Paragraph("Comments", FONT_DOC_BOLD));

            strategySubWedgeTable.getDefaultCell().setBackgroundColor(WHITE_COLOR);
            // rows
            for (Iterator<StrategySubWedgeInformation> s = swi.getListStrategySubWedgeInformation()
                    .iterator(); s.hasNext();) {
                StrategySubWedgeInformation sswi = s.next();
                strategySubWedgeTable.addCell(new Paragraph(sswi.getSubWedgeNumber(), FONT_DOC));
                strategySubWedgeTable.addCell(new Paragraph(sswi.getRotationAxis(), FONT_DOC));
                strategySubWedgeTable.addCell(new Paragraph(sswi.getAxisStart(), FONT_DOC));
                strategySubWedgeTable.addCell(new Paragraph(sswi.getAxisEnd(), FONT_DOC));
                strategySubWedgeTable.addCell(new Paragraph(sswi.getExposureTime(), FONT_DOC));
                strategySubWedgeTable.addCell(new Paragraph(sswi.getTransmission(), FONT_DOC));
                strategySubWedgeTable.addCell(new Paragraph(sswi.getOscillationRange(), FONT_DOC));
                strategySubWedgeTable.addCell(new Paragraph(sswi.getCompleteness(), FONT_DOC));
                strategySubWedgeTable.addCell(new Paragraph(sswi.getMultiplicity(), FONT_DOC));
                strategySubWedgeTable.addCell(new Paragraph(sswi.getDoseTotal(), FONT_DOC));
                strategySubWedgeTable.addCell(new Paragraph(sswi.getNumberOfImages(), FONT_DOC));
                strategySubWedgeTable.addCell(new Paragraph(sswi.getComments(), FONT_DOC));
            }
            document.add(strategySubWedgeTable);
        }
    }
    document.add(new Paragraph(" ", VERY_SMALL_FONT));
}

From source file:ispyb.client.mx.collection.PdfRtfExporter.java

License:Open Source License

private void setRankingTable(Document document, DataCollectionInformation dcInfo) throws Exception {
    SampleRankingVO rankingVO = dcInfo.getSampleRankingVO();
    if (rankingVO == null) {
        return;/*from  www . j av  a 2s  .  c  o  m*/
    }
    DecimalFormat decimalFormat1 = (DecimalFormat) NumberFormat.getInstance(Locale.US);
    decimalFormat1.applyPattern("0");
    DecimalFormat decimalFormat2 = (DecimalFormat) NumberFormat.getInstance(Locale.US);
    decimalFormat2.applyPattern("0.00");
    Table aTable = new Table(6);
    // aTable.setWidth(100); // percentage
    aTable.setPadding(3);
    aTable.setCellsFitPage(true);
    aTable.getDefaultCell().setBorderWidth(1);
    aTable.setBorderWidth(1);
    aTable.getDefaultCell().setHorizontalAlignment(Element.ALIGN_CENTER);
    // header
    aTable.getDefaultCell().setGrayFill(GREY_FILL_HEADER);
    aTable.addCell(new Paragraph("Ranking Resolution\n(" + Constants.ANGSTROM + ")", FONT_DOC_BOLD));
    aTable.addCell(new Paragraph("Exposure Time\n(s)", FONT_DOC_BOLD));
    aTable.addCell(new Paragraph("Mosaicity\n(" + Constants.DEGREE + ")", FONT_DOC_BOLD));
    aTable.addCell(new Paragraph("Number of spots", FONT_DOC_BOLD));
    aTable.addCell(new Paragraph("Number of images", FONT_DOC_BOLD));
    aTable.addCell(new Paragraph("Total", FONT_DOC_BOLD));
    aTable.getDefaultCell().setBackgroundColor(WHITE_COLOR);
    // row
    String rankRes = "#" + decimalFormat1.format(rankingVO.getTheoreticalResolutionRank());
    if (rankingVO.getTheoreticalResolutionValue() != null
            && !Double.isNaN(rankingVO.getTheoreticalResolutionValue())) {
        rankRes += "   " + decimalFormat2.format(rankingVO.getTheoreticalResolutionValue());
    }
    String rankExp = "#" + decimalFormat1.format(rankingVO.getTotalExposureTimeRank());
    if (rankingVO.getTotalExposureTimeValue() != null && !Double.isNaN(rankingVO.getTotalExposureTimeValue())) {
        rankExp += "   " + decimalFormat2.format(rankingVO.getTotalExposureTimeValue());
    }
    String rankMos = "#" + decimalFormat1.format(rankingVO.getMosaicityRank());
    if (rankingVO.getMosaicityValue() != null && !Double.isNaN(rankingVO.getMosaicityValue())) {
        rankMos += "   " + decimalFormat2.format(rankingVO.getMosaicityValue());
    }
    String rankSpot = "#" + decimalFormat1.format(rankingVO.getNumberOfSpotsIndexedRank());
    if (rankingVO.getNumberOfSpotsIndexedValue() != null
            && !Double.isNaN(rankingVO.getNumberOfSpotsIndexedValue())) {
        rankSpot += "   " + decimalFormat1.format(rankingVO.getNumberOfSpotsIndexedValue());
    }
    String rankImages = "#" + decimalFormat1.format(rankingVO.getNumberOfImagesRank());
    if (rankingVO.getNumberOfImagesValue() != null && !Double.isNaN(rankingVO.getNumberOfImagesValue())) {
        rankImages += "   " + decimalFormat1.format(rankingVO.getNumberOfImagesValue());
    }
    String rankTotal = "#" + decimalFormat1.format(rankingVO.getTotalRank());
    if (rankingVO.getTotalScore() != null && !Double.isNaN(rankingVO.getTotalScore())) {
        rankTotal += "   " + decimalFormat1.format(rankingVO.getTotalScore()) + " %";
    }
    // ... rank res
    if (rankingVO.getTheoreticalResolutionRank() == 1) {
        aTable.getDefaultCell().setBackgroundColor(GREEN_COLOR_RANK);
    } else if (rankingVO.getTheoreticalResolutionValue() == null
            || Double.isNaN(rankingVO.getTheoreticalResolutionValue())) {
        aTable.getDefaultCell().setBackgroundColor(NULL_COLOR_RANK);
    } else {
        aTable.getDefaultCell().setBackgroundColor(WHITE_COLOR);
    }
    aTable.addCell(new Paragraph(rankRes, FONT_DOC));
    // ... exp. time
    if (rankingVO.getTotalExposureTimeRank() == 1) {
        aTable.getDefaultCell().setBackgroundColor(GREEN_COLOR_RANK);
    } else if (rankingVO.getTotalExposureTimeValue() == null
            || Double.isNaN(rankingVO.getTotalExposureTimeValue())) {
        aTable.getDefaultCell().setBackgroundColor(NULL_COLOR_RANK);
    } else {
        aTable.getDefaultCell().setBackgroundColor(WHITE_COLOR);
    }
    aTable.addCell(new Paragraph(rankExp, FONT_DOC));
    // ... mosaicity
    if (rankingVO.getMosaicityRank() == 1) {
        aTable.getDefaultCell().setBackgroundColor(GREEN_COLOR_RANK);
    } else if (rankingVO.getMosaicityValue() == null || Double.isNaN(rankingVO.getMosaicityValue())) {
        aTable.getDefaultCell().setBackgroundColor(NULL_COLOR_RANK);
    } else {
        aTable.getDefaultCell().setBackgroundColor(WHITE_COLOR);
    }
    aTable.addCell(new Paragraph(rankMos, FONT_DOC));
    // ... number of spots
    if (rankingVO.getNumberOfSpotsIndexedRank() == 1) {
        aTable.getDefaultCell().setBackgroundColor(GREEN_COLOR_RANK);
    } else if (rankingVO.getNumberOfSpotsIndexedValue() == null
            || Double.isNaN(rankingVO.getNumberOfSpotsIndexedValue())) {
        aTable.getDefaultCell().setBackgroundColor(NULL_COLOR_RANK);
    } else {
        aTable.getDefaultCell().setBackgroundColor(WHITE_COLOR);
    }
    aTable.addCell(new Paragraph(rankSpot, FONT_DOC));
    // ... number of images
    if (rankingVO.getNumberOfImagesRank() == 1) {
        aTable.getDefaultCell().setBackgroundColor(GREEN_COLOR_RANK);
    } else if (rankingVO.getNumberOfImagesValue() == null || Double.isNaN(rankingVO.getNumberOfImagesValue())) {
        aTable.getDefaultCell().setBackgroundColor(NULL_COLOR_RANK);
    } else {
        aTable.getDefaultCell().setBackgroundColor(WHITE_COLOR);
    }
    aTable.addCell(new Paragraph(rankImages, FONT_DOC));
    // ... total
    if (rankingVO.getTotalRank() == 1) {
        aTable.getDefaultCell().setBackgroundColor(GREEN_COLOR_RANK);
    } else if (rankingVO.getTotalScore() == null || Double.isNaN(rankingVO.getTotalScore())) {
        aTable.getDefaultCell().setBackgroundColor(NULL_COLOR_RANK);
    } else {
        aTable.getDefaultCell().setBackgroundColor(WHITE_COLOR);
    }
    aTable.addCell(new Paragraph(rankTotal, FONT_DOC));
    //
    document.add(aTable);
    document.add(new Paragraph(" ", VERY_SMALL_FONT));
}

From source file:ispyb.client.mx.collection.PdfRtfExporter.java

License:Open Source License

private void setAutoProcRankingTable(Document document, DataCollectionInformation dcInfo) throws Exception {
    AutoProcRankingVO rankingVO = dcInfo.getAutoProcRankingVO();
    if (rankingVO == null) {
        return;/*from   w w  w  .  j a v  a2  s. co  m*/
    }
    DecimalFormat decimalFormat1 = (DecimalFormat) NumberFormat.getInstance(Locale.US);
    decimalFormat1.applyPattern("0");
    DecimalFormat decimalFormat2 = (DecimalFormat) NumberFormat.getInstance(Locale.US);
    decimalFormat2.applyPattern("0.00");
    Table aTable = new Table(4);
    // aTable.setWidth(100); // percentage
    aTable.setPadding(3);
    aTable.setCellsFitPage(true);
    aTable.getDefaultCell().setBorderWidth(1);
    aTable.setBorderWidth(1);
    aTable.getDefaultCell().setHorizontalAlignment(Element.ALIGN_CENTER);
    // header
    aTable.getDefaultCell().setGrayFill(GREY_FILL_HEADER);
    aTable.addCell(new Paragraph("R-factor\n(" + Constants.ANGSTROM + ")", FONT_DOC_BOLD));
    aTable.addCell(new Paragraph("Highest resolution\n(" + Constants.ANGSTROM + ")", FONT_DOC_BOLD));
    aTable.addCell(new Paragraph("Completeness\n(%)", FONT_DOC_BOLD));
    aTable.addCell(new Paragraph("Total", FONT_DOC_BOLD));
    aTable.getDefaultCell().setBackgroundColor(WHITE_COLOR);
    // row
    String rankRfactor = "#" + decimalFormat1.format(rankingVO.getOverallRFactorRank());
    if (rankingVO.getOverallRFactorValue() != null && !Double.isNaN(rankingVO.getOverallRFactorValue())) {
        rankRfactor += "   " + decimalFormat2.format(rankingVO.getOverallRFactorValue());
    }
    String rankHighestRes = "#" + decimalFormat1.format(rankingVO.getHighestResolutionRank());
    if (rankingVO.getHighestResolutionValue() != null && !Double.isNaN(rankingVO.getHighestResolutionValue())) {
        rankHighestRes += "   " + decimalFormat2.format(rankingVO.getHighestResolutionValue());
    }
    String rankCom = "#" + decimalFormat1.format(rankingVO.getCompletenessRank());
    if (rankingVO.getCompletenessValue() != null && !Double.isNaN(rankingVO.getCompletenessValue())) {
        rankCom += "   " + decimalFormat2.format(rankingVO.getCompletenessValue());
    }
    String rankTotal = "#" + decimalFormat1.format(rankingVO.getTotalRank());
    if (rankingVO.getTotalScore() != null && !Double.isNaN(rankingVO.getTotalScore())) {
        rankTotal += "   " + decimalFormat1.format(rankingVO.getTotalScore()) + " %";
    }
    // ... R-factor
    if (rankingVO.getOverallRFactorRank() == 1) {
        aTable.getDefaultCell().setBackgroundColor(GREEN_COLOR_RANK);
    } else if (rankingVO.getOverallRFactorValue() == null || Double.isNaN(rankingVO.getOverallRFactorValue())) {
        aTable.getDefaultCell().setBackgroundColor(NULL_COLOR_RANK);
    } else {
        aTable.getDefaultCell().setBackgroundColor(WHITE_COLOR);
    }
    aTable.addCell(new Paragraph(rankRfactor, FONT_DOC));
    // ... highest resolution
    if (rankingVO.getHighestResolutionRank() == 1) {
        aTable.getDefaultCell().setBackgroundColor(GREEN_COLOR_RANK);
    } else if (rankingVO.getHighestResolutionValue() == null
            || Double.isNaN(rankingVO.getHighestResolutionValue())) {
        aTable.getDefaultCell().setBackgroundColor(NULL_COLOR_RANK);
    } else {
        aTable.getDefaultCell().setBackgroundColor(WHITE_COLOR);
    }
    aTable.addCell(new Paragraph(rankHighestRes, FONT_DOC));
    // ... completeness
    if (rankingVO.getCompletenessRank() == 1) {
        aTable.getDefaultCell().setBackgroundColor(GREEN_COLOR_RANK);
    } else if (rankingVO.getCompletenessValue() == null || Double.isNaN(rankingVO.getCompletenessValue())) {
        aTable.getDefaultCell().setBackgroundColor(NULL_COLOR_RANK);
    } else {
        aTable.getDefaultCell().setBackgroundColor(WHITE_COLOR);
    }
    aTable.addCell(new Paragraph(rankCom, FONT_DOC));
    // ... total
    if (rankingVO.getTotalRank() == 1) {
        aTable.getDefaultCell().setBackgroundColor(GREEN_COLOR_RANK);
    } else if (rankingVO.getTotalScore() == null || Double.isNaN(rankingVO.getTotalScore())) {
        aTable.getDefaultCell().setBackgroundColor(NULL_COLOR_RANK);
    } else {
        aTable.getDefaultCell().setBackgroundColor(WHITE_COLOR);
    }
    aTable.addCell(new Paragraph(rankTotal, FONT_DOC));
    //
    document.add(aTable);
    document.add(new Paragraph(" ", VERY_SMALL_FONT));
}

From source file:ispyb.client.mx.results.ExportAutoProcAction.java

License:Open Source License

private void setAutoProcInfo(Document document) throws Exception {
    // header/*  w  ww . j  a  v a2s.  co m*/
    Table headerTable = new Table(1);
    headerTable.getDefaultCell().setBorderWidth(0);
    headerTable.setBorderWidth(0);
    headerTable.setCellsFitPage(true);
    headerTable.setAlignment(Element.ALIGN_LEFT);
    headerTable.getDefaultCell().setHorizontalAlignment(Element.ALIGN_LEFT);
    headerTable.getDefaultCell().setBackgroundColor(PdfRtfExporter.LIGHT_YELLOW_COLOR);
    headerTable.getDefaultCell().setLeading(3);
    headerTable.setWidth(100); // percentage
    headerTable
            .addCell(new Paragraph("Crystal data and data-collection statistics", PdfRtfExporter.FONT_DOC_11));
    headerTable.addCell(new Paragraph("Values in parentheses are for the highest resolution shell.",
            PdfRtfExporter.FONT_DOC_11));
    document.add(headerTable);
    document.add(new Paragraph(" ", PdfRtfExporter.VERY_SMALL_FONT));
    // auto proc table
    Table autoProcTable = new Table(2);
    autoProcTable.getDefaultCell().setBorderWidth(0);
    autoProcTable.setBorderWidth(0);
    autoProcTable.setCellsFitPage(true);
    autoProcTable.setAlignment(Element.ALIGN_LEFT);
    autoProcTable.getDefaultCell().setHorizontalAlignment(Element.ALIGN_LEFT);
    // autoProcTable.getDefaultCell().setLeading(3);
    autoProcTable.setPadding(2);
    autoProcTable.setWidth(100); // percentage
    // data
    String spaceGroup = autoProc == null ? "" : autoProc.getSpaceGroup();
    String unitCell_a = autoProc == null ? "" : autoProc.getRefinedCellA().toString();
    String unitCell_b = autoProc == null ? "" : autoProc.getRefinedCellB().toString();
    String unitCell_c = autoProc == null ? "" : autoProc.getRefinedCellC().toString();
    String unitCell_alpha = autoProc == null ? "" : autoProc.getRefinedCellAlpha().toString();
    String unitCell_beta = autoProc == null ? "" : autoProc.getRefinedCellBeta().toString();
    String unitCell_gamma = autoProc == null ? "" : autoProc.getRefinedCellGamma().toString();
    String resolutionRange = "";
    String nTotalObservations = "";
    String nTotalUniqueReflections = "";
    String completeness = "";
    String multiplicity = "";
    String isigma = "";
    String rmerge = "";
    if (autoProcStatisticsOverall != null) {
        resolutionRange = autoProcStatisticsOverall.getResolutionLimitLow() + " - "
                + autoProcStatisticsOverall.getResolutionLimitHigh();
        nTotalObservations = "" + autoProcStatisticsOverall.getnTotalObservations();
        nTotalUniqueReflections = "" + (autoProcStatisticsOverall.getnTotalUniqueObservations() == null ? ""
                : autoProcStatisticsOverall.getnTotalUniqueObservations());
        completeness = "" + autoProcStatisticsOverall.getCompleteness();
        multiplicity = "" + autoProcStatisticsOverall.getMultiplicity();
        isigma = "" + autoProcStatisticsOverall.getMeanIoverSigI();
        rmerge = ""
                + (autoProcStatisticsOverall.getRmerge() == null ? "" : autoProcStatisticsOverall.getRmerge());
    }
    if (autoProcStatisticsOuter != null) {
        resolutionRange += " (" + autoProcStatisticsOuter.getResolutionLimitLow() + " - "
                + autoProcStatisticsOuter.getResolutionLimitHigh() + ")";
        nTotalObservations += " (" + autoProcStatisticsOuter.getnTotalObservations() + ")";
        nTotalUniqueReflections += autoProcStatisticsOuter.getnTotalUniqueObservations() == null ? ""
                : (" (" + autoProcStatisticsOuter.getnTotalUniqueObservations() + ")");
        completeness += " (" + autoProcStatisticsOuter.getCompleteness() + ")";
        multiplicity += " (" + autoProcStatisticsOuter.getMultiplicity() + ")";
        isigma += " (" + autoProcStatisticsOuter.getMeanIoverSigI() + ")";
        rmerge += " ("
                + (autoProcStatisticsOuter.getRmerge() == null ? "" : autoProcStatisticsOuter.getRmerge())
                + ")";
    }
    // space group
    autoProcTable.addCell(new Paragraph("Space Group", PdfRtfExporter.FONT_DOC_11));
    autoProcTable.addCell(new Paragraph(spaceGroup, PdfRtfExporter.FONT_DOC_11));
    // unit cell parameters
    autoProcTable.addCell(
            new Paragraph("Unit-cell parameters (" + Constants.ANGSTROM + ")", PdfRtfExporter.FONT_DOC_11));
    autoProcTable.addCell(new Paragraph("", PdfRtfExporter.FONT_DOC_11));
    Paragraph pa = new Paragraph("\t a", PdfRtfExporter.FONT_DOC_11);
    pa.setAlignment(Element.ALIGN_JUSTIFIED);
    pa.setIndentationLeft(PdfRtfExporter.INDENTATION_LEFT);
    autoProcTable.addCell(pa);
    autoProcTable.addCell(new Paragraph(unitCell_a, PdfRtfExporter.FONT_DOC_11));
    Paragraph pb = new Paragraph("\t b", PdfRtfExporter.FONT_DOC_11);
    pb.setAlignment(Element.ALIGN_JUSTIFIED);
    pb.setIndentationLeft(PdfRtfExporter.INDENTATION_LEFT);
    autoProcTable.addCell(pb);
    autoProcTable.addCell(new Paragraph(unitCell_b, PdfRtfExporter.FONT_DOC_11));
    Paragraph pc = new Paragraph("\t c", PdfRtfExporter.FONT_DOC_11);
    pc.setAlignment(Element.ALIGN_JUSTIFIED);
    pc.setIndentationLeft(PdfRtfExporter.INDENTATION_LEFT);
    autoProcTable.addCell(pc);
    autoProcTable.addCell(new Paragraph(unitCell_c, PdfRtfExporter.FONT_DOC_11));
    // Issue 1733: cell angles info added
    Paragraph palpha = new Paragraph("\t alpha", PdfRtfExporter.FONT_DOC_11);
    palpha.setAlignment(Element.ALIGN_JUSTIFIED);
    palpha.setIndentationLeft(PdfRtfExporter.INDENTATION_LEFT);
    autoProcTable.addCell(palpha);
    autoProcTable.addCell(new Paragraph(unitCell_alpha, PdfRtfExporter.FONT_DOC_11));
    Paragraph pbeta = new Paragraph("\t beta", PdfRtfExporter.FONT_DOC_11);
    pbeta.setAlignment(Element.ALIGN_JUSTIFIED);
    pbeta.setIndentationLeft(PdfRtfExporter.INDENTATION_LEFT);
    autoProcTable.addCell(pbeta);
    autoProcTable.addCell(new Paragraph(unitCell_beta, PdfRtfExporter.FONT_DOC_11));
    Paragraph pgamma = new Paragraph("\t gamma", PdfRtfExporter.FONT_DOC_11);
    pgamma.setAlignment(Element.ALIGN_JUSTIFIED);
    pgamma.setIndentationLeft(PdfRtfExporter.INDENTATION_LEFT);
    autoProcTable.addCell(pgamma);
    autoProcTable.addCell(new Paragraph(unitCell_gamma, PdfRtfExporter.FONT_DOC_11));
    // resolution range
    autoProcTable.addCell(
            new Paragraph("Resolution range (" + Constants.ANGSTROM + ")", PdfRtfExporter.FONT_DOC_11));
    autoProcTable.addCell(new Paragraph(resolutionRange, PdfRtfExporter.FONT_DOC_11));
    // Observed reflections
    autoProcTable.addCell(new Paragraph("Observed reflections", PdfRtfExporter.FONT_DOC_11));
    autoProcTable.addCell(new Paragraph(nTotalObservations, PdfRtfExporter.FONT_DOC_11));
    // No. of unique reflections
    autoProcTable.addCell(new Paragraph("No. of unique reflections", PdfRtfExporter.FONT_DOC_11));
    autoProcTable.addCell(new Paragraph(nTotalUniqueReflections, PdfRtfExporter.FONT_DOC_11));
    // Completeness
    autoProcTable.addCell(new Paragraph("Completeness (%)", PdfRtfExporter.FONT_DOC_11));
    autoProcTable.addCell(new Paragraph(completeness, PdfRtfExporter.FONT_DOC_11));
    // multiplicity
    autoProcTable.addCell(new Paragraph("Multiplicity", PdfRtfExporter.FONT_DOC_11));
    autoProcTable.addCell(new Paragraph(multiplicity, PdfRtfExporter.FONT_DOC_11));
    new Phrase();
    // I/(I)
    Phrase p = Phrase.getInstance("<I/" + (char) 963 + "(I)>");
    p.setFont(PdfRtfExporter.FONT_DOC_11);
    autoProcTable.addCell(p);
    autoProcTable.addCell(new Paragraph(isigma, PdfRtfExporter.FONT_DOC_11));
    // Rmerge
    Chunk c1 = new Chunk("R", PdfRtfExporter.FONT_DOC_11);
    Chunk c2 = new Chunk("merge", PdfRtfExporter.FONT_DOC_EXPONENT);
    c2.setTextRise(PdfRtfExporter.TEXT_RISE_SUB);
    Chunk c3 = new Chunk("(%)", PdfRtfExporter.FONT_DOC_11);
    Chunk c4 = new Chunk("#", PdfRtfExporter.FONT_DOC_EXPONENT_BLUE);
    c4.setTextRise(PdfRtfExporter.TEXT_RISE_EXP);
    Paragraph rMergeParagraph = new Paragraph();
    rMergeParagraph.add(c1);
    rMergeParagraph.add(c2);
    rMergeParagraph.add(c3);
    rMergeParagraph.add(c4);
    autoProcTable.addCell(rMergeParagraph);
    autoProcTable.addCell(new Paragraph(rmerge, PdfRtfExporter.FONT_DOC_11));
    document.add(autoProcTable);
    document.add(new Paragraph(" ", PdfRtfExporter.FONT_DOC_11));
    // nota bene info
    Paragraph nbParagraph = new Paragraph();
    nbParagraph.add(c4);
    nbParagraph.add(c1);
    nbParagraph.add(c2);
    Chunk cesp = new Chunk(" ", PdfRtfExporter.FONT_DOC_11);
    Chunk c5 = new Chunk(" = ", PdfRtfExporter.FONT_DOC_11);
    nbParagraph.add(c5);
    Phrase pSigma = Phrase.getInstance("" + (char) 931);
    pSigma.setFont(PdfRtfExporter.FONT_DOC_11);
    nbParagraph.add(pSigma);
    Chunk chkl = new Chunk("hkl", PdfRtfExporter.FONT_DOC_EXPONENT);
    chkl.setTextRise(PdfRtfExporter.TEXT_RISE_SUB);
    nbParagraph.add(chkl);
    nbParagraph.add(cesp);
    nbParagraph.add(pSigma);
    Chunk ci = new Chunk("i", PdfRtfExporter.FONT_DOC_EXPONENT);
    ci.setTextRise(PdfRtfExporter.TEXT_RISE_SUB);
    nbParagraph.add(ci);
    Chunk c8 = new Chunk(" |I", PdfRtfExporter.FONT_DOC_11);
    nbParagraph.add(c8);
    nbParagraph.add(ci);
    Chunk c9 = new Chunk("(hkl) - (I(hkl))| / ", PdfRtfExporter.FONT_DOC_11);
    nbParagraph.add(c9);
    nbParagraph.add(pSigma);
    nbParagraph.add(chkl);
    nbParagraph.add(cesp);
    nbParagraph.add(pSigma);
    nbParagraph.add(ci);
    nbParagraph.add(cesp);
    Chunk c10 = new Chunk("I", PdfRtfExporter.FONT_DOC_11);
    nbParagraph.add(c10);
    nbParagraph.add(ci);
    Chunk c11 = new Chunk("(hkl), where ", PdfRtfExporter.FONT_DOC_11);
    nbParagraph.add(c11);
    Chunk c12 = new Chunk("I", PdfRtfExporter.FONT_DOC_11_ITALIC);
    nbParagraph.add(c12);
    Chunk cii = new Chunk("i", PdfRtfExporter.FONT_DOC_EXPONENT_ITALIC);
    cii.setTextRise(PdfRtfExporter.TEXT_RISE_SUB);
    nbParagraph.add(cii);
    Chunk c13 = new Chunk("(hkl)", PdfRtfExporter.FONT_DOC_11_ITALIC);
    nbParagraph.add(c13);
    Chunk c14 = new Chunk(" is the ", PdfRtfExporter.FONT_DOC_11);
    nbParagraph.add(c14);
    Chunk c15 = new Chunk("i", PdfRtfExporter.FONT_DOC_11_ITALIC);
    nbParagraph.add(c15);
    Chunk c16 = new Chunk("th observation of reflection ", PdfRtfExporter.FONT_DOC_11);
    nbParagraph.add(c16);
    Chunk chklI = new Chunk("hkl", PdfRtfExporter.FONT_DOC_11_ITALIC);
    nbParagraph.add(chklI);
    Chunk c17 = new Chunk(" and ", PdfRtfExporter.FONT_DOC_11);
    nbParagraph.add(c17);
    Chunk c18 = new Chunk("<I(hkl)> ", PdfRtfExporter.FONT_DOC_11_ITALIC);
    nbParagraph.add(c18);
    Chunk c19 = new Chunk(" is the weighted average intensity for all observations of reflection ",
            PdfRtfExporter.FONT_DOC_11);
    nbParagraph.add(c19);
    nbParagraph.add(chklI);
    Chunk c20 = new Chunk(".", PdfRtfExporter.FONT_DOC_11);
    nbParagraph.add(c20);
    document.add(nbParagraph);
    document.add(new Paragraph(" ", PdfRtfExporter.FONT_DOC_11));
}

From source file:jmemorize.core.io.PdfRtfBuilder.java

License:Open Source License

/**
 * Adds given card to document//from w  w w .  ja v a2 s  .co m
 * 
 * @param doc document to add to
 * @param card given card
 */
private static void writeCard(Document doc, Card card) throws DocumentException {
    Table table = new Table(2);

    table.setPadding(3f);
    table.setBorderWidth(1.0f);
    table.setTableFitsPage(true);
    table.complete();

    Phrase front = new Phrase(card.getFrontSide().getText().getUnformatted(), frontFont);
    table.addCell(front);
    Phrase back = new Phrase(card.getBackSide().getText().getUnformatted(), backFont);
    table.addCell(back);

    doc.add(table);
}