Search in sources :

Example 1 with VerseRange

use of biblemulticonverter.data.VerseRange in project BibleMultiConverter by schierlm.

the class LogosHTML method exportChapter.

protected void exportChapter(String milestone, String cname, Chapter chapter, String versemap, VersificationScheme scheme, String verseSeparator, boolean noChapterHeadings, BufferedWriter bw, StringWriter footnotes, Book book, BitSet[] chapterVerses, BitSet thisChapterVerses) throws IOException {
    String chapterRef = "@" + formatMilestone(milestone, cname, "");
    boolean writeChapterNumber = false;
    int usedHeadlines = 2;
    if (book.getChapters().size() > 1) {
        if (noChapterHeadings) {
            writeChapterNumber = true;
        } else {
            usedHeadlines = 3;
            bw.write("<h3>[[" + chapterRef + "]]{{~ " + book.getAbbr() + " " + cname + " }}</h3>\n");
        }
    }
    footnoteNumber = 0;
    if (chapter.getProlog() != null) {
        chapter.getProlog().accept(new LogosVisitor(bw, "", footnotes, book.getId().isNT(), versemap, scheme, null, null, null, usedHeadlines));
        bw.write("\n<br/>\n");
    }
    for (VerseRange vr : chapter.createVerseRanges()) {
        String versePrefix = "", versePrefixBeforeHeadline = "", versePrefixAfterHeadline = "";
        if (writeChapterNumber) {
            versePrefix = "<b style=\"font-size: 20pt\">[[" + chapterRef + "]]" + cname + "</b>" + verseSeparator;
            versePrefixBeforeHeadline = "[[" + chapterRef + "]]";
            versePrefixAfterHeadline = "<b style=\"font-size: 20pt\">" + cname + "</b>" + verseSeparator;
            writeChapterNumber = false;
        }
        BitSet allowedVerses = thisChapterVerses;
        String vcname = cname;
        if (vr.getChapter() != 0) {
            allowedVerses = chapterVerses != null && vr.getChapter() <= chapterVerses.length ? chapterVerses[vr.getChapter() - 1] : null;
            vcname = "" + vr.getChapter();
        }
        boolean printMilestone = allowedVerses != null && !allowedVerses.isEmpty();
        if (printMilestone) {
            int minVerse = vr.getMinVerse(), maxVerse = vr.getMaxVerse();
            while (maxVerse >= minVerse && !allowedVerses.get(maxVerse)) maxVerse--;
            while (minVerse <= maxVerse && !allowedVerses.get(minVerse)) minVerse++;
            String verseMilestone = "";
            if (minVerse == maxVerse) {
                if (minVerse >= 1000 && minVerse < 1000 + NAMED_VERSES.length) {
                    verseMilestone += "[[@" + formatMilestone(milestone, vcname, NAMED_VERSES[minVerse - 1000]) + "]]";
                } else {
                    verseMilestone += "[[@" + formatMilestone(milestone, vcname, "" + minVerse) + "]]";
                }
            } else if (minVerse < maxVerse) {
                verseMilestone += "[[@" + formatMilestone(milestone, vcname, minVerse + "-" + maxVerse) + "]]";
            }
            versePrefix += verseMilestone;
            if (versePrefixBeforeHeadline.endsWith("]]") && verseMilestone.startsWith("[[@"))
                versePrefixBeforeHeadline += "\uFEFF";
            versePrefixBeforeHeadline += verseMilestone;
        }
        for (Verse v : vr.getVerses()) {
            bw.write(verseSeparator);
            String verseNumber = "<b>" + v.getNumber() + "</b> ";
            v.accept(new LogosVisitor(bw, "", footnotes, book.getId().isNT(), versemap, scheme, versePrefix + verseNumber, versePrefixBeforeHeadline, versePrefixAfterHeadline + verseNumber, usedHeadlines));
            versePrefix = "";
            versePrefixBeforeHeadline = "";
            versePrefixAfterHeadline = "";
            bw.write("\n");
        }
    }
}
Also used : VerseRange(biblemulticonverter.data.VerseRange) BitSet(java.util.BitSet) Verse(biblemulticonverter.data.Verse)

