本文整理汇总了Java中org.netbeans.editor.Utilities.getRowCount方法的典型用法代码示例。如果您正苦于以下问题:Java Utilities.getRowCount方法的具体用法?Java Utilities.getRowCount怎么用?Java Utilities.getRowCount使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.netbeans.editor.Utilities
的用法示例。
在下文中一共展示了Utilities.getRowCount方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: getModelToViewImpl
import org.netbeans.editor.Utilities; //导入方法依赖的package包/类
private synchronized int getModelToViewImpl(int line) throws BadLocationException {
int docLines = Utilities.getRowCount(doc);
if (modelToViewCache == null || height != pane.getHeight() || lines != docLines) {
modelToViewCache = new int[Utilities.getRowCount(doc) + 2];
lines = Utilities.getRowCount(doc);
height = pane.getHeight();
}
if (line >= docLines)
return -1;
int result = modelToViewCache[line + 1];
if (result == 0) {
int lineOffset = Utilities.getRowStartFromLineOffset((BaseDocument) pane.getDocument(), line);
modelToViewCache[line + 1] = result = getYFromPos(lineOffset);
}
if (result == (-1))
result = 0;
return result;
}
示例2: getLinesSpan
import org.netbeans.editor.Utilities; //导入方法依赖的package包/类
int[] getLinesSpan(int currentLine) {
AbstractDocument adoc = doc;
if (adoc != null)
adoc.readLock();
try {
double componentHeight = getComponentHeight();
double usableHeight = getUsableHeight();
double position = _modelToView(currentLine, componentHeight, usableHeight);
if (position == (-1))
return new int[] {currentLine, currentLine};
int startLine = currentLine;
int endLine = currentLine;
while (position == _modelToView(startLine - 1, componentHeight, usableHeight) && startLine > 0)
startLine--;
while ((endLine + 1) < Utilities.getRowCount(doc) && position == _modelToView(endLine + 1, componentHeight, usableHeight))
endLine++;
return new int[] {startLine, endLine};
} finally {
if (adoc != null)
adoc.readUnlock();
}
}
示例3: performGoto
import org.netbeans.editor.Utilities; //导入方法依赖的package包/类
/** Perform the goto operation.
* @return whether the dialog should be made invisible or not
*/
protected boolean performGoto() {
JTextComponent c = EditorRegistry.lastFocusedComponent();
if (c != null) {
try {
int line = Integer.parseInt(getGotoValueText());
//issue 188976
if (line==0)
line = 1;
//end of issue 188976
BaseDocument doc = Utilities.getDocument(c);
if (doc != null) {
int rowCount = Utilities.getRowCount(doc);
if (line > rowCount)
line = rowCount;
// Obtain the offset where to jump
int pos = Utilities.getRowStartFromLineOffset(doc, line - 1);
BaseKit kit = Utilities.getKit(c);
if (kit != null) {
Action a = kit.getActionByName(ExtKit.gotoAction);
if (a instanceof ExtKit.GotoAction) {
pos = ((ExtKit.GotoAction)a).getOffsetFromLine(doc, line - 1);
}
}
if (pos != -1) {
Caret caret = c.getCaret();
caret.setDot(pos);
} else {
c.getToolkit().beep();
return false;
}
}
} catch (NumberFormatException e) {
c.getToolkit().beep();
return false;
}
}
return true;
}
示例4: moveNext
import org.netbeans.editor.Utilities; //导入方法依赖的package包/类
@Override
public boolean moveNext() {
synchronized (EmbeddedSectionsHighlighting.this) {
if (checkVersion()) {
if (sequence == null) {
sequence = scanner.tokenSequence();
if (sequence == null) {
return false;
} else {
sequence.move(startOffset);
}
}
int delimiterSize = 0;
while (sequence.moveNext() && sequence.offset() < endOffset) {
if (sequence.token().id() == YamlTokenId.DELIMITER) {
// opening delimiters can have different lenght
delimiterSize = sequence.token().length();
} else if (YamlTokenId.isRuby(sequence.token().id())) {
sectionStart = sequence.offset();
sectionEnd = sequence.offset() + sequence.token().length();
try {
int docLen = document.getLength();
int startLine = Utilities.getLineOffset((BaseDocument) document, Math.min(sectionStart, docLen));
int endLine = Utilities.getLineOffset((BaseDocument) document, Math.min(sectionEnd, docLen));
if (startLine != endLine) {
// multiline scriplet section
// adjust the sections start to the beginning of the firts line
int firstLineStartOffset = Utilities.getRowStartFromLineOffset((BaseDocument) document, startLine);
if (firstLineStartOffset < sectionStart - delimiterSize
&& isWhitespace(document, firstLineStartOffset, sectionStart - delimiterSize)) // always preceeded by the delimiter
{
sectionStart = firstLineStartOffset;
}
// adjust the sections end to the end of the last line
int lines = Utilities.getRowCount((BaseDocument) document);
int lastLineEndOffset;
if (endLine + 1 < lines) {
lastLineEndOffset = Utilities.getRowStartFromLineOffset((BaseDocument) document, endLine + 1);
} else {
lastLineEndOffset = document.getLength() + 1;
}
if (sectionEnd + 2 >= lastLineEndOffset || // unclosed section
isWhitespace(document, sectionEnd + 2, lastLineEndOffset)) // always succeeded by '%>' hence +2
{
sectionEnd = lastLineEndOffset;
}
}
} catch (BadLocationException ble) {
LOG.log(Level.WARNING, null, ble);
}
return true;
}
}
}
sectionStart = -1;
sectionEnd = -1;
finished = true;
return false;
}
}