mirror of
https://github.com/geometer/FBReaderJ.git
synced 2025-10-04 18:29:23 +02:00
git-svn-id: https://only.mawhrin.net/repos/FBReaderJ/trunk@859 6a642e6f-84f6-412e-ac94-c4a38d5a04b0
This commit is contained in:
parent
6df63fb609
commit
fb4784fbac
10 changed files with 148 additions and 34 deletions
|
@ -36,6 +36,7 @@ public final class BookModel {
|
||||||
|
|
||||||
private final HashMap myFootnotes = new HashMap();
|
private final HashMap myFootnotes = new HashMap();
|
||||||
private final HashMap myInternalHyperlinks = new HashMap();
|
private final HashMap myInternalHyperlinks = new HashMap();
|
||||||
|
private final ArrayList myBookTextModels;
|
||||||
|
|
||||||
private final ZLImageMap myImageMap = new ZLImageMap();
|
private final ZLImageMap myImageMap = new ZLImageMap();
|
||||||
|
|
||||||
|
@ -43,13 +44,18 @@ public final class BookModel {
|
||||||
public final int ParagraphNumber;
|
public final int ParagraphNumber;
|
||||||
public final ZLTextModel Model;
|
public final ZLTextModel Model;
|
||||||
|
|
||||||
|
public final int ModelNumber;
|
||||||
|
|
||||||
Label(ZLTextModel model, int paragraphNumber) {
|
Label(ZLTextModel model, int paragraphNumber) {
|
||||||
ParagraphNumber = paragraphNumber;
|
ParagraphNumber = paragraphNumber;
|
||||||
Model = model;
|
Model = model;
|
||||||
|
ModelNumber = myBookTextModels.indexOf(model);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public BookModel(final BookDescription description) {
|
public BookModel(final BookDescription description) {
|
||||||
|
myBookTextModels = new ArrayList();
|
||||||
|
myBookTextModels.add(BookTextModel);
|
||||||
Description = description;
|
Description = description;
|
||||||
ZLFile file = new ZLFile(description.FileName);
|
ZLFile file = new ZLFile(description.FileName);
|
||||||
FormatPlugin plugin = PluginCollection.instance().getPlugin(file, false);
|
FormatPlugin plugin = PluginCollection.instance().getPlugin(file, false);
|
||||||
|
@ -92,4 +98,15 @@ public final class BookModel {
|
||||||
void addImage(String id, ZLImage image) {
|
void addImage(String id, ZLImage image) {
|
||||||
myImageMap.put(id, image);
|
myImageMap.put(id, image);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//
|
||||||
|
public ZLTextPlainModel addBookTextModel() {
|
||||||
|
ZLTextPlainModel bookTextModel = new ZLTextPlainModel(65536);
|
||||||
|
myBookTextModels.add(bookTextModel);
|
||||||
|
return bookTextModel;
|
||||||
|
}
|
||||||
|
|
||||||
|
public ArrayList getBookTextModels() {
|
||||||
|
return myBookTextModels;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -145,10 +145,10 @@ public class BookReader {
|
||||||
insertEndParagraph(ZLTextParagraph.Kind.END_OF_SECTION_PARAGRAPH);
|
insertEndParagraph(ZLTextParagraph.Kind.END_OF_SECTION_PARAGRAPH);
|
||||||
}
|
}
|
||||||
|
|
||||||
public final void insertEndOfTextParagraph() {
|
/* public final void insertEndOfTextParagraph() {
|
||||||
insertEndParagraph(ZLTextParagraph.Kind.END_OF_TEXT_PARAGRAPH);
|
insertEndParagraph(ZLTextParagraph.Kind.END_OF_TEXT_PARAGRAPH);
|
||||||
}
|
}
|
||||||
|
*/
|
||||||
public final void unsetCurrentTextModel() {
|
public final void unsetCurrentTextModel() {
|
||||||
myCurrentTextModel = null;
|
myCurrentTextModel = null;
|
||||||
}
|
}
|
||||||
|
@ -326,4 +326,9 @@ public class BookReader {
|
||||||
myCurrentTextModel.addFixedHSpace(length);
|
myCurrentTextModel.addFixedHSpace(length);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//
|
||||||
|
public final void setNewTextModel() {
|
||||||
|
myCurrentTextModel = Model.addBookTextModel();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -35,6 +35,7 @@ public class BookTextView extends FBView {
|
||||||
private static final String PARAGRAPH_PREFIX = "Paragraph_";
|
private static final String PARAGRAPH_PREFIX = "Paragraph_";
|
||||||
private static final String WORD_PREFIX = "Word_";
|
private static final String WORD_PREFIX = "Word_";
|
||||||
private static final String CHAR_PREFIX = "Char_";
|
private static final String CHAR_PREFIX = "Char_";
|
||||||
|
private static final String MODEL_PREFIX = "Model_";
|
||||||
|
|
||||||
private static final int MAX_UNDO_STACK_SIZE = 20;
|
private static final int MAX_UNDO_STACK_SIZE = 20;
|
||||||
|
|
||||||
|
@ -62,8 +63,7 @@ public class BookTextView extends FBView {
|
||||||
myContentsModel = contentsModel;
|
myContentsModel = contentsModel;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setModel(ZLTextModel model, String fileName) {
|
public void setModels(ArrayList/*<ZLTextModel>*/ models, String fileName) {
|
||||||
super.setModel(model);
|
|
||||||
myFileName = fileName;
|
myFileName = fileName;
|
||||||
|
|
||||||
myPositionStack.clear();
|
myPositionStack.clear();
|
||||||
|
@ -75,11 +75,18 @@ public class BookTextView extends FBView {
|
||||||
myPositionStack.add(new Position(
|
myPositionStack.add(new Position(
|
||||||
new ZLIntegerOption(ZLOption.STATE_CATEGORY, fileName, PARAGRAPH_PREFIX + i, 0).getValue(),
|
new ZLIntegerOption(ZLOption.STATE_CATEGORY, fileName, PARAGRAPH_PREFIX + i, 0).getValue(),
|
||||||
new ZLIntegerOption(ZLOption.STATE_CATEGORY, fileName, WORD_PREFIX + i, 0).getValue(),
|
new ZLIntegerOption(ZLOption.STATE_CATEGORY, fileName, WORD_PREFIX + i, 0).getValue(),
|
||||||
new ZLIntegerOption(ZLOption.STATE_CATEGORY, fileName, CHAR_PREFIX + i, 0).getValue()
|
new ZLIntegerOption(ZLOption.STATE_CATEGORY, fileName, CHAR_PREFIX + i, 0).getValue(),
|
||||||
|
new ZLIntegerOption(ZLOption.STATE_CATEGORY, fileName, MODEL_PREFIX + i, 0).getValue()
|
||||||
));
|
));
|
||||||
}
|
}
|
||||||
|
|
||||||
if ((model != null) && (!myPositionStack.isEmpty())) {
|
if (!myPositionStack.isEmpty()) {
|
||||||
|
System.out.println("stack is not empty");
|
||||||
|
super.setModels(models, ((Position)myPositionStack.get(myCurrentPointInStack)).ModelIndex);
|
||||||
|
} else {
|
||||||
|
super.setModels(models, 0);
|
||||||
|
}
|
||||||
|
if ((getModel() != null) && (!myPositionStack.isEmpty())) {
|
||||||
gotoPosition((Position)myPositionStack.get(myCurrentPointInStack));
|
gotoPosition((Position)myPositionStack.get(myCurrentPointInStack));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -90,21 +97,27 @@ public class BookTextView extends FBView {
|
||||||
myPositionStack.add(new Position(StartCursor));
|
myPositionStack.add(new Position(StartCursor));
|
||||||
} else {
|
} else {
|
||||||
((Position)myPositionStack.get(myCurrentPointInStack)).set(StartCursor);
|
((Position)myPositionStack.get(myCurrentPointInStack)).set(StartCursor);
|
||||||
|
Position position = (Position)myPositionStack.get(myCurrentPointInStack);
|
||||||
|
System.out.println("current position " + position.ModelIndex + " , " + position.ParagraphIndex);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void scrollToHome() {
|
void scrollToHome() {
|
||||||
final ZLTextWordCursor cursor = StartCursor;
|
final ZLTextWordCursor cursor = StartCursor;
|
||||||
if (!cursor.isNull() && cursor.isStartOfParagraph() && cursor.getParagraphCursor().Index == 0) {
|
if (!cursor.isNull() && cursor.isStartOfParagraph() && cursor.getParagraphCursor().Index == 0
|
||||||
|
&& myCurrentModelIndex == 0) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
setModel(0);
|
||||||
final Position position = new Position(cursor);
|
final Position position = new Position(cursor);
|
||||||
gotoParagraph(0, false);
|
gotoParagraph(0, false);
|
||||||
gotoPosition(0, 0, 0);
|
gotoPosition(0, 0, 0);
|
||||||
preparePaintInfo();
|
preparePaintInfo();
|
||||||
if (!position.equalsToCursor(StartCursor)) {
|
/* if (!position.equalsToCursor(StartCursor)) {
|
||||||
savePosition(position);
|
savePosition(position);
|
||||||
}
|
}
|
||||||
|
*/
|
||||||
|
savePosition(position, StartCursor);
|
||||||
Application.refreshWindow();
|
Application.refreshWindow();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -115,9 +128,11 @@ public class BookTextView extends FBView {
|
||||||
final Position position = new Position(cursor);
|
final Position position = new Position(cursor);
|
||||||
gotoParagraph(paragraphIndex, false);
|
gotoParagraph(paragraphIndex, false);
|
||||||
preparePaintInfo();
|
preparePaintInfo();
|
||||||
if (!position.equalsToCursor(StartCursor)) {
|
/* if (!position.equalsToCursor(StartCursor)) {
|
||||||
savePosition(position);
|
savePosition(position);
|
||||||
}
|
}
|
||||||
|
*/
|
||||||
|
savePosition(position, StartCursor);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -204,6 +219,8 @@ public class BookTextView extends FBView {
|
||||||
new ZLIntegerOption(ZLOption.STATE_CATEGORY, group, PARAGRAPH_PREFIX + i, 0).setValue(position.ParagraphIndex);
|
new ZLIntegerOption(ZLOption.STATE_CATEGORY, group, PARAGRAPH_PREFIX + i, 0).setValue(position.ParagraphIndex);
|
||||||
new ZLIntegerOption(ZLOption.STATE_CATEGORY, group, WORD_PREFIX + i, 0).setValue(position.WordIndex);
|
new ZLIntegerOption(ZLOption.STATE_CATEGORY, group, WORD_PREFIX + i, 0).setValue(position.WordIndex);
|
||||||
new ZLIntegerOption(ZLOption.STATE_CATEGORY, group, CHAR_PREFIX + i, 0).setValue(position.CharIndex);
|
new ZLIntegerOption(ZLOption.STATE_CATEGORY, group, CHAR_PREFIX + i, 0).setValue(position.CharIndex);
|
||||||
|
new ZLIntegerOption(ZLOption.STATE_CATEGORY, group, MODEL_PREFIX + i, 0).setValue(position.ModelIndex);
|
||||||
|
System.out.println("saving model index " + position.ModelIndex);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -224,4 +241,5 @@ public class BookTextView extends FBView {
|
||||||
gotoPosition((Position)myPositionStack.get(++myCurrentPointInStack));
|
gotoPosition((Position)myPositionStack.get(++myCurrentPointInStack));
|
||||||
((FBReader)Application).refreshWindow();
|
((FBReader)Application).refreshWindow();
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -267,7 +267,9 @@ public final class FBReader extends ZLApplication {
|
||||||
if (myBookModel != null) {
|
if (myBookModel != null) {
|
||||||
BookModel.Label label = myBookModel.getLabel(id);
|
BookModel.Label label = myBookModel.getLabel(id);
|
||||||
if ((label != null) && (label.Model != null)) {
|
if ((label != null) && (label.Model != null)) {
|
||||||
if (label.Model == myBookModel.BookTextModel) {
|
// if (label.Model == myBookModel.BookTextModel) {
|
||||||
|
if (label.ModelNumber != -1) {
|
||||||
|
BookTextView.setModel(label.ModelNumber);
|
||||||
BookTextView.gotoParagraphSafe(label.ParagraphNumber);
|
BookTextView.gotoParagraphSafe(label.ParagraphNumber);
|
||||||
} else {
|
} else {
|
||||||
FootnoteView.setModel(label.Model);
|
FootnoteView.setModel(label.Model);
|
||||||
|
@ -291,7 +293,7 @@ public final class FBReader extends ZLApplication {
|
||||||
void openBookInternal(BookDescription description) {
|
void openBookInternal(BookDescription description) {
|
||||||
if (description != null) {
|
if (description != null) {
|
||||||
BookTextView.saveState();
|
BookTextView.saveState();
|
||||||
BookTextView.setModel(null, "");
|
BookTextView.setModels(null, "");
|
||||||
BookTextView.setContentsModel(null);
|
BookTextView.setContentsModel(null);
|
||||||
ContentsView.setModel(null);
|
ContentsView.setModel(null);
|
||||||
|
|
||||||
|
@ -299,7 +301,8 @@ public final class FBReader extends ZLApplication {
|
||||||
final String fileName = description.FileName;
|
final String fileName = description.FileName;
|
||||||
myBookNameOption.setValue(fileName);
|
myBookNameOption.setValue(fileName);
|
||||||
ZLTextHyphenator.getInstance().load(description.getLanguage());
|
ZLTextHyphenator.getInstance().load(description.getLanguage());
|
||||||
BookTextView.setModel(myBookModel.BookTextModel, fileName);
|
// BookTextView.setModel(myBookModel.BookTextModel, fileName);
|
||||||
|
BookTextView.setModels(myBookModel.getBookTextModels(), fileName);
|
||||||
BookTextView.setCaption(description.getTitle());
|
BookTextView.setCaption(description.getTitle());
|
||||||
BookTextView.setContentsModel(myBookModel.ContentsModel);
|
BookTextView.setContentsModel(myBookModel.ContentsModel);
|
||||||
FootnoteView.setModel(null);
|
FootnoteView.setModel(null);
|
||||||
|
|
|
@ -40,7 +40,7 @@ public class PluginCollection {
|
||||||
if (ourInstance == null) {
|
if (ourInstance == null) {
|
||||||
ourInstance = new PluginCollection();
|
ourInstance = new PluginCollection();
|
||||||
ourInstance.myPlugins.add(new FB2Plugin());
|
ourInstance.myPlugins.add(new FB2Plugin());
|
||||||
//ourInstance.myPlugins.add(new PluckerPlugin());
|
ourInstance.myPlugins.add(new PluckerPlugin());
|
||||||
//ourInstance->myPlugins.push_back(new DocBookPlugin());
|
//ourInstance->myPlugins.push_back(new DocBookPlugin());
|
||||||
//ourInstance.myPlugins.add(new HtmlPlugin());
|
//ourInstance.myPlugins.add(new HtmlPlugin());
|
||||||
/*ourInstance.myPlugins.add(new TxtPlugin());
|
/*ourInstance.myPlugins.add(new TxtPlugin());
|
||||||
|
|
|
@ -190,8 +190,9 @@ public class PluckerBookReader extends BookReader {
|
||||||
myParagraphVector = (ArrayList)myParagraphMap.get(uid);
|
myParagraphVector = (ArrayList)myParagraphMap.get(uid);
|
||||||
processTextRecord(size, pars);
|
processTextRecord(size, pars);
|
||||||
if ((flags & 0x1) == 0) {
|
if ((flags & 0x1) == 0) {
|
||||||
// System.out.println("insert endoftext");
|
System.out.println("setting new text model");
|
||||||
insertEndOfTextParagraph();
|
// insertEndOfTextParagraph();
|
||||||
|
setNewTextModel();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
@ -202,8 +203,8 @@ public class PluckerBookReader extends BookReader {
|
||||||
final String mime = "image/palm";
|
final String mime = "image/palm";
|
||||||
ZLImage image = null;
|
ZLImage image = null;
|
||||||
if (type == 2) {
|
if (type == 2) {
|
||||||
System.out.println("type2");
|
// System.out.println("type2");
|
||||||
image = new ZLFileImage(mime, myFilePath, myStream.offset());
|
// image = new PluckerFileImage(mime, myFilePath, myStream.offset(), recordSize - 8);
|
||||||
} else if (myCompressionVersion == 1) {
|
} else if (myCompressionVersion == 1) {
|
||||||
//image = new DocCompressedFileImage(mime, myFilePath, myStream->offset(), recordSize - 8);
|
//image = new DocCompressedFileImage(mime, myFilePath, myStream->offset(), recordSize - 8);
|
||||||
} else if (myCompressionVersion == 2) {
|
} else if (myCompressionVersion == 2) {
|
||||||
|
@ -341,7 +342,7 @@ public class PluckerBookReader extends BookReader {
|
||||||
break;
|
break;
|
||||||
case 0x1A:
|
case 0x1A:
|
||||||
safeBeginParagraph();
|
safeBeginParagraph();
|
||||||
System.out.println("image ref");
|
// System.out.println("image ref");
|
||||||
addImageReference(fromNumber(twoBytes(ptr, cur + 1)), (short) 0);
|
addImageReference(fromNumber(twoBytes(ptr, cur + 1)), (short) 0);
|
||||||
break;
|
break;
|
||||||
case 0x22:
|
case 0x22:
|
||||||
|
@ -381,7 +382,7 @@ public class PluckerBookReader extends BookReader {
|
||||||
case 0x53: // color setting is ignored
|
case 0x53: // color setting is ignored
|
||||||
break;
|
break;
|
||||||
case 0x5C:
|
case 0x5C:
|
||||||
System.out.println("image ref");
|
// System.out.println("image ref");
|
||||||
addImageReference(fromNumber(twoBytes(ptr, cur + 3)), (short) 0);
|
addImageReference(fromNumber(twoBytes(ptr, cur + 3)), (short) 0);
|
||||||
break;
|
break;
|
||||||
case 0x60: // underlined text is ignored
|
case 0x60: // underlined text is ignored
|
||||||
|
|
|
@ -25,6 +25,9 @@ import org.geometerplus.zlibrary.core.util.*;
|
||||||
import org.geometerplus.zlibrary.core.library.ZLibrary;
|
import org.geometerplus.zlibrary.core.library.ZLibrary;
|
||||||
|
|
||||||
public class ZLFileImage implements ZLImage {
|
public class ZLFileImage implements ZLImage {
|
||||||
|
private final String myPath;
|
||||||
|
private final int myOffset;
|
||||||
|
|
||||||
public ZLFileImage(String mimeType, String path, int offset) {
|
public ZLFileImage(String mimeType, String path, int offset) {
|
||||||
myPath = path;
|
myPath = path;
|
||||||
myOffset = offset;
|
myOffset = offset;
|
||||||
|
@ -53,9 +56,7 @@ public class ZLFileImage implements ZLImage {
|
||||||
return buffer;
|
return buffer;
|
||||||
} catch (IOException e) {
|
} catch (IOException e) {
|
||||||
}
|
}
|
||||||
|
|
||||||
return new byte[0];
|
return new byte[0];
|
||||||
}
|
}
|
||||||
|
|
||||||
private final String myPath;
|
|
||||||
private final int myOffset;
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -19,6 +19,9 @@
|
||||||
|
|
||||||
package org.geometerplus.zlibrary.text.view;
|
package org.geometerplus.zlibrary.text.view;
|
||||||
|
|
||||||
|
import java.util.*;
|
||||||
|
import org.geometerplus.zlibrary.core.util.*;
|
||||||
|
|
||||||
import org.geometerplus.zlibrary.core.view.*;
|
import org.geometerplus.zlibrary.core.view.*;
|
||||||
import org.geometerplus.zlibrary.core.application.ZLApplication;
|
import org.geometerplus.zlibrary.core.application.ZLApplication;
|
||||||
|
|
||||||
|
@ -36,7 +39,15 @@ public abstract class ZLTextView extends ZLView {
|
||||||
super(application, context);
|
super(application, context);
|
||||||
}
|
}
|
||||||
|
|
||||||
public abstract void setModel(ZLTextModel model);
|
public final void setModel(ZLTextModel model) {
|
||||||
|
final ArrayList list = new ArrayList(1);
|
||||||
|
list.add(model);
|
||||||
|
setModels(list, 0);
|
||||||
|
}
|
||||||
|
|
||||||
|
public abstract void setModel(int modelNumber);
|
||||||
|
|
||||||
|
public abstract void setModels(ArrayList/*<ZLTextModel>*/ model, int current);
|
||||||
|
|
||||||
public abstract void scrollPage(boolean forward, int scrollingMode, int value);
|
public abstract void scrollPage(boolean forward, int scrollingMode, int value);
|
||||||
|
|
||||||
|
|
|
@ -19,6 +19,8 @@
|
||||||
|
|
||||||
package org.geometerplus.zlibrary.text.view.impl;
|
package org.geometerplus.zlibrary.text.view.impl;
|
||||||
|
|
||||||
|
import java.util.ArrayList;
|
||||||
|
|
||||||
import org.geometerplus.zlibrary.core.application.ZLApplication;
|
import org.geometerplus.zlibrary.core.application.ZLApplication;
|
||||||
import org.geometerplus.zlibrary.core.view.ZLPaintContext;
|
import org.geometerplus.zlibrary.core.view.ZLPaintContext;
|
||||||
import org.geometerplus.zlibrary.text.model.*;
|
import org.geometerplus.zlibrary.text.model.*;
|
||||||
|
@ -28,17 +30,21 @@ import org.geometerplus.zlibrary.text.view.style.*;
|
||||||
|
|
||||||
public abstract class ZLTextViewImpl extends ZLTextView {
|
public abstract class ZLTextViewImpl extends ZLTextView {
|
||||||
private ZLTextModel myModel;
|
private ZLTextModel myModel;
|
||||||
|
protected int myCurrentModelIndex; //?
|
||||||
|
private ArrayList/*<ZLTextModel>*/ myModels;
|
||||||
private final ZLTextSelectionModel mySelectionModel;
|
private final ZLTextSelectionModel mySelectionModel;
|
||||||
|
|
||||||
protected class Position {
|
protected class Position {
|
||||||
public int ParagraphIndex;
|
public int ParagraphIndex;
|
||||||
public int WordIndex;
|
public int WordIndex;
|
||||||
public int CharIndex;
|
public int CharIndex;
|
||||||
|
public int ModelIndex;
|
||||||
|
|
||||||
public Position(int paragraphIndex, int wordIndex, int charIndex) {
|
public Position(int paragraphIndex, int wordIndex, int charIndex, int modelIndex) {
|
||||||
ParagraphIndex = paragraphIndex;
|
ParagraphIndex = paragraphIndex;
|
||||||
WordIndex = wordIndex;
|
WordIndex = wordIndex;
|
||||||
CharIndex = charIndex;
|
CharIndex = charIndex;
|
||||||
|
ModelIndex = modelIndex;
|
||||||
}
|
}
|
||||||
|
|
||||||
public Position(ZLTextWordCursor cursor) {
|
public Position(ZLTextWordCursor cursor) {
|
||||||
|
@ -51,6 +57,8 @@ public abstract class ZLTextViewImpl extends ZLTextView {
|
||||||
WordIndex = cursor.getWordIndex();
|
WordIndex = cursor.getWordIndex();
|
||||||
CharIndex = cursor.getCharIndex();
|
CharIndex = cursor.getCharIndex();
|
||||||
}
|
}
|
||||||
|
ModelIndex = myCurrentModelIndex;
|
||||||
|
// System.out.println("creating position " + myCurrentModelIndex);
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean equalsToCursor(ZLTextWordCursor cursor) {
|
public boolean equalsToCursor(ZLTextWordCursor cursor) {
|
||||||
|
@ -58,7 +66,9 @@ public abstract class ZLTextViewImpl extends ZLTextView {
|
||||||
(ParagraphIndex == cursor.getParagraphCursor().Index) &&
|
(ParagraphIndex == cursor.getParagraphCursor().Index) &&
|
||||||
(WordIndex == cursor.getWordIndex()) &&
|
(WordIndex == cursor.getWordIndex()) &&
|
||||||
(CharIndex == cursor.getCharIndex());
|
(CharIndex == cursor.getCharIndex());
|
||||||
|
// (ModelIndex == cursor.getModelIndex());
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private interface SizeUnit {
|
private interface SizeUnit {
|
||||||
|
@ -104,23 +114,43 @@ public abstract class ZLTextViewImpl extends ZLTextView {
|
||||||
mySelectionModel = new ZLTextSelectionModel(this, application);
|
mySelectionModel = new ZLTextSelectionModel(this, application);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setModel(ZLTextModel model) {
|
public void setModels(ArrayList models, int current) {
|
||||||
myModel = model;
|
System.out.println(current);
|
||||||
if (model != null) {
|
myModels = (models != null) ? models : new ArrayList();
|
||||||
final int paragraphsNumber = model.getParagraphsNumber();
|
myModel = (current >= 0 && current < myModels.size()) ?
|
||||||
|
(ZLTextModel) myModels.get(current) : null;
|
||||||
|
myCurrentModelIndex = current;
|
||||||
|
setModelInternal();
|
||||||
|
}
|
||||||
|
|
||||||
|
private void setModelInternal() {
|
||||||
|
if (myModel != null) {
|
||||||
|
final int paragraphsNumber = myModel.getParagraphsNumber();
|
||||||
if (paragraphsNumber > 0) {
|
if (paragraphsNumber > 0) {
|
||||||
myTextSize = new int[paragraphsNumber + 1];
|
myTextSize = new int[paragraphsNumber + 1];
|
||||||
myTextSize[0] = 0;
|
myTextSize[0] = 0;
|
||||||
for (int i = 0; i < paragraphsNumber; ++i) {
|
for (int i = 0; i < paragraphsNumber; ++i) {
|
||||||
myTextSize[i + 1] = myTextSize[i] + model.getParagraphTextLength(i);
|
myTextSize[i + 1] = myTextSize[i] + myModel.getParagraphTextLength(i);
|
||||||
}
|
}
|
||||||
StartCursor.setCursor(ZLTextParagraphCursor.cursor(model, 0));
|
StartCursor.setCursor(ZLTextParagraphCursor.cursor(myModel, 0));
|
||||||
EndCursor.reset();
|
EndCursor.reset();
|
||||||
myPaintState = PaintState.START_IS_KNOWN;
|
myPaintState = PaintState.START_IS_KNOWN;
|
||||||
|
|
||||||
|
// StartCursor.setModelIndex(myCurrentModelIndex);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void setModel(int modelNumber) {
|
||||||
|
if ((modelNumber != myCurrentModelIndex) && (modelNumber >= 0) &&
|
||||||
|
(modelNumber < myModels.size())) {
|
||||||
|
myModel = (ZLTextModel) myModels.get(modelNumber);
|
||||||
|
myCurrentModelIndex = modelNumber;
|
||||||
|
System.out.println("setting model number " + modelNumber);
|
||||||
|
setModelInternal();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
protected ZLTextModel getModel() {
|
protected ZLTextModel getModel() {
|
||||||
return myModel;
|
return myModel;
|
||||||
}
|
}
|
||||||
|
@ -310,9 +340,11 @@ public abstract class ZLTextViewImpl extends ZLTextView {
|
||||||
if (StartCursor.isNull()) {
|
if (StartCursor.isNull()) {
|
||||||
preparePaintInfo();
|
preparePaintInfo();
|
||||||
}
|
}
|
||||||
if (!position.equalsToCursor(StartCursor)) {
|
/* if (!position.equalsToCursor(StartCursor)) {
|
||||||
savePosition(position);
|
savePosition(position);
|
||||||
}
|
}
|
||||||
|
*/
|
||||||
|
savePosition(position, StartCursor);
|
||||||
Application.refreshWindow();
|
Application.refreshWindow();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -320,6 +352,13 @@ public abstract class ZLTextViewImpl extends ZLTextView {
|
||||||
protected void savePosition(Position position) {
|
protected void savePosition(Position position) {
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//?
|
||||||
|
protected final void savePosition(Position position, ZLTextWordCursor cursor) {
|
||||||
|
if (!position.equalsToCursor(cursor)) {
|
||||||
|
savePosition(position);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
public void search(final String text, boolean ignoreCase, boolean wholeText, boolean backward, boolean thisSectionOnly) {
|
public void search(final String text, boolean ignoreCase, boolean wholeText, boolean backward, boolean thisSectionOnly) {
|
||||||
if (text.length() == 0) {
|
if (text.length() == 0) {
|
||||||
return;
|
return;
|
||||||
|
@ -1021,7 +1060,7 @@ public abstract class ZLTextViewImpl extends ZLTextView {
|
||||||
}
|
}
|
||||||
|
|
||||||
public final void gotoPosition(Position position) {
|
public final void gotoPosition(Position position) {
|
||||||
gotoPosition(position.ParagraphIndex, position.WordIndex, position.CharIndex);
|
gotoPosition(position.ParagraphIndex, position.WordIndex, position.CharIndex, position.ModelIndex);
|
||||||
}
|
}
|
||||||
|
|
||||||
public final void gotoPosition(int paragraphIndex, int wordIndex, int charIndex) {
|
public final void gotoPosition(int paragraphIndex, int wordIndex, int charIndex) {
|
||||||
|
@ -1037,6 +1076,11 @@ public abstract class ZLTextViewImpl extends ZLTextView {
|
||||||
EndCursor.reset();
|
EndCursor.reset();
|
||||||
myPaintState = PaintState.START_IS_KNOWN;
|
myPaintState = PaintState.START_IS_KNOWN;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public final void gotoPosition(int paragraphIndex, int wordIndex, int charIndex, int modelIndex) {
|
||||||
|
setModel(modelIndex);
|
||||||
|
gotoPosition(paragraphIndex, wordIndex, charIndex);
|
||||||
|
}
|
||||||
|
|
||||||
public void gotoParagraph(int num, boolean last) {
|
public void gotoParagraph(int num, boolean last) {
|
||||||
if (myModel == null) {
|
if (myModel == null) {
|
||||||
|
@ -1441,9 +1485,11 @@ public abstract class ZLTextViewImpl extends ZLTextView {
|
||||||
if (StartCursor.isNull()) {
|
if (StartCursor.isNull()) {
|
||||||
preparePaintInfo();
|
preparePaintInfo();
|
||||||
}
|
}
|
||||||
if (!position.equalsToCursor(StartCursor)) {
|
/* if (!position.equalsToCursor(StartCursor)) {
|
||||||
savePosition(position);
|
savePosition(position);
|
||||||
}
|
}
|
||||||
|
*/
|
||||||
|
savePosition(position, StartCursor);
|
||||||
Application.refreshWindow();
|
Application.refreshWindow();
|
||||||
myTreeStateIsFrozen = false;
|
myTreeStateIsFrozen = false;
|
||||||
return true;
|
return true;
|
||||||
|
@ -1510,4 +1556,5 @@ public abstract class ZLTextViewImpl extends ZLTextView {
|
||||||
Application.refreshWindow();
|
Application.refreshWindow();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -25,6 +25,8 @@ public final class ZLTextWordCursor {
|
||||||
private ZLTextParagraphCursor myParagraphCursor;
|
private ZLTextParagraphCursor myParagraphCursor;
|
||||||
private int myWordIndex;
|
private int myWordIndex;
|
||||||
private int myCharIndex;
|
private int myCharIndex;
|
||||||
|
|
||||||
|
// private int myModelIndex;
|
||||||
|
|
||||||
public ZLTextWordCursor() {
|
public ZLTextWordCursor() {
|
||||||
}
|
}
|
||||||
|
@ -197,4 +199,13 @@ public final class ZLTextWordCursor {
|
||||||
moveTo(myWordIndex, myCharIndex);
|
moveTo(myWordIndex, myCharIndex);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* public int getModelIndex() {
|
||||||
|
return myModelIndex;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setModelIndex(int modelIndex) {
|
||||||
|
myModelIndex = modelIndex;
|
||||||
|
}
|
||||||
|
*/
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue