mirror of
https://github.com/geometer/FBReaderJ.git
synced 2025-10-04 02:09:35 +02:00
refactoring (compute hilites one time per page)
This commit is contained in:
parent
7f71050027
commit
e23808f87e
1 changed files with 21 additions and 18 deletions
|
@ -508,11 +508,13 @@ public abstract class ZLTextView extends ZLTextViewBase {
|
||||||
previousInfo = info;
|
previousInfo = info;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
final List<ZLTextHighlighting> hilites = findHilites(page);
|
||||||
|
if (!hilites.isEmpty()) {
|
||||||
x = getLeftMargin();
|
x = getLeftMargin();
|
||||||
y = getTopMargin();
|
y = getTopMargin();
|
||||||
index = 0;
|
index = 0;
|
||||||
for (ZLTextLineInfo info : lineInfos) {
|
for (ZLTextLineInfo info : lineInfos) {
|
||||||
drawHighlightings(page, info, labels[index], labels[index + 1], x, y);
|
drawHighlightings(page, hilites, info, labels[index], labels[index + 1], x, y);
|
||||||
y += info.Height + info.Descent + info.VSpaceAfter;
|
y += info.Height + info.Descent + info.VSpaceAfter;
|
||||||
++index;
|
++index;
|
||||||
if (index == page.Column0Height) {
|
if (index == page.Column0Height) {
|
||||||
|
@ -520,12 +522,13 @@ public abstract class ZLTextView extends ZLTextViewBase {
|
||||||
x += page.getTextWidth() + getSpaceBetweenColumns();
|
x += page.getTextWidth() + getSpaceBetweenColumns();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
x = getLeftMargin();
|
x = getLeftMargin();
|
||||||
y = getTopMargin();
|
y = getTopMargin();
|
||||||
index = 0;
|
index = 0;
|
||||||
for (ZLTextLineInfo info : lineInfos) {
|
for (ZLTextLineInfo info : lineInfos) {
|
||||||
drawTextLine(page, info, labels[index], labels[index + 1]);
|
drawTextLine(page, hilites, info, labels[index], labels[index + 1]);
|
||||||
y += info.Height + info.Descent + info.VSpaceAfter;
|
y += info.Height + info.Descent + info.VSpaceAfter;
|
||||||
++index;
|
++index;
|
||||||
if (index == page.Column0Height) {
|
if (index == page.Column0Height) {
|
||||||
|
@ -823,11 +826,7 @@ public abstract class ZLTextView extends ZLTextViewBase {
|
||||||
preparePaintInfo();
|
preparePaintInfo();
|
||||||
}
|
}
|
||||||
|
|
||||||
private void drawHighlightings(ZLTextPage page, ZLTextLineInfo info, int from, int to, int x, int y) {
|
private List<ZLTextHighlighting> findHilites(ZLTextPage page) {
|
||||||
if (from == to) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
final LinkedList<ZLTextHighlighting> hilites = new LinkedList<ZLTextHighlighting>();
|
final LinkedList<ZLTextHighlighting> hilites = new LinkedList<ZLTextHighlighting>();
|
||||||
if (mySelection.intersects(page)) {
|
if (mySelection.intersects(page)) {
|
||||||
hilites.add(mySelection);
|
hilites.add(mySelection);
|
||||||
|
@ -839,7 +838,11 @@ public abstract class ZLTextView extends ZLTextViewBase {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (hilites.isEmpty()) {
|
return hilites;
|
||||||
|
}
|
||||||
|
|
||||||
|
private void drawHighlightings(ZLTextPage page, List<ZLTextHighlighting> hilites, ZLTextLineInfo info, int from, int to, int x, int y) {
|
||||||
|
if (from == to) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -880,7 +883,7 @@ public abstract class ZLTextView extends ZLTextViewBase {
|
||||||
protected abstract ZLPaintContext.ColorAdjustingMode getAdjustingModeForImages();
|
protected abstract ZLPaintContext.ColorAdjustingMode getAdjustingModeForImages();
|
||||||
|
|
||||||
private static final char[] SPACE = new char[] { ' ' };
|
private static final char[] SPACE = new char[] { ' ' };
|
||||||
private void drawTextLine(ZLTextPage page, ZLTextLineInfo info, int from, int to) {
|
private void drawTextLine(ZLTextPage page, List<ZLTextHighlighting> hilites, ZLTextLineInfo info, int from, int to) {
|
||||||
final ZLPaintContext context = getContext();
|
final ZLPaintContext context = getContext();
|
||||||
final ZLTextParagraphCursor paragraph = info.ParagraphCursor;
|
final ZLTextParagraphCursor paragraph = info.ParagraphCursor;
|
||||||
int index = from;
|
int index = from;
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue