本文整理汇总了Java中org.w3c.dom.ranges.Range.setStart方法的典型用法代码示例。如果您正苦于以下问题:Java Range.setStart方法的具体用法?Java Range.setStart怎么用?Java Range.setStart使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.w3c.dom.ranges.Range
的用法示例。
在下文中一共展示了Range.setStart方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: getSelectionRange
import org.w3c.dom.ranges.Range; //导入方法依赖的package包/类
public Range getSelectionRange() {
if (this.dotInfo == null || this.dotInfo.range == null) {
return null;
}
Range r = docRange.createRange();
// some xml parsers don't allow end<start in the same text node. So,
// handle dot<mark here
if (this.markInfo.range.compareBoundaryPoints(Range.START_TO_START, this.dotInfo.range) <= 0) {
r.setStart(this.markInfo.range.getStartContainer(), this.markInfo.range.getStartOffset());
r.setEnd(this.dotInfo.range.getStartContainer(), this.dotInfo.range.getStartOffset());
} else {
r.setStart(this.dotInfo.range.getStartContainer(), this.dotInfo.range.getStartOffset());
r.setEnd(this.markInfo.range.getStartContainer(), this.markInfo.range.getStartOffset());
}
return r;
}
示例2: cloneRange
import org.w3c.dom.ranges.Range; //导入方法依赖的package包/类
public Range cloneRange(){
if( fDetach) {
throw new DOMException(
DOMException.INVALID_STATE_ERR,
DOMMessageFormatter.formatMessage(DOMMessageFormatter.DOM_DOMAIN, "INVALID_STATE_ERR", null));
}
Range range = fDocument.createRange();
range.setStart(fStartContainer, fStartOffset);
range.setEnd(fEndContainer, fEndOffset);
return range;
}
示例3: cloneRange
import org.w3c.dom.ranges.Range; //导入方法依赖的package包/类
public Range cloneRange(){
if( fDetach) {
throw new DOMException(
DOMException.INVALID_STATE_ERR,
DOMMessageFormatter.formatMessage(DOMMessageFormatter.DOM_DOMAIN, "INVALID_STATE_ERR", null));
}
Range range = fDocument.createRange();
range.setStart(fStartContainer, fStartOffset);
range.setEnd(fEndContainer, fEndOffset);
return range;
}
示例4: selectAll
import org.w3c.dom.ranges.Range; //导入方法依赖的package包/类
public void selectAll() {
if (this.getComponent() == null || this.getComponent().getWidth() == 0
|| this.getComponent().getHeight() == 0) {
return;
}
checkDocument();
NodeIterator nodeIterator = this.docTraversal.createNodeIterator(this.document.getDocumentElement(),
NodeFilter.SHOW_TEXT, null, false);
Text firstText = null;
Text lastText = null;
while (true) {
Node n = nodeIterator.nextNode();
if (n == null) {
break;
}
if (!textInlineMap.containsKey(n)) {
continue;
}
lastText = (Text) n;
if (firstText == null) {
firstText = lastText;
}
}
if (firstText == null) {
return;
}
Range r = docRange.createRange();
r.setStart(firstText, 0);
ViewModelInfo firstPoint = new ViewModelInfo(r, (InlineText) ((List) textInlineMap.get(firstText)).get(0));
r = docRange.createRange();
try {
// possibly some dom impls don't handle this?
r.setStart(lastText, lastText.getLength());
} catch (Exception e) {
r.setStart(lastText, Math.max(0, lastText.getLength() - 1));
}
List l = (List) textInlineMap.get(firstText);
ViewModelInfo lastPoint = new ViewModelInfo(r, (InlineText) l.get(l.size() - 1));
setDot(firstPoint);
moveDot(lastPoint);
}