当前位置: 首页>>代码示例>>Java>>正文


Java SwingUtilities.computeIntersection方法代码示例

本文整理汇总了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;
    }
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:75,代码来源:BufferedCanvasComponent.java


注:本文中的javax.swing.SwingUtilities.computeIntersection方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。