Example 2 with VerseRange

use of biblemulticonverter.data.VerseRange in project BibleMultiConverter by schierlm.

the class AbstractVersificationDetector method doExport.

@Override
public void doExport(Bible bible, String... exportArgs) throws Exception {
    VersificationScheme[] schemes = loadSchemes();
    Set<String> totalVerses = new HashSet<String>();
    boolean includeXref = exportArgs.length > 0 && exportArgs[0].equals("-xref");
    XrefCountVisitor xcv = includeXref ? new XrefCountVisitor(schemes, totalVerses) : null;
    // fill missing verses
    for (Book book : bible.getBooks()) {
        for (int cc = 0; cc < book.getChapters().size(); cc++) {
            Chapter chapter = book.getChapters().get(cc);
            if (includeXref && chapter.getProlog() != null) {
                chapter.getProlog().accept(xcv);
            }
            if (useVerseRanges()) {
                for (VerseRange vr : chapter.createVerseRanges()) {
                    int cnumber = vr.getChapter() == 0 ? cc + 1 : vr.getChapter();
                    countVerse(schemes, totalVerses, book.getAbbr(), book.getId(), cnumber, vr.getMinVerse());
                    countVerse(schemes, totalVerses, book.getAbbr(), book.getId(), cnumber, vr.getMaxVerse());
                }
            } else {
                for (VirtualVerse v : chapter.createVirtualVerses()) {
                    countVerse(schemes, totalVerses, book.getAbbr(), book.getId(), cc + 1, v.getNumber());
                }
            }
            if (includeXref) {
                for (Verse vv : chapter.getVerses()) {
                    vv.accept(xcv);
                }
            }
        }
    }
    // sort them
    Arrays.sort(schemes);
    // print them
    System.out.print("Best match:  ");
    int totalVerseCount = totalVerses.size();
    printScheme(schemes[0], totalVerseCount);
    System.out.println();
    System.out.println("Other options:");
    for (int i = 1; i < Math.min(11, schemes.length); i++) {
        printScheme(schemes[i], totalVerseCount);
        if (schemes[i].missingChapters.size() > schemes[0].missingChapters.size() + 2 || schemes[i].missingVerses.size() > schemes[0].missingVerses.size() + 5)
            break;
    }
    // print selected schemes
    if (exportArgs.length > (includeXref ? 1 : 0)) {
        System.out.println();
        System.out.println("Selected schemes:");
        for (int i = includeXref ? 1 : 0; i < exportArgs.length; i++) {
            boolean found = false;
            for (VersificationScheme scheme : schemes) {
                if (scheme.getName().equals(exportArgs[i])) {
                    printScheme(scheme, totalVerseCount);
                    found = true;
                    break;
                }
            }
            if (!found)
                System.out.println(exportArgs[i] + " (Unknown scheme)");
        }
    }
}
Also used : VerseRange(biblemulticonverter.data.VerseRange) VirtualVerse(biblemulticonverter.data.VirtualVerse) Chapter(biblemulticonverter.data.Chapter) Book(biblemulticonverter.data.Book) VirtualVerse(biblemulticonverter.data.VirtualVerse) Verse(biblemulticonverter.data.Verse) HashSet(java.util.HashSet)

Aggregations

Verse (biblemulticonverter.data.Verse)2 VerseRange (biblemulticonverter.data.VerseRange)2 Book (biblemulticonverter.data.Book)1 Chapter (biblemulticonverter.data.Chapter)1 VirtualVerse (biblemulticonverter.data.VirtualVerse)1 BitSet (java.util.BitSet)1 HashSet (java.util.HashSet)1