Java Code Examples for sun.java2d.pipe.Region#getIntersection()

The following examples show how to use sun.java2d.pipe.Region#getIntersection() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: Container.java    From jdk-1.7-annotated with Apache License 2.0 6 votes vote down vote up
@Override
final Region getOpaqueShape() {
    checkTreeLock();
    if (isLightweight() && isNonOpaqueForMixing()
            && hasLightweightDescendants())
    {
        Region s = Region.EMPTY_REGION;
        for (int index = 0; index < getComponentCount(); index++) {
            Component c = getComponent(index);
            if (c.isLightweight() && c.isShowing()) {
                s = s.getUnion(c.getOpaqueShape());
            }
        }
        return s.getIntersection(getNormalShape());
    }
    return super.getOpaqueShape();
}
 
Example 2
Source File: Container.java    From jdk8u_jdk with GNU General Public License v2.0 6 votes vote down vote up
@Override
final Region getOpaqueShape() {
    checkTreeLock();
    if (isLightweight() && isNonOpaqueForMixing()
            && hasLightweightDescendants())
    {
        Region s = Region.EMPTY_REGION;
        for (int index = 0; index < getComponentCount(); index++) {
            Component c = getComponent(index);
            if (c.isLightweight() && c.isShowing()) {
                s = s.getUnion(c.getOpaqueShape());
            }
        }
        return s.getIntersection(getNormalShape());
    }
    return super.getOpaqueShape();
}
 
Example 3
Source File: Container.java    From jdk8u-jdk with GNU General Public License v2.0 6 votes vote down vote up
@Override
final Region getOpaqueShape() {
    checkTreeLock();
    if (isLightweight() && isNonOpaqueForMixing()
            && hasLightweightDescendants())
    {
        Region s = Region.EMPTY_REGION;
        for (int index = 0; index < getComponentCount(); index++) {
            Component c = getComponent(index);
            if (c.isLightweight() && c.isShowing()) {
                s = s.getUnion(c.getOpaqueShape());
            }
        }
        return s.getIntersection(getNormalShape());
    }
    return super.getOpaqueShape();
}
 
Example 4
Source File: Container.java    From openjdk-8 with GNU General Public License v2.0 6 votes vote down vote up
@Override
final Region getOpaqueShape() {
    checkTreeLock();
    if (isLightweight() && isNonOpaqueForMixing()
            && hasLightweightDescendants())
    {
        Region s = Region.EMPTY_REGION;
        for (int index = 0; index < getComponentCount(); index++) {
            Component c = getComponent(index);
            if (c.isLightweight() && c.isShowing()) {
                s = s.getUnion(c.getOpaqueShape());
            }
        }
        return s.getIntersection(getNormalShape());
    }
    return super.getOpaqueShape();
}
 
Example 5
Source File: CustomComponent.java    From jdk8u60 with GNU General Public License v2.0 5 votes vote down vote up
public static Region getRegionOfInterest(SurfaceData src, SurfaceData dst,
                                         Region clip,
                                         int srcx, int srcy,
                                         int dstx, int dsty,
                                         int w, int h)
{
    /*
     * Intersect all of:
     *   - operation area (dstx, dsty, w, h)
     *   - destination bounds
     *   - (translated) src bounds
     *   - supplied clip (may be non-rectangular)
     * Intersect the rectangular regions first since those are
     * simpler operations.
     */
    Region ret = Region.getInstanceXYWH(dstx, dsty, w, h);
    ret = ret.getIntersection(dst.getBounds());
    Rectangle r = src.getBounds();
    // srcxy in src space maps to dstxy in dst space
    r.translate(dstx - srcx, dsty - srcy);
    ret = ret.getIntersection(r);
    if (clip != null) {
        // Intersect with clip last since it may be non-rectangular
        ret = ret.getIntersection(clip);
    }
    return ret;
}
 
Example 6
Source File: SunGraphics2D.java    From jdk8u-dev-jdk with GNU General Public License v2.0 5 votes vote down vote up
/**
 * Constrain rendering for lightweight objects.
 */
