本文整理了Java中com.koolearn.klibrary.text.view.ZLTextViewBase
类的一些代码示例,展示了ZLTextViewBase
类的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。ZLTextViewBase
类的具体详情如下:
包路径:com.koolearn.klibrary.text.view.ZLTextViewBase
类名称:ZLTextViewBase
暂无
代码示例来源:origin: ydcx/KooReader
void applyStyleChangeElement(ZLTextElement element) {
if (element == ZLTextElement.StyleClose) {
applyStyleClose();
} else if (element instanceof ZLTextStyleElement) {
applyStyle((ZLTextStyleElement) element);
} else if (element instanceof ZLTextControlElement) {
applyControl((ZLTextControlElement) element);
}
}
代码示例来源:origin: ydcx/KooReader
@Override
int getAreaLength(ZLTextParagraphCursor paragraph, ZLTextElementArea area, int toCharIndex) {
return super.getAreaLength(paragraph, area, toCharIndex);
}
代码示例来源:origin: ydcx/KooReader
int getTextAreaHeight() { // 文字显示区域
return getContextHeight() - getTopMargin() - getBottomMargin();
}
代码示例来源:origin: Jiangzqts/EpubRead
protected int getColumnIndex(int x) { // 文字选择相关
if (!twoColumnView()) {
return -1;
}
return 2 * x <= getContextWidth() + getLeftMargin() - getRightMargin() ? 0 : 1;
}
代码示例来源:origin: Jiangzqts/EpubRead
final int getElementHeight(ZLTextElement element) {
if (element == ZLTextElement.NBSpace ||
element instanceof ZLTextWord ||
element instanceof ZLTextFixedHSpaceElement) {
return getWordHeight();
} else if (element instanceof ZLTextImageElement) {
final ZLTextImageElement imageElement = (ZLTextImageElement) element;
final ZLPaintContext.Size size = getContext().imageSize(
imageElement.ImageData,
getTextAreaSize(),
getScalingType(imageElement)
);
return (size != null ? size.Height : 0) +
Math.max(getContext().getStringHeight() * (myTextStyle.getLineSpacePercent() - 100) / 100, 3);
} else if (element instanceof ZLTextVideoElement) {
return Math.min(Math.min(200, getTextAreaHeight()), getTextColumnWidth() * 2 / 3);
} else if (element instanceof ExtensionElement) {
return ((ExtensionElement) element).getHeight();
}
return 0;
}
代码示例来源:origin: ydcx/KooReader
final int getElementWidth(ZLTextElement element, int charIndex) {
if (element instanceof ZLTextWord) {
return getWordWidth((ZLTextWord) element, charIndex);
} else if (element instanceof ZLTextImageElement) {
final ZLTextImageElement imageElement = (ZLTextImageElement) element;
final ZLPaintContext.Size size = getContext().imageSize(
imageElement.ImageData,
getTextAreaSize(),
getScalingType(imageElement)
);
return size != null ? size.Width : 0;
} else if (element instanceof ZLTextVideoElement) {
return Math.min(300, getTextColumnWidth());
} else if (element instanceof ExtensionElement) {
return ((ExtensionElement) element).getWidth();
} else if (element == ZLTextElement.NBSpace) {
return getContext().getSpaceWidth();
} else if (element == ZLTextElement.Indent) {
return myTextStyle.getFirstLineIndent(metrics());
} else if (element instanceof ZLTextFixedHSpaceElement) {
return getContext().getSpaceWidth() * ((ZLTextFixedHSpaceElement) element).Length;
}
return 0;
}
代码示例来源:origin: Jiangzqts/EpubRead
final int getWordHeight() {
if (myWordHeight == -1) {
final ZLTextStyle textStyle = myTextStyle;
myWordHeight = getContext().getStringHeight() * textStyle.getLineSpacePercent() / 100 + textStyle.getVerticalAlign(metrics());
}
return myWordHeight;
}
代码示例来源: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: 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
void applyStyleChanges(ZLTextParagraphCursor cursor, int index, int end) {
for (; index != end; ++index) {
applyStyleChangeElement(cursor.getElement(index));
}
}
代码示例来源:origin: Jiangzqts/EpubRead
public int getTextColumnWidth() {
return twoColumnView()
? (getContextWidth() - getLeftMargin() - getSpaceBetweenColumns() - getRightMargin()) / 2
: getContextWidth() - getLeftMargin() - getRightMargin();
}
代码示例来源:origin: ydcx/KooReader
final int getElementHeight(ZLTextElement element) {
if (element == ZLTextElement.NBSpace ||
element instanceof ZLTextWord ||
element instanceof ZLTextFixedHSpaceElement) {
return getWordHeight();
} else if (element instanceof ZLTextImageElement) {
final ZLTextImageElement imageElement = (ZLTextImageElement) element;
final ZLPaintContext.Size size = getContext().imageSize(
imageElement.ImageData,
getTextAreaSize(),
getScalingType(imageElement)
);
return (size != null ? size.Height : 0) +
Math.max(getContext().getStringHeight() * (myTextStyle.getLineSpacePercent() - 100) / 100, 3);
} else if (element instanceof ZLTextVideoElement) {
return Math.min(Math.min(200, getTextAreaHeight()), getTextColumnWidth() * 2 / 3);
} else if (element instanceof ExtensionElement) {
return ((ExtensionElement) element).getHeight();
}
return 0;
}
代码示例来源:origin: Jiangzqts/EpubRead
final int getElementWidth(ZLTextElement element, int charIndex) {
if (element instanceof ZLTextWord) {
return getWordWidth((ZLTextWord) element, charIndex);
} else if (element instanceof ZLTextImageElement) {
final ZLTextImageElement imageElement = (ZLTextImageElement) element;
final ZLPaintContext.Size size = getContext().imageSize(
imageElement.ImageData,
getTextAreaSize(),
getScalingType(imageElement)
);
return size != null ? size.Width : 0;
} else if (element instanceof ZLTextVideoElement) {
return Math.min(300, getTextColumnWidth());
} else if (element instanceof ExtensionElement) {
return ((ExtensionElement) element).getWidth();
} else if (element == ZLTextElement.NBSpace) {
return getContext().getSpaceWidth();
} else if (element == ZLTextElement.Indent) {
return myTextStyle.getFirstLineIndent(metrics());
} else if (element instanceof ZLTextFixedHSpaceElement) {
return getContext().getSpaceWidth() * ((ZLTextFixedHSpaceElement) element).Length;
}
return 0;
}
代码示例来源:origin: ydcx/KooReader
final int getWordHeight() {
if (myWordHeight == -1) {
final ZLTextStyle textStyle = myTextStyle;
myWordHeight = getContext().getStringHeight() * textStyle.getLineSpacePercent() / 100 + textStyle.getVerticalAlign(metrics());
}
return myWordHeight;
}
代码示例来源: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: 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
void applyStyleChanges(ZLTextParagraphCursor cursor, int index, int end) {
for (; index != end; ++index) {
applyStyleChangeElement(cursor.getElement(index));
}
}
代码示例来源:origin: ydcx/KooReader
protected int getColumnIndex(int x) { // 文字选择相关
if (!twoColumnView()) {
return -1;
}
return 2 * x <= getContextWidth() + getLeftMargin() - getRightMargin() ? 0 : 1;
}
代码示例来源:origin: Jiangzqts/EpubRead
void applyStyleChangeElement(ZLTextElement element) {
if (element == ZLTextElement.StyleClose) {
applyStyleClose();
} else if (element instanceof ZLTextStyleElement) {
applyStyle((ZLTextStyleElement) element);
} else if (element instanceof ZLTextControlElement) {
applyControl((ZLTextControlElement) element);
}
}
代码示例来源:origin: Jiangzqts/EpubRead
int getTextAreaHeight() { // 文字显示区域
return getContextHeight() - getTopMargin() - getBottomMargin();
}
内容来源于网络,如有侵权,请联系作者删除!