本文整理汇总了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;
}