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


Java View.getStartOffset方法代码示例

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


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

示例1: modelToView

import javax.swing.text.View; //导入方法依赖的package包/类
@Override
public Shape modelToView(int pos, Shape a, Position.Bias b)
		throws BadLocationException {

	if (! isAllocationValid()) {
		Rectangle alloc = a.getBounds();
		setSize(alloc.width, alloc.height);
	}

	boolean isBackward = (b == Position.Bias.Backward);
	int testPos = (isBackward) ? Math.max(0, pos - 1) : pos;
	if(isBackward && testPos < getStartOffset()) {
		return null;
	}

	int vIndex = getViewIndexAtPosition(testPos);
	if ((vIndex != -1) && (vIndex < getViewCount())) {
		View v = getView(vIndex);
		if(v != null && testPos >= v.getStartOffset() &&
				testPos < v.getEndOffset()) {
			Shape childShape = getChildAllocation(vIndex, a);
			if (childShape == null) {
				// We are likely invalid, fail.
				return null;
			}
			Shape retShape = v.modelToView(pos, childShape, b);
			if(retShape == null && v.getEndOffset() == pos) {
				if(++vIndex < getViewCount()) {
					v = getView(vIndex);
					retShape = v.modelToView(pos, getChildAllocation(vIndex, a), b);
				}
			}
			return retShape;
		}
	}

	throw new BadLocationException("Position not represented by view", pos);

}
 
开发者ID:Thecarisma,项目名称:powertext,代码行数:40,代码来源:WrappedSyntaxView.java

示例2: findViewIndexBounded

import javax.swing.text.View; //导入方法依赖的package包/类
/**
    * Find child index representing the given offset
    * or -1 if the offset is not represented by any child view
    * i.e. it is outside of the bounds of this view
    * or when the given view does not have any children.
    *
    * @param view view having children to be inspected.
    * @param offset the position >= 0.
    * @return index of the child view representing the given position
    *  or -1 if <code>
    *        offset < view.getStartOffset()
    *     || offset >= view.getEndOffset()</code>
    *     || getViewCount() == 0
    *  </code>.
    */
   public static int findViewIndexBounded(View view, int offset) {
       int viewStartOffset = view.getStartOffset();
       if (offset == viewStartOffset)
           return 0;
if ((offset >= viewStartOffset) && (offset < view.getEndOffset())) {
    return findViewIndex(view, offset);
}

return -1; // outside of view bounds
   }
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:26,代码来源:ViewUtilitiesImpl.java


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