當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。