Search in sources :

Example 11 with BookModel

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

the class FBReader method onResume.

@Override
protected void onResume() {
    super.onResume();
    myStartTimer = true;
    Config.Instance().runOnConnect(new Runnable() {

        public void run() {
            SyncOperations.enableSync(FBReader.this, myFBReaderApp.SyncOptions);
            final int brightnessLevel = getZLibrary().ScreenBrightnessLevelOption.getValue();
            if (brightnessLevel != 0) {
                getViewWidget().setScreenBrightness(brightnessLevel);
            } else {
                setScreenBrightnessAuto();
            }
            if (getZLibrary().DisableButtonLightsOption.getValue()) {
                setButtonLight(false);
            }
            getCollection().bindToService(FBReader.this, new Runnable() {

                public void run() {
                    final BookModel model = myFBReaderApp.Model;
                    if (model == null || model.Book == null) {
                        return;
                    }
                    onPreferencesUpdate(myFBReaderApp.Collection.getBookById(model.Book.getId()));
                }
            });
        }
    });
    registerReceiver(myBatteryInfoReceiver, new IntentFilter(Intent.ACTION_BATTERY_CHANGED));
    IsPaused = false;
    myResumeTimestamp = System.currentTimeMillis();
    if (OnResumeAction != null) {
        final Runnable action = OnResumeAction;
        OnResumeAction = null;
        action.run();
    }
    registerReceiver(mySyncUpdateReceiver, new IntentFilter(FBReaderIntents.Event.SYNC_UPDATED));
    SetScreenOrientationAction.setOrientation(this, getZLibrary().getOrientationOption().getValue());
    if (myCancelIntent != null) {
        final Intent intent = myCancelIntent;
        myCancelIntent = null;
        getCollection().bindToService(this, new Runnable() {

            public void run() {
                runCancelAction(intent);
            }
        });
        return;
    } else if (myOpenBookIntent != null) {
        final Intent intent = myOpenBookIntent;
        myOpenBookIntent = null;
        getCollection().bindToService(this, new Runnable() {

            public void run() {
                openBook(intent, null, true);
            }
        });
    } else if (myFBReaderApp.getCurrentServerBook(null) != null) {
        getCollection().bindToService(this, new Runnable() {

            public void run() {
                myFBReaderApp.useSyncInfo(true, myNotifier);
            }
        });
    } else if (myFBReaderApp.Model == null && myFBReaderApp.ExternalBook != null) {
        getCollection().bindToService(this, new Runnable() {

            public void run() {
                myFBReaderApp.openBook(myFBReaderApp.ExternalBook, null, null, myNotifier);
            }
        });
    } else {
        getCollection().bindToService(this, new Runnable() {

            public void run() {
                myFBReaderApp.useSyncInfo(true, myNotifier);
            }
        });
    }
    PopupPanel.restoreVisibilities(myFBReaderApp);
    ApiServerImplementation.sendEvent(this, ApiListener.EVENT_READ_MODE_OPENED);
}
Also used : BookModel(org.geometerplus.fbreader.bookmodel.BookModel)

Example 12 with BookModel

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

the class TestFB2Reader method testImageSize.

public void testImageSize() {
    BookModel model = new BookModel(myDirectory + "image.fb2");
    new FB2Reader(model).read();
    ZLImage image = model.getImageMap().getImage("cover.jpg");
    ZLImageData imageData = ZLImageManager.getInstance().getImageData(image);
    ZLSwingPaintContext paint = new ZLSwingPaintContext();
    assertTrue(paint.imageHeight(imageData) == 277);
    assertTrue(paint.imageWidth(imageData) == 200);
}
Also used : BookModel(org.geometerplus.fbreader.bookmodel.BookModel) ZLSwingPaintContext(org.geometerplus.zlibrary.ui.swing.view.ZLSwingPaintContext) FB2Reader(org.geometerplus.fbreader.formats.fb2.FB2Reader)

Example 13 with BookModel

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

the class TestFB2Reader method testAnnotationBeforeBodyParagraph.

public void testAnnotationBeforeBodyParagraph() {
    BookModel bookModel = new BookModel(myDirectory + "annotation_before.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 14 with BookModel

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

the class TestFB2Reader method testNotesSimple.

public void testNotesSimple() {
    BookModel model = new BookModel(myDirectory + "simple_notes.fb2");
    new FB2Reader(model).read();
    assertNotNull(model.getFootnoteModel("1"));
}
Also used : BookModel(org.geometerplus.fbreader.bookmodel.BookModel) FB2Reader(org.geometerplus.fbreader.formats.fb2.FB2Reader)

Example 15 with BookModel

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

the class TestFB2Reader method testImage.

/*	public void testPnvs() {
		FB2Reader reader = new FB2Reader("M:/Books/pnvs.fb2");
		reader.read();
	}
*/
public void testImage() {
    BookModel model = new BookModel(myDirectory + "image.fb2");
    new FB2Reader(model).read();
    byte[] image = (model.getImageMap().getImage("cover.jpg")).byteData();
    try {
        BufferedImage img = ImageIO.read(new ByteArrayInputStream(image));
        ImageIO.write(img, "jpg", new File(myDirectory + "img.jpg"));
    } catch (IOException e) {
        fail();
    }
}
Also used : BookModel(org.geometerplus.fbreader.bookmodel.BookModel) FB2Reader(org.geometerplus.fbreader.formats.fb2.FB2Reader) BufferedImage(java.awt.image.BufferedImage)

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