mirror of
https://github.com/geometer/FBReaderJ.git
synced 2025-10-03 09:49:19 +02:00
git-svn-id: https://only.mawhrin.net/repos/FBReaderJ/trunk@107 6a642e6f-84f6-412e-ac94-c4a38d5a04b0
This commit is contained in:
parent
4b833c39d8
commit
7e728b6090
4 changed files with 64 additions and 5 deletions
|
@ -1,6 +1,10 @@
|
||||||
package org.zlibrary.text.view.impl;
|
package org.zlibrary.text.view.impl;
|
||||||
|
|
||||||
class ZLTextLineInfo {
|
class ZLTextLineInfo {
|
||||||
|
|
||||||
|
/*This class has public fields like struct in C++.
|
||||||
|
Should I remove prefix "my", or should I make "getters" and "setters" for all the fields, making them private?*/
|
||||||
|
|
||||||
public ZLTextWordCursor myStart;
|
public ZLTextWordCursor myStart;
|
||||||
public ZLTextWordCursor myRealStart;
|
public ZLTextWordCursor myRealStart;
|
||||||
public ZLTextWordCursor myEnd;
|
public ZLTextWordCursor myEnd;
|
||||||
|
|
|
@ -2,10 +2,44 @@ package org.zlibrary.text.view.impl;
|
||||||
|
|
||||||
import org.zlibrary.text.model.ZLTextModel;
|
import org.zlibrary.text.model.ZLTextModel;
|
||||||
import org.zlibrary.text.model.ZLTextParagraph;
|
import org.zlibrary.text.model.ZLTextParagraph;
|
||||||
|
import org.zlibrary.text.model.entry.ZLTextParagraphEntry;
|
||||||
|
import org.zlibrary.text.model.entry.ZLTextEntry;
|
||||||
|
|
||||||
import java.util.*;
|
import java.util.*;
|
||||||
|
|
||||||
abstract class ZLTextParagraphCursor {
|
abstract class ZLTextParagraphCursor {
|
||||||
|
|
||||||
|
|
||||||
|
private static abstract class Processor {
|
||||||
|
protected ZLTextParagraph myParagraph;
|
||||||
|
protected List <ZLTextElement> myElements;
|
||||||
|
protected int myOffset;
|
||||||
|
|
||||||
|
protected Processor(ZLTextParagraph paragraph, int index, List <ZLTextElement> elements) {
|
||||||
|
myParagraph = paragraph;
|
||||||
|
myElements = elements;
|
||||||
|
myOffset = 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void fill() {
|
||||||
|
List <ZLTextParagraphEntry> entries = myParagraph.getEntries();
|
||||||
|
for (ZLTextParagraphEntry entry : entries) {
|
||||||
|
// switch (entry.Kind) {
|
||||||
|
// case ZLTextParagraphEntry.Kind.TEXT_ENTRY: {
|
||||||
|
processTextEntry((ZLTextEntry) entry);
|
||||||
|
// break;
|
||||||
|
// }
|
||||||
|
// }
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public abstract void processTextEntry(ZLTextEntry textEntry);
|
||||||
|
|
||||||
|
protected void addWord(String s, int offset, int len) {
|
||||||
|
myElements.add(new ZLTextWord(s, (short) len, offset));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
protected ZLTextModel myModel;
|
protected ZLTextModel myModel;
|
||||||
protected int myIndex;
|
protected int myIndex;
|
||||||
protected List <ZLTextElement> myElements;
|
protected List <ZLTextElement> myElements;
|
||||||
|
|
|
@ -1,11 +1,30 @@
|
||||||
package org.zlibrary.text.view.impl;
|
package org.zlibrary.text.view.impl;
|
||||||
|
|
||||||
|
import org.zlibrary.text.model.*;
|
||||||
import org.zlibrary.text.view.ZLTextView;
|
import org.zlibrary.text.view.ZLTextView;
|
||||||
|
|
||||||
class ZLTextViewImpl implements ZLTextView {
|
class ZLTextViewImpl implements ZLTextView {
|
||||||
|
|
||||||
ZLTextLineInfo processTextLine(ZLTextWordCursor start, ZLTextWordCursor end) {
|
private ZLTextModel myModel;
|
||||||
|
|
||||||
|
/* ZLTextLineInfo processTextLine(ZLTextWordCursor start, ZLTextWordCursor end) {
|
||||||
ZLTextLineInfo info = new ZLTextLineInfo(start);
|
ZLTextLineInfo info = new ZLTextLineInfo(start);
|
||||||
|
ZLTextWordCursor current = start;
|
||||||
|
final ZLTextParagraphCursor paragraphCursor = current.getParagraphCursor();
|
||||||
|
final boolean isFirstLine = current.isStartOfParagraph();
|
||||||
|
|
||||||
|
if (isFirstLine) {
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
if (info.myRealStart.equalWordNumber(length)) {
|
||||||
|
info.myEnd = info.myRealStart;
|
||||||
|
return info;
|
||||||
|
}
|
||||||
|
|
||||||
|
int newWidth = info.myWidth;
|
||||||
|
int newHeight = info.myHeight;
|
||||||
|
|
||||||
return info;
|
return info;
|
||||||
}
|
}*/
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,12 +1,14 @@
|
||||||
package org.zlibrary.text.view.impl;
|
package org.zlibrary.text.view.impl;
|
||||||
|
|
||||||
class ZLTextWord extends ZLTextElement {
|
/*package*/ class ZLTextWord extends ZLTextElement {
|
||||||
public String myData;
|
public String myData;
|
||||||
public short mySize;
|
public short mySize;
|
||||||
public short myLength;
|
public short myLength;
|
||||||
public int myParagraphOffset;
|
public int myParagraphOffset;
|
||||||
|
|
||||||
private ZLTextWord(String data, short size, int paragraphOffset) {
|
/*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;
|
myData = data;
|
||||||
mySize = size;
|
mySize = size;
|
||||||
myLength = (short) data.length();
|
myLength = (short) data.length();
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue