当前位置: 首页>>代码示例>>Java>>正文


Java Bias.Forward方法代码示例

本文整理汇总了Java中javax.swing.text.Position.Bias.Forward方法的典型用法代码示例。如果您正苦于以下问题:Java Bias.Forward方法的具体用法?Java Bias.Forward怎么用?Java Bias.Forward使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在javax.swing.text.Position.Bias的用法示例。


在下文中一共展示了Bias.Forward方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: getNextMatch

import javax.swing.text.Position.Bias; //导入方法依赖的package包/类
@Override
public int getNextMatch(String prefix, int startIndex, Bias bias) {
    ListModel model = getModel();
    if (!(model instanceof TableModel)) {
        return super.getNextMatch(prefix, startIndex, bias);
    }
    TableModel tablesModel = (TableModel)model;
    int max = tablesModel.getSize();
    int increment = (bias == Bias.Forward) ? 1 : -1;
    int index = startIndex;
    prefix = prefix.toUpperCase();
    do {
        Table table = tablesModel.getElementAt(index);
        String tableName = table.getName().toUpperCase();
        if (tableName.startsWith(prefix)) {
            return index;
        }
        index = (index + increment + max) % max;
    } while (index != startIndex);
    return -1;
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:22,代码来源:TableUISupport.java

示例2: insert

import javax.swing.text.Position.Bias; //导入方法依赖的package包/类
void insert(BaseDocument doc, int offset) throws InvalidMarkException, BadLocationException {
     BaseDocument ldoc = this.doc;
     if (ldoc != null) {
         throw new InvalidMarkException("Mark already inserted: mark=" + this // NOI18N
             + ", class=" + this.getClass()); // NOI18N
     }

     this.doc = doc;
     ldoc = this.doc;
     synchronized (ldoc) {
         if (pos != null) {
             throw new IllegalStateException("Mark already inserted: mark=" + this // NOI18N
             + ", class=" + this.getClass()); // NOI18N
         }

if (offset < 0 || offset > ldoc.getLength() + 1) { // doc.getEndPosition() is valid
	throw new BadLocationException("Invalid offset", offset); // NOI18N
}

// Deal with supplementary characters #164820

if (offset <= ldoc.getLength() && Character.isLowSurrogate(org.netbeans.lib.editor.util.swing.DocumentUtilities.getText(ldoc).charAt(offset))) {
	if (bias == Bias.Forward && offset < ldoc.getLength()) {
		offset++;

	} else if (bias == Bias.Backward && offset > 0) {
		offset--;
	}
	
	// If there is still a low surrogate after recalculating,
	// treat it as an invalid document, just ignore and pass through.
	// Since there should be a surrogate pair in Java and Unicode to
	// represent a supplementary character.
}

         pos = doc.createPosition(offset, bias);
     }
 }
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:39,代码来源:Mark.java

示例3: getNextVisualPositionFromChecked

import javax.swing.text.Position.Bias; //导入方法依赖的package包/类
@Override
public int getNextVisualPositionFromChecked(int offset, Bias bias, Shape alloc, int direction, Bias[] biasRet) {
    int startOffset = getStartOffset();
    int endOffset = startOffset + getLength();
    int retOffset = -1;
    switch (direction) {
        case EAST:
            biasRet[0] = Bias.Forward;
            if (offset == -1) {
                retOffset = getStartOffset();
            } else {
                retOffset = offset + 1;
                if (retOffset >= endOffset) {
                    retOffset = endOffset;
                    biasRet[0] = Bias.Backward;
                }
            }
            break;

        case WEST:
            biasRet[0] = Bias.Forward;
            if (offset == -1) {
                retOffset = endOffset - 1;
            } else {
                retOffset = offset - 1;
                if (retOffset < startOffset) {
                    retOffset = -1;
                }
            }
            break;

        case View.NORTH:
        case View.SOUTH:
            break; // Return -1
        default:
            throw new IllegalArgumentException("Bad direction: " + direction);
    }
    return retOffset;
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:40,代码来源:TabView.java

示例4: getNextVisualPositionFromChecked

import javax.swing.text.Position.Bias; //导入方法依赖的package包/类
@Override
public int getNextVisualPositionFromChecked(int offset, Bias bias, Shape alloc, int direction, Bias[] biasRet) {
    int retOffset;
    biasRet[0] = Bias.Forward; // BaseCaret ignores bias
    int viewStartOffset = getStartOffset();
    switch (direction) {
        case View.EAST:
            if (offset == -1) {
                retOffset = viewStartOffset;
            } else {
                retOffset = -1;
            }
            break;

        case View.WEST:
            if (offset == -1) {
                retOffset = viewStartOffset;
            } else if (offset == viewStartOffset) { // Regular offset
                retOffset = -1;
            } else {
                retOffset = viewStartOffset;
            }
            break;

        case View.NORTH:
        case View.SOUTH:
            retOffset = -1;
            break;
        default:
            throw new IllegalArgumentException("Bad direction: " + direction);
    }
    return retOffset;
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:34,代码来源:NewlineView.java


注:本文中的javax.swing.text.Position.Bias.Forward方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。