Search in sources :

Example 6 with BookModel

use of org.geometerplus.fbreader.bookmodel.BookModel in project FBReaderJ by geometer.

the class TestFB2Reader method writeTextModelDumpToFile.

private void writeTextModelDumpToFile(String inputFile, String outputFile) {
    BookModel bookModel = new BookModel(inputFile);
    new FB2Reader(bookModel).read();
    ZLTextModel model = bookModel.getBookTextModel();
    writeDumpToFile(model, outputFile);
}
Also used : BookModel(org.geometerplus.fbreader.bookmodel.BookModel) ZLTextModel(org.geometerplus.zlibrary.text.model.ZLTextModel) FB2Reader(org.geometerplus.fbreader.formats.fb2.FB2Reader)

Example 7 with BookModel

use of org.geometerplus.fbreader.bookmodel.BookModel in project FBReaderJ by geometer.

the class TestFB2Reader method testEndOfSectionParagraph.

public void testEndOfSectionParagraph() {
    BookModel bookModel = new BookModel(myDirectory + "section.fb2");
    new FB2Reader(bookModel).read();
    ZLTextModel model = bookModel.getBookTextModel();
    assertEquals(model.getParagraph(1).getKind(), ZLTextParagraph.Kind.END_OF_SECTION_PARAGRAPH);
}
Also used : BookModel(org.geometerplus.fbreader.bookmodel.BookModel) ZLTextModel(org.geometerplus.zlibrary.text.model.ZLTextModel) FB2Reader(org.geometerplus.fbreader.formats.fb2.FB2Reader)

Example 8 with BookModel

use of org.geometerplus.fbreader.bookmodel.BookModel in project FBReaderJ by geometer.

the class TestFB2Reader method testStanzaParagraphKinds.

public void testStanzaParagraphKinds() {
    BookModel bookModel = new BookModel(myDirectory + "stanza.fb2");
    new FB2Reader(bookModel).read();
    ZLTextModel model = bookModel.getBookTextModel();
    assertEquals(model.getParagraph(0).getKind(), ZLTextParagraph.Kind.BEFORE_SKIP_PARAGRAPH);
    assertEquals(model.getParagraph(2).getKind(), ZLTextParagraph.Kind.AFTER_SKIP_PARAGRAPH);
    assertEquals(model.getParagraph(1).getKind(), ZLTextParagraph.Kind.TEXT_PARAGRAPH);
}
Also used : BookModel(org.geometerplus.fbreader.bookmodel.BookModel) ZLTextModel(org.geometerplus.zlibrary.text.model.ZLTextModel) FB2Reader(org.geometerplus.fbreader.formats.fb2.FB2Reader)

Example 9 with BookModel

use of org.geometerplus.fbreader.bookmodel.BookModel in project FBReaderJ by geometer.

the class TestFB2Reader method testTreeParagraphRef.

public void testTreeParagraphRef() {
    BookModel bookModel = new BookModel(myDirectory + "tree1.fb2");
    new FB2Reader(bookModel).read();
    ContentsModel model = bookModel.getContentsModel();
    assertTrue(model.getReference((ZLTextTreeParagraph) model.getParagraph(0)) == 0);
}
Also used : ContentsModel(org.geometerplus.fbreader.bookmodel.ContentsModel) BookModel(org.geometerplus.fbreader.bookmodel.BookModel) FB2Reader(org.geometerplus.fbreader.formats.fb2.FB2Reader)

Example 10 with BookModel

use of org.geometerplus.fbreader.bookmodel.BookModel in project FBReaderJ by geometer.

the class OEBNativePlugin method readModel.

@Override
public void readModel(BookModel model) throws BookReadingException {
    final ZLFile file = BookUtil.fileByBook(model.Book);
    file.setCached(true);
    try {
        super.readModel(model);
        model.setLabelResolver(new BookModel.LabelResolver() {

            public List<String> getCandidates(String id) {
                final int index = id.indexOf("#");
                return index > 0 ? Collections.<String>singletonList(id.substring(0, index)) : Collections.<String>emptyList();
            }
        });
    } finally {
        file.setCached(false);
    }
}
Also used : BookModel(org.geometerplus.fbreader.bookmodel.BookModel) ZLFile(org.geometerplus.zlibrary.core.filesystem.ZLFile) List(java.util.List)

Aggregations

BookModel (org.geometerplus.fbreader.bookmodel.BookModel)16 FB2Reader (org.geometerplus.fbreader.formats.fb2.FB2Reader)13 ZLTextModel (org.geometerplus.zlibrary.text.model.ZLTextModel)8 ZLTextParagraph (org.geometerplus.zlibrary.text.model.ZLTextParagraph)2 BufferedImage (java.awt.image.BufferedImage)1 List (java.util.List)1 ContentsModel (org.geometerplus.fbreader.bookmodel.ContentsModel)1 BookDescription (org.geometerplus.fbreader.description.BookDescription)1 ZLFile (org.geometerplus.zlibrary.core.filesystem.ZLFile)1 ZLImageEntry (org.geometerplus.zlibrary.text.model.impl.ZLImageEntry)1 ZLSwingPaintContext (org.geometerplus.zlibrary.ui.swing.view.ZLSwingPaintContext)1