Example usage for org.apache.poi.xwpf.usermodel UnderlinePatterns SINGLE

List of usage examples for org.apache.poi.xwpf.usermodel UnderlinePatterns SINGLE

Introduction

In this page you can find the example usage for org.apache.poi.xwpf.usermodel UnderlinePatterns SINGLE.

Prototype

UnderlinePatterns SINGLE

To view the source code for org.apache.poi.xwpf.usermodel UnderlinePatterns SINGLE.

Click Source Link

Document

Specifies an underline consisting of a single line beneath all characters in this run.

Usage

From source file:com.crimelab.service.PolygraphServiceImpl.java

@Override
public XWPFDocument create(Polygraph polygraph, HttpSession session) {
    XWPFDocument document = null;/*  ww  w  .  j a va  2 s  .co  m*/

    //Insert into dbase
    //        polygraphDAO.polygraphInfo(polygraph);
    try {
        //Blank Document
        InputStream inpDocx = session.getServletContext()
                .getResourceAsStream("/WEB-INF/templates/Polygraph.docx");
        document = new XWPFDocument(inpDocx);

        //create Paragraph
        XWPFParagraph subjectNo = document.createParagraph();
        XWPFRun r1 = subjectNo.createRun();
        r1.setText("POLYGRAPH SUBJECT NO: " + polygraph.getSubjectNo());
        subjectNo.setAlignment(ParagraphAlignment.CENTER);
        r1.setBold(true);
        ;

        //create table
        XWPFTable table = document.createTable();
        //width 
        CTTbl tableFix = table.getCTTbl();
        CTTblPr pr = tableFix.getTblPr();
        CTTblWidth tblW = pr.getTblW();
        tblW.setW(BigInteger.valueOf(4800));
        tblW.setType(STTblWidth.PCT);
        pr.setTblW(tblW);
        tableFix.setTblPr(pr);

        //create first row
        XWPFTableRow tableRowOne = table.getRow(0);
        XWPFTableCell headerCell = tableRowOne.getCell(0);
        XWPFParagraph headerParagraph = headerCell.getParagraphs().get(0);
        XWPFRun hRun = headerParagraph.createRun();
        headerCell.setColor("CDCDB4");
        hRun.setText("PERSONAL INFORMATION");
        tableRowOne.addNewTableCell().setText(null);

        headerParagraph.setAlignment(ParagraphAlignment.CENTER);
        XWPFTableCell photoHeaderCell = tableRowOne.getCell(1);
        XWPFParagraph photoHeaderParagraph = photoHeaderCell.getParagraphs().get(0);
        XWPFRun pRun = photoHeaderParagraph.createRun();
        photoHeaderCell.setColor("CDCDB4");
        pRun.setText("PHOTO");
        photoHeaderParagraph.setAlignment(ParagraphAlignment.CENTER);

        XWPFTableRow tableRowTwo = table.createRow();
        XWPFTableCell cell = tableRowTwo.getCell(0);
        XWPFParagraph personalInfo = cell.getParagraphs().get(0);
        XWPFRun r2 = personalInfo.createRun();
        r2.setText("Name");
        r2.addTab();
        r2.addTab();
        r2.setText(": " + polygraph.getName());
        r2.addBreak();
        r2.setText("Gender");
        r2.addTab();
        r2.addTab();
        r2.setText(": " + polygraph.getGender());
        r2.addBreak();
        r2.setText("Age");
        r2.addTab();
        r2.addTab();
        r2.setText(": " + polygraph.getAge());
        r2.addBreak();
        r2.setText("Date of Birth");
        r2.addTab();
        r2.setText(": " + polygraph.getBirthdate());
        r2.addBreak();
        r2.setText("Civil Status");
        r2.addTab();
        r2.setText(": " + polygraph.getCivilStatus());
        r2.addBreak();
        r2.setText("ID Presented");
        r2.addTab();
        r2.setText(": " + polygraph.getIdPresented());
        r2.addBreak();
        r2.setText("Address");
        r2.addTab();
        r2.setText(": " + polygraph.getAddress());

        //Adding the picture
        XWPFTableCell pictureCell = tableRowTwo.getCell(1);
        XWPFParagraph pictureHolder = pictureCell.getParagraphs().get(0);
        XWPFRun pictureRun = pictureHolder.createRun();
        FileInputStream getPhoto = new FileInputStream(polygraph.getPhotoLocation());
        FileInputStream getImage = new FileInputStream(polygraph.getPhotoLocation());
        ImageInputStream imageInput = ImageIO.createImageInputStream(getPhoto);
        BufferedImage bi = ImageIO.read(imageInput);
        pictureHolder.setAlignment(ParagraphAlignment.RIGHT);
        pictureRun.addPicture(getImage, XWPFDocument.PICTURE_TYPE_JPEG, null, Units.toEMU(120),
                Units.toEMU(120));

        XWPFParagraph spacing = document.createParagraph();
        XWPFRun spacingRun = spacing.createRun();

        //create table
        XWPFTable otherTable = document.createTable();
        //width 
        CTTbl tableFixTwo = otherTable.getCTTbl();
        CTTblPr prTwo = tableFixTwo.getTblPr();
        CTTblWidth tblWTwo = prTwo.getTblW();
        tblWTwo.setW(BigInteger.valueOf(4800));
        tblWTwo.setType(STTblWidth.PCT);
        prTwo.setTblW(tblWTwo);
        tableFixTwo.setTblPr(prTwo);

        XWPFTableRow examInfoHeader = otherTable.createRow();
        XWPFTableCell cellInfo = examInfoHeader.getCell(0);
        XWPFParagraph examInfo = cellInfo.getParagraphs().get(0);
        XWPFRun r3 = examInfo.createRun();
        cellInfo.setColor("CDCDB4");
        r3.setText("EXAM INFORMATION");
        examInfo.setAlignment(ParagraphAlignment.CENTER);

        XWPFTableRow examInfoRow = otherTable.createRow();
        XWPFTableCell cellRowInfo = examInfoRow.getCell(0);
        XWPFParagraph examInfoRowP = cellRowInfo.getParagraphs().get(0);
        XWPFRun examRun = examInfoRowP.createRun();
        examRun.setText("Case Number");
        examRun.addTab();
        examRun.addTab();
        examRun.setText(": " + polygraph.getCaseNo());
        examRun.addBreak();
        examRun.setText("Requesting Party");
        examRun.addTab();
        examRun.setText(": " + polygraph.getRequestingParty());
        examRun.addBreak();
        examRun.setText("Time/Date Received");
        examRun.addTab();
        examRun.setText(": " + polygraph.getTimeDateReceived());
        examRun.addBreak();
        examRun.setText("Nature of Case");
        examRun.addTab();
        examRun.addTab();
        examRun.setText(": " + polygraph.getNatureOfCase());
        examRun.addBreak();
        examRun.setText("Exam Location");
        examRun.addTab();
        examRun.addTab();
        examRun.setText(": " + polygraph.getExamLocation());
        examRun.addBreak();
        examRun.setText("Exam Date");
        examRun.addTab();
        examRun.addTab();
        examRun.setText(": " + polygraph.getExamDate());

        otherTable.removeRow(0);

        XWPFParagraph purposeOfExamination = document.createParagraph();
        XWPFRun r4 = purposeOfExamination.createRun();
        r4.setUnderline(UnderlinePatterns.SINGLE);
        r4.addBreak();
        r4.setText("SECTION 1: PURPOSE OF EXAMINATION");
        r4.addTab();
        r4.addTab();
        r4.addTab();
        r4.addTab();
        r4.addTab();
        r4.addTab();
        r4.addTab();
        r4.addTab();
        r4.addTab();

        XWPFParagraph purposeOfExaminationContents = document.createParagraph();
        XWPFRun r4Contents = purposeOfExaminationContents.createRun();
        r4Contents.setText(polygraph.getPurpose());

        XWPFParagraph preTestInterview = document.createParagraph();
        XWPFRun r5 = preTestInterview.createRun();
        r5.setUnderline(UnderlinePatterns.SINGLE);
        r5.setText("SECTION 2: PRE-TEST INTERVIEW");
        r5.addTab();
        r5.addTab();
        r5.addTab();
        r5.addTab();
        r5.addTab();
        r5.addTab();
        r5.addTab();
        r5.addTab();
        r5.addTab();

        XWPFParagraph preTestInterviewContents = document.createParagraph();
        XWPFRun r5Contents = preTestInterviewContents.createRun();
        r5Contents.setText(polygraph.getPreTest());

        XWPFParagraph inTestPhase = document.createParagraph();
        XWPFRun r6 = inTestPhase.createRun();
        r6.setUnderline(UnderlinePatterns.SINGLE);
        r6.setText("SECTION 3: IN-TEST PHASE");
        r6.addTab();
        r6.addTab();
        r6.addTab();
        r6.addTab();
        r6.addTab();
        r6.addTab();
        r6.addTab();
        r6.addTab();
        r6.addTab();
        r6.addTab();

        XWPFParagraph inTestPhaseContents = document.createParagraph();
        XWPFRun r6Contents = inTestPhaseContents.createRun();
        r6Contents.setText(polygraph.getInTest());

        XWPFParagraph result = document.createParagraph();
        XWPFRun r7 = result.createRun();
        r7.setUnderline(UnderlinePatterns.SINGLE);
        r7.setText("SECTION 4: RESULT");
        r7.addTab();
        r7.addTab();
        r7.addTab();
        r7.addTab();
        r7.addTab();
        r7.addTab();
        r7.addTab();
        r7.addTab();
        r7.addTab();
        r7.addTab();
        r7.addTab();

        XWPFParagraph resultContents = document.createParagraph();
        XWPFRun r7Contents = resultContents.createRun();
        r7Contents.setText(polygraph.getResult());

        XWPFParagraph postTestInterview = document.createParagraph();
        XWPFRun r8 = postTestInterview.createRun();
        r8.setUnderline(UnderlinePatterns.SINGLE);
        r8.setText("SECTION 5: POST-TEST INTERVIEW");
        r8.addTab();
        r8.addTab();
        r8.addTab();
        r8.addTab();
        r8.addTab();
        r8.addTab();
        r8.addTab();
        r8.addTab();
        r8.addTab();

        XWPFParagraph postTestInterviewContents = document.createParagraph();
        XWPFRun r8Contents = postTestInterviewContents.createRun();
        r8Contents.setText(polygraph.getPostTest());

        XWPFParagraph remarks = document.createParagraph();
        XWPFRun r9 = remarks.createRun();
        r9.setUnderline(UnderlinePatterns.SINGLE);
        r9.setText("REMARKS:");
        r9.addTab();
        r9.addTab();
        r9.addTab();
        r9.addTab();
        r9.addTab();
        r9.addTab();
        r9.addTab();
        r9.addTab();
        r9.addTab();
        r9.addTab();
        r9.addTab();
        r9.addTab();

        XWPFParagraph remarksContents = document.createParagraph();
        XWPFRun r9Contents = remarksContents.createRun();
        r9Contents.setText(polygraph.getRemarks());

        XWPFParagraph timeDateCompleted = document.createParagraph();
        XWPFRun r10 = timeDateCompleted.createRun();
        r10.setUnderline(UnderlinePatterns.SINGLE);
        r10.setText("TIME AND DATE COMPLETED:");
        r10.addTab();
        r10.addTab();
        r10.addTab();
        r10.addTab();
        r10.addTab();
        r10.addTab();
        r10.addTab();
        r10.addTab();
        r10.addTab();
        r10.addTab();

        XWPFParagraph timeDateCompletedContents = document.createParagraph();
        XWPFRun r10Contents = timeDateCompletedContents.createRun();
        r10Contents.setText(polygraph.getTimeDateCompleted());

        XWPFParagraph examinedBy = document.createParagraph();
        XWPFRun r11 = examinedBy.createRun();
        r11.setUnderline(UnderlinePatterns.SINGLE);
        r11.setText("EXAMINED BY:");
        r11.addTab();
        r11.addTab();
        r11.addTab();
        r11.addTab();
        r11.addTab();
        r11.addTab();
        r11.addTab();
        r11.addTab();
        r11.addTab();
        r11.addTab();
        r11.addTab();
        r11.addTab();

        XWPFParagraph examinedByContents = document.createParagraph();
        XWPFRun r11Contents = examinedByContents.createRun();
        r11Contents.setText(polygraph.getExaminerName());
        r11Contents.addBreak();
        r11Contents.setText(polygraph.getExaminerRank());
        r11Contents.addBreak();
        r11Contents.setText(polygraph.getExaminerPosition());

        XWPFParagraph approvedBy = document.createParagraph();
        XWPFRun r12 = approvedBy.createRun();
        r12.setUnderline(UnderlinePatterns.SINGLE);
        r12.setText("APPROVED BY:");
        r12.addTab();
        r12.addTab();
        r12.addTab();
        r12.addTab();
        r12.addTab();
        r12.addTab();
        r12.addTab();
        r12.addTab();
        r12.addTab();
        r12.addTab();
        r12.addTab();
        r12.addTab();

        XWPFParagraph approvedByContents = document.createParagraph();
        XWPFRun r12Contents = approvedByContents.createRun();
        //            r12Contents.setText(polygraph.getApprovedName());
        //            r12Contents.addBreak();
        //            r12Contents.setText(polygraph.getApprovedRank());
        //            r12Contents.addBreak();
        //            r12Contents.setText(polygraph.getApprovedPosition());
        //            r12Contents.addBreak();

        XWPFParagraph notedBy = document.createParagraph();
        XWPFRun r13 = notedBy.createRun();
        r13.setUnderline(UnderlinePatterns.SINGLE);
        r13.setText("NOTED BY:");
        r13.addTab();
        r13.addTab();
        r13.addTab();
        r13.addTab();
        r13.addTab();
        r13.addTab();
        r13.addTab();
        r13.addTab();
        r13.addTab();
        r13.addTab();
        r13.addTab();
        r13.addTab();

        XWPFParagraph notedByContents = document.createParagraph();
        XWPFRun r13Contents = notedByContents.createRun();
        r13Contents.setText(polygraph.getNotedName());
        r13Contents.addBreak();
        r13Contents.setText(polygraph.getNotedRank());
        r13Contents.addBreak();
        r13Contents.setText(polygraph.getNotedPosition());
        r13Contents.addBreak();
        table.setInsideVBorder(XWPFTable.XWPFBorderType.NIL, 0, 0, "white");

        document.getXWPFDocument();
    } catch (Exception e) {
        e.printStackTrace();
    }
    return document;
}

