本文整理了Java中com.koolearn.klibrary.text.view.ZLTextWord
类的一些代码示例,展示了ZLTextWord
类的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。ZLTextWord
类的具体详情如下:
包路径:com.koolearn.klibrary.text.view.ZLTextWord
类名称:ZLTextWord
暂无
代码示例来源:origin: ydcx/KooReader
private final void addWord(char[] data, int offset, int len, int paragraphOffset, ZLTextHyperlink hyperlink) {
ZLTextWord word = new ZLTextWord(data, offset, len, paragraphOffset);
for (int i = myFirstMark; i < myLastMark; ++i) {
final ZLTextMark mark = (ZLTextMark)myMarks.get(i);
if ((mark.Offset < paragraphOffset + len) && (mark.Offset + mark.Length > paragraphOffset)) {
word.addMark(mark.Offset - paragraphOffset, mark.Length);
}
}
if (hyperlink != null) {
hyperlink.addElementIndex(myElements.size());
}
myElements.add(word);
}
}
代码示例来源:origin: ydcx/KooReader
@Override
public String toString() {
return getString();
}
代码示例来源:origin: Jiangzqts/EpubRead
final int getWordWidth(ZLTextWord word, int start) {
return
start == 0 ?
word.getWidth(getContext()) :
getContext().getStringWidth(word.Data, word.Offset + start, word.Length - start);
}
代码示例来源:origin: Jiangzqts/EpubRead
public ZLTextMark getMark() {
if (myParagraphCursor == null) {
return null;
}
final ZLTextParagraphCursor paragraph = myParagraphCursor;
int paragraphLength = paragraph.getParagraphLength();
int wordIndex = myElementIndex;
while ((wordIndex < paragraphLength) && (!(paragraph.getElement(wordIndex) instanceof ZLTextWord))) {
wordIndex++;
}
if (wordIndex < paragraphLength) {
return new ZLTextMark(paragraph.Index, ((ZLTextWord) paragraph.getElement(wordIndex)).getParagraphOffset(), 0);
}
return new ZLTextMark(paragraph.Index + 1, 0, 0);
}
代码示例来源:origin: ydcx/KooReader
void fill() {
ZLTextParagraph paragraph = Model.getParagraph(Index);
switch (paragraph.getKind()) {
case ZLTextParagraph.Kind.TEXT_PARAGRAPH:
new Processor(paragraph, CursorManager.ExtensionManager, new LineBreaker(Model.getLanguage()), Model.getMarks(), Index, myElements).fill();
break;
case ZLTextParagraph.Kind.EMPTY_LINE_PARAGRAPH:
myElements.add(new ZLTextWord(SPACE_ARRAY, 0, 1, 0));
break;
case ZLTextParagraph.Kind.ENCRYPTED_SECTION_PARAGRAPH:
{
final ZLTextStyleEntry entry = new ZLTextOtherStyleEntry();
entry.setFontModifier(ZLTextStyleEntry.FontModifier.FONT_MODIFIER_BOLD, true);
myElements.add(new ZLTextStyleElement(entry));
myElements.add(new ZLTextWord(ZLResource.resource("drm").getResource("encryptedSection").getValue(), 0));
break;
}
default:
break;
}
}
代码示例来源:origin: ydcx/KooReader
final void drawWord(int x, int y, ZLTextWord word, int start, int length, boolean addHyphenationSign, ZLColor color) {
final ZLPaintContext context = getContext();
if (start == 0 && length == -1) {
drawString(context, x, y, word.Data, word.Offset, word.Length, word.getMark(), color, 0);
} else {
LogUtil.i10("drawWord");
if (length == -1) {
length = word.Length - start;
}
if (!addHyphenationSign) {
drawString(context, x, y, word.Data, word.Offset + start, length, word.getMark(), color, start);
} else {
char[] part = myWordPartArray;
if (length + 1 > part.length) {
part = new char[length + 1];
myWordPartArray = part;
}
System.arraycopy(word.Data, word.Offset + start, part, 0, length);
part[length] = '-';
drawString(context, x, y, part, 0, length + 1, word.getMark(), color, start);
}
}
}
代码示例来源:origin: ydcx/KooReader
public boolean add(ZLTextElementArea area) {
synchronized (myAreas) {
if (myCurrentElementRegion != null
&& myCurrentElementRegion.getSoul().accepts(area)) {
myCurrentElementRegion.extend();
} else {
ZLTextRegion.Soul soul = null;
final ZLTextHyperlink hyperlink = area.Style.Hyperlink;
if (hyperlink.Id != null) {
soul = new ZLTextHyperlinkRegionSoul(area, hyperlink);
} else if (area.Element instanceof ZLTextImageElement) {
soul = new ZLTextImageRegionSoul(area, (ZLTextImageElement)area.Element);
} else if (area.Element instanceof ZLTextVideoElement) {
soul = new ZLTextVideoRegionSoul(area, (ZLTextVideoElement)area.Element);
} else if (area.Element instanceof ZLTextWord && !((ZLTextWord)area.Element).isASpace()) {
soul = new ZLTextWordRegionSoul(area, (ZLTextWord)area.Element);
} else if (area.Element instanceof ExtensionElement) {
soul = new ExtensionRegionSoul(area, (ExtensionElement)area.Element);
}
if (soul != null) {
myCurrentElementRegion = new ZLTextRegion(soul, myAreas, myAreas.size());
myElementRegions.add(myCurrentElementRegion);
} else {
myCurrentElementRegion = null;
}
}
return myAreas.add(area);
}
}
代码示例来源:origin: ydcx/KooReader
final int getWordWidth(ZLTextWord word, int start) {
return
start == 0 ?
word.getWidth(getContext()) :
getContext().getStringWidth(word.Data, word.Offset + start, word.Length - start);
}
代码示例来源:origin: ydcx/KooReader
public ZLTextMark getMark() {
if (myParagraphCursor == null) {
return null;
}
final ZLTextParagraphCursor paragraph = myParagraphCursor;
int paragraphLength = paragraph.getParagraphLength();
int wordIndex = myElementIndex;
while ((wordIndex < paragraphLength) && (!(paragraph.getElement(wordIndex) instanceof ZLTextWord))) {
wordIndex++;
}
if (wordIndex < paragraphLength) {
return new ZLTextMark(paragraph.Index, ((ZLTextWord) paragraph.getElement(wordIndex)).getParagraphOffset(), 0);
}
return new ZLTextMark(paragraph.Index + 1, 0, 0);
}
代码示例来源:origin: Jiangzqts/EpubRead
void fill() {
ZLTextParagraph paragraph = Model.getParagraph(Index);
switch (paragraph.getKind()) {
case ZLTextParagraph.Kind.TEXT_PARAGRAPH:
new Processor(paragraph, CursorManager.ExtensionManager, new LineBreaker(Model.getLanguage()), Model.getMarks(), Index, myElements).fill();
break;
case ZLTextParagraph.Kind.EMPTY_LINE_PARAGRAPH:
myElements.add(new ZLTextWord(SPACE_ARRAY, 0, 1, 0));
break;
case ZLTextParagraph.Kind.ENCRYPTED_SECTION_PARAGRAPH:
{
final ZLTextStyleEntry entry = new ZLTextOtherStyleEntry();
entry.setFontModifier(ZLTextStyleEntry.FontModifier.FONT_MODIFIER_BOLD, true);
myElements.add(new ZLTextStyleElement(entry));
myElements.add(new ZLTextWord(ZLResource.resource("drm").getResource("encryptedSection").getValue(), 0));
break;
}
default:
break;
}
}
代码示例来源:origin: Jiangzqts/EpubRead
final void drawWord(int x, int y, ZLTextWord word, int start, int length, boolean addHyphenationSign, ZLColor color) {
final ZLPaintContext context = getContext();
if (start == 0 && length == -1) {
drawString(context, x, y, word.Data, word.Offset, word.Length, word.getMark(), color, 0);
} else {
LogUtil.i10("drawWord");
if (length == -1) {
length = word.Length - start;
}
if (!addHyphenationSign) {
drawString(context, x, y, word.Data, word.Offset + start, length, word.getMark(), color, start);
} else {
char[] part = myWordPartArray;
if (length + 1 > part.length) {
part = new char[length + 1];
myWordPartArray = part;
}
System.arraycopy(word.Data, word.Offset + start, part, 0, length);
part[length] = '-';
drawString(context, x, y, part, 0, length + 1, word.getMark(), color, start);
}
}
}
代码示例来源:origin: Jiangzqts/EpubRead
public boolean add(ZLTextElementArea area) {
synchronized (myAreas) {
if (myCurrentElementRegion != null
&& myCurrentElementRegion.getSoul().accepts(area)) {
myCurrentElementRegion.extend();
} else {
ZLTextRegion.Soul soul = null;
final ZLTextHyperlink hyperlink = area.Style.Hyperlink;
if (hyperlink.Id != null) {
soul = new ZLTextHyperlinkRegionSoul(area, hyperlink);
} else if (area.Element instanceof ZLTextImageElement) {
soul = new ZLTextImageRegionSoul(area, (ZLTextImageElement)area.Element);
} else if (area.Element instanceof ZLTextVideoElement) {
soul = new ZLTextVideoRegionSoul(area, (ZLTextVideoElement)area.Element);
} else if (area.Element instanceof ZLTextWord && !((ZLTextWord)area.Element).isASpace()) {
soul = new ZLTextWordRegionSoul(area, (ZLTextWord)area.Element);
} else if (area.Element instanceof ExtensionElement) {
soul = new ExtensionRegionSoul(area, (ExtensionElement)area.Element);
}
if (soul != null) {
myCurrentElementRegion = new ZLTextRegion(soul, myAreas, myAreas.size());
myElementRegions.add(myCurrentElementRegion);
} else {
myCurrentElementRegion = null;
}
}
return myAreas.add(area);
}
}
代码示例来源:origin: Jiangzqts/EpubRead
private final void addWord(char[] data, int offset, int len, int paragraphOffset, ZLTextHyperlink hyperlink) {
ZLTextWord word = new ZLTextWord(data, offset, len, paragraphOffset);
for (int i = myFirstMark; i < myLastMark; ++i) {
final ZLTextMark mark = myMarks.get(i);
if ((mark.Offset < paragraphOffset + len) && (mark.Offset + mark.Length > paragraphOffset)) {
word.addMark(mark.Offset - paragraphOffset, mark.Length);
}
}
if (hyperlink != null) {
hyperlink.addElementIndex(myElements.size());
}
myElements.add(word);
}
}
代码示例来源:origin: ydcx/KooReader
final int getWordWidth(ZLTextWord word, int start, int length, boolean addHyphenationSign) {
if (length == -1) {
if (start == 0) {
return word.getWidth(getContext());
}
length = word.Length - start;
}
if (!addHyphenationSign) {
return getContext().getStringWidth(word.Data, word.Offset + start, length);
}
char[] part = myWordPartArray;
if (length + 1 > part.length) {
part = new char[length + 1];
myWordPartArray = part;
}
System.arraycopy(word.Data, word.Offset + start, part, 0, length);
part[length] = '-';
return getContext().getStringWidth(part, 0, length + 1);
}
代码示例来源:origin: Jiangzqts/EpubRead
@Override
public String toString() {
return getString();
}
代码示例来源:origin: Jiangzqts/EpubRead
final int getWordWidth(ZLTextWord word, int start, int length, boolean addHyphenationSign) {
if (length == -1) {
if (start == 0) {
return word.getWidth(getContext());
}
length = word.Length - start;
}
if (!addHyphenationSign) {
return getContext().getStringWidth(word.Data, word.Offset + start, length);
}
char[] part = myWordPartArray;
if (length + 1 > part.length) {
part = new char[length + 1];
myWordPartArray = part;
}
System.arraycopy(word.Data, word.Offset + start, part, 0, length);
part[length] = '-';
return getContext().getStringWidth(part, 0, length + 1);
}
内容来源于网络,如有侵权,请联系作者删除!