當前位置: 首頁>>代碼示例>>Java>>正文


Java View.getChildAllocation方法代碼示例

本文整理匯總了Java中javax.swing.text.View.getChildAllocation方法的典型用法代碼示例。如果您正苦於以下問題:Java View.getChildAllocation方法的具體用法?Java View.getChildAllocation怎麽用?Java View.getChildAllocation使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在javax.swing.text.View的用法示例。


在下文中一共展示了View.getChildAllocation方法的2個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: getChildViewBounds

import javax.swing.text.View; //導入方法依賴的package包/類
/**
 * Returns the bounds of a child view as a rectangle, since
 * <code>View</code>s tend to use <code>Shape</code>.
 *
 * @param parent The parent view of the child whose bounds we're getting.
 * @param line The index of the child view.
 * @param editorRect Returned from the text area's
 *        <code>getVisibleEditorRect</code> method.
 * @return The child view's bounds.
 */
protected static final Rectangle getChildViewBounds(View parent, int line,
									Rectangle editorRect) {
	Shape alloc = parent.getChildAllocation(line, editorRect);
	if (alloc==null) {
		// WrappedSyntaxView can have this when made so small it's
		// no longer visible
		return new Rectangle();
	}
	return alloc instanceof Rectangle ? (Rectangle)alloc :
									alloc.getBounds();
}
 
開發者ID:Thecarisma,項目名稱:powertext,代碼行數:22,代碼來源:AbstractGutterComponent.java

示例2: printView

import javax.swing.text.View; //導入方法依賴的package包/類
private boolean printView(final Graphics2D graphics2D,
                          final Shape allocation, final View view) {
    boolean pageExists = false;
    final Rectangle clipRectangle = new Rectangle(0, 0, (int) (pageFormat
            .getImageableWidth() / SCALE), (int) clientHeight);
    Shape childAllocation;
    View childView;

    if (view.getViewCount() > 0) {
        for (int i = 0; i < view.getViewCount(); i++) {
            childAllocation = view.getChildAllocation(i, allocation);
            if (childAllocation != null) {
                childView = view.getView(i);
                if (printView(graphics2D, childAllocation, childView)) {
                    pageExists = true;
                }
            }
        }
    } else {
        if (allocation.getBounds().getMaxY() >= clipRectangle.getY()) {

            if (allocation.getBounds().getHeight() > clipRectangle
                    .getHeight()
                    && allocation.intersects(clipRectangle)) {
                paintView(graphics2D, view, allocation);
                pageExists = true;
            } else {
                if (allocation.getBounds().getY() >= clipRectangle.getY()) {
                    if (allocation.getBounds().getMaxY() <= clipRectangle
                            .getMaxY()) {
                        paintView(graphics2D, view, allocation);
                        pageExists = true;

                    } else {
                        if (allocation.getBounds().getY() < pageEndY) {
                            pageEndY = allocation.getBounds().getY();
                        }
                    }
                }
            }
        }
    }
    return pageExists;
}
 
開發者ID:Vitaliy-Yakovchuk,項目名稱:ramus,代碼行數:45,代碼來源:HTMLPrintable.java


注:本文中的javax.swing.text.View.getChildAllocation方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。