From source file:org.apache.tika.parser.microsoft.ooxml.RunProperties.java

License:Apache License

public void setUnderline(String underlineString) {
    if (underlineString == null || underlineString.equals("")) {
        underline = UnderlinePatterns.SINGLE;
    } else if (UnderlinePatterns.NONE.name().equals(underlineString)) {
        underline = UnderlinePatterns.NONE;
    } else {//w w w. j av  a2 s. co m
        //TODO -- fill out rest
        underline = UnderlinePatterns.SINGLE;
    }
}

From source file:org.articleEditor.insertContent.DocumentUpdater1.java

License:Apache License

public void applyAttributes(XWPFRun run, AttributeSet attributes) {
    Enumeration attributeNames = attributes.getAttributeNames();
    while (attributeNames.hasMoreElements()) {
        Object attributeName = attributeNames.nextElement();
        Object attributeValue = attributes.getAttribute(attributeName);
        if (attributeName == Bold) {
            run.setBold((Boolean) attributeValue);
        } else if (attributeName == Italic) {
            run.setItalic((Boolean) attributeValue);
        } else if (attributeName == Underline) {
            run.setUnderline((Boolean) attributeValue ? UnderlinePatterns.SINGLE : UnderlinePatterns.NONE);
        } else if (attributeName == FontFamily || attributeName == Family) {
            run.setFontFamily((String) attributeValue);
        } else if (attributeName == FontSize) {
            run.setFontSize(((Number) attributeValue).intValue());
        } else if (attributeName == Foreground) {
            Color color = (Color) attributeValue;
            String rgb = Integer.toHexString((color.getRGB() & 0xffffff) | 0x1000000).substring(1);
            run.setColor(rgb);/*from  w w  w  . ja  v  a2  s. c  o m*/
        } else if (attributeName == Background) {
            Color color = (Color) attributeValue;
            String rgb = Integer.toHexString((color.getRGB() & 0xffffff) | 0x1000000).substring(1);
            //run.getCTR().getRPr().setHighlight();
        } else if (attributeName == Subscript) {
            run.setSubscript((Boolean) attributeValue ? VerticalAlign.SUBSCRIPT : VerticalAlign.BASELINE);
        } else if (attributeName == Superscript) {
            run.setSubscript((Boolean) attributeValue ? VerticalAlign.SUPERSCRIPT : VerticalAlign.BASELINE);
        } else if (attributeName == StrikeThrough) {
            run.setStrike((Boolean) attributeValue);
        } else if (attributeName == Alignment) {
            ParagraphAlignment alignment = documentToPOI((Integer) attributeValue);
            run.getParagraph().setAlignment(alignment);
        }
    }
}

From source file:org.obeonetwork.m2doc.generator.M2DocEvaluator.java

License:Open Source License

/**
 * Apply the given style to the given run. Background color is not taken into account here since it does not apply to runs.
 * /*  w  w w  .  j a  va2  s. c om*/
 * @param run
 *            The run to style
 * @param style
 *            The style to apply, can be <code>null</code>
 */
private void applyMStyle(XWPFRun run, MStyle style) {
    if (style.getFontSize() != -1) {
        run.setFontSize(style.getFontSize());
    }
    if (style.getFontModifiers() != -1) {
        run.setBold((style.getFontModifiers() & MStyle.FONT_BOLD) != 0);
        run.setItalic((style.getFontModifiers() & MStyle.FONT_ITALIC) != 0);
        if ((style.getFontModifiers() & MStyle.FONT_UNDERLINE) != 0) {
            run.setUnderline(UnderlinePatterns.SINGLE);
        }
        run.setStrikeThrough((style.getFontModifiers() & MStyle.FONT_STRIKE_THROUGH) != 0);
    }
    if (style.getForegroundColor() != null) {
        run.setColor(hexColor(style.getForegroundColor()));
    }
}

From source file:org.obeonetwork.m2doc.generator.TableClientProcessor.java

License:Open Source License

/**
 * Apply the given style to the given run. Background color is not taken into account here since it does not apply to runs.
 * //from  w w  w. jav  a2  s .  c o m
 * @param run
 *            The run to style
 * @param style
 *            The style to apply, can be <code>null</code>
 */
private void applyTableClientStyle(XWPFRun run, MStyle style) {
    run.setFontSize(style.getFontSize());
    run.setBold((style.getFontModifiers() & MStyle.FONT_BOLD) != 0);
    run.setItalic((style.getFontModifiers() & MStyle.FONT_ITALIC) != 0);
    if ((style.getFontModifiers() & MStyle.FONT_UNDERLINE) != 0) {
        run.setUnderline(UnderlinePatterns.SINGLE);
    }
    run.setStrikeThrough((style.getFontModifiers() & MStyle.FONT_STRIKE_THROUGH) != 0);
    run.setColor(hexColor(style.getForegroundColor()));
}

From source file:org.obeonetwork.m2doc.generator.test.TableClientProcessorWithStyleTest.java

License:Open Source License

@Test
@Override//from  ww  w  .  ja  v a  2 s  .c o m
public void testWithoutAnyParameter() throws ProviderException {
    super.testWithoutAnyParameter();

    // Check styles
    List<XWPFTable> tables = doc.getTables();
    XWPFTable table = tables.get(0);

    // First Row (header)
    XWPFTableRow row = table.getRow(0);

    // Header => no style
    XWPFTableCell cell = row.getCell(1);
    XWPFParagraph cellParagraph = cell.getParagraphs().get(0);
    XWPFRun cellRun = cellParagraph.getRuns().get(0);
    assertNull(cell.getColor());
    assertNull(cellRun.getColor());
    assertFalse(cellRun.isBold());
    assertFalse(cellRun.isItalic());
    assertFalse(cellRun.isStrikeThrough());
    assertEquals(UnderlinePatterns.NONE, cellRun.getUnderline());

    // Header => no style
    cell = row.getCell(2);
    cellParagraph = cell.getParagraphs().get(0);
    cellRun = cellParagraph.getRuns().get(0);
    assertNull(cell.getColor());
    assertNull(cellRun.getColor());
    assertFalse(cellRun.isBold());
    assertFalse(cellRun.isItalic());
    assertFalse(cellRun.isStrikeThrough());
    assertEquals(UnderlinePatterns.NONE, cellRun.getUnderline());

    // First row
    row = table.getRow(1);

    // first row, row header => no style
    cell = row.getCell(0);
    cellParagraph = cell.getParagraphs().get(0);
    cellRun = cellParagraph.getRuns().get(0);
    assertNull(cell.getColor());
    assertNull(cellRun.getColor());
    assertFalse(cellRun.isBold());
    assertFalse(cellRun.isItalic());
    assertFalse(cellRun.isStrikeThrough());
    assertEquals(UnderlinePatterns.NONE, cellRun.getUnderline());

    // first row, first cell => cell style
    cell = row.getCell(1);
    cellParagraph = cell.getParagraphs().get(0);
    cellRun = cellParagraph.getRuns().get(0);
    assertEquals(CELL_BG_COLOR, cell.getColor().toUpperCase());
    assertEquals(CELL_FG_COLOR, cellRun.getColor().toUpperCase());
    assertEquals(CELL_FONT_SIZE, cellRun.getFontSize());
    assertTrue(cellRun.isBold());
    assertFalse(cellRun.isItalic());
    assertFalse(cellRun.isStrikeThrough());
    assertEquals(UnderlinePatterns.SINGLE, cellRun.getUnderline());

    // first row, second cell => row style
    cell = row.getCell(2);
    cellParagraph = cell.getParagraphs().get(0);
    assertEquals(ROW_BG_COLOR, cell.getColor().toUpperCase());
    assertTrue(cellParagraph.getRuns().isEmpty());

    // Second row
    row = table.getRow(2);

    // second row, row header => no style
    cell = row.getCell(0);
    cellParagraph = cell.getParagraphs().get(0);
    cellRun = cellParagraph.getRuns().get(0);
    assertNull(cell.getColor());
    assertNull(cellRun.getColor());
    assertFalse(cellRun.isBold());
    assertFalse(cellRun.isItalic());
    assertFalse(cellRun.isStrikeThrough());
    assertEquals(UnderlinePatterns.NONE, cellRun.getUnderline());

    // second row, first cell => column style
    cell = row.getCell(1);
    cellParagraph = cell.getParagraphs().get(0);
    assertEquals(COL_BG_COLOR, cell.getColor().toUpperCase());
    assertTrue(cellParagraph.getRuns().isEmpty());

    // second row, second cell => cell style
    cell = row.getCell(2);
    cellParagraph = cell.getParagraphs().get(0);
    cellRun = cellParagraph.getRuns().get(0);
    assertEquals(CELL_BG_COLOR, cell.getColor().toUpperCase());
    assertEquals(CELL_FG_COLOR, cellRun.getColor().toUpperCase());
    assertEquals(CELL_FONT_SIZE, cellRun.getFontSize());
    assertTrue(cellRun.isBold());
    assertFalse(cellRun.isItalic());
    assertFalse(cellRun.isStrikeThrough());
    assertEquals(UnderlinePatterns.SINGLE, cellRun.getUnderline());
}

From source file:org.obeonetwork.m2doc.tests.generator.TableClientProcessorWithStyleTests.java

License:Open Source License

