Search in sources :

Example 1 with FB2Reader

use of org.geometerplus.fbreader.formats.fb2.FB2Reader in project FBReaderJ by geometer.

the class TestFB2Reader method testImageModel.

public void testImageModel() {
    BookModel bModel = new BookModel(myDirectory + "image.fb2");
    new FB2Reader(bModel).read();
    ZLTextModel model = bModel.getBookTextModel();
    ZLTextParagraph paragraph = model.getParagraph(0);
    ZLTextParagraph.EntryIterator it = paragraph.iterator();
    it.next();
    it.next();
    ZLImageEntry entry = it.getImageEntry();
    assertEquals(entry.VOffset, 0);
    assertEquals(entry.getImage(), bModel.getImageMap().getImage("cover.jpg"));
}
Also used : BookModel(org.geometerplus.fbreader.bookmodel.BookModel) ZLImageEntry(org.geometerplus.zlibrary.text.model.impl.ZLImageEntry) ZLTextParagraph(org.geometerplus.zlibrary.text.model.ZLTextParagraph) ZLTextModel(org.geometerplus.zlibrary.text.model.ZLTextModel) FB2Reader(org.geometerplus.fbreader.formats.fb2.FB2Reader)

Example 2 with FB2Reader

use of org.geometerplus.fbreader.formats.fb2.FB2Reader in project FBReaderJ by geometer.

the class TestFB2Reader method testFootnote1.

public void testFootnote1() {
    BookModel model = new BookModel(myDirectory + "footnote1.fb2");
    new FB2Reader(model).read();
    ZLTextParagraph paragraph = model.getParagraphByLink("note1");
    ZLTextParagraph.EntryIterator it = paragraph.iterator();
    it.next();
    it.next();
    assertEquals(it.getType(), ZLTextParagraph.Entry.TEXT);
    assertEquals("footnote", new String(it.getTextData(), it.getTextOffset(), it.getTextLength()));
}
Also used : BookModel(org.geometerplus.fbreader.bookmodel.BookModel) ZLTextParagraph(org.geometerplus.zlibrary.text.model.ZLTextParagraph) FB2Reader(org.geometerplus.fbreader.formats.fb2.FB2Reader)

Example 3 with FB2Reader

use of org.geometerplus.fbreader.formats.fb2.FB2Reader in project FBReaderJ by geometer.

the class TestFB2Reader method testOneNote.

public void testOneNote() {
    BookModel bookModel = new BookModel(myDirectory + "one_note.fb2");
    new FB2Reader(bookModel).read();
    ZLTextModel model = bookModel.getFootnoteModel("1");
    String output = myDirectory + "one_note_act.txt";
    writeDumpToFile(model, output);
    assertTrue(compareFiles(myDirectory + "one_note_exp.txt", output));
    new File(output).delete();
}
Also used : BookModel(org.geometerplus.fbreader.bookmodel.BookModel) ZLTextModel(org.geometerplus.zlibrary.text.model.ZLTextModel) FB2Reader(org.geometerplus.fbreader.formats.fb2.FB2Reader)

Example 4 with FB2Reader

use of org.geometerplus.fbreader.formats.fb2.FB2Reader in project FBReaderJ by geometer.

the class TestFB2Reader method testEmptyLineParagraphKind.

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

Example 5 with FB2Reader

use of org.geometerplus.fbreader.formats.fb2.FB2Reader in project FBReaderJ by geometer.

the class TestFB2Reader method writeTreeModelDumpToFile.

private void writeTreeModelDumpToFile(String inputFile, String outputFile) {
    BookModel bookModel = new BookModel(inputFile);
    new FB2Reader(bookModel).read();
    ZLTextModel model = bookModel.getContentsModel();
    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)

Aggregations

BookModel (org.geometerplus.fbreader.bookmodel.BookModel)13 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 ContentsModel (org.geometerplus.fbreader.bookmodel.ContentsModel)1 ZLImageEntry (org.geometerplus.zlibrary.text.model.impl.ZLImageEntry)1 ZLSwingPaintContext (org.geometerplus.zlibrary.ui.swing.view.ZLSwingPaintContext)1