Search in sources :

Example 1 with Region

use of sun.java2d.pipe.Region in project jdk8u_jdk by JetBrains.

the class Component method subtractAndApplyShapeBelowMe.

final void subtractAndApplyShapeBelowMe() {
    checkTreeLock();
    Container parent = getContainer();
    if (parent != null && isShowing()) {
        Region opaqueShape = getOpaqueShape();
        // First, cut my siblings
        parent.recursiveSubtractAndApplyShape(opaqueShape, getSiblingIndexBelow());
        // Second, if my container is non-opaque, cut siblings of my container
        Container parent2 = parent.getContainer();
        while (!parent.isOpaque() && parent2 != null) {
            parent2.recursiveSubtractAndApplyShape(opaqueShape, parent.getSiblingIndexBelow());
            parent = parent2;
            parent2 = parent.getContainer();
        }
    }
}
Also used : Region(sun.java2d.pipe.Region)

Example 2 with Region

use of sun.java2d.pipe.Region in project jdk8u_jdk by JetBrains.

the class Component method calculateCurrentShape.

private Region calculateCurrentShape() {
    checkTreeLock();
    Region s = getNormalShape();
    if (mixingLog.isLoggable(PlatformLogger.Level.FINE)) {
        mixingLog.fine("this = " + this + "; normalShape=" + s);
    }
    if (getContainer() != null) {
        Component comp = this;
        Container cont = comp.getContainer();
        while (cont != null) {
            for (int index = comp.getSiblingIndexAbove(); index != -1; --index) {
                /* It is assumed that:
                     *
                     *    getComponent(getContainer().getComponentZOrder(comp)) == comp
                     *
                     * The assumption has been made according to the current
                     * implementation of the Container class.
                     */
                Component c = cont.getComponent(index);
                if (c.isLightweight() && c.isShowing()) {
                    s = s.getDifference(c.getOpaqueShape());
                }
            }
            if (cont.isLightweight()) {
                s = s.getIntersection(cont.getNormalShape());
            } else {
                break;
            }
            comp = cont;
            cont = cont.getContainer();
        }
    }
    if (mixingLog.isLoggable(PlatformLogger.Level.FINE)) {
        mixingLog.fine("currentShape=" + s);
    }
    return s;
}
Also used : Region(sun.java2d.pipe.Region)

Example 3 with Region

use of sun.java2d.pipe.Region in project jdk8u_jdk by JetBrains.

the class Component method mixOnZOrderChanging.

void mixOnZOrderChanging(int oldZorder, int newZorder) {
    synchronized (getTreeLock()) {
        boolean becameHigher = newZorder < oldZorder;
        Container parent = getContainer();
        if (mixingLog.isLoggable(PlatformLogger.Level.FINE)) {
            mixingLog.fine("this = " + this + "; oldZorder=" + oldZorder + "; newZorder=" + newZorder + "; parent=" + parent);
        }
        if (!isMixingNeeded()) {
            return;
        }
        if (isLightweight()) {
            if (becameHigher) {
                if (parent != null && isShowing()) {
                    parent.recursiveSubtractAndApplyShape(getOpaqueShape(), getSiblingIndexBelow(), oldZorder);
                }
            } else {
                if (parent != null) {
                    parent.recursiveApplyCurrentShape(oldZorder, newZorder);
                }
            }
        } else {
            if (becameHigher) {
                applyCurrentShape();
            } else {
                if (parent != null) {
                    Region shape = getAppliedShape();
                    for (int index = oldZorder; index < newZorder; index++) {
                        Component c = parent.getComponent(index);
                        if (c.isLightweight() && c.isShowing()) {
                            shape = shape.getDifference(c.getOpaqueShape());
                        }
                    }
                    applyCompoundShape(shape);
                }
            }
        }
    }
}
Also used : Region(sun.java2d.pipe.Region)

Example 4 with Region

use of sun.java2d.pipe.Region in project jdk8u_jdk by JetBrains.

the class XorCopyArgbToAny method getRegionOfInterest.

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;
}
Also used : Rectangle(java.awt.Rectangle) Region(sun.java2d.pipe.Region)

Example 5 with Region

use of sun.java2d.pipe.Region in project jdk8u_jdk by JetBrains.

the class SunGraphics2D method constrain.

/**
     * 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();
    }
}
Also used : Region(sun.java2d.pipe.Region)

Aggregations

Region (sun.java2d.pipe.Region)22 Rectangle (java.awt.Rectangle)5 GradientPaint (java.awt.GradientPaint)3 LinearGradientPaint (java.awt.LinearGradientPaint)3 Paint (java.awt.Paint)3 RadialGradientPaint (java.awt.RadialGradientPaint)3 TexturePaint (java.awt.TexturePaint)3 ShapeSpanIterator (sun.java2d.pipe.ShapeSpanIterator)3 Composite (java.awt.Composite)2 AffineTransform (java.awt.geom.AffineTransform)2 ColorModel (java.awt.image.ColorModel)2 Raster (java.awt.image.Raster)2 WritableRaster (java.awt.image.WritableRaster)2 CompositeType (sun.java2d.loops.CompositeType)2 AlphaComposite (java.awt.AlphaComposite)1 Polygon (java.awt.Polygon)1 PathIterator (java.awt.geom.PathIterator)1 Rectangle2D (java.awt.geom.Rectangle2D)1 BufferedImage (java.awt.image.BufferedImage)1 IntegerComponentRaster (sun.awt.image.IntegerComponentRaster)1