@Test
@Override/*from w w w .  jav a  2 s .c om*/
public void testWithoutAnyParameter() throws ProviderException {
    super.testWithoutAnyParameter();

    // Check styles
    List<XWPFTable> tables = doc.getTables();
    XWPFTable table = tables.get(0);

    // First Row (header)
    XWPFTableRow row = table.getRow(0);

    // Header => col 1 has "column style"
    XWPFTableCell cell = row.getCell(1);
    XWPFParagraph cellParagraph = cell.getParagraphs().get(0);
    XWPFRun cellRun = cellParagraph.getRuns().get(0);
    assertEquals(COL_BG_COLOR, cell.getColor().toUpperCase());
    assertEquals(COL_FG_COLOR, cellRun.getColor().toUpperCase());
    assertEquals(COL_FONT_SIZE, cellRun.getFontSize());
    assertTrue(cellRun.isBold());
    assertFalse(cellRun.isItalic());
    assertFalse(cellRun.isStrikeThrough());
    assertEquals(UnderlinePatterns.NONE, cellRun.getUnderline());

    // Header => no style
    cell = row.getCell(2);
    cellParagraph = cell.getParagraphs().get(0);
    cellRun = cellParagraph.getRuns().get(0);
    assertNull(cell.getColor());
    assertNull(cellRun.getColor());
    assertFalse(cellRun.isBold());
    assertFalse(cellRun.isItalic());
    assertFalse(cellRun.isStrikeThrough());
    assertEquals(UnderlinePatterns.NONE, cellRun.getUnderline());

    // First row
    row = table.getRow(1);

    // first row, row header => no style
    cell = row.getCell(0);
    cellParagraph = cell.getParagraphs().get(0);
    cellRun = cellParagraph.getRuns().get(0);
    assertNull(cell.getColor());
    assertNull(cellRun.getColor());
    assertFalse(cellRun.isBold());
    assertFalse(cellRun.isItalic());
    assertFalse(cellRun.isStrikeThrough());
    assertEquals(UnderlinePatterns.NONE, cellRun.getUnderline());

    // first row, first cell => cell style
    cell = row.getCell(1);
    cellParagraph = cell.getParagraphs().get(0);
    cellRun = cellParagraph.getRuns().get(0);
    assertEquals(ROW_BG_COLOR, cell.getColor().toUpperCase());
    assertEquals(ROW_FG_COLOR, cellRun.getColor().toUpperCase());
    assertEquals(ROW_FONT_SIZE, cellRun.getFontSize());
    assertFalse(cellRun.isBold());
    assertTrue(cellRun.isItalic());
    assertFalse(cellRun.isStrikeThrough());
    assertEquals(UnderlinePatterns.NONE, cellRun.getUnderline());

    // first row, second cell => no style
    cell = row.getCell(2);
    cellParagraph = cell.getParagraphs().get(0);
    assertNull(cell.getColor());
    cellRun = cellParagraph.getRuns().get(0);
    assertFalse(cellRun.isBold());
    assertFalse(cellRun.isItalic());
    assertFalse(cellRun.isStrikeThrough());
    assertEquals(UnderlinePatterns.NONE, cellRun.getUnderline());

    // Second row
    row = table.getRow(2);

    // second row, row header => no style
    cell = row.getCell(0);
    cellParagraph = cell.getParagraphs().get(0);
    cellRun = cellParagraph.getRuns().get(0);
    assertNull(cell.getColor());
    assertNull(cellRun.getColor());
    assertFalse(cellRun.isBold());
    assertFalse(cellRun.isItalic());
    assertFalse(cellRun.isStrikeThrough());
    assertEquals(UnderlinePatterns.NONE, cellRun.getUnderline());

    // second row, first cell => no style
    cell = row.getCell(1);
    cellParagraph = cell.getParagraphs().get(0);
    assertNull(cell.getColor());
    cellRun = cellParagraph.getRuns().get(0);
    assertFalse(cellRun.isBold());
    assertFalse(cellRun.isItalic());
    assertFalse(cellRun.isStrikeThrough());
    assertEquals(UnderlinePatterns.NONE, cellRun.getUnderline());

    // second row, second cell => cell style
    cell = row.getCell(2);
    cellParagraph = cell.getParagraphs().get(0);
    cellRun = cellParagraph.getRuns().get(0);
    assertEquals(CELL_BG_COLOR, cell.getColor().toUpperCase());
    assertEquals(CELL_FG_COLOR, cellRun.getColor().toUpperCase());
    assertEquals(CELL_FONT_SIZE, cellRun.getFontSize());
    assertTrue(cellRun.isBold());
    assertFalse(cellRun.isItalic());
    assertFalse(cellRun.isStrikeThrough());
    assertEquals(UnderlinePatterns.SINGLE, cellRun.getUnderline());
}

From source file:patientmanagerv1.HomeController.java