public void constrain(int x, int y, int w, int h, Region region) {
    if ((x | y) != 0) {
        translate(x, y);
    }
    if (transformState > TRANSFORM_TRANSLATESCALE) {
        clipRect(0, 0, w, h);
        return;
    }
    // changes parameters according to the current scale and translate.
    final double scaleX = transform.getScaleX();
    final double scaleY = transform.getScaleY();
    x = constrainX = (int) transform.getTranslateX();
    y = constrainY = (int) transform.getTranslateY();
    w = Region.dimAdd(x, Region.clipScale(w, scaleX));
    h = Region.dimAdd(y, Region.clipScale(h, scaleY));

    Region c = constrainClip;
    if (c == null) {
        c = Region.getInstanceXYXY(x, y, w, h);
    } else {
        c = c.getIntersectionXYXY(x, y, w, h);
    }
    if (region != null) {
        region = region.getScaledRegion(scaleX, scaleY);
        region = region.getTranslatedRegion(x, y);
        c = c.getIntersection(region);
    }

    if (c == constrainClip) {
        // Common case to ignore
        return;
    }

    constrainClip = c;
    if (!devClip.isInsideQuickCheck(c)) {
        devClip = devClip.getIntersection(c);
        validateCompClip();
    }
}
 
Example 7
Source File: LWComponentPeer.java    From openjdk-8 with GNU General Public License v2.0 5 votes vote down vote up
static final Region computeVisibleRect(final LWComponentPeer<?, ?> c,
                                       Region region) {
    final LWContainerPeer<?, ?> p = c.getContainerPeer();
    if (p != null) {
        final Rectangle r = c.getBounds();
        region = region.getTranslatedRegion(r.x, r.y);
        region = region.getIntersection(p.getRegion());
        region = region.getIntersection(p.getContentSize());
        region = p.cutChildren(region, c);
        region = computeVisibleRect(p, region);
        region = region.getTranslatedRegion(-r.x, -r.y);
    }
    return region;
}
 
Example 8
Source File: CustomComponent.java    From hottub with GNU General Public License v2.0 5 votes vote down vote up
public static Region getRegionOfInterest(SurfaceData src, SurfaceData dst,
                                         Region clip,
                                         int srcx, int srcy,
                                         int dstx, int dsty,
                                         int w, int h)
{
    /*
     * Intersect all of:
     *   - operation area (dstx, dsty, w, h)
     *   - destination bounds
     *   - (translated) src bounds
     *   - supplied clip (may be non-rectangular)
     * Intersect the rectangular regions first since those are
     * simpler operations.
     */
    Region ret = Region.getInstanceXYWH(dstx, dsty, w, h);
    ret = ret.getIntersection(dst.getBounds());
    Rectangle r = src.getBounds();
    // srcxy in src space maps to dstxy in dst space
    r.translate(dstx - srcx, dsty - srcy);
    ret = ret.getIntersection(r);
    if (clip != null) {
        // Intersect with clip last since it may be non-rectangular
        ret = ret.getIntersection(clip);
    }
    return ret;
}
 
Example 9
Source File: CustomComponent.java    From openjdk-jdk8u with GNU General Public License v2.0 5 votes vote down vote up
public static Region getRegionOfInterest(SurfaceData src, SurfaceData dst,
                                         Region clip,
                                         int srcx, int srcy,
                                         int dstx, int dsty,
                                         int w, int h)
{
    /*
     * Intersect all of:
     *   - operation area (dstx, dsty, w, h)
     *   - destination bounds
     *   - (translated) src bounds
     *   - supplied clip (may be non-rectangular)
     * Intersect the rectangular regions first since those are
     * simpler operations.
     */
    Region ret = Region.getInstanceXYWH(dstx, dsty, w, h);
    ret = ret.getIntersection(dst.getBounds());
    Rectangle r = src.getBounds();
    // srcxy in src space maps to dstxy in dst space
    r.translate(dstx - srcx, dsty - srcy);
    ret = ret.getIntersection(r);
    if (clip != null) {
        // Intersect with clip last since it may be non-rectangular
        ret = ret.getIntersection(clip);
    }
    return ret;
}
 
