本文整理匯總了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();
}
示例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;
}