public void writeEvalToDocX(boolean customPath, String path) {
    FileOutputStream outstream;//from w ww.j  av a 2  s  . c o  m

    try {
        if (customPath == false) {
            outstream = new FileOutputStream(installationPath + "/userdata/" + firstName + lastName + dob + "/"
                    + firstName + lastName + dob + "psychiatricevaluation.docx");
        } else {
            outstream = new FileOutputStream(path + ".docx");
        }

        XWPFDocument doc = new XWPFDocument();
        //due to the redirection of these e's, even physically, your str will begin to deteriorate. Corpse-like, in other words.

        /*XWPFParagraph para = doc.createParagraph();
        para.setAlignment(ParagraphAlignment.CENTER);
        XWPFRun paraRun = para.createRun();
        paraRun.setBold(true);
        paraRun.setFontSize(12);
        //paraRun.setFontSize(16);
        paraRun.setText("Hello World");*/

        XWPFParagraph header = doc.createParagraph(); //Paragraph
        XWPFRun headerLabel = header.createRun(); //Where the text will be written from
        header.setAlignment(ParagraphAlignment.CENTER);
        headerLabel.setFontFamily("16");
        headerLabel.setBold(true);
        headerLabel.setText("Advanced Psychiatric Associates");
        headerLabel.addBreak();
        headerLabel.setText("Psychiatric Evaluation");
        headerLabel.addBreak();

        XWPFParagraph p = doc.createParagraph(); //Paragraph
        XWPFRun run = p.createRun(); //Where the text will be written from
        XWPFRun run2 = p.createRun();
        XWPFRun run3 = p.createRun();
        XWPFRun run4 = p.createRun();
        XWPFRun run5 = p.createRun();
        XWPFRun run6 = p.createRun();
        XWPFRun run7 = p.createRun();
        XWPFRun run8 = p.createRun();
        XWPFRun run9 = p.createRun();
        XWPFRun run10 = p.createRun();
        XWPFRun run11 = p.createRun();
        XWPFRun run12 = p.createRun();
        XWPFRun run13 = p.createRun();
        XWPFRun run14 = p.createRun();
        XWPFRun run15 = p.createRun();
        XWPFRun run16 = p.createRun();
        XWPFRun run17 = p.createRun();
        XWPFRun run18 = p.createRun();
        XWPFRun anEdit1 = p.createRun();
        XWPFRun run19 = p.createRun();
        XWPFRun run20 = p.createRun();
        XWPFRun run21 = p.createRun();
        XWPFRun run22 = p.createRun();
        XWPFRun run23 = p.createRun();
        XWPFRun run24 = p.createRun();
        XWPFRun run25 = p.createRun();
        XWPFRun run26 = p.createRun();
        XWPFRun run27 = p.createRun();
        XWPFRun run28 = p.createRun();
        XWPFRun run29 = p.createRun();
        XWPFRun run30 = p.createRun();
        XWPFRun run31 = p.createRun(); //Where the text will be written from
        XWPFRun run32 = p.createRun();
        XWPFRun run33 = p.createRun();
        XWPFRun run34 = p.createRun();
        XWPFRun run35 = p.createRun();
        XWPFRun run36 = p.createRun();
        XWPFRun run37 = p.createRun();
        XWPFRun run38 = p.createRun();
        XWPFRun run39 = p.createRun();
        XWPFRun run40 = p.createRun();
        XWPFRun run41 = p.createRun();
        XWPFRun run42 = p.createRun();
        XWPFRun run42Bold = p.createRun();
        XWPFRun runPre43 = p.createRun();
        XWPFRun run43 = p.createRun();
        XWPFRun run44 = p.createRun();
        XWPFRun run45 = p.createRun();
        XWPFRun run46 = p.createRun();
        XWPFRun run47 = p.createRun();
        XWPFRun run48 = p.createRun();
        XWPFRun run49 = p.createRun();
        XWPFRun run50 = p.createRun();
        XWPFRun run51 = p.createRun();
        XWPFRun run52 = p.createRun();
        XWPFRun run53 = p.createRun();
        XWPFRun run54 = p.createRun();
        XWPFRun run55 = p.createRun();
        XWPFRun run56 = p.createRun();
        XWPFRun run57 = p.createRun();
        XWPFRun run58 = p.createRun();
        XWPFRun run59 = p.createRun();
        XWPFRun run60 = p.createRun();

        run.setBold(true);
        run2.setBold(false);
        run3.setBold(true);
        run4.setBold(false);
        run5.setBold(true);
        run6.setBold(false);
        run7.setBold(true);
        run8.setBold(false);
        run9.setBold(true);
        run10.setBold(false);
        run11.setBold(true);
        run12.setBold(false);
        run13.setBold(true);
        run14.setBold(false);
        run15.setBold(true);
        run16.setBold(false);
        run17.setBold(true);
        run18.setBold(false);
        run19.setBold(true);
        run20.setBold(false);
        run21.setBold(true);
        run22.setBold(false);
        run23.setBold(true);
        run24.setBold(false);
        run25.setBold(true);
        run26.setBold(false);
        run27.setBold(true);
        run28.setBold(false);
        run29.setBold(true);
        run30.setBold(false);

        /*
            @FXML
        AnchorPane ap;
        @FXML
        TextField first, last, ageText, dobText;
        @FXML
        TextField ethnicityothertext;
        @FXML
        RadioButton male, female;
        @FXML
        RadioButton single, engaged, married, seperated, divorced, commonlawspouse, cohabiting; 
        @FXML
        CheckBox africanamerican, nativeamerican, hispanic, asian, caucasian, ethnicityother, ocd, bipolardisorder, socialphobia, panicdisorder, eatingdisorder, majordepressivedisorder, psychosis;
        @FXML
        RadioButton insurance, internet, pcp, cps, therapist, referredbyother;
        @FXML
        TextField referredbytherapisttext, referredbyothertext, reasonforreferralbox;
        @FXML
        Button sign, saveButton;
        @FXML
        Label signature;
        @FXML
        CheckBox patient, spouse, mother, father, othersourceofinformation, emp, unemp, disabilityincome;
        @FXML
        TextField othersourceofinformationbox, otherreliabilityofinformationbox;
        @FXML
        RadioButton good, fair, vague, minimizing, otherreliabilityofinformation, sano, sayes, physicalabuseno, physicalabuseyes, sexualabuseno, sexualabuseyes, violentaggressivebehaviorsno, violentaggressivebehaviorsyes, selfinjuriousbehaviorsno, selfinjuriousbehaviorsyes;
        @FXML
        TextArea historyofpresentillness, currentmedications, pastpsychiatrichistory, pasthistoryoftext, historyofmedicationtrialsinthepasttable, historyofmedicationtrialsinthepastcomments, substanceusehistory;
        @FXML
        ListView listOfProgressReports;
        @FXML
        CheckBox significantwithdrawals, dts, withdrawalseizures, historyofdetox, outpatient, inpatient, na, aa, substancetreatmentprogram, nkda, environmental;
        @FXML
        TextField inpatientbox, parents, siblings, children, education, allergiesdescriptionbox;
        @FXML
        TextArea socialhistorygeneral, familyhistoryofmentalillness, legalhistory, pastmedicalhistory;
        @FXML
        RadioButton fhomiNO, fhomiYES, eyecontactgood, eyecontactpoor, eyecontactvariable;
        @FXML
        TextField appearanceotherbox, attitudeotherbox, motoractivityotherbox;
        @FXML
        CheckBox wellgroomed, casual, disheveled, bizarre, inappropriate, appearanceother, cooperative, guarded, suspicious, withdrawn, uncooperative, hostile, defensive, attitudeother;
        @FXML
        CheckBox normal, agitated, motorretardation, hyperactive, catatonia, tremorstics, motoractivityother;
        @FXML
        CheckBox appropriate, labile, expansive, constricted, affecthappy, affectsad, blunted, flat, masking, affectnormalrange;
        @FXML
        CheckBox euthymic, depressed, dysphoric, anxious, euphoric, angry, irritable, moodsad;
        @FXML
        CheckBox normal2, delayed, soft, loud, slurred, excessive, pressured, perseverating, rapid, rambling, incoherent, disorganized, decreasedproductivity;
        @FXML
        CheckBox intact, circumstantial, loa, tangential, foi, logicalgoaldirected, thoughtblocking, ruminating, racingthoughts, thoughtinsertionwithdrawalbroadcast;
        */

        //alternative solution: so I guess, a seperate run for each form element, followed by an if statement
        //run is created here if(divorced.isSelected == "true"){run.setBold(true); run.setText("divorced");} else {run.setBold(false); run.setText("divorced")}
        //single, engaged, married, seperated, divorced, commonlawspouse, cohabiting; 

        //greater: MM, gbits, (much) lesser: id'ing
        run.setText("Patient Name: ");
        //doc.write(outstream);
        //outstream.close();
        // doc.createParagraph().createRun().setBold(true);

        //run.setBold(false);
        //run.setText("Ciel Phantomhive");

        run2.setText(first.getText() + " " + last.getText());
        run3.setText("              Age: ");
        //run2.setTextPosition(run2.getTextPosition());
        run4.setText(ageText.getText());
        run5.setText("                              DOB: ");
        run6.setText(dobText.getText());
        run6.addBreak();
        run6.addBreak();

        run7.setBold(false);
        run7.setText("Marital Status: ");
        //single, engaged, married, seperated, divorced, commonlawspouse, cohabiting;             
        if (single.isSelected()) {
            run7.setText("     Single");
        }
        if (engaged.isSelected()) {
            run7.setText("     Engaged");
        }
        if (married.isSelected()) {
            run7.setText("     Married");
        }
        if (seperated.isSelected()) {
            run7.setText("     Seperated");
        }
        if (divorced.isSelected()) {
            run7.setText("     Divorced");
        }
        if (commonlawspouse.isSelected()) {
            run7.setText("     Common Law Spouse");
        }
        if (cohabiting.isSelected()) {
            run7.setText("     Cohabiting");
        }
        run7.addBreak();
        run7.setText("Ethnicity: ");
        //africanamerican, nativeamerican, hispanic, asian, caucasian, ethnicityother, ocd, bipolardisorder, socialphobia, panicdisorder, eatingdisorder, majordepressivedisorder, psychosis;
        if (africanamerican.isSelected()) {
            run7.setText("     African American");
        }
        if (nativeamerican.isSelected()) {
            run7.setText("      Native American");
        }
        if (hispanic.isSelected()) {
            run7.setText("     Hispanic");
        }
        if (asian.isSelected()) {
            run7.setText("     Asian");
        }
        if (caucasian.isSelected()) {
            run7.setText("     Caucasian");
        }
        if (ethnicityother.isSelected()) {
            run7.setText("     " + ethnicityothertext.getText());
        }

        run7.addBreak();
        run7.setText("Sex: ");
        if (male.isSelected()) {
            run7.setText("     Male");
        }
        if (female.isSelected()) {
            run7.setText("      Female");
        }

        run7.addBreak();
        run7.setText("Referred By: ");
        //insurance, internet, pcp, cps, therapist, referredbyother
        if (insurance.isSelected()) {
            run7.setText("     Insurance");
        }
        if (internet.isSelected()) {
            run7.setText("     Internet");
        }
        if (pcp.isSelected()) {
            run7.setText("     PCP");
        }
        if (cps.isSelected()) {
            run7.setText("     CPS");
        }
        if (therapist.isSelected()) {
            run7.setText("     therapist- " + referredbytherapisttext.getText());
        }
        if (referredbyother.isSelected()) {
            run7.setText("     " + referredbyothertext.getText());
        }

        run7.addBreak();
        run7.setText("Reason for Referral: ");
        if (reasonforreferralpsychiatricevaluation.isSelected()) {
            run7.setText("     Psychiatric Evaluation");
        }
        if (reasonforreferralmedicationmanagement.isSelected()) {
            run7.setText("      Medication Management");
        }

        run7.addBreak();
        run7.setText("Source of Information: ");
        //insurance, internet, pcp, cps, therapist, referredbyother
        if (patient.isSelected()) {
            run7.setText("     Patient");
        }
        if (spouse.isSelected()) {
            run7.setText("     Spouse");
        }
        if (mother.isSelected()) {
            run7.setText("     Mother");
        }
        if (father.isSelected()) {
            run7.setText("     Father");
        }
        if (othersourceofinformation.isSelected()) {
            run7.setText("     " + othersourceofinformationbox.getText());
        }

        run7.addBreak();
        run7.setText("Reliability of Information: ");
        //insurance, internet, pcp, cps, therapist, referredbyother
        if (good.isSelected()) {
            run7.setText("     Good");
        }
        if (fair.isSelected()) {
            run7.setText("     Fair");
        }
        if (vague.isSelected()) {
            run7.setText("     Vague");
        }
        if (minimizing.isSelected()) {
            run7.setText("     Minimizing");
        }
        if (otherreliabilityofinformation.isSelected()) {
            run7.setText("     " + otherreliabilityofinformationbox.getText());
        }

        run7.setText(" (Options: good, fair, vague, minimizing, other)");
        run7.addBreak();
        run7.addBreak();
        run8.setBold(true);
        run8.setUnderline(UnderlinePatterns.SINGLE);
        run8.setText("History of Present Illness");
        run8.addBreak();
        run9.setBold(false);
        run9.setText(historyofpresentillness.getText());
        run9.addBreak();
        run9.addBreak();
        run10.setBold(true);
        run10.setText("Patient denied signs or symptoms of: ");
        run11.setBold(false);

        //ocd, bipolardisorder, socialphobia, panicdisorder, eatingdisorder, majordepressivedisorder, psychosis

        if (ocd.isSelected() == true) {
            run11.setText("     OCD");
        }
        if (bipolardisorder.isSelected() == true) {
            run11.setText("     Bipolar Disorder");
        }
        if (socialphobia.isSelected() == true) {
            run11.setText("     Social Phobia");
        }
        if (panicdisorder.isSelected() == true) {
            run11.setText("     Panic Disorder");
        }
        if (eatingdisorder.isSelected() == true) {
            run11.setText("     Eating Disorder");
        }
        if (majordepressivedisorder.isSelected() == true) {
            run11.setText("     Major Depressive Disorder");
        }
        if (psychosis.isSelected() == true) {
            run11.setText("     Psychosis");
        }
        run11.addBreak();
        run11.addBreak();

        run12.setUnderline(UnderlinePatterns.SINGLE);
        run12.setBold(true);
        run12.setText("Current Medications (including over-the-counter medications and vitamins)");
        run12.addBreak();
        run13.setBold(false);
        run13.setText(currentmedications.getText());

        run13.addBreak();
        run13.addBreak();

        run14.setUnderline(UnderlinePatterns.SINGLE);
        run14.setBold(true);
        run14.setText("Past Psychiatric History");
        run14.addBreak();
        run15.setBold(false);
        run15.setText(pastpsychiatrichistory.getText());
        run15.addBreak();
        run15.addBreak();

        run16.setBold(true);
        run16.setText("Past History Of");
        run16.addBreak();

        run17.setBold(false);
        run17.setText("Suicide Attempts: ");

        //past history of
        if (sano.isSelected() == true) {
            run17.setText("No");
        } else if (sayes.isSelected() == true) {
            run17.setText("Yes");
        }
        run17.addBreak();
        if (physicalabuseno.isSelected() == true) {
            run17.setText("Physical Abuse: No");
        } else if (physicalabuseyes.isSelected() == true) {
            run17.setText("Physical Abuse: Yes");
        }
        run17.addBreak();
        if (sexualabuseno.isSelected() == true) {
            run17.setText("Sexual Abuse: No");
        } else if (sexualabuseyes.isSelected() == true) {
            run17.setText("Sexual Abuse: Yes");
        }
        run17.addBreak();
        if (violentaggressivebehaviorsno.isSelected() == true) {
            run17.setText("Violent/Aggressive Behaviors: No");
        } else if (violentaggressivebehaviorsyes.isSelected() == true) {
            run17.setText("Violent/Aggressive Behaviors: Yes");
        }
        run17.addBreak();
        if (selfinjuriousbehaviorsno.isSelected() == true) {
            run17.setText("Self-Injurious Behaviors: No");
        } else if (selfinjuriousbehaviorsyes.isSelected() == true) {
            run17.setText("Self-Injurious Behaviors: Yes");
        }
        run17.addBreak();
        run17.setText(pasthistoryoftext.getText());
        run17.addBreak();
        run17.addBreak();

        run18.setUnderline(UnderlinePatterns.SINGLE);
        run18.setBold(true);
        run18.setText("History of Medication Trials in the Past");
        run18.addBreak();
        anEdit1.setBold(true);
        anEdit1.setText(
                "Medication                                   Dosage                                 Duration");
        anEdit1.addBreak();

        run19.setBold(false);

        String fulltext = historyofmedicationtrialsinthepasttable.getText();
        String[] lines = fulltext.split("\n");

        for (int i = 0; i < lines.length; i++) {
            String[] modifyThis = lines[i].split("    ");
            for (int j = 0; j < modifyThis.length; j++) {
                run19.setText(modifyThis[j].trim() + "                ");
            }

            //run19.setText(lines[i]);

            run19.addBreak();
        }

        //run19.setText(lines[0]);
        run19.addBreak();
        run19.addBreak();
        run19.setText("Comments: " + historyofmedicationtrialsinthepastcomments.getText());
        run19.addBreak();
        run19.addBreak();

        run20.setBold(true);
        run20.setText("Substance Use History:");
        run20.addBreak();

        run21.setBold(false);
        run21.setText(substanceusehistory.getText());
        run21.addBreak();
        //run21.setText("Denies history of: ");

        String denies = "";

        if (significantwithdrawals.isSelected() == true) {
            denies = denies + "Significant Withdrawals, ";
        }
        if (dts.isSelected() == true) {
            denies = denies + "DTS, ";
        }
        if (withdrawalseizures.isSelected() == true) {
            denies = denies + "Withdrawal Seizures, ";
        }
        if (historyofdetox.isSelected() == true) {
            denies = denies + "History Of Detox, ";
        }
        if (outpatient.isSelected() == true) {
            denies = denies + "Outpatient, ";
        }
        if (inpatient.isSelected() == true) {
            denies = denies + "Inpatient, ";
        }
        if (na.isSelected() == true) {
            denies = denies + "NA, ";
        }
        if (aa.isSelected() == true) {
            denies = denies + "AA, ";
        }
        if (substancetreatmentprogram.isSelected() == true) {
            denies = denies + "Substance Treatment Program, ";
        }

        if (denies.length() > 2) {
            denies = denies.substring(0, denies.length() - 2);
            denies = denies.trim();
        }

        //Fandom Follower- anonomously discuss your fandom
        //select/create/add a new fandom group to the list/search
        //browse fanart, view fandom updates, add materials to your local board
        run21.setText("Denies History Of: " + denies);
        run21.addBreak();
        run21.addBreak();

        run22.setUnderline(UnderlinePatterns.SINGLE);
        run22.setBold(true);
        run22.setText("Social History: ");
        run22.addBreak();
        //y the fm, m homu cov e's, ah chained, ank snk
        //
        //ASP.NET in visual studio, eclipse, netbeans

        //dk y lol
        run23.setBold(false);
        run23.setText(socialhistorygeneral.getText());
        run23.addBreak();
        run23.addBreak();
        run23.setText("Parents: " + parents.getText());
        run23.addBreak();
        run23.setText("Siblings: " + siblings.getText());
        run23.addBreak();
        run23.setText("Children: " + children.getText());
        run23.addBreak();

        String faHist;
        if (fhomiNO.isSelected() == true) {
            faHist = "No";
        } else {
            faHist = "Yes";
        }

        run23.setText("Family History of Mental Illness? " + faHist);
        run23.addBreak();
        run23.setText(familyhistoryofmentalillness.getText());
        run23.addBreak();
        run23.addBreak();
        run23.setText(education.getText());
        run23.addBreak();

        String e = "";
        if (emp.isSelected() == true) {
            e = e + "Employed, ";
        }
        if (unemp.isSelected() == true) {
            e = e + "Unemployed, ";
        }
        if (disabilityincome.isSelected() == true) {
            e = e + "Disability Income, ";
        }

        if (e.length() > 2) {
            e = e.substring(0, e.length() - 2);
            e = e.trim();
        }

        run23.setText("Employment: " + e);
        run23.addBreak();

        run23.setText(legalhistory.getText());
        run23.addBreak();
        run23.addBreak();

        run24.setUnderline(UnderlinePatterns.SINGLE);
        run24.setBold(true);
        run24.setText("Past Medical History");
        run24.addBreak();
        run25.setBold(false);
        run25.setText(pastmedicalhistory.getText());
        run25.addBreak();
        run26.setBold(true);
        run26.setText("Allergies: ");
        String allergies = " ";

        if (nkda.isSelected() == true) {
            allergies = allergies + "nkda, ";
        }
        if (environmental.isSelected() == true) {
            allergies = allergies + "environmental, ";
        }

        if (allergies.length() > 2) {
            allergies = allergies.substring(0, allergies.length() - 2);
            allergies = allergies.trim();
        }

        run27.setBold(false);
        run27.setText(allergies);
        run27.addBreak();
        run27.setText(allergiesdescriptionbox.getText());
        run27.addBreak();
        run27.addBreak();

        run28.setUnderline(UnderlinePatterns.SINGLE);
        run28.setBold(true);
        run28.setText("Mental Status Examination:");
        run29.addBreak();
        run30.setBold(false);

        String appearance = " ";

        if (wellgroomed.isSelected() == true) {
            appearance = appearance + "Well Groomed, ";
        }
        if (casual.isSelected() == true) {
            appearance = appearance + "Casual, ";
        }
        if (disheveled.isSelected() == true) {
            appearance = appearance + "Disheveled, ";
        }
        if (bizarre.isSelected() == true) {
            appearance = appearance + "Bizarre, ";
        }
        if (inappropriate.isSelected() == true) {
            appearance = appearance + "Inappropriate,";
        }
        if (appearanceother.isSelected() == true) {
            appearance = appearance + "Other: ";
        }

        if (appearance.length() > 2) {
            appearance = appearance.substring(0, appearance.length() - 2);
            appearance = appearance.trim();
        }

        run30.setText("Appearance: " + appearance);
        if (appearanceother.isSelected()) {
            run30.setText(" - " + appearanceotherbox.getText());
        }

        run30.addBreak();

        String eC = "blah";

        if (eyecontactgood.isSelected() == true) {
            eC = "Good";
        }
        if (eyecontactpoor.isSelected() == true) {
            eC = "Poor";
        }
        if (eyecontactvariable.isSelected() == true) {
            eC = "Variable";
        }

        run30.setText("Eye Contact: " + eC);
        run30.addBreak();

        String attitude = " ";

        if (cooperative.isSelected() == true) {
            attitude = attitude + "Cooperative, ";
        }
        if (guarded.isSelected() == true) {
            attitude = attitude + "Guarded, ";
        }
        if (suspicious.isSelected() == true) {
            attitude = attitude + "Suspicious, ";
        }
        if (withdrawn.isSelected() == true) {
            attitude = attitude + "Withdrawn, ";
        }
        if (uncooperative.isSelected() == true) {
            attitude = attitude + "Uncooperative, ";
        }
        if (hostile.isSelected() == true) {
            attitude = attitude + "Hostile, ";
        }
        if (defensive.isSelected() == true) {
            attitude = attitude + "Defensive, ";
        }
        if (attitudeother.isSelected() == true) {
            attitude = attitude + "Other: ";
        }

        if (attitude.length() > 2) {
            attitude = attitude.substring(0, attitude.length() - 2);
            attitude = attitude.trim();
        }

        run30.setText("Attitude: " + attitude);
        if (attitudeother.isSelected()) {
            run30.setText(" - " + attitudeotherbox.getText());
        }
        run30.addBreak();

        String motoractivity = " ";

        if (normal.isSelected() == true) {
            motoractivity = motoractivity + "Normal, ";
        }
        if (agitated.isSelected() == true) {
            motoractivity = motoractivity + "Agitated, ";
        }
        if (motorretardation.isSelected() == true) {
            motoractivity = motoractivity + "Motor Retardation, ";
        }
        if (hyperactive.isSelected() == true) {
            motoractivity = motoractivity + "Hyperactive, ";
        }
        if (catatonia.isSelected() == true) {
            motoractivity = motoractivity + "Catatonia, ";
        }
        if (tremorstics.isSelected() == true) {
            motoractivity = motoractivity + "Tremors/Tics, ";
        }
        if (motoractivityother.isSelected() == true) {
            motoractivity = motoractivity + "Other: ";
        }

        if (motoractivity.length() > 2) {
            motoractivity = motoractivity.substring(0, motoractivity.length() - 2);
            motoractivity = motoractivity.trim();
        }

        run30.setText("Motor Activity: " + motoractivity);
        if (motoractivityother.isSelected()) {
            run30.setText(" - " + motoractivityotherbox.getText());
        }

        run30.addBreak();

        String affect = " ";

        if (appropriate.isSelected() == true) {
            affect = affect + "Appropriate, ";
        }
        if (labile.isSelected() == true) {
            affect = affect + "Labile, ";
        }
        if (expansive.isSelected() == true) {
            affect = affect + "Expansive, ";
        }
        if (constricted.isSelected() == true) {
            affect = affect + "Constricted, ";
        }
        if (affecthappy.isSelected() == true) {
            affect = affect + "Happy, ";
        }
        if (affectsad.isSelected() == true) {
            affect = affect + "Sad, ";
        }
        if (blunted.isSelected() == true) {
            affect = affect + "Blunted, ";
        }
        if (flat.isSelected() == true) {
            affect = affect + "Flat, ";
        }
        if (masking.isSelected() == true) {
            affect = affect + "Masking, ";
        }
        if (affectnormalrange.isSelected() == true) {
            affect = affect + "Normal Range, ";
        }

        if (affect.length() > 2) {
            affect = affect.substring(0, affect.length() - 2);
            affect = affect.trim();
        }

        run30.setText("Affect: " + affect);
        run30.addBreak();

        String mood = " ";

        if (euthymic.isSelected() == true) {
            mood = mood + "Euthymic, ";
        }
        if (depressed.isSelected() == true) {
            mood = mood + "Depressed, ";
        }
        if (dysphoric.isSelected() == true) {
            mood = mood + "Dysphoric, ";
        }
        if (anxious.isSelected() == true) {
            mood = mood + "Anxious, ";
        }
        if (euphoric.isSelected() == true) {
            mood = mood + "Euphoric, ";
        }
        if (angry.isSelected() == true) {
            mood = mood + "Angry, ";
        }
        if (irritable.isSelected() == true) {
            mood = mood + "Irritable, ";
        }
        if (moodsad.isSelected() == true) {
            mood = mood + "Sad, ";
        }

        if (mood.length() > 2) {
            mood = mood.substring(0, mood.length() - 2);
            mood = mood.trim();
        }

        run30.setText("Mood: " + mood);
        run30.addBreak();

        String speech = " ";

        if (normal2.isSelected() == true) {
            speech = speech + "Normal, ";
        }
        if (delayed.isSelected() == true) {
            speech = speech + "Delayed, ";
        }
        if (soft.isSelected() == true) {
            speech = speech + "Soft, ";
        }
        if (loud.isSelected() == true) {
            speech = speech + "Loud, ";
        }
        if (slurred.isSelected() == true) {
            speech = speech + "Slurred, ";
        }
        if (excessive.isSelected() == true) {
            speech = speech + "Excessive, ";
        }
        if (pressured.isSelected() == true) {
            speech = speech + "Pressured, ";
        }
        if (perseverating.isSelected() == true) {
            speech = speech + "Perseverating, ";
        }
        if (rapid.isSelected() == true) {
            speech = speech + "Rapid, ";
        }
        if (rambling.isSelected() == true) {
            speech = speech + "Rambling, ";
        }
        if (incoherent.isSelected() == true) {
            speech = speech + "Incoherent, ";
        }
        if (disorganized.isSelected() == true) {
            speech = speech + "Disorganized, ";
        }
        if (decreasedproductivity.isSelected() == true) {
            speech = speech + "Decreased Productivity, ";
        }

        if (speech.length() > 2) {
            speech = speech.substring(0, speech.length() - 2);
            speech = speech.trim();
        }

        run30.setText("Speech: " + speech);
        run30.addBreak();

        String per = " ";

        if (visualhallucinations.isSelected() == true) {
            per = per + "Visual Hallucinations, ";
        }
        if (auditoryhallucinations.isSelected() == true) {
            per = per + "Auditory Hallucinations, ";
        }
        if (depersonalization.isSelected() == true) {
            per = per + "Depersonalization, ";
        }
        if (derealization.isSelected() == true) {
            per = per + "Derealization, ";
        }
        if (commandah.isSelected() == true) {
            per = per + "Command AH, ";
        }
        if (delusions2.isSelected() == true) {
            per = per + "Delusions, ";
        }
        if (illusions.isSelected() == true) {
            per = per + "Illusions, ";
        }
        if (perceptionnoimpairment.isSelected() == true) {
            per = per + "No Impairment, ";
        }

        if (per.length() > 2) {
            per = per.substring(0, per.length() - 2);
            per = per.trim();
        }

        run30.setText("Perception: " + per);
        run30.addBreak();

        String thoughtProcess = " ";

        if (intact.isSelected() == true) {
            thoughtProcess = thoughtProcess + "Intact, ";
        }
        if (circumstantial.isSelected() == true) {
            thoughtProcess = thoughtProcess + "Circumstantial, ";
        }
        if (loa.isSelected() == true) {
            thoughtProcess = thoughtProcess + "LOA, ";
        }
        if (tangential.isSelected() == true) {
            thoughtProcess = thoughtProcess + "Tangential, ";
        }
        if (foi.isSelected() == true) {
            thoughtProcess = thoughtProcess + "FOI, ";
        }
        if (logicalgoaldirected.isSelected() == true) {
            thoughtProcess = thoughtProcess + "Logical Goal Directed, ";
        }
        if (thoughtblocking.isSelected() == true) {
            thoughtProcess = thoughtProcess + "Thought Blocking, ";
        }
        if (ruminating.isSelected() == true) {
            thoughtProcess = thoughtProcess + "Ruminating, ";
        }
        if (racingthoughts.isSelected() == true) {
            thoughtProcess = thoughtProcess + "Racing Thoughts, ";
        }
        if (thoughtinsertionwithdrawalbroadcast.isSelected() == true) {
            thoughtProcess = thoughtProcess + "Thought Insertion/Withdrawal/Broadcast, ";
        }

        if (thoughtProcess.length() > 2) {
            thoughtProcess = thoughtProcess.substring(0, thoughtProcess.length() - 2);
            thoughtProcess = thoughtProcess.trim();
        }

        run30.setText("Thought Process: " + thoughtProcess);
        run30.addBreak();

        String thoughtContent = "";
        //hummus/tahini, "steak", p seeds/walnuts, k p + sm papr; curry, hazelnut meal + a fig + 1tsp pb + 1tsp white flour + a few drops of maple syrup
        //get some (pepper) A1!!!
        //bbq sauce
        if (logicalcoherent.isSelected() == true) {
            thoughtContent = thoughtContent + "Logical Coherent, ";
        }
        if (povertyofcontent.isSelected() == true) {
            thoughtContent = thoughtContent + "Poverty Of Content, ";
        }
        if (ideasofreference.isSelected() == true) {
            thoughtContent = thoughtContent + "Ideas Of Reference, ";
        }
        if (obsessions.isSelected() == true) {
            thoughtContent = thoughtContent + "Obsessions, ";
        }
        if (phobias.isSelected() == true) {
            thoughtContent = thoughtContent + "Phobias, ";
        }
        if (paranoidideation.isSelected() == true) {
            thoughtContent = thoughtContent + "Paranoid Ideation, ";
        }
        if (delusions.isSelected() == true) {
            thoughtContent = thoughtContent + "Delusions, ";
        }

        if (thoughtContent.length() > 2) {
            thoughtContent = thoughtContent.substring(0, thoughtContent.length() - 2);
            thoughtContent = thoughtContent.trim();
        }

        run30.setText("Thought Content: " + thoughtContent);
        if (delusions.isSelected()) {
            run30.setText(" - " + delusionsbox.getText());
        }
        run30.addBreak();

        String suicidality = " ";

        if (suicidalitydenied.isSelected() == true) {
            suicidality = suicidality + "Suicidality Denied, ";
        }
        if (suicidalityideation.isSelected() == true) {
            suicidality = suicidality + "Suicidality Ideation, ";
        }
        if (suicidalityintent.isSelected() == true) {
            suicidality = suicidality + "Suicidality Intent, ";
        }
        if (suicidalityplan.isSelected() == true) {
            suicidality = suicidality + "Suicidality Plan: ";
        }

        if (suicidality.length() > 2) {
            suicidality = suicidality.substring(0, suicidality.length() - 2);
            suicidality = suicidality.trim();
        }

        run30.setText("Suicidality: " + suicidality);
        if (suicidalityplan.isSelected()) {
            run30.setText(" - " + suicidalityplanbox.getText());
        }
        run30.addBreak();

        String homicidality = " ";

        if (homicidalitydenied.isSelected() == true) {
            homicidality = homicidality + "Homicidality Denied, ";
        }
        if (homicidalityideation.isSelected() == true) {
            homicidality = homicidality + "Homicidality Ideation, ";
        }
        if (homicidalityintent.isSelected() == true) {
            homicidality = homicidality + "Homicidality Intent, ";
        }
        if (homicidalityplan.isSelected() == true) {
            homicidality = homicidality + "Homicidality Plan: ";
        }

        if (homicidality.length() > 2) {
            homicidality = homicidality.substring(0, homicidality.length() - 2);
            homicidality = homicidality.trim();
        }

        run30.setText("Homicidality: " + homicidality);
        if (homicidalityplan.isSelected()) {
            run30.setText(" - " + homicidalityplanbox.getText());
        }
        run30.addBreak();
        if (suicidalityhomicidalitycomments.getText().length() >= 2) {
            run30.setText(" \t Comments - " + suicidalityhomicidalitycomments.getText());
        }
        run30.addBreak();

        String orientation = " ";

        if (fullyoriented.isSelected() == true) {
            orientation = orientation + "Fully Oriented, ";
        }
        if (disoriented.isSelected() == true) {
            orientation = orientation + "Disoriented: ";
        }
        if (person.isSelected() == true) {
            orientation = orientation + "Person, ";
        }
        if (place.isSelected() == true) {
            orientation = orientation + "Place, ";
        }
        if (time.isSelected() == true) {
            orientation = orientation + "Time, ";
        }

        if (orientation.length() > 2) {
            orientation = orientation.substring(0, orientation.length() - 2);
            orientation = orientation.trim();
        }

        run30.setText("Orientation: " + orientation);
        run30.addBreak();

        String stm = " ";

        //shorttermmemorywithinnormallimits, shorttermmermorydeficits, longtermmemorywithinnormallimits,longtermmemorydeficits, shorttermmemorydeficitsbox, longtermmemorydeficitsbox
        if (shorttermmemorywithinnormallimits.isSelected() == true) {
            stm = stm + "Within Normal Limits, ";
        }
        if (shorttermmemorydeficits.isSelected() == true) {
            stm = stm + "Deficits, ";
        }

        if (stm.length() > 2) {
            stm = stm.substring(0, stm.length() - 2);
            stm = stm.trim();
        }

        run30.setText("Short Term Memory: " + stm);
        if (shorttermmemorydeficits.isSelected() == true) {
            run30.setText(" - " + shorttermmemorydeficitsbox.getText());
        }
        run30.addBreak();

        String ltm = " ";

        if (longtermmemorywithinnormallimits.isSelected() == true) {
            ltm = ltm + "Within Normal Limits, ";
        }
        if (longtermmemorydeficits.isSelected() == true) {
            ltm = ltm + "Deficits, ";
        }

        if (ltm.length() > 2) {
            ltm = ltm.substring(0, ltm.length() - 2);
            ltm = ltm.trim();
        }

        run30.setText("Long Term Memory: " + ltm);
        if (longtermmemorydeficits.isSelected() == true) {
            run30.setText(" - " + longtermmemorydeficitsbox.getText());
        }
        run30.addBreak();

        String gfok = " ";

        if (generalfundofknowledgewithinnormallimits.isSelected() == true) {
            gfok = gfok + "Within Normal Limits, ";
        }
        if (generalfundofknowledgedeficits.isSelected() == true) {
            gfok = gfok + "Deficits, ";
        }

        if (gfok.length() > 2) {
            gfok = gfok.substring(0, gfok.length() - 2);
            gfok = gfok.trim();
        }

        run30.setText("General Fund of Knowledge: " + gfok);
        if (generalfundofknowledgedeficits.isSelected() == true) {
            run30.setText(" - " + generalfundofknowledgedeficitsbox.getText());
        }
        run30.addBreak();

        String intellect = " ";

        if (intellectaboveaverage.isSelected() == true) {
            intellect = intellect + "Above Average, ";
        }
        if (intellectaverage.isSelected() == true) {
            intellect = intellect + "Average, ";
        }
        if (intellectbelowaverage.isSelected() == true) {
            intellect = intellect + "Below Average, ";
        }

        if (intellect.length() > 2) {
            intellect = intellect.substring(0, intellect.length() - 2);
            intellect = intellect.trim();
        }

        run30.setText("Intellect: " + intellect);
        if (intellectbelowaverage.isSelected() == true) {
            run30.setText(" - " + intellectbelowaveragebox.getText());
        }
        run30.addBreak();

        String abstraction = " ";

        if (abstractionintact.isSelected() == true) {
            abstraction = abstraction + "Intact, ";
        }
        if (abstractionconcrete.isSelected() == true) {
            abstraction = abstraction + "Concrete, ";
        }
        if (abstractionidiosyncratic.isSelected() == true) {
            abstraction = abstraction + "Idiosyncratic, ";
        }

        if (abstraction.length() > 2) {
            abstraction = abstraction.substring(0, abstraction.length() - 2);
            abstraction = abstraction.trim();
        }

        run30.setText("Abstraction: " + abstraction);
        run30.addBreak();

        String judgement = " ";

        if (judgementintact.isSelected() == true) {
            judgement = judgement + "Intact, ";
        }
        if (judgementimpaired.isSelected() == true) {
            judgement = judgement + "Impaired -  ";
        }
        if (judgementminimal.isSelected() == true) {
            judgement = judgement + "Minimal, ";
        }
        if (judgementmoderate.isSelected() == true) {
            judgement = judgement + "Moderate, ";
        }
        if (judgementsevere.isSelected() == true) {
            judgement = judgement + "Severe, ";
        }

        if (judgement.length() > 2) {
            judgement = judgement.substring(0, judgement.length() - 2);
            judgement = judgement.trim();
        }

        run30.setText("Judgement: " + judgement);
        run30.addBreak();

        String insight = " ";

        if (insightintact.isSelected() == true) {
            insight = insight + "Intact, ";
        }
        if (insightimpaired.isSelected() == true) {
            insight = insight + "Impaired -  ";
        }
        if (insightminimal.isSelected() == true) {
            insight = insight + "Minimal, ";
        }
        if (insightmoderate.isSelected() == true) {
            insight = insight + "Moderate, ";
        }
        if (insightsevere.isSelected() == true) {
            insight = insight + "Severe, ";
        }

        if (insight.length() > 2) {
            insight = insight.substring(0, insight.length() - 2);
            insight = insight.trim();
        }

        run30.setText("Insight: " + insight);
        run30.addBreak();
        run30.addBreak();

        run31.setUnderline(UnderlinePatterns.SINGLE);
        run31.setBold(true);
        run31.setText("Clinical Notes pertaining to MSE");
        run31.addBreak();
        run32.setBold(false);
        run32.setText(clinicalnotes.getText());
        run32.addBreak();
        run32.addBreak();

        run33.setBold(true);
        run33.setText("Diagnosis: ");
        run33.addBreak();

        run34.setBold(false);
        run34.setText("Axis I: " + axis1.getText());
        run34.addBreak();
        run34.setText("Axis II: " + axis2.getText());
        run34.addBreak();
        run34.setText("Axis III: " + axis3.getText());
        run34.addBreak();
        run34.setText("Axis IV: " + axis4.getText());
        run34.addBreak();

        String a4cb = " ";

        if (a4none.isSelected() == true) {
            a4cb = a4cb + "None, ";
        }
        if (a4primarysupportgroup.isSelected() == true) {
            a4cb = a4cb + "Primary Support Group, ";
        }
        if (a4partnerrelationalproblems.isSelected() == true) {
            a4cb = a4cb + "Partner Relational Problems, ";
        }
        if (a4parentchildrelationalproblems.isSelected() == true) {
            a4cb = a4cb + "Parent Child Relational Problems, ";
        }
        if (a4socialenvironment.isSelected() == true) {
            a4cb = a4cb + "Social Environment, ";
        }
        //a4occupation, a4economics, a4legalsystem, a4education, a4housing, 
        //a4noncompliancewithtreatment, a4other, axis5none;
        if (a4occupation.isSelected() == true) {
            a4cb = a4cb + "Occupation, ";
        }
        if (a4economics.isSelected() == true) {
            a4cb = a4cb + "Economics, ";
        }
        if (a4legalsystem.isSelected() == true) {
            a4cb = a4cb + "Legal System, ";
        }
        if (a4education.isSelected() == true) {
            a4cb = a4cb + "Education, ";
        }
        if (a4housing.isSelected() == true) {
            a4cb = a4cb + "Housing, ";
        }
        if (a4noncompliancewithtreatment.isSelected() == true) {
            a4cb = a4cb + "Noncompliance With Treatment, ";
        }
        if (a4other.isSelected() == true) {
            a4cb = a4cb + "Other, ";
        }

        if (a4cb.length() > 2) {
            a4cb = a4cb.substring(0, a4cb.length() - 2);
            a4cb = a4cb.trim();
        }

        run34.setText(a4cb);
        if (a4other.isSelected() == true) {
            run34.setText(" - " + axis4otherbox.getText());
        }
        run34.addBreak();

        run34.setText("Axis V: GAF " + "Current: " + axis5current.getText() + "  Highest in Past Year: "
                + axis5highestinpastyear.getText());
        if (axis5none.isSelected() == true) {
            run34.setText("   None");
        }
        run34.addBreak();
        run34.addBreak();

        run35.setUnderline(UnderlinePatterns.SINGLE);
        run35.setBold(true);
        run35.setText("Reccommendations and Plans");
        run35.addBreak();

        run36.setBold(false);
        run36.setText("Diagnosis and treatment options discussed with the patient? - ");
        if (treatmentplancheckbox1.isSelected() == true) {
            run36.setText("Yes");
        } else {
            run36.setText("No");
        }
        run36.addBreak();

        run36.addBreak();

        //run36.setText("Treatment Plan: " + treatmentplanbox1.getText());

        run36.setText("Treatment Plan: ");

        String[] tpLines = treatmentplanbox1.getText().split("\n");

        for (int i = 0; i < tpLines.length; i++) {
            run36.setText(tpLines[i]);
            run36.addBreak();
        }

        run36.addBreak();
        run36.addBreak();

        run36.setText(
                "Discussed that any overuse or abuse of prescription Benzodiazepines could result in patient being discharged from the practice. - ");
        if (treatmentplancheckbox2.isSelected() == true) {
            run36.setText("Yes");
        } else {
            run36.setText("No");
        }
        run36.addBreak();

        run36.setText("Nevada Prescription Monitoring Board Reviewed? - ");
        if (treatmentplancheckbox3.isSelected() == true) {
            run36.setText("Yes");
        } else {
            run36.setText("No");
        }
        run36.addBreak();
        run36.setText(treatmentplantextfield.getText());
        run36.addBreak();
        run36.addBreak();

        run37.setUnderline(UnderlinePatterns.SINGLE);
        run37.setItalic(true);
        run37.setText("Medication Prescribed");
        run37.addBreak();

        run38.setBold(false);
        run38.setText(treatmentplanbox2.getText());
        run38.addBreak();
        run38.addBreak();

        run39.setUnderline(UnderlinePatterns.SINGLE);
        run39.setBold(true);
        run39.setText("Side Effects Discussed: ");
        run39.addBreak();

        run40.setBold(false);

        String se = " ";

        if (riskforreboundhypertension.isSelected() == true) {
            se = se + "Risk For Rebound Hypertension, ";
        }
        if (complexsleeprelatedbehavior.isSelected() == true) {
            se = se + "Complex Sleep Related Behavior, ";
        }
        if (ssoftoxicity.isSelected() == true) {
            se = se + "S/S of Toxicity, ";
        }
        if (withdrawalsyndrome.isSelected() == true) {
            se = se + "Withdrawal Syndrome, ";
        }
        if (riskforaddiction.isSelected() == true) {
            se = se + "Risk for Addiction, ";
        }
        if (seizures.isSelected() == true) {
            se = se + "Seizures, ";
        }
        if (prolongedqtc.isSelected() == true) {
            se = se + "Prolonged QTC, ";
        }
        if (tardivedyskinesiadystonia.isSelected() == true) {
            se = se + "Tardive Dyskinesia/Dystonia, ";
        }
        if (acuteneurologicalse.isSelected() == true) {
            se = se + "Acute Neurological SE, ";
        }
        if (metabolicsyndrome.isSelected() == true) {
            se = se + "Metabolic Syndrome, ";
        }

        //decreasedeffectivenessofobc, teratogenicity, hyponatremia, hypothyroidism, rashsjsyndrome, 
        //weightgainloss, constipation, drymouth, increasedriskofsi, hyperprolactinemia, serotoninsyndrome, 
        //hairloss, hypotension, htn, dizziness, insomnia, sedation, sexual, gi;
        if (decreasedeffectivenessofobc.isSelected() == true) {
            se = se + "Decreased Effectiveness of OBC, ";
        }
        if (teratogenicity.isSelected() == true) {
            se = se + "Teratogenicity- ";
            se = se + sebox2.getText() + ", ";
        }
        if (hyponatremia.isSelected() == true) {
            se = se + "Hyponatremia, ";
        }
        if (hypothyroidism.isSelected() == true) {
            se = se + "Hypothyroidism, ";
        }
        if (rashsjsyndrome.isSelected() == true) {
            se = se + "Rash - SJ Syndrome- ";
            se = se + sebox1.getText() + ", ";
        }
        if (weightgainloss.isSelected() == true) {
            se = se + "Weight Gain/Loss, ";
        }
        if (constipation.isSelected() == true) {
            se = se + "Constipation, ";
        }
        if (drymouth.isSelected() == true) {
            se = se + "Dry Mouth, ";
        }
        if (increasedriskofsi.isSelected() == true) {
            se = se + "Increased Risk of SI, ";
        }
        if (hyperprolactinemia.isSelected() == true) {
            se = se + "Hyperprolactinemia, ";
        }
        if (serotoninsyndrome.isSelected() == true) {
            se = se + "Serotonin Syndrome, ";
        }
        if (hairloss.isSelected() == true) {
            se = se + "Hair Loss, ";
        }
        if (hypotension.isSelected() == true) {
            se = se + "Hypotension, ";
        }
        if (htn.isSelected() == true) {
            se = se + "HTN, ";
        }
        if (dizziness.isSelected() == true) {
            se = se + "Dizziness, ";
        }
        if (insomnia.isSelected() == true) {
            se = se + "Insomnia, ";
        }
        if (sedation.isSelected() == true) {
            se = se + "Sedation, ";
        }
        if (sexual.isSelected() == true) {
            se = se + "Sexual, ";
        }
        if (gi.isSelected() == true) {
            se = se + "GI, ";
        }

        if (se.length() > 2) {
            se = se.substring(0, se.length() - 2);
            se = se.trim();
        }

        run40.setText(se);
        run40.addBreak();
        run40.addBreak();

        run41.setUnderline(UnderlinePatterns.SINGLE);
        run41.setBold(true);
        run41.setText("Labs:");
        run41.addBreak();

        run42.setBold(false);

        String labs = " ";

        if (vitd.isSelected() == true) {
            labs = labs + "Vit D, ";
        }

        if (hivscreen.isSelected() == true) {
            labs = labs + "HIV Screen, ";
        }
        if (vitaminb12folicacid.isSelected() == true) {
            labs = labs + "Vitamin B12/Folic Acid, ";
        }

        if (ua.isSelected() == true) {
            labs = labs + "UA, ";
        }

        if (uds.isSelected() == true) {
            labs = labs + "UDS, ";
        }

        if (selectrolyte.isSelected() == true) {
            labs = labs + "S Electrolyte, ";
        }

        if (lithium.isSelected() == true) {
            labs = labs + "Lithium, ";
        }

        if (lamictallevel.isSelected() == true) {
            labs = labs + "Lamictal Level, ";
        }

        if (trileptallevel.isSelected() == true) {
            labs = labs + "Trileptal Level, ";
        }

        if (depakotelevel.isSelected() == true) {
            labs = labs + "Depakote Level, ";
        }

        if (bmp.isSelected() == true) {
            labs = labs + "BMP, ";
        }

        if (tft.isSelected() == true) {
            labs = labs + "TFT, ";
        }

        if (lft.isSelected() == true) {
            labs = labs + "LFT, ";
        }

        if (hgba1c.isSelected() == true) {
            labs = labs + "HGB A1C, ";
        }

        if (lipidprofile.isSelected() == true) {
            labs = labs + "Lipid Profile, ";
        }

        if (cmp.isSelected() == true) {
            labs = labs + "CMP, ";
        }

        if (cbc.isSelected() == true) {
            labs = labs + "CBC, ";
        }
        if (blanklabs.isSelected() == true) {
            labs = labs + labstextfield.getText() + ", ";
        }

        if (labs.length() > 2) {
            labs = labs.substring(0, labs.length() - 2);
            labs = labs.trim();
        }

        run42.setText(labs);

        run42.addBreak();
        run42.addBreak();

        run42Bold.setBold(true);
        run42Bold.setText(
                "Verbal informed consent obtained from patient for trial of " + ebox1.getText() + ": ");

        if (yes1.isSelected() == true) {
            run42Bold.setText("Yes");
        }
        if (no1.isSelected() == true) {
            run42Bold.setText("No");
        }

        run42Bold.addBreak();

        run42Bold.setText("Risks/benefits of prescribed medications discussed with patient: ");

        if (yes2.isSelected() == true) {
            run42Bold.setText("Yes");
        }
        if (no2.isSelected()) {
            run42Bold.setText("No");
        }

        run42Bold.addBreak();
        run42Bold.addBreak();

        String end = "", end2 = "";

        if (riskofsuicidelow.isSelected() == true) {
            end = end + "Low, ";
        }

        if (riskofsuicidemoderate.isSelected() == true) {
            end = end + "Moderate, ";
        }

        if (riskofsuicidehigh.isSelected() == true) {
            end = end + "High, ";
        }

        if (riskofsuicidemodifiableriskfactorsaddressed.isSelected() == true) {
            end = end + "Modifiable Risk Factors Addressed, ";
        }

        if (dangertootherslow.isSelected() == true) {
            end2 = end2 + "Low, ";
        }

        if (dangertoothersmoderate.isSelected() == true) {
            end2 = end2 + "Moderate, ";
        }

        if (dangertoothershigh.isSelected() == true) {
            end2 = end2 + "High, ";
        }

        if (dangertoothersmodifiableriskfactorsaddressed.isSelected() == true) {
            end2 = end2 + "Modifiable Risk Factors Addressed, ";
        }

        if (end.length() > 2) {
            end = end.substring(0, end.length() - 2);
            end = end.trim();
        }

        if (end2.length() > 2) {
            end2 = end2.substring(0, end2.length() - 2);
            end2 = end2.trim();
        }

        run42Bold.setText("Risk of Suicide/Self-Harm: " + end);
        run42Bold.addBreak();
        run42Bold.setText("Danger to others: " + end2);
        run42Bold.addBreak();
        run42Bold.addBreak();
        run42Bold.addBreak();
        run42Bold.addBreak();

        if (partnerSigned == true) {
            if (businesscardprovided.isSelected()) {
                runPre43.setText("Business Card Provided: Yes");
                runPre43.addBreak();
            } else {
                runPre43.setText("Business Card Provided: No");
                runPre43.addBreak();
            }

            if (discussedassistant.isSelected()) {
                if (who.getText() != null || who.getText() != "" || who.getText() != " ") {
                    runPre43.setText("Discussed with [" + who.getText()
                            + "] accompanying the patient that I am a physician assistant");
                    runPre43.addBreak();
                } else {
                    runPre43.setText("Discussed with patient that I am a physician assistant");
                    runPre43.addBreak();
                }

            } else {

            }

            //runPre43.addBreak();
            //runPre43.addBreak();

            run43.setBold(true);
            run43.setText(
                    "Signature: This Document Has Been Digitally Signed By Izabella Ostolski, PA-C            Date: ");
            DateFormat dateFormat = new SimpleDateFormat("MM-dd-yyyy");
            Date date = new Date();
            String alpha = dateFormat.format(date);
            run43.setText(alpha);
        }

        if (dccSigned == true) {
            run44.addBreak();
            run44.addBreak();
            run44.addBreak();
            run44.setBold(false);
            run44.setItalic(true);
            //run44.setTextPosition(20);
            run44.setText("I have reviewed and discussed the case. I agree with the current treatment plan.");
            run44.addBreak();
            //run44.setText(signaturenotes.getText());
            //run44.addBreak();
            run46.setBold(true);
            run46.setText(
                    "Signature: This Document Has Been Digitally Signed By David Zhvikov MD           Date: ");
            DateFormat dateFormat = new SimpleDateFormat("MM-dd-yyyy");
            Date date = new Date();
            String alpha = dateFormat.format(date);
            run46.setText(alpha);

            try {
                //code prac'k wrkoxx
                /*FileInputStream is = new FileInputStream("C:/Users/Quiggy/Desktop/javascript-based psych forms/sig.bmp");
                //doc.addPictureData(IOUtils.toByteArray(is), doc.PICTURE_TYPE_BMP)
                        
                XWPFParagraph title = doc.createParagraph();    
                XWPFRun imageRun = title.createRun();
                imageRun.setText("Fig.1 A Natural Scene");
                imageRun.setBold(true);
                title.setAlignment(ParagraphAlignment.CENTER);
                imageRun.addPicture(is, XWPFDocument.PICTURE_TYPE_BMP, "sig.bmp", 300, 200);*/

                //String picId = "C:/Users/Quiggy/Desktop/javascript-based psych forms/sig1.png";
                //doc.addPictureData(new FileInputStream("C:/Users/Quiggy/Desktop/javascript-based psych forms/sig1.png"), XWPFDocument.PICTURE_TYPE_PNG);  
                //doc.add

                //doc.createPicture(picId, doc.getNextPicNameNumber(XWPFDocument.PICTURE_TYPE_PNG), 200, 150);  

                //String imgFile = "C:/Users/Quiggy/Desktop/javascript-based psych forms/sig1.png";
                //FileInputStream is = new FileInputStream(picId);
                //run43.addBreak();
                //run43.addPicture(is, XWPFDocument.PICTURE_TYPE_PNG, picId, 200, 300); // 200x200 pixels
                //run43.addPicture(is, XWPFDocument.PICTURE_TYPE_JPEG, null, 0, 100);
                //run43.add
                //is.close();
            } catch (Exception anException) {
                //System.out.println(anException);

                //add the selected ones to the arraylist, and remove these from the second array list. print the first arraylist in bold, and then print the second arraylist unbolded.

            }
        }

        //Find: laundry bags(3), black pants (cargos), 2nd scientific calculator, iPAD mini CHARGER

        //Daskin NOW 36C
        //Masi pants
        //google jacket model number

        //dcc's old phone (with the lb, lx, & a lockscreen pic:)

        //"Enter the Physician's Assistant Passcode OR the Physician's Passcode to enable/unlock editing"

        //general-access password: dolphin-->dolphin92
        //Isabella's Password: siberianplatypus
        //Your Password: protooncogene-->protooncogene6

        //the "go-to" choice for disorganized writers/authors

        //also make an xml and php -based web chat application to complement f f
        //code this in visual studio with ASP.NET
        //that IBM? tutorial with the "free website" thing

        /*if(single.isSelected())
        {   
        run8.setItalic(true);
        run8.setBold(true);
        run8.setText("      Single");
        }
        else
        {
        run8.setItalic(false);
        run8.setBold(false);
        run8.setText("      Single");
        }
                
        if(engaged.isSelected())
        {
        run9.setItalic(true);
        run9.setBold(true);
        run9.setText("      Engaged");
        }
        else
        {
        run9.setBold(false);
        run9.setItalic(false);
        run9.setText("      Engaged");
        }
        //but not (both AT THE SAME TIME/ARE TRUE/HOLD)
        if(married.isSelected())
        {
        run10.setItalic(true);
        run10.setBold(true);
        run10.setText("     Married");
        }//nightmares, when they occurred, were less terrifying, somehow.
        else
        {
        run10.setItalic(false);
        run10.setBold(false);
        run10.setText("     Married");
        }//is fundamentally incomprehensible from the level of c at which you've considered it
        //because NEITHER are true
        //there is no
        if(seperated.isSelected())
        {
        run11.setItalic(true);
        run11.setBold(true);
        run11.setText("     Seperated");
        }
        else
        {
        run11.setItalic(false);
        run11.setBold(false);
        run11.setText("     Seperated");
        }
                
        if(divorced.isSelected())
        {
        run12.setItalic(true);
        run12.setBold(true);
        run12.setText("     Divorced");
        }//there is only choice...choice is the only thing left to identify/indicate [that] individuality [exists indeed]
        else
        {
        run12.setItalic(false);
        run12.setBold(false);
        run12.setText("     Divorced");
        }
                
        if(commonlawspouse.isSelected())
        {
        run13.setItalic(true);
        run13.setBold(true);
        run13.setText("     Common Law Spouse");
        }
        else
        {
        run13.setItalic(false);
        run13.setBold(false);
        run13.setText("     Common Law Spouse");
        }
                
        if(cohabiting.isSelected())
        {
        run14.setItalic(true);
        run14.setBold(true);
        run14.setText("     Cohabiting");
        }
        else
        {
        run14.setItalic(false);
        run14.setBold(false);
        run14.setText("     Cohabiting");
        }*/

        //run is created here if(divorced.isSelected == "true"){run.setBold(true); run.setText("divorced");} else {run.setBold(false); run.setText("divorced")}
        //single, engaged, married, seperated, divorced, commonlawspouse, cohabiting; 

        //printDOB(doc);

        //one (not-so-great) solution to the numerous runs problem: list everything to be bolded first (array 1- run 1), and then everything else (array 2- run 2)

        //doc.createParagraph().createRun().setText("           " + paragraphs.get(c).toString());
        //doc.createParagraph().createRun().addBreak();

        doc.write(outstream);
        outstream.close();

        //paraRun.setText(Primary.getText());

        //doc.createParagraph().createRun().addBreak();                 //inserts a line break
        //doc.createParagraph().createRun().setText("blah");            //creates another paragraph

        /*for(int c = 0; c < paragraphs.size(); c++)
        {
             /*XWPFParagraph p = doc.createParagraph(); //Paragraph
             XWPFRun run = p.createRun();  //Where the text will be written from
             run.setText("\t");*/

        /*            XWPFParagraph p = doc.createParagraph(); //Paragraph
            XWPFRun run = p.createRun();  //Where the text will be written from
                    
            String currentParagraph = paragraphs.get(c).toString();
            for(int d = 0; d < currentParagraph.length(); d++)
            {
        if(currentParagraph.charAt(d) == '@')
        {
            currentParagraph = currentParagraph.substring(d+1, currentParagraph.length() - 2);
                    
            run.setBold(true);
                    
                    
        }
        else
        {
            //run.setBold(false);
        }
            }
                    
            run.setText("           " + currentParagraph);
            //doc.createParagraph().createRun().setText("           " + paragraphs.get(c).toString());
            //doc.createParagraph().createRun().addBreak();
        }
                
                
        doc.write(outstream);
        outstream.close();
        //JOptionPane.showConfirmDialog(null, "Are you sure you want to create the word document?");
                
        //Makes the chapter titles bold and removes the "@" & "-"
                
        JOptionPane.showMessageDialog(null, "Document Successfully Created. The program/AA will now exit");
        System.exit(0);*/

    } catch (Exception e) {

    }
}