Example 10
Source File: LWComponentPeer.java    From jdk8u-jdk with GNU General Public License v2.0 5 votes vote down vote up
static final Region computeVisibleRect(final LWComponentPeer<?, ?> c,
                                       Region region) {
    final LWContainerPeer<?, ?> p = c.getContainerPeer();
    if (p != null) {
        final Rectangle r = c.getBounds();
        region = region.getTranslatedRegion(r.x, r.y);
        region = region.getIntersection(p.getRegion());
        region = region.getIntersection(p.getContentSize());
        region = p.cutChildren(region, c);
        region = computeVisibleRect(p, region);
        region = region.getTranslatedRegion(-r.x, -r.y);
    }
    return region;
}
 
Example 11
Source File: SunGraphics2D.java    From openjdk-8-source with GNU General Public License v2.0 5 votes vote down vote up
/**
 * Constrain rendering for lightweight objects.
 */
public void constrain(int x, int y, int w, int h, Region region) {
    if ((x | y) != 0) {
        translate(x, y);
    }
    if (transformState > TRANSFORM_TRANSLATESCALE) {
        clipRect(0, 0, w, h);
        return;
    }
    // changes parameters according to the current scale and translate.
    final double scaleX = transform.getScaleX();
    final double scaleY = transform.getScaleY();
    x = constrainX = (int) transform.getTranslateX();
    y = constrainY = (int) transform.getTranslateY();
    w = Region.dimAdd(x, Region.clipScale(w, scaleX));
    h = Region.dimAdd(y, Region.clipScale(h, scaleY));

    Region c = constrainClip;
    if (c == null) {
        c = Region.getInstanceXYXY(x, y, w, h);
    } else {
        c = c.getIntersectionXYXY(x, y, w, h);
    }
    if (region != null) {
        region = region.getScaledRegion(scaleX, scaleY);
        region = region.getTranslatedRegion(x, y);
        c = c.getIntersection(region);
    }

    if (c == constrainClip) {
        // Common case to ignore
        return;
    }

    constrainClip = c;
    if (!devClip.isInsideQuickCheck(c)) {
        devClip = devClip.getIntersection(c);
        validateCompClip();
    }
}
 
Example 12
Source File: LWComponentPeer.java    From openjdk-jdk8u-backup with GNU General Public License v2.0 5 votes vote down vote up
static final Region computeVisibleRect(final LWComponentPeer<?, ?> c,
                                       Region region) {
    final LWContainerPeer<?, ?> p = c.getContainerPeer();
    if (p != null) {
        final Rectangle r = c.getBounds();
        region = region.getTranslatedRegion(r.x, r.y);
        region = region.getIntersection(p.getRegion());
        region = region.getIntersection(p.getContentSize());
        region = p.cutChildren(region, c);
        region = computeVisibleRect(p, region);
        region = region.getTranslatedRegion(-r.x, -r.y);
    }
    return region;
}
 
Example 13
Source File: SunGraphics2D.java    From Bytecoder with Apache License 2.0 5 votes vote down vote up
/**
 * Constrain rendering for lightweight objects.
 */
public void constrain(int x, int y, int w, int h, Region region) {
    if ((x | y) != 0) {
        translate(x, y);
    }
    if (transformState > TRANSFORM_TRANSLATESCALE) {
        clipRect(0, 0, w, h);
        return;
    }
    // changes parameters according to the current scale and translate.
    final double scaleX = transform.getScaleX();
    final double scaleY = transform.getScaleY();
    x = constrainX = (int) transform.getTranslateX();
    y = constrainY = (int) transform.getTranslateY();
    w = Region.dimAdd(x, Region.clipScale(w, scaleX));
    h = Region.dimAdd(y, Region.clipScale(h, scaleY));

    Region c = constrainClip;
    if (c == null) {
        c = Region.getInstanceXYXY(x, y, w, h);
    } else {
        c = c.getIntersectionXYXY(x, y, w, h);
    }
    if (region != null) {
        region = region.getScaledRegion(scaleX, scaleY);
        region = region.getTranslatedRegion(x, y);
        c = c.getIntersection(region);
    }

    if (c == constrainClip) {
        // Common case to ignore
        return;
    }

    constrainClip = c;
    if (!devClip.isInsideQuickCheck(c)) {
        devClip = devClip.getIntersection(c);
        validateCompClip();
    }
}
 
Example 14
Source File: SunGraphics2D.java    From jdk8u-jdk with GNU General Public License v2.0 5 votes vote down vote up
/**
 * Constrain rendering for lightweight objects.
 */
public void constrain(int x, int y, int w, int h, Region region) {
    if ((x | y) != 0) {
        translate(x, y);
    }
    if (transformState > TRANSFORM_TRANSLATESCALE) {
        clipRect(0, 0, w, h);
        return;
    }
    // changes parameters according to the current scale and translate.
    final double scaleX = transform.getScaleX();
    final double scaleY = transform.getScaleY();
    x = constrainX = (int) transform.getTranslateX();
    y = constrainY = (int) transform.getTranslateY();
    w = Region.dimAdd(x, Region.clipScale(w, scaleX));
    h = Region.dimAdd(y, Region.clipScale(h, scaleY));

    Region c = constrainClip;
    if (c == null) {
        c = Region.getInstanceXYXY(x, y, w, h);
    } else {
        c = c.getIntersectionXYXY(x, y, w, h);
    }
    if (region != null) {
        region = region.getScaledRegion(scaleX, scaleY);
        region = region.getTranslatedRegion(x, y);
        c = c.getIntersection(region);
    }

    if (c == constrainClip) {
        // Common case to ignore
        return;
    }

    constrainClip = c;
    if (!devClip.isInsideQuickCheck(c)) {
        devClip = devClip.getIntersection(c);
        validateCompClip();
    }
}
 
Example 15
Source File: SunGraphics2D.java    From TencentKona-8 with GNU General Public License v2.0 5 votes vote down vote up
/**
 * Constrain rendering for lightweight objects.
 */
public void constrain(int x, int y, int w, int h, Region region) {
    if ((x | y) != 0) {
        translate(x, y);
    }
    if (transformState > TRANSFORM_TRANSLATESCALE) {
        clipRect(0, 0, w, h);
        return;
    }
    // changes parameters according to the current scale and translate.
    final double scaleX = transform.getScaleX();
    final double scaleY = transform.getScaleY();
    x = constrainX = (int) transform.getTranslateX();
    y = constrainY = (int) transform.getTranslateY();
    w = Region.dimAdd(x, Region.clipScale(w, scaleX));
    h = Region.dimAdd(y, Region.clipScale(h, scaleY));

    Region c = constrainClip;
    if (c == null) {
        c = Region.getInstanceXYXY(x, y, w, h);
    } else {
        c = c.getIntersectionXYXY(x, y, w, h);
    }
    if (region != null) {
        region = region.getScaledRegion(scaleX, scaleY);
        region = region.getTranslatedRegion(x, y);
        c = c.getIntersection(region);
    }

    if (c == constrainClip) {
        // Common case to ignore
        return;
    }

    constrainClip = c;
    if (!devClip.isInsideQuickCheck(c)) {
        devClip = devClip.getIntersection(c);
        validateCompClip();
    }
}
 
Example 16
Source File: LWComponentPeer.java    From openjdk-jdk9 with GNU General Public License v2.0 5 votes vote down vote up
static final Region computeVisibleRect(final LWComponentPeer<?, ?> c,
                                       Region region) {
    final LWContainerPeer<?, ?> p = c.getContainerPeer();
    if (p != null) {
        final Rectangle r = c.getBounds();
        region = region.getTranslatedRegion(r.x, r.y);
        region = region.getIntersection(p.getRegion());
        region = region.getIntersection(p.getContentSize());
        region = p.cutChildren(region, c);
        region = computeVisibleRect(p, region);
        region = region.getTranslatedRegion(-r.x, -r.y);
    }
    return region;
}
 
Example 17
Source File: LWComponentPeer.java    From dragonwell8_jdk with GNU General Public License v2.0 5 votes vote down vote up
static final Region computeVisibleRect(final LWComponentPeer<?, ?> c,
                                       Region region) {
    final LWContainerPeer<?, ?> p = c.getContainerPeer();
    if (p != null) {
        final Rectangle r = c.getBounds();
        region = region.getTranslatedRegion(r.x, r.y);
        region = region.getIntersection(p.getRegion());
        region = region.getIntersection(p.getContentSize());
        region = p.cutChildren(region, c);
        region = computeVisibleRect(p, region);
        region = region.getTranslatedRegion(-r.x, -r.y);
    }
    return region;
}
 
