Example usage for com.lowagie.text Chunk Chunk

List of usage examples for com.lowagie.text Chunk Chunk

Introduction

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

Prototype

public Chunk(DrawInterface separator) 

Source Link

Document

Creates a separator Chunk.

Usage

From source file:org.oscarehr.casemgmt.print.OscarChartPrinter.java

License:Open Source License

public void printDiseaseRegistry() throws DocumentException {
    DxresearchDAO dxDao = (DxresearchDAO) SpringUtils.getBean("DxresearchDAO");
    IssueDAO issueDao = (IssueDAO) SpringUtils.getBean("IssueDAO");
    SimpleDateFormat formatter = new SimpleDateFormat("yyyy-MM-dd");

    List<Dxresearch> dxs = dxDao.getDxResearchItemsByPatient(demographic.getDemographicNo());

    if (dxs.size() == 0) {
        return;/*from w  w w  .j a va2s  . c o m*/
    }
    Paragraph p = new Paragraph();
    Font obsfont = new Font(bf, FONTSIZE, Font.UNDERLINE);
    Phrase phrase = new Phrase(LEADING, "", obsfont);
    p.setAlignment(Paragraph.ALIGN_LEFT);
    phrase.add("Disease Registry");
    p.add(phrase);
    document.add(p);

    for (Dxresearch dx : dxs) {
        String codingSystem = dx.getCodingSystem();
        String code = dx.getDxresearchCode();
        Date startDate = dx.getStartDate();
        char status = dx.getStatus();

        Issue issue = issueDao.findIssueByTypeAndCode(codingSystem, code);

        p = new Paragraph();
        phrase = new Phrase(LEADING, "", getFont());
        Chunk chunk = new Chunk("Start Date:" + formatter.format(startDate) + "\n");
        phrase.add(chunk);
        if (issue != null) {
            chunk = new Chunk("Issue:" + issue.getDescription() + "\n");
            phrase.add(chunk);
        } else {
            chunk = new Chunk("Issue: <Unknown>" + "\n");
            phrase.add(chunk);
        }
        chunk = new Chunk("Status:" + status + "\n\n");
        phrase.add(chunk);

        p.add(phrase);
        getDocument().add(p);
    }

}

From source file:org.oscarehr.casemgmt.print.OscarChartPrinter.java

License:Open Source License

public void printCurrentAdmissions() throws DocumentException {
    AdmissionDao admissionDao = (AdmissionDao) SpringUtils.getBean("admissionDao");
    ProgramDao programDao = (ProgramDao) SpringUtils.getBean("programDao");

    List<Admission> admissions = admissionDao.getCurrentAdmissions(demographic.getDemographicNo());

    if (admissions.size() == 0) {
        return;//from   w  ww. j a  v  a  2s  .c o m
    }
    Paragraph p = new Paragraph();
    Font obsfont = new Font(bf, FONTSIZE, Font.UNDERLINE);
    Phrase phrase = new Phrase(LEADING, "", obsfont);
    p.setAlignment(Paragraph.ALIGN_LEFT);
    phrase.add("Current Admissions");
    p.add(phrase);
    document.add(p);

    for (Admission admission : admissions) {
        String admissionDate = admission.getAdmissionDate("yyyy-MM-dd");
        String admissionNotes = admission.getAdmissionNotes();
        String programName = programDao.getProgramName(admission.getProgramId());
        String programType = admission.getProgramType();
        String providerName = providerDao.getProvider(admission.getProviderNo()).getFormattedName();

        p = new Paragraph();
        phrase = new Phrase(LEADING, "", getFont());
        Chunk chunk = new Chunk("Summary:" + programName + "(" + programType + ")" + " by " + providerName
                + " on " + admissionDate + "\n");
        phrase.add(chunk);
        chunk = new Chunk("Admission Notes:" + admissionNotes + "\n\n");
        phrase.add(chunk);

        p.add(phrase);
        getDocument().add(p);
    }

}

From source file:org.oscarehr.casemgmt.print.OscarChartPrinter.java

License:Open Source License

public void printPastAdmissions() throws DocumentException {
    AdmissionDao admissionDao = (AdmissionDao) SpringUtils.getBean("admissionDao");
    ProgramDao programDao = (ProgramDao) SpringUtils.getBean("programDao");
    SimpleDateFormat formatter = new SimpleDateFormat("yyyy-MM-dd");

    List<Admission> admissions = admissionDao.getAdmissions(demographic.getDemographicNo());
    admissions = filterOutCurrentAdmissions(admissions);

    if (admissions.size() == 0) {
        return;//from w w w .j  ava  2s . c o m
    }
    Paragraph p = new Paragraph();
    Font obsfont = new Font(bf, FONTSIZE, Font.UNDERLINE);
    Phrase phrase = new Phrase(LEADING, "", obsfont);
    p.setAlignment(Paragraph.ALIGN_LEFT);
    phrase.add("Past Admissions");
    p.add(phrase);
    document.add(p);

    for (Admission admission : admissions) {
        String admissionDate = admission.getAdmissionDate("yyyy-MM-dd");
        String admissionNotes = admission.getAdmissionNotes();
        String programName = programDao.getProgramName(admission.getProgramId());
        String programType = admission.getProgramType();
        String providerName = providerDao.getProvider(admission.getProviderNo()).getFormattedName();
        String dischargeDate = formatter.format(admission.getDischargeDate());
        String dischargeNotes = admission.getDischargeNotes();

        p = new Paragraph();
        phrase = new Phrase(LEADING, "", getFont());
        Chunk chunk = new Chunk("Summary:" + programName + "(" + programType + ")" + " by " + providerName
                + " on " + admissionDate + "\n");
        phrase.add(chunk);
        chunk = new Chunk("Admission Notes:" + admissionNotes + "\n\n");
        phrase.add(chunk);
        chunk = new Chunk("Discharged on " + dischargeDate + ", Notes:" + dischargeNotes + "\n\n");
        phrase.add(chunk);

        p.add(phrase);
        getDocument().add(p);
    }

}

From source file:org.oscarehr.casemgmt.print.OscarChartPrinter.java

License:Open Source License

public void printCurrentIssues() throws DocumentException {
    CaseManagementIssueDAO cmIssueDao = (CaseManagementIssueDAO) SpringUtils.getBean("CaseManagementIssueDAO");

    List<CaseManagementIssue> issues = cmIssueDao
            .getIssuesByDemographic(String.valueOf(demographic.getDemographicNo()));

    Paragraph p = new Paragraph();
    Font obsfont = new Font(bf, FONTSIZE, Font.UNDERLINE);
    Phrase phrase = new Phrase(LEADING, "", obsfont);
    p.setAlignment(Paragraph.ALIGN_LEFT);
    phrase.add("Current Issues");
    p.add(phrase);//from   w  w  w  .j  a  va2s  .c om
    document.add(p);

    for (CaseManagementIssue issue : issues) {
        String type = issue.getType();
        String description = issue.getIssue().getDescription();

        p = new Paragraph();
        phrase = new Phrase(LEADING, "", getFont());
        Chunk chunk = new Chunk(description + "\n\n");
        phrase.add(chunk);

        p.add(phrase);
        getDocument().add(p);
    }

}

From source file:org.oscarehr.common.service.PdfRecordPrinter.java

License:Open Source License

public void printNotes(Collection<CaseManagementNote> notes, boolean compact) throws DocumentException {

    CaseManagementNote note;//from www.  j a  va2  s .  c o  m
    Font obsfont = new Font(bf, FONTSIZE, Font.UNDERLINE);
    Paragraph p;
    Phrase phrase;
    Chunk chunk;

    //if( newPage )
    //     document.newPage();
    // else
    //     newPage = true;

    //Print notes
    Iterator<CaseManagementNote> notesIter = notes.iterator();
    while (notesIter.hasNext()) {
        note = notesIter.next();
        p = new Paragraph();
        //p.setSpacingBefore(font.leading(LINESPACING)*2f);
        phrase = new Phrase(LEADING, "", font);

        if (compact) {
            phrase.add(new Chunk(formatter.format(note.getUpdate_date()) + ":"));
        } else {
            chunk = new Chunk("Impression/Plan: (" + formatter.format(note.getUpdate_date()) + ")\n", obsfont);
            phrase.add(chunk);
        }
        if (compact) {
            phrase.add(note.getNote() + "\n");
        } else {
            phrase.add(note.getNote() + "\n\n");
        }
        p.add(phrase);
        document.add(p);
    }
}

From source file:org.pz.platypus.plugin.pdf.commands.PdfBulletListPlainStartWithOptions.java

License:Open Source License

/**
 * Look up the symbol in the symbol table and get the Unicode value and any symbol font info.
 * //from   w  ww  . ja  va 2 s. c  o  m
 * @param param value passed with the "bullet:" parameter
 * @param pdd the PDF document data
 * @param tok the token for the whole bullet list command
 * @return Chunk containing for the bullet symbol
 */
Chunk lookupBulletSymbol(final String param, final Token tok, final PdfData pdd) {
    assert (pdd != null);
    assert (tok != null);
    assert (param != null);

    GDD gdd = pdd.getGdd();

    StringBuilder sb = new StringBuilder(10);
    int i = 0;
    while (i < param.length() && param.charAt(i) != '}' && param.charAt(i) != ']')
        sb.append(param.charAt(i++));

    if (param.charAt(i) != '}') {
        errorUnclosedOption(gdd, tok);
        return (new Chunk(DefaultValues.BULLET));
    }

    String root = "[" + sb.toString() + "]";
    ICommand value = gdd.getCommandTable().getCommand(root);
    if (!(value instanceof Symbol)) {
        errorBulletSymbolNotFound(gdd, tok);
    }

    // get the entry for this symbol. Should be a string that specifies the char value
    // as a Unicode value, with an optional font name.
    PdfSymbol processor = (PdfSymbol) pdd.getCommandTable().getCommand(root);
    String symEquivalent = processor.getSymEquivalent();

    // get the Unicode value and font name, if any
    String font = processor.getFontName(symEquivalent, gdd, tok);
    String sym = processor.getCharCode(symEquivalent);

    if (font == null || font.isEmpty()) {
        return (new Chunk(sym));
    } else {
        PdfFont newFont = new PdfFont(pdd, font, pdd.getFont());
        FontSelector fs = new FontSelector();
        fs.addFont(newFont.getItextFont());
        Chunk chk = new Chunk(sym, newFont.getItextFont());
        return (chk);
    }
}

From source file:org.pz.platypus.plugin.pdf.commands.PdfBulletListPlainStartWithOptions.java

License:Open Source License

/**
 * extracts a literal that serves as the bullet character (e.g. -, >, ->, etc.)
 *
 * @param param parameter portion that specifies the bullet character
 * @return bullet character as a string.
 *///from  w  ww. j ava 2 s .c o m
Chunk extractBulletSymbolFromParam(final String param) {
    StringBuilder sb = new StringBuilder(10);
    int i = 0;
    while (i < param.length() && param.charAt(i) != '|' && param.charAt(i) != ']')
        sb.append(param.charAt(i++));
    return new Chunk(sb.toString());
}

From source file:org.pz.platypus.plugin.pdf.commands.PdfCodeOff.java

License:Open Source License

public int process(final IOutputContext context, final Token tok, final int tokNum) {
    if (context == null || tok == null) {
        throw new IllegalArgumentException();
    }/* w w w. j  a  v a  2s  .com*/

    PdfData pdd = (PdfData) context;
    if (!pdd.inCodeSection()) {
        return 0; //not currently in a code section
    }

    int addlTokensToSkip = 0;
    TokenList tokens = pdd.getGdd().getInputTokens();

    // must output the paragraph manually for listing, because the [-code] command after a
    // listing implies an end of a paragraph and adds a CR/LF to the listing.
    if (pdd.isInCodeListing()) {
        pdd.setInCodeListing(false);
        PdfOutfile outfile = pdd.getOutfile();
        if (outfile != null) {
            Paragraph para = outfile.getItPara();
            if (para != null && para.size() > 0) {
                if (nextTokenIsEol(tokens, tokNum) && !justBeforeEndOfParagraph(tokens, tokNum)) {
                    para.add(new Chunk(Chunk.NEWLINE));
                    addlTokensToSkip += 1;
                }
                //                    outfile.addParagraph( para, outfile.getItColumn() );
                //                    outfile.setItPara( new Paragraph( pdd.getLeading() ));
            }
        }
    }

    PdfRestoreFormat.restore(pdd, tok.getSource());
    pdd.setInCodeSection(false, tok.getSource());
    return (addlTokensToSkip);
}

From source file:org.pz.platypus.plugin.pdf.commands.PdfCodeWithOptions.java

License:Open Source License

/**
 * Emits a CR or CR/LF to the PDF outfile.
 * @param outfile to which newLine is written
 *///  w ww  .j ava 2 s.co  m
private void emitNewLine(final PdfOutfile outfile) {
    Paragraph para = outfile.getItPara();
    para.add(new Chunk(Chunk.NEWLINE));
}

From source file:org.pz.platypus.plugin.pdf.commands.PdfEol.java

License:Open Source License

public int process(final IOutputContext context, final Token tok, final int tokNum) {
    if (context == null) {
        throw new IllegalArgumentException();
    }/*from w w w  .j  a  va  2s .c o  m*/

    PdfData pdf = (PdfData) context;
    PdfOutfile outfile = pdf.getOutfile();
    TokenList tl = pdf.getGdd().getInputTokens();
    Token nextTok = tl.getNextToken(tokNum);

    // if we're at the last input token, then do nothing
    if (nextTok == null) {
        return 0;
    }

    // if the [cr] occurs at the end of a line that consisted entirely of commands,
    // then ignore it (so that the following text does not have an unwanted leading character).
    // so with a line consisting entirely of [fsize:12pt] simply changes font size, but
    // adds no character to the ouput stream
    if (!tl.lineSoFarEmitsText(tokNum)) {
        return 0;
    }

    // if EolTreatment = hard, issue CR/LF
    if (!new EolTreatment().isSoft(pdf.getEolTreatment())) {
        Paragraph para = outfile.getItPara();
        if (para != null) {
            para.add(new Chunk(Chunk.NEWLINE));
        }
        return 0;
    }

    outfile.emitText(" ");
    return 0;
}