Example usage for com.lowagie.text Font SYMBOL

List of usage examples for com.lowagie.text Font SYMBOL

Introduction

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

Prototype

int SYMBOL

To view the source code for com.lowagie.text Font SYMBOL.

Click Source Link

Document

a possible value of a font family.

Usage

From source file:com.stratelia.webactiv.almanach.control.AlmanachPdfGenerator.java

License:Open Source License

private static void generateAlmanach(Chapter chapter, AlmanachSessionController almanach,
        List<DisplayableEventOccurrence> occurrences, String mode) throws AlmanachException {

    boolean monthScope = AlmanachPdfGenerator.PDF_MONTH_EVENTSONLY.equals(mode)
            || AlmanachPdfGenerator.PDF_MONTH_ALLDAYS.equals(mode);
    boolean yearScope = AlmanachPdfGenerator.PDF_YEAR_EVENTSONLY.equals(mode);

    int currentDay = -1;
    Calendar calendar = Calendar.getInstance();
    calendar.setTime(almanach.getCurrentDay());
    calendar.set(Calendar.DAY_OF_MONTH, 1);
    int currentMonth = calendar.get(Calendar.MONTH);
    int currentYear = calendar.get(Calendar.YEAR);

    if (yearScope) {
        // start from begin of current year
        calendar.set(Calendar.MONTH, 0);
    }/* ww  w.  j a  va  2s  . c  om*/

    // for each day of the current month
    while ((monthScope && currentMonth == calendar.get(Calendar.MONTH))
            || (yearScope && currentYear == calendar.get(Calendar.YEAR))) {
        Section section = null;
        if (AlmanachPdfGenerator.PDF_MONTH_ALLDAYS.equals(mode)) {
            section = chapter.addSection(generateParagraph(calendar, almanach), 0);
        }

        Font titleTextFont = new Font(Font.BOLD, 12, Font.SYMBOL, new Color(0, 0, 0));

        // get the events of the current day
        for (DisplayableEventOccurrence occurrence : occurrences) {
            EventDetail event = occurrence.getEventDetail();
            String theDay = DateUtil.date2SQLDate(calendar.getTime());
            String startDay = DateUtil.date2SQLDate(occurrence.getStartDate().asDate());
            String startHour = event.getStartHour();
            String endHour = event.getEndHour();

            if (startDay.compareTo(theDay) > 0) {
                continue;
            }

            String endDay = startDay;
            if (event.getEndDate() != null) {
                endDay = DateUtil.date2SQLDate(occurrence.getEndDate().asDate());
            }

            if (endDay.compareTo(theDay) < 0) {
                continue;
            }

            if (calendar.get(Calendar.DAY_OF_MONTH) != currentDay) {
                if (AlmanachPdfGenerator.PDF_MONTH_EVENTSONLY.equals(mode)
                        || AlmanachPdfGenerator.PDF_YEAR_EVENTSONLY.equals(mode)) {
                    section = chapter.addSection(generateParagraph(calendar, almanach), 0);
                }
                currentDay = calendar.get(Calendar.DAY_OF_MONTH);
            }

            Font textFont;
            if (event.getPriority() == 0) {
                textFont = new Font(Font.HELVETICA, 10, Font.NORMAL, new Color(0, 0, 0));
            } else {
                textFont = new Font(Font.HELVETICA, 10, Font.BOLD, new Color(0, 0, 0));
            }

            String eventTitle = event.getTitle();
            if (startDay.compareTo(theDay) == 0 && startHour != null && startHour.length() != 0) {
                eventTitle += " (" + startHour;
                if (endDay.compareTo(theDay) == 0 && endHour != null && endHour.length() != 0) {
                    eventTitle += "-" + endHour;
                }
                eventTitle += ")";
            }

            section.add(new Paragraph(eventTitle, titleTextFont));
            if (StringUtil.isDefined(event.getPlace())) {
                section.add(new Paragraph(event.getPlace(), titleTextFont));
            }
            if (StringUtil.isDefined(event.getDescription(almanach.getLanguage()))) {
                section.add(new Paragraph(event.getDescription(almanach.getLanguage()), textFont));
            }
            section.add(new Paragraph("\n"));

        } // end for
        calendar.add(Calendar.DAY_OF_MONTH, 1);
    }
}

From source file:org.jcryptool.visual.crt.export.FileExporter.java

License:Open Source License

/**
 * creates the PDF output-file using iText library
 *//*from   ww w .  j  a  v a 2s .  co m*/
public void exportToPDF() {
    Font fontSupscript = new Font(Font.HELVETICA, 6, Font.NORMAL);
    Font fontSymbol = new Font(Font.SYMBOL, 12, Font.NORMAL);

    try {
        PdfWriter.getInstance(document, new FileOutputStream(file));
        document.open();

        document.add(new Paragraph("Chinese Remainder Theorem"));
        document.add(new Paragraph(" "));
        document.add(new Paragraph("Equations:"));
        document.add(new Paragraph(" "));
        for (int i = 0; i < valueA.length; i++) {
            document.add(new Paragraph("x = " + valueA[i] + " mod " + valueModuli[i]));
        }
        document.add(new Paragraph(" "));
        document.add(new Paragraph("Compute"));
        document.add(new Paragraph(" "));

        Chunk space = new Chunk(" ");
        Chunk spaceBig = new Chunk("    ");
        Chunk index = new Chunk("i", fontSupscript);
        index.setTextRise(-3.0f);
        Chunk m = new Chunk("m");
        Chunk equal = new Chunk("=");
        Chunk openB = new Chunk("(");
        Chunk closeB = new Chunk(")");
        Chunk p = new Chunk("P", fontSymbol);
        Chunk comma = new Chunk(",");
        Chunk range = new Chunk("i=0 to n-1");
        Chunk bigM = new Chunk("M");
        Chunk div = new Chunk("/");

        document.add(m);
        document.add(space);
        document.add(equal);
        document.add(space);
        document.add(p);
        document.add(space);
        document.add(openB);
        document.add(space);
        document.add(m);
        document.add(index);
        document.add(space);
        document.add(closeB);
        document.add(comma);
        document.add(spaceBig);
        document.add(bigM);
        document.add(space);
        document.add(equal);
        document.add(space);
        document.add(m);
        document.add(space);
        document.add(div);
        document.add(space);
        document.add(m);
        document.add(index);
        document.add(comma);
        document.add(spaceBig);
        document.add(range);

        document.add(new Paragraph(" "));
        document.add(new Paragraph("m = " + crt.getModulus()));
        document.add(new Paragraph(" "));
        for (int i = 0; i < valueBigM.length; i++) {
            m = new Chunk("m");
            index = new Chunk(String.valueOf(i), fontSupscript);
            index.setTextRise(-3.0f);
            Chunk value = new Chunk(valueBigM[i].toString());

            document.add(m);
            document.add(index);
            document.add(new Chunk(" = "));
            document.add(value);
            document.add(new Paragraph());
        }
        document.add(new Paragraph(" "));
        document.add(new Paragraph("To get the inverse you can use the extended euclidean."));
        document.add(new Paragraph(" "));

        Chunk y = new Chunk("y");
        Chunk equiv = new Chunk("=");
        Chunk mod = new Chunk("mod");
        index = new Chunk("i", fontSupscript);
        index.setTextRise(-3.0f);

        document.add(y);
        document.add(index);
        document.add(bigM);
        document.add(index);
        document.add(space);
        document.add(equiv);
        document.add(space);
        document.add(new Chunk("1"));
        document.add(space);
        document.add(mod);
        document.add(space);
        document.add(m);
        document.add(index);
        document.add(comma);
        document.add(spaceBig);
        document.add(range);

        document.add(new Paragraph(" "));
        for (int i = 0; i < valueBigM.length; i++) {
            index = new Chunk(String.valueOf(i), fontSupscript);
            index.setTextRise(-3.0f);
            Chunk value = new Chunk(valueInverse[i].toString());

            document.add(new Chunk("y"));
            document.add(index);
            document.add(new Chunk(" = "));
            document.add(value);
            document.add(new Paragraph());
        }
        document.add(new Paragraph(" "));
        document.add(new Paragraph("To get one solution of the simultaneous congruences."));
        document.add(new Paragraph(" "));

        Chunk sum = new Chunk("S", fontSymbol);
        index = new Chunk("i", fontSupscript);
        index.setTextRise(-3.0f);

        document.add(new Chunk("x = "));
        document.add(sum);
        document.add(space);
        document.add(new Chunk());
        document.add(new Chunk("a"));
        document.add(index);
        document.add(new Chunk("y"));
        document.add(index);
        document.add(bigM);
        document.add(index);
        document.add(space);
        document.add(new Chunk("mod"));
        document.add(space);
        document.add(m);
        document.add(comma);
        document.add(spaceBig);
        document.add(range);
        document.add(new Chunk("."));

        document.add(new Paragraph(" "));
        document.add(new Paragraph("One solution is: " + crt.getFinalResult()));

        document.close();

    } catch (FileNotFoundException e) {
        LogUtil.logError(e);
    } catch (DocumentException e) {
        LogUtil.logError(e);
    }
}

From source file:org.silverpeas.components.almanach.control.AlmanachPdfGenerator.java

License:Open Source License

private static void generateAlmanach(Chapter chapter, AlmanachSessionController almanach,
        List<DisplayableEventOccurrence> occurrences, String mode) {

    boolean monthScope = AlmanachPdfGenerator.PDF_MONTH_EVENTSONLY.equals(mode)
            || AlmanachPdfGenerator.PDF_MONTH_ALLDAYS.equals(mode);
    boolean yearScope = AlmanachPdfGenerator.PDF_YEAR_EVENTSONLY.equals(mode);

    int currentDay = -1;
    Calendar calendar = Calendar.getInstance();
    calendar.setTime(almanach.getCurrentDay());
    calendar.set(Calendar.DAY_OF_MONTH, 1);
    int currentMonth = calendar.get(Calendar.MONTH);
    int currentYear = calendar.get(Calendar.YEAR);

    if (yearScope) {
        // start from begin of current year
        calendar.set(Calendar.MONTH, 0);
    }//from ww w . j  a  v a  2s  .c o m

    // for each day of the current month
    while ((monthScope && currentMonth == calendar.get(Calendar.MONTH))
            || (yearScope && currentYear == calendar.get(Calendar.YEAR))) {
        Section section = null;
        if (AlmanachPdfGenerator.PDF_MONTH_ALLDAYS.equals(mode)) {
            section = chapter.addSection(generateParagraph(calendar, almanach), 0);
        }

        Font titleTextFont = new Font(Font.BOLD, 12, Font.SYMBOL, new Color(0, 0, 0));

        // get the events of the current day
        for (DisplayableEventOccurrence occurrence : occurrences) {
            EventDetail event = occurrence.getEventDetail();
            String theDay = DateUtil.date2SQLDate(calendar.getTime());
            String startDay = DateUtil.date2SQLDate(occurrence.getStartDate().asDate());
            String startHour = event.getStartHour();
            String endHour = event.getEndHour();

            if (startDay.compareTo(theDay) > 0) {
                continue;
            }

            String endDay = startDay;
            if (event.getEndDate() != null) {
                endDay = DateUtil.date2SQLDate(occurrence.getEndDate().asDate());
            }

            if (endDay.compareTo(theDay) < 0) {
                continue;
            }

            if (calendar.get(Calendar.DAY_OF_MONTH) != currentDay) {
                if (AlmanachPdfGenerator.PDF_MONTH_EVENTSONLY.equals(mode)
                        || AlmanachPdfGenerator.PDF_YEAR_EVENTSONLY.equals(mode)) {
                    section = chapter.addSection(generateParagraph(calendar, almanach), 0);
                }
                currentDay = calendar.get(Calendar.DAY_OF_MONTH);
            }

            Font textFont;
            if (event.getPriority() == 0) {
                textFont = new Font(Font.HELVETICA, 10, Font.NORMAL, new Color(0, 0, 0));
            } else {
                textFont = new Font(Font.HELVETICA, 10, Font.BOLD, new Color(0, 0, 0));
            }

            String eventTitle = event.getTitle();
            if (startDay.compareTo(theDay) == 0 && startHour != null && startHour.length() != 0) {
                eventTitle += " (" + startHour;
                if (endDay.compareTo(theDay) == 0 && endHour != null && endHour.length() != 0) {
                    eventTitle += "-" + endHour;
                }
                eventTitle += ")";
            }

            section.add(new Paragraph(eventTitle, titleTextFont));
            if (StringUtil.isDefined(event.getPlace())) {
                section.add(new Paragraph(event.getPlace(), titleTextFont));
            }
            if (StringUtil.isDefined(event.getDescription(almanach.getLanguage()))) {
                section.add(new Paragraph(event.getDescription(almanach.getLanguage()), textFont));
            }
            section.add(new Paragraph("\n"));

        } // end for
        calendar.add(Calendar.DAY_OF_MONTH, 1);
    }
}