Example 18
Source File: SunGraphics2D.java    From dragonwell8_jdk with GNU General Public License v2.0 5 votes vote down vote up
/**
 * Constrain rendering for lightweight objects.
 */
public void constrain(int x, int y, int w, int h, Region region) {
    if ((x | y) != 0) {
        translate(x, y);
    }
    if (transformState > TRANSFORM_TRANSLATESCALE) {
        clipRect(0, 0, w, h);
        return;
    }
    // changes parameters according to the current scale and translate.
    final double scaleX = transform.getScaleX();
    final double scaleY = transform.getScaleY();
    x = constrainX = (int) transform.getTranslateX();
    y = constrainY = (int) transform.getTranslateY();
    w = Region.dimAdd(x, Region.clipScale(w, scaleX));
    h = Region.dimAdd(y, Region.clipScale(h, scaleY));

    Region c = constrainClip;
    if (c == null) {
        c = Region.getInstanceXYXY(x, y, w, h);
    } else {
        c = c.getIntersectionXYXY(x, y, w, h);
    }
    if (region != null) {
        region = region.getScaledRegion(scaleX, scaleY);
        region = region.getTranslatedRegion(x, y);
        c = c.getIntersection(region);
    }

    if (c == constrainClip) {
        // Common case to ignore
        return;
    }

    constrainClip = c;
    if (!devClip.isInsideQuickCheck(c)) {
        devClip = devClip.getIntersection(c);
        validateCompClip();
    }
}
 
Example 19
Source File: CustomComponent.java    From openjdk-jdk9 with GNU General Public License v2.0 5 votes vote down vote up
public static Region getRegionOfInterest(SurfaceData src, SurfaceData dst,
                                         Region clip,
                                         int srcx, int srcy,
                                         int dstx, int dsty,
                                         int w, int h)
{
    /*
     * Intersect all of:
     *   - operation area (dstx, dsty, w, h)
     *   - destination bounds
     *   - (translated) src bounds
     *   - supplied clip (may be non-rectangular)
     * Intersect the rectangular regions first since those are
     * simpler operations.
     */
    Region ret = Region.getInstanceXYWH(dstx, dsty, w, h);
    ret = ret.getIntersection(dst.getBounds());
    Rectangle r = src.getBounds();
    // srcxy in src space maps to dstxy in dst space
    r.translate(dstx - srcx, dsty - srcy);
    ret = ret.getIntersection(r);
    if (clip != null) {
        // Intersect with clip last since it may be non-rectangular
        ret = ret.getIntersection(clip);
    }
    return ret;
}
 
Example 20
Source File: SunGraphics2D.java    From hottub with GNU General Public License v2.0 5 votes vote down vote up
/**
 * Constrain rendering for lightweight objects.
 */
public void constrain(int x, int y, int w, int h, Region region) {
    if ((x | y) != 0) {
        translate(x, y);
    }
    if (transformState > TRANSFORM_TRANSLATESCALE) {
        clipRect(0, 0, w, h);
        return;
    }
    // changes parameters according to the current scale and translate.
    final double scaleX = transform.getScaleX();
    final double scaleY = transform.getScaleY();
    x = constrainX = (int) transform.getTranslateX();
    y = constrainY = (int) transform.getTranslateY();
    w = Region.dimAdd(x, Region.clipScale(w, scaleX));
    h = Region.dimAdd(y, Region.clipScale(h, scaleY));

    Region c = constrainClip;
    if (c == null) {
        c = Region.getInstanceXYXY(x, y, w, h);
    } else {
        c = c.getIntersectionXYXY(x, y, w, h);
    }
    if (region != null) {
        region = region.getScaledRegion(scaleX, scaleY);
        region = region.getTranslatedRegion(x, y);
        c = c.getIntersection(region);
    }

    if (c == constrainClip) {
        // Common case to ignore
        return;
    }

    constrainClip = c;
    if (!devClip.isInsideQuickCheck(c)) {
        devClip = devClip.getIntersection(c);
        validateCompClip();
    }
}