mirror of
https://github.com/geometer/FBReaderJ.git
synced 2025-10-05 10:49:24 +02:00
images can be selected
This commit is contained in:
parent
2a0e9e25b2
commit
114b9b8ed0
5 changed files with 66 additions and 25 deletions
|
@ -177,7 +177,7 @@ public final class FBView extends ZLTextView {
|
|||
}
|
||||
}
|
||||
|
||||
final ZLTextElementRegion region = findRegion(x, y, 10, ZLTextHyperlinkRegion.Filter);
|
||||
final ZLTextElementRegion region = findRegion(x, y, 10, ZLTextElementRegion.ImageOrHyperlinkFilter);
|
||||
if (region != null) {
|
||||
selectRegion(region);
|
||||
myReader.repaintView();
|
||||
|
@ -352,7 +352,7 @@ public final class FBView extends ZLTextView {
|
|||
|
||||
if (myReader.DictionaryTappingActionOption.getValue() !=
|
||||
FBReaderApp.DictionaryTappingAction.doNothing) {
|
||||
final ZLTextElementRegion region = findRegion(x, y, 10, ZLTextElementRegion.Filter);
|
||||
final ZLTextElementRegion region = findRegion(x, y, 10, ZLTextElementRegion.AnyRegionFilter);
|
||||
if (region != null) {
|
||||
selectRegion(region);
|
||||
myReader.repaintView();
|
||||
|
@ -370,7 +370,7 @@ public final class FBView extends ZLTextView {
|
|||
|
||||
if (myReader.DictionaryTappingActionOption.getValue() !=
|
||||
FBReaderApp.DictionaryTappingAction.doNothing) {
|
||||
final ZLTextElementRegion region = findRegion(x, y, 10, ZLTextElementRegion.Filter);
|
||||
final ZLTextElementRegion region = findRegion(x, y, 10, ZLTextElementRegion.AnyRegionFilter);
|
||||
if (region != null) {
|
||||
selectRegion(region);
|
||||
myReader.repaintView();
|
||||
|
@ -406,7 +406,7 @@ public final class FBView extends ZLTextView {
|
|||
ZLTextElementRegion region = currentRegion();
|
||||
final ZLTextElementRegion.Filter filter =
|
||||
region instanceof ZLTextWordRegion || myReader.NavigateAllWordsOption.getValue()
|
||||
? ZLTextElementRegion.Filter : ZLTextHyperlinkRegion.Filter;
|
||||
? ZLTextElementRegion.AnyRegionFilter : ZLTextElementRegion.ImageOrHyperlinkFilter;
|
||||
region = nextRegion(direction, filter);
|
||||
if (region != null) {
|
||||
selectRegion(region);
|
||||
|
|
|
@ -37,20 +37,7 @@ final class ZLTextElementAreaVector extends ArrayList<ZLTextElementArea> {
|
|||
@Override
|
||||
public boolean add(ZLTextElementArea area) {
|
||||
final ZLTextHyperlink hyperlink = area.Style.Hyperlink;
|
||||
if (hyperlink.Id == null) {
|
||||
if (area.Element instanceof ZLTextWord && ((ZLTextWord)area.Element).isAWord()) {
|
||||
if (!(myCurrentElementRegion instanceof ZLTextWordRegion) ||
|
||||
((ZLTextWordRegion)myCurrentElementRegion).Word != area.Element) {
|
||||
myCurrentElementRegion =
|
||||
new ZLTextWordRegion((ZLTextWord)area.Element, this, size());
|
||||
ElementRegions.add(myCurrentElementRegion);
|
||||
} else {
|
||||
myCurrentElementRegion.extend();
|
||||
}
|
||||
} else {
|
||||
myCurrentElementRegion = null;
|
||||
}
|
||||
} else {
|
||||
if (hyperlink.Id != null) {
|
||||
if (!(myCurrentElementRegion instanceof ZLTextHyperlinkRegion) ||
|
||||
((ZLTextHyperlinkRegion)myCurrentElementRegion).Hyperlink != hyperlink) {
|
||||
myCurrentElementRegion = new ZLTextHyperlinkRegion(hyperlink, this, size());
|
||||
|
@ -58,6 +45,20 @@ final class ZLTextElementAreaVector extends ArrayList<ZLTextElementArea> {
|
|||
} else {
|
||||
myCurrentElementRegion.extend();
|
||||
}
|
||||
} else if (area.Element instanceof ZLTextImageElement) {
|
||||
ElementRegions.add(new ZLTextImageRegion((ZLTextImageElement)area.Element, this, size()));
|
||||
myCurrentElementRegion = null;
|
||||
} else if (area.Element instanceof ZLTextWord && ((ZLTextWord)area.Element).isAWord()) {
|
||||
if (!(myCurrentElementRegion instanceof ZLTextWordRegion) ||
|
||||
((ZLTextWordRegion)myCurrentElementRegion).Word != area.Element) {
|
||||
myCurrentElementRegion =
|
||||
new ZLTextWordRegion((ZLTextWord)area.Element, this, size());
|
||||
ElementRegions.add(myCurrentElementRegion);
|
||||
} else {
|
||||
myCurrentElementRegion.extend();
|
||||
}
|
||||
} else {
|
||||
myCurrentElementRegion = null;
|
||||
}
|
||||
return super.add(area);
|
||||
}
|
||||
|
|
|
@ -28,12 +28,20 @@ public abstract class ZLTextElementRegion {
|
|||
boolean accepts(ZLTextElementRegion region);
|
||||
}
|
||||
|
||||
public static Filter Filter = new Filter() {
|
||||
public static Filter AnyRegionFilter = new Filter() {
|
||||
public boolean accepts(ZLTextElementRegion region) {
|
||||
return true;
|
||||
}
|
||||
};
|
||||
|
||||
public static Filter ImageOrHyperlinkFilter = new Filter() {
|
||||
public boolean accepts(ZLTextElementRegion region) {
|
||||
return
|
||||
region instanceof ZLTextImageRegion ||
|
||||
region instanceof ZLTextHyperlinkRegion;
|
||||
}
|
||||
};
|
||||
|
||||
private final List<ZLTextElementArea> myList;
|
||||
private final int myFromIndex;
|
||||
private int myToIndex;
|
||||
|
|
|
@ -22,12 +22,6 @@ package org.geometerplus.zlibrary.text.view;
|
|||
import java.util.List;
|
||||
|
||||
public class ZLTextHyperlinkRegion extends ZLTextElementRegion {
|
||||
public static Filter Filter = new Filter() {
|
||||
public boolean accepts(ZLTextElementRegion region) {
|
||||
return region instanceof ZLTextHyperlinkRegion;
|
||||
}
|
||||
};
|
||||
|
||||
public final ZLTextHyperlink Hyperlink;
|
||||
|
||||
ZLTextHyperlinkRegion(ZLTextHyperlink hyperlink, List<ZLTextElementArea> list, int fromIndex) {
|
||||
|
|
|
@ -0,0 +1,38 @@
|
|||
/*
|
||||
* Copyright (C) 2009-2011 Geometer Plus <contact@geometerplus.com>
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation; either version 2 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program; if not, write to the Free Software
|
||||
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
|
||||
* 02110-1301, USA.
|
||||
*/
|
||||
|
||||
package org.geometerplus.zlibrary.text.view;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
public class ZLTextImageRegion extends ZLTextElementRegion {
|
||||
public final ZLTextImageElement ImageElement;
|
||||
|
||||
ZLTextImageRegion(ZLTextImageElement imageElement, List<ZLTextElementArea> list, int fromIndex) {
|
||||
super(list, fromIndex);
|
||||
ImageElement = imageElement;
|
||||
}
|
||||
|
||||
public boolean equals(Object other) {
|
||||
if (!(other instanceof ZLTextImageRegion)) {
|
||||
return false;
|
||||
}
|
||||
return ImageElement == ((ZLTextImageRegion)other).ImageElement;
|
||||
}
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue