本文整理匯總了Java中javax.swing.SwingUtilities.computeIntersection方法的典型用法代碼示例。如果您正苦於以下問題:Java SwingUtilities.computeIntersection方法的具體用法?Java SwingUtilities.computeIntersection怎麽用?Java SwingUtilities.computeIntersection使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類javax.swing.SwingUtilities
的用法示例。
在下文中一共展示了SwingUtilities.computeIntersection方法的1個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: canDirectlyAccessGraphics
import javax.swing.SwingUtilities; //導入方法依賴的package包/類
protected boolean canDirectlyAccessGraphics() {
// TODO: what about popup windows / tooltips???
// TODO: some of the queries could be cached instead of polling,
// for example isShowing(), isOpaque(), getParent() etc.
////// // Shouldn't access graphics - no buffering would cause flickering
////// if (bufferType == BUFFER_NONE) return false;
// Cannot access graphics - there are some child components
if (getComponentCount() != 0) return false;
// Cannot access graphics - component doesn't fully control its area
if (!isOpaque()) return false;
// Cannot access graphics - not in Swing tree
if (!(getParent() instanceof JComponent)) return false;
// Cannot access graphics - component not showing, doesn't make sense
if (!isShowing()) return false;
// Cannot access graphics - component area is not up-to-date
Rectangle dirtyRegion = RepaintManager.currentManager(this).
getDirtyRegion((JComponent)getParent());
if (dirtyRegion != null && dirtyRegion.width > 0 &&
dirtyRegion.height > 0) return false;
// --- Reused from JViewport -------------------------------------------
Rectangle clip = new Rectangle(0, 0, getWidth(), getHeight());
Rectangle oldClip = new Rectangle();
Rectangle tmp2 = null;
Container parent;
Component lastParent = null;
int x, y, w, h;
for (parent = this; parent != null && isLightweightComponent(parent); parent = parent.getParent()) {
x = parent.getX();
y = parent.getY();
w = parent.getWidth();
h = parent.getHeight();
oldClip.setBounds(clip);
SwingUtilities.computeIntersection(0, 0, w, h, clip);
if (!clip.equals(oldClip)) return false;
if (lastParent != null && parent instanceof JComponent &&
!((JComponent)parent).isOptimizedDrawingEnabled()) {
Component comps[] = parent.getComponents();
int index = 0;
for (int i = comps.length - 1 ;i >= 0; i--) {
if (comps[i] == lastParent) {
index = i - 1;
break;
}
}
while (index >= 0) {
tmp2 = comps[index].getBounds(tmp2);
if (tmp2.intersects(clip)) return false;
index--;
}
}
clip.x += x;
clip.y += y;
lastParent = parent;
}
// No Window parent.
if (parent == null) return false;
return true;
}