From source file:pe.gob.onpe.rae.controller.registro.registroController.java

@RequestMapping(value = "generateFVDoc/{codExpediente}", method = RequestMethod.GET)
public void generateFVDoc(HttpServletRequest request, @PathVariable("codExpediente") int codExpediente,
        HttpServletResponse response) {/*www. ja  v  a 2s  .co m*/
    try {
        ServletContext sc = request.getSession().getServletContext();

        Expediente expediente = new Expediente(codExpediente);
        expediente = expedienteDAO.find(expediente);

        Ambito amb = new Ambito(expediente.getAmbito().getId());
        amb = ambitoDAO.find(amb);

        int totalElectoresRemitidos = expedientePadronDAO.getCountByExpediente(expediente);
        int totalElectoresIncorporados = expedientePadronDAO.getCountByExpedienteAndEstado(expediente,
                Parametros.ESTADO_ELECTOR_ACTIVO);

        JsonParser jsonParser = new JsonParser();
        JsonObject jsonObject = (JsonObject) jsonParser.parse(amb.getInformacion());
        String nombre = jsonObject.get("nombres").toString() + " "
                + jsonObject.get("apellidoPaterno").toString() + " "
                + jsonObject.get("apellidoMaterno").toString();

        InputStream is = registroController.class.getResourceAsStream("/ejemplo.docx");
        XWPFDocument document = new XWPFDocument(is);

        XWPFHeaderFooterPolicy policy = document.getHeaderFooterPolicy();
        if (policy == null) {
            CTSectPr sectPr = document.getDocument().getBody().addNewSectPr();
            policy = new XWPFHeaderFooterPolicy(document, sectPr);
        }

        if (policy.getDefaultHeader() == null && policy.getFirstPageHeader() == null
                && policy.getDefaultFooter() == null) {
            XWPFFooter footerD = policy.getFooter(1);// createFooter(policy.DEFAULT);
            XWPFRun run = footerD.getParagraphs().get(0).createRun();
            run.setText("usuario");
            XWPFParagraph paragraph = footerD.createParagraph();
            paragraph.setAlignment(ParagraphAlignment.DISTRIBUTE);
            run = paragraph.createRun();
            run.setFontFamily("Arial");
            run.setFontSize(8);
            run.setText(
                    "Jr.Washington N 1894, Cercado de Lima. Central Telefonica: 417-0630 www.onpe.gob.pe informes@onpe.gob.pe");

        }

        XWPFParagraph paragraph = document.createParagraph();

        XWPFRun run = paragraph.createRun();
        run.setFontSize(11);
        run.setFontFamily("Arial");
        run.setText("Lima,");
        run.addBreak();

        paragraph = document.createParagraph();
        run = paragraph.createRun();
        run.setFontSize(11);
        run.setFontFamily("Arial");
        run.setBold(true);
        run.setText("OFICIO N       -2016-GPP/ONPE");
        run.setUnderline(UnderlinePatterns.SINGLE);
        run.addBreak();

        paragraph = document.createParagraph();
        run = paragraph.createRun();
        run.setFontSize(11);
        run.setFontFamily("Arial");
        run.setText("Seor");

        XWPFRun run1 = paragraph.createRun();
        run1.setFontSize(11);
        run1.setFontFamily("Arial");
        run1.setText(nombre.replace("\"", ""));
        run1.setBold(true);
        run1.addBreak();

        XWPFRun run2 = paragraph.createRun();
        run2.setFontSize(11);
        run2.setFontFamily("Arial");
        run2.setText(jsonObject.get("cargo").toString().replace("\"", ""));
        run2.addBreak();
        run2.setText("Centro Poblado " + amb.getNombreAmbito());
        run2.addBreak();
        run2.setText("Av. 28 de Julio S/N Centro Cvico Huacrachuco - Municipalidad Provincial de "
                + amb.getProvincia());
        run2.addBreak();
        run2.setText(amb.getDepartamento() + " - " + amb.getProvincia() + " - " + amb.getDistrito());
        run2.addBreak();

        run2 = paragraph.createRun();
        run2.setFontSize(11);
        run2.setFontFamily("Arial");
        run2.setUnderline(UnderlinePatterns.WORDS);
        run2.setText("Presente");

        run2 = paragraph.createRun();
        run2.setFontSize(11);
        run2.setFontFamily("Arial");
        run2.setText(".-");

        paragraph = document.createParagraph();
        run.addBreak();
        run = paragraph.createRun();
        run.setFontSize(11);
        run.setFontFamily("Arial");
        run.addBreak();
        run.setText("Asunto");
        run.addTab();
        run.addTab();
        run.setText(": SOLICITUD DE CREACIN DE MESA DE SUFRAGIO.");
        run.addBreak();

        paragraph = document.createParagraph();
        run = paragraph.createRun();
        run.setFontSize(11);
        run.setFontFamily("Arial");
        run.setText("Referencia");
        run.addTab();
        run.setText(": OFICIO N 087-2016/M-CP.CHOCOBAMBA (16AGO2016) - Exp. " + expediente.getExpediente());
        run.addBreak();

        paragraph = document.createParagraph();
        paragraph.setAlignment(ParagraphAlignment.THAI_DISTRIBUTE);
        run = paragraph.createRun();
        run.setFontSize(11);
        run.setFontFamily("Arial");
        run.setText(
                "Me dirijo a usted con relacin al documento de la referencia con la finalidad de hacer de su "
                        + "conocimiento que se ha cumplido con todos los requisitos que dan inicio al trmite de "
                        + "instalacin de mesas de sufragio en el Centro Poblado " + amb.getNombreAmbito()
                        + ", distrito " + amb.getDistrito() + ", " + "provincia " + amb.getProvincia()
                        + ", departamento " + amb.getDepartamento() + ".");
        paragraph = document.createParagraph();
        paragraph.setAlignment(ParagraphAlignment.THAI_DISTRIBUTE);
        run = paragraph.createRun();
        run.setFontSize(11);
        run.setFontFamily("Arial");
        run.addBreak();
        run.setText("Al respecto, el mencionado expediente contiene un listado de electores que solicitan ser "
                + "parte de la mesa de sufragio de la localidad " + amb.getNombreAmbito()
                + ", el cual, luego de la validacin " + "realizada, se informa que podrn ser incorporados "
                + totalElectoresIncorporados + " electores del total de " + totalElectoresRemitidos
                + " registros "
                + "de electores remitidos. Se adjunta un cuadro resumen con las observaciones mencionadas.");
        paragraph = document.createParagraph();
        paragraph.setAlignment(ParagraphAlignment.THAI_DISTRIBUTE);
        run = paragraph.createRun();
        run.setFontSize(11);
        run.setFontFamily("Arial");
        run.addBreak();
        run.setText(
                "Asimismo, se programar un viaje para la verificacin de rutas, tiempos y servicios de la "
                        + "localidad, la cual se coordinar previamente con las autoridades del centro poblado a fin de "
                        + "programarla adecuadamente; luego de lo cual se emitir un informe de respuesta al "
                        + "resultado de la solicitud, que de ser positivo, conllevara a la instalacin de mesas de sufragio "
                        + "en el centro poblado en mencin, con miras a las ");
        run = paragraph.createRun();
        run.setFontSize(11);
        run.setFontFamily("Arial");
        run.setBold(true);
        run.setText("Elecciones Regionales y Municipales de 2018.");
        paragraph = document.createParagraph();
        paragraph.setAlignment(ParagraphAlignment.THAI_DISTRIBUTE);
        run = paragraph.createRun();
        run.setFontSize(11);
        run.setFontFamily("Arial");
        run.addBreak();
        run.setText("Finalmente, de requerir mayor informacin, agradeceremos se comunique con nosotros al "
                + "telefono 417-0630 anexo 8484 o al 8481.");
        paragraph = document.createParagraph();
        paragraph.setAlignment(ParagraphAlignment.THAI_DISTRIBUTE);
        run = paragraph.createRun();
        run.setFontSize(11);
        run.setFontFamily("Arial");
        run.addBreak();
        run.setText("Sin otro particular.");

        paragraph = document.createParagraph();
        paragraph.setAlignment(ParagraphAlignment.THAI_DISTRIBUTE);
        run = paragraph.createRun();
        run.setFontSize(11);
        run.setFontFamily("Arial");
        run.addBreak();
        run.addBreak();
        run.setText("Atentamente,");
        response.setContentType("application/vnd.openxmlformats-officedocument.wordprocessingml.document");
        document.write(response.getOutputStream());
    } catch (Exception ex) {
        Logger.getLogger(registroController.class.getName()).log(Level.SEVERE, null, ex);
    }
}

From source file:Utils.FileHandler.java

private void boldText(XWPFParagraph paragraph, String text, boolean underline) {
    XWPFRun r = paragraph.createRun();/*from  w  ww .j  av  a  2  s . c  o m*/
    r.setText(text);
    r.setBold(true);

    if (underline) {
        r.setUnderline(UnderlinePatterns.SINGLE);
    }
}