mirror of
https://github.com/geometer/FBReaderJ.git
synced 2025-10-03 09:49:19 +02:00
more interesting sample application
git-svn-id: https://only.mawhrin.net/repos/FBReaderJ/trunk@122 6a642e6f-84f6-412e-ac94-c4a38d5a04b0
This commit is contained in:
parent
21bd36a26c
commit
356ada3740
4 changed files with 29 additions and 14 deletions
|
@ -5,7 +5,7 @@ import org.zlibrary.core.library.ZLibrary;
|
|||
public class Main {
|
||||
public static void main(String[] args) {
|
||||
ZLibrary.init();
|
||||
ZLibrary.run(new SampleApplication());
|
||||
ZLibrary.run(new SampleApplication(args[0]));
|
||||
ZLibrary.shutdown();
|
||||
}
|
||||
}
|
||||
|
|
|
@ -4,9 +4,11 @@ import org.zlibrary.core.application.*;
|
|||
|
||||
|
||||
public class SampleApplication extends ZLApplication {
|
||||
public SampleApplication() {
|
||||
public SampleApplication(String fileName) {
|
||||
super("Sample");
|
||||
setView(new SampleView(this, getContext()));
|
||||
SampleView view = new SampleView(this, getContext());
|
||||
view.setModel(fileName);
|
||||
setView(view);
|
||||
}
|
||||
|
||||
public ZLKeyBindings keyBindings() {
|
||||
|
|
|
@ -9,26 +9,39 @@ import org.zlibrary.text.model.entry.*;
|
|||
|
||||
import org.zlibrary.text.view.impl.*;
|
||||
|
||||
import org.fbreader.bookmodel.*;
|
||||
import org.fbreader.formats.fb2.*;
|
||||
|
||||
class SampleView extends ZLView {
|
||||
SampleView(SampleApplication application, ZLPaintContext context) {
|
||||
super(application, context);
|
||||
private BookModel myModel;
|
||||
|
||||
void setModel(String fileName) {
|
||||
myModel = new FB2Reader(fileName).read();
|
||||
}
|
||||
|
||||
public void paint() {
|
||||
ZLPaintContext context = getContext();
|
||||
SampleView(SampleApplication application, ZLPaintContext context) {
|
||||
super(application, context);
|
||||
|
||||
/*
|
||||
ZLModelFactory modelFactory = new ZLModelFactory();
|
||||
ZLTextModel model = modelFactory.createPlainModel();
|
||||
myModel = modelFactory.createPlainModel();
|
||||
ZLTextParagraph paragraph = modelFactory.createParagraph();
|
||||
ZLTextEntry entry;
|
||||
entry = modelFactory.createTextEntry("First paragraph: Some text here ");
|
||||
paragraph.addEntry(entry);
|
||||
model.addParagraphInternal(paragraph);
|
||||
myModel.addParagraphInternal(paragraph);
|
||||
|
||||
paragraph = modelFactory.createParagraph();
|
||||
entry = modelFactory.createTextEntry(" Second paragraph: ");
|
||||
paragraph.addEntry(entry);
|
||||
model.addParagraphInternal(paragraph);
|
||||
myModel.addParagraphInternal(paragraph);
|
||||
*/
|
||||
}
|
||||
|
||||
public void paint() {
|
||||
ZLPaintContext context = getContext();
|
||||
|
||||
ZLTextModel model = myModel.getBookModel();
|
||||
int paragraphs = model.getParagraphsNumber();
|
||||
int h = 0;
|
||||
int dh = context.stringHeight();
|
||||
|
|
|
@ -4,17 +4,17 @@ package org.zlibrary.text.view.impl;
|
|||
|
||||
public class ZLTextWord extends ZLTextElement {
|
||||
public String myData;
|
||||
public short mySize;
|
||||
//public short mySize;
|
||||
public short myLength;
|
||||
public int myParagraphOffset;
|
||||
//public int myParagraphOffset;
|
||||
|
||||
/*Temporarily made public to avoid implementing ZLTextElementPool with all its messy allocators, wtf is it?*/
|
||||
|
||||
public ZLTextWord(String data, short size, int paragraphOffset) {
|
||||
myData = data;
|
||||
mySize = size;
|
||||
//mySize = size;
|
||||
myLength = (short) data.length();
|
||||
myParagraphOffset = paragraphOffset;
|
||||
//myParagraphOffset = paragraphOffset;
|
||||
}
|
||||
|
||||
/* public Kind getKind() {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue