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

The following examples show how to use sun.java2d.pipe.Region#getHiY() . 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: DrawGlyphList.java    From jdk8u_jdk with GNU General Public License v2.0 5 votes vote down vote up
public void DrawGlyphList(SunGraphics2D sg2d, SurfaceData dest,
                          GlyphList gl, int fromGlyph, int toGlyph) {

    Region clip = sg2d.getCompClip();
    int cx1 = clip.getLoX();
    int cy1 = clip.getLoY();
    int cx2 = clip.getHiX();
    int cy2 = clip.getHiY();
    for (int i = fromGlyph; i < toGlyph; i++) {
        gl.setGlyphIndex(i);
        int metrics[] = gl.getMetrics();
        int gx1 = metrics[0];
        int gy1 = metrics[1];
        int w = metrics[2];
        int gx2 = gx1 + w;
        int gy2 = gy1 + metrics[3];
        int off = 0;
        if (gx1 < cx1) {
            off = cx1 - gx1;
            gx1 = cx1;
        }
        if (gy1 < cy1) {
            off += (cy1 - gy1) * w;
            gy1 = cy1;
        }
        if (gx2 > cx2) gx2 = cx2;
        if (gy2 > cy2) gy2 = cy2;
        if (gx2 > gx1 && gy2 > gy1) {
            byte alpha[] = gl.getGrayBits();
            maskop.MaskFill(sg2d, dest, sg2d.composite,
                            gx1, gy1, gx2 - gx1, gy2 - gy1,
                            alpha, off, w);
        }
    }
}
 
Example 2
Source File: GeneralRenderer.java    From openjdk-jdk9 with GNU General Public License v2.0 5 votes vote down vote up
public static void doDrawRect(PixelWriter pw,
                              SunGraphics2D sg2d, SurfaceData sData,
                              int x, int y, int w, int h)
{
    if (w < 0 || h < 0) {
        return;
    }
    int x2 = Region.dimAdd(Region.dimAdd(x, w), 1);
    int y2 = Region.dimAdd(Region.dimAdd(y, h), 1);
    Region r = sg2d.getCompClip().getBoundsIntersectionXYXY(x, y, x2, y2);
    if (r.isEmpty()) {
        return;
    }
    int cx1 = r.getLoX();
    int cy1 = r.getLoY();
    int cx2 = r.getHiX();
    int cy2 = r.getHiY();

    if (w < 2 || h < 2) {
        doSetRect(sData, pw, cx1, cy1, cx2, cy2);
        return;
    }


    if (cy1 == y) {
        doSetRect(sData, pw,   cx1,   cy1,   cx2, cy1+1);
    }
    if (cx1 == x) {
        doSetRect(sData, pw,   cx1, cy1+1, cx1+1, cy2-1);
    }
    if (cx2 == x2) {
        doSetRect(sData, pw, cx2-1, cy1+1,   cx2, cy2-1);
    }
    if (cy2 == y2) {
        doSetRect(sData, pw,   cx1, cy2-1,   cx2,   cy2);
    }
}
 
Example 3
Source File: DrawGlyphListAA.java    From jdk8u-dev-jdk with GNU General Public License v2.0 5 votes vote down vote up
public void DrawGlyphListAA(SunGraphics2D sg2d, SurfaceData dest,
                            GlyphList gl)
{
    gl.getBounds(); // Don't delete, bug 4895493
    int num = gl.getNumGlyphs();
    Region clip = sg2d.getCompClip();
    int cx1 = clip.getLoX();
    int cy1 = clip.getLoY();
    int cx2 = clip.getHiX();
    int cy2 = clip.getHiY();
    for (int i = 0; i < num; i++) {
        gl.setGlyphIndex(i);
        int metrics[] = gl.getMetrics();
        int gx1 = metrics[0];
        int gy1 = metrics[1];
        int w = metrics[2];
        int gx2 = gx1 + w;
        int gy2 = gy1 + metrics[3];
        int off = 0;
        if (gx1 < cx1) {
            off = cx1 - gx1;
            gx1 = cx1;
        }
        if (gy1 < cy1) {
            off += (cy1 - gy1) * w;
            gy1 = cy1;
        }
        if (gx2 > cx2) gx2 = cx2;
        if (gy2 > cy2) gy2 = cy2;
        if (gx2 > gx1 && gy2 > gy1) {
            byte alpha[] = gl.getGrayBits();
            maskop.MaskFill(sg2d, dest, sg2d.composite,
                            gx1, gy1, gx2 - gx1, gy2 - gy1,
                            alpha, off, w);
        }
    }
}
 
Example 4
Source File: DrawGlyphListAA.java    From openjdk-8 with GNU General Public License v2.0 5 votes vote down vote up
public void DrawGlyphListAA(SunGraphics2D sg2d, SurfaceData dest,
                            GlyphList gl)
{
    gl.getBounds(); // Don't delete, bug 4895493
    int num = gl.getNumGlyphs();
    Region clip = sg2d.getCompClip();
    int cx1 = clip.getLoX();
    int cy1 = clip.getLoY();
    int cx2 = clip.getHiX();
    int cy2 = clip.getHiY();
    for (int i = 0; i < num; i++) {
        gl.setGlyphIndex(i);
        int metrics[] = gl.getMetrics();
        int gx1 = metrics[0];
        int gy1 = metrics[1];
        int w = metrics[2];
        int gx2 = gx1 + w;
        int gy2 = gy1 + metrics[3];
        int off = 0;
        if (gx1 < cx1) {
            off = cx1 - gx1;
            gx1 = cx1;
        }
        if (gy1 < cy1) {
            off += (cy1 - gy1) * w;
            gy1 = cy1;
        }
        if (gx2 > cx2) gx2 = cx2;
        if (gy2 > cy2) gy2 = cy2;
        if (gx2 > gx1 && gy2 > gy1) {
            byte alpha[] = gl.getGrayBits();
            maskop.MaskFill(sg2d, dest, sg2d.composite,
                            gx1, gy1, gx2 - gx1, gy2 - gy1,
                            alpha, off, w);
        }
    }
}
 
Example 5
Source File: GeneralRenderer.java    From jdk8u_jdk with GNU General Public License v2.0 5 votes vote down vote up
public static void doDrawRect(PixelWriter pw,
                              SunGraphics2D sg2d, SurfaceData sData,
                              int x, int y, int w, int h)
{
    if (w < 0 || h < 0) {
        return;
    }
    int x2 = Region.dimAdd(Region.dimAdd(x, w), 1);
    int y2 = Region.dimAdd(Region.dimAdd(y, h), 1);
    Region r = sg2d.getCompClip().getBoundsIntersectionXYXY(x, y, x2, y2);
    if (r.isEmpty()) {
        return;
    }
    int cx1 = r.getLoX();
    int cy1 = r.getLoY();
    int cx2 = r.getHiX();
    int cy2 = r.getHiY();

    if (w < 2 || h < 2) {
        doSetRect(sData, pw, cx1, cy1, cx2, cy2);
        return;
    }


    if (cy1 == y) {
        doSetRect(sData, pw,   cx1,   cy1,   cx2, cy1+1);
    }
    if (cx1 == x) {
        doSetRect(sData, pw,   cx1, cy1+1, cx1+1, cy2-1);
    }
    if (cx2 == x2) {
        doSetRect(sData, pw, cx2-1, cy1+1,   cx2, cy2-1);
    }
    if (cy2 == y2) {
        doSetRect(sData, pw,   cx1, cy2-1,   cx2,   cy2);
    }
}
 
Example 6
Source File: DrawGlyphList.java    From jdk8u60 with GNU General Public License v2.0 5 votes vote down vote up
public void DrawGlyphList(SunGraphics2D sg2d, SurfaceData dest,
                          GlyphList gl) {

    int strbounds[] = gl.getBounds(); // Don't delete, bug 4895493
    int num = gl.getNumGlyphs();
    Region clip = sg2d.getCompClip();
    int cx1 = clip.getLoX();
    int cy1 = clip.getLoY();
    int cx2 = clip.getHiX();
    int cy2 = clip.getHiY();
    for (int i = 0; i < num; i++) {
        gl.setGlyphIndex(i);
        int metrics[] = gl.getMetrics();
        int gx1 = metrics[0];
        int gy1 = metrics[1];
        int w = metrics[2];
        int gx2 = gx1 + w;
        int gy2 = gy1 + metrics[3];
        int off = 0;
        if (gx1 < cx1) {
            off = cx1 - gx1;
            gx1 = cx1;
        }
        if (gy1 < cy1) {
            off += (cy1 - gy1) * w;
            gy1 = cy1;
        }
        if (gx2 > cx2) gx2 = cx2;
        if (gy2 > cy2) gy2 = cy2;
        if (gx2 > gx1 && gy2 > gy1) {
            byte alpha[] = gl.getGrayBits();
            maskop.MaskFill(sg2d, dest, sg2d.composite,
                            gx1, gy1, gx2 - gx1, gy2 - gy1,
                            alpha, off, w);
        }
    }
}
 
Example 7
Source File: GeneralRenderer.java    From jdk8u-dev-jdk with GNU General Public License v2.0 5 votes vote down vote up
public PixelWriterDrawHandler(SurfaceData sData, PixelWriter pw,
                              Region clip, int strokeHint) {
    super(clip.getLoX(), clip.getLoY(),
          clip.getHiX(), clip.getHiY(),
          strokeHint);
    this.sData = sData;
    this.pw = pw;
    this.clip = clip;
}
 
Example 8
Source File: DrawGlyphList.java    From Bytecoder with Apache License 2.0 5 votes vote down vote up
public void DrawGlyphList(SunGraphics2D sg2d, SurfaceData dest,
                          GlyphList gl) {

    int[] strbounds = gl.getBounds(); // Don't delete, bug 4895493
    int num = gl.getNumGlyphs();
    Region clip = sg2d.getCompClip();
    int cx1 = clip.getLoX();
    int cy1 = clip.getLoY();
    int cx2 = clip.getHiX();
    int cy2 = clip.getHiY();
    for (int i = 0; i < num; i++) {
        gl.setGlyphIndex(i);
        int[] metrics = gl.getMetrics();
        int gx1 = metrics[0];
        int gy1 = metrics[1];
        int w = metrics[2];
        int gx2 = gx1 + w;
        int gy2 = gy1 + metrics[3];
        int off = 0;
        if (gx1 < cx1) {
            off = cx1 - gx1;
            gx1 = cx1;
        }
        if (gy1 < cy1) {
            off += (cy1 - gy1) * w;
            gy1 = cy1;
        }
        if (gx2 > cx2) gx2 = cx2;
        if (gy2 > cy2) gy2 = cy2;
        if (gx2 > gx1 && gy2 > gy1) {
            byte[] alpha = gl.getGrayBits();
            maskop.MaskFill(sg2d, dest, sg2d.composite,
                            gx1, gy1, gx2 - gx1, gy2 - gy1,
                            alpha, off, w);
        }
    }
}
 
Example 9
Source File: DrawGlyphListAA.java    From openjdk-jdk8u-backup with GNU General Public License v2.0 5 votes vote down vote up
public void DrawGlyphListAA(SunGraphics2D sg2d, SurfaceData dest,
                            GlyphList gl)
{
    gl.getBounds(); // Don't delete, bug 4895493
    int num = gl.getNumGlyphs();
    Region clip = sg2d.getCompClip();
    int cx1 = clip.getLoX();
    int cy1 = clip.getLoY();
    int cx2 = clip.getHiX();
    int cy2 = clip.getHiY();
    for (int i = 0; i < num; i++) {
        gl.setGlyphIndex(i);
        int metrics[] = gl.getMetrics();
        int gx1 = metrics[0];
        int gy1 = metrics[1];
        int w = metrics[2];
        int gx2 = gx1 + w;
        int gy2 = gy1 + metrics[3];
        int off = 0;
        if (gx1 < cx1) {
            off = cx1 - gx1;
            gx1 = cx1;
        }
        if (gy1 < cy1) {
            off += (cy1 - gy1) * w;
            gy1 = cy1;
        }
        if (gx2 > cx2) gx2 = cx2;
        if (gy2 > cy2) gy2 = cy2;
        if (gx2 > gx1 && gy2 > gy1) {
            byte alpha[] = gl.getGrayBits();
            maskop.MaskFill(sg2d, dest, sg2d.composite,
                            gx1, gy1, gx2 - gx1, gy2 - gy1,
                            alpha, off, w);
        }
    }
}
 
Example 10
Source File: DrawGlyphList.java    From hottub with GNU General Public License v2.0 5 votes vote down vote up
public void DrawGlyphList(SunGraphics2D sg2d, SurfaceData dest,
                          GlyphList gl) {

    int strbounds[] = gl.getBounds(); // Don't delete, bug 4895493
    int num = gl.getNumGlyphs();
    Region clip = sg2d.getCompClip();
    int cx1 = clip.getLoX();
    int cy1 = clip.getLoY();
    int cx2 = clip.getHiX();
    int cy2 = clip.getHiY();
    for (int i = 0; i < num; i++) {
        gl.setGlyphIndex(i);
        int metrics[] = gl.getMetrics();
        int gx1 = metrics[0];
        int gy1 = metrics[1];
        int w = metrics[2];
        int gx2 = gx1 + w;
        int gy2 = gy1 + metrics[3];
        int off = 0;
        if (gx1 < cx1) {
            off = cx1 - gx1;
            gx1 = cx1;
        }
        if (gy1 < cy1) {
            off += (cy1 - gy1) * w;
            gy1 = cy1;
        }
        if (gx2 > cx2) gx2 = cx2;
        if (gy2 > cy2) gy2 = cy2;
        if (gx2 > gx1 && gy2 > gy1) {
            byte alpha[] = gl.getGrayBits();
            maskop.MaskFill(sg2d, dest, sg2d.composite,
                            gx1, gy1, gx2 - gx1, gy2 - gy1,
                            alpha, off, w);
        }
    }
}
 
Example 11
Source File: DrawGlyphList.java    From openjdk-jdk8u with GNU General Public License v2.0 5 votes vote down vote up
public void DrawGlyphList(SunGraphics2D sg2d, SurfaceData dest,
                          GlyphList gl) {

    int strbounds[] = gl.getBounds(); // Don't delete, bug 4895493
    int num = gl.getNumGlyphs();
    Region clip = sg2d.getCompClip();
    int cx1 = clip.getLoX();
    int cy1 = clip.getLoY();
    int cx2 = clip.getHiX();
    int cy2 = clip.getHiY();
    for (int i = 0; i < num; i++) {
        gl.setGlyphIndex(i);
        int metrics[] = gl.getMetrics();
        int gx1 = metrics[0];
        int gy1 = metrics[1];
        int w = metrics[2];
        int gx2 = gx1 + w;
        int gy2 = gy1 + metrics[3];
        int off = 0;
        if (gx1 < cx1) {
            off = cx1 - gx1;
            gx1 = cx1;
        }
        if (gy1 < cy1) {
            off += (cy1 - gy1) * w;
            gy1 = cy1;
        }
        if (gx2 > cx2) gx2 = cx2;
        if (gy2 > cy2) gy2 = cy2;
        if (gx2 > gx1 && gy2 > gy1) {
            byte alpha[] = gl.getGrayBits();
            maskop.MaskFill(sg2d, dest, sg2d.composite,
                            gx1, gy1, gx2 - gx1, gy2 - gy1,
                            alpha, off, w);
        }
    }
}
 
Example 12
Source File: GeneralRenderer.java    From jdk8u_jdk with GNU General Public License v2.0 5 votes vote down vote up
public PixelWriterDrawHandler(SurfaceData sData, PixelWriter pw,
                              Region clip, int strokeHint) {
    super(clip.getLoX(), clip.getLoY(),
          clip.getHiX(), clip.getHiY(),
          strokeHint);
    this.sData = sData;
    this.pw = pw;
    this.clip = clip;
}
 
Example 13
Source File: GeneralRenderer.java    From TencentKona-8 with GNU General Public License v2.0 5 votes vote down vote up
public static void doDrawRect(PixelWriter pw,
                              SunGraphics2D sg2d, SurfaceData sData,
                              int x, int y, int w, int h)
{
    if (w < 0 || h < 0) {
        return;
    }
    int x2 = Region.dimAdd(Region.dimAdd(x, w), 1);
    int y2 = Region.dimAdd(Region.dimAdd(y, h), 1);
    Region r = sg2d.getCompClip().getBoundsIntersectionXYXY(x, y, x2, y2);
    if (r.isEmpty()) {
        return;
    }
    int cx1 = r.getLoX();
    int cy1 = r.getLoY();
    int cx2 = r.getHiX();
    int cy2 = r.getHiY();

    if (w < 2 || h < 2) {
        doSetRect(sData, pw, cx1, cy1, cx2, cy2);
        return;
    }


    if (cy1 == y) {
        doSetRect(sData, pw,   cx1,   cy1,   cx2, cy1+1);
    }
    if (cx1 == x) {
        doSetRect(sData, pw,   cx1, cy1+1, cx1+1, cy2-1);
    }
    if (cx2 == x2) {
        doSetRect(sData, pw, cx2-1, cy1+1,   cx2, cy2-1);
    }
    if (cy2 == y2) {
        doSetRect(sData, pw,   cx1, cy2-1,   cx2,   cy2);
    }
}
 
Example 14
Source File: GDIWindowSurfaceData.java    From openjdk-8 with GNU General Public License v2.0 5 votes vote down vote up
public boolean copyArea(SunGraphics2D sg2d,
                        int x, int y, int w, int h, int dx, int dy)
{
    CompositeType comptype = sg2d.imageComp;
    if (sg2d.transformState < sg2d.TRANSFORM_TRANSLATESCALE &&
        sg2d.clipState != sg2d.CLIP_SHAPE &&
        (CompositeType.SrcOverNoEa.equals(comptype) ||
         CompositeType.SrcNoEa.equals(comptype)))
    {
        x += sg2d.transX;
        y += sg2d.transY;
        int dstx1 = x + dx;
        int dsty1 = y + dy;
        int dstx2 = dstx1 + w;
        int dsty2 = dsty1 + h;
        Region clip = sg2d.getCompClip();
        if (dstx1 < clip.getLoX()) dstx1 = clip.getLoX();
        if (dsty1 < clip.getLoY()) dsty1 = clip.getLoY();
        if (dstx2 > clip.getHiX()) dstx2 = clip.getHiX();
        if (dsty2 > clip.getHiY()) dsty2 = clip.getHiY();
        if (dstx1 < dstx2 && dsty1 < dsty2) {
            gdiPipe.devCopyArea(this, dstx1 - dx, dsty1 - dy,
                                dx, dy,
                                dstx2 - dstx1, dsty2 - dsty1);
        }
        return true;
    }
    return false;
}
 
Example 15
Source File: DrawGlyphListAA.java    From hottub with GNU General Public License v2.0 5 votes vote down vote up
public void DrawGlyphListAA(SunGraphics2D sg2d, SurfaceData dest,
                            GlyphList gl)
{
    gl.getBounds(); // Don't delete, bug 4895493
    int num = gl.getNumGlyphs();
    Region clip = sg2d.getCompClip();
    int cx1 = clip.getLoX();
    int cy1 = clip.getLoY();
    int cx2 = clip.getHiX();
    int cy2 = clip.getHiY();
    for (int i = 0; i < num; i++) {
        gl.setGlyphIndex(i);
        int metrics[] = gl.getMetrics();
        int gx1 = metrics[0];
        int gy1 = metrics[1];
        int w = metrics[2];
        int gx2 = gx1 + w;
        int gy2 = gy1 + metrics[3];
        int off = 0;
        if (gx1 < cx1) {
            off = cx1 - gx1;
            gx1 = cx1;
        }
        if (gy1 < cy1) {
            off += (cy1 - gy1) * w;
            gy1 = cy1;
        }
        if (gx2 > cx2) gx2 = cx2;
        if (gy2 > cy2) gy2 = cy2;
        if (gx2 > gx1 && gy2 > gy1) {
            byte alpha[] = gl.getGrayBits();
            maskop.MaskFill(sg2d, dest, sg2d.composite,
                            gx1, gy1, gx2 - gx1, gy2 - gy1,
                            alpha, off, w);
        }
    }
}
 
Example 16
Source File: GDIWindowSurfaceData.java    From jdk8u-jdk with GNU General Public License v2.0 5 votes vote down vote up
public boolean copyArea(SunGraphics2D sg2d,
                        int x, int y, int w, int h, int dx, int dy)
{
    CompositeType comptype = sg2d.imageComp;
    if (sg2d.transformState < sg2d.TRANSFORM_TRANSLATESCALE &&
        sg2d.clipState != sg2d.CLIP_SHAPE &&
        (CompositeType.SrcOverNoEa.equals(comptype) ||
         CompositeType.SrcNoEa.equals(comptype)))
    {
        x += sg2d.transX;
        y += sg2d.transY;
        int dstx1 = x + dx;
        int dsty1 = y + dy;
        int dstx2 = dstx1 + w;
        int dsty2 = dsty1 + h;
        Region clip = sg2d.getCompClip();
        if (dstx1 < clip.getLoX()) dstx1 = clip.getLoX();
        if (dsty1 < clip.getLoY()) dsty1 = clip.getLoY();
        if (dstx2 > clip.getHiX()) dstx2 = clip.getHiX();
        if (dsty2 > clip.getHiY()) dsty2 = clip.getHiY();
        if (dstx1 < dstx2 && dsty1 < dsty2) {
            gdiPipe.devCopyArea(this, dstx1 - dx, dsty1 - dy,
                                dx, dy,
                                dstx2 - dstx1, dsty2 - dsty1);
        }
        return true;
    }
    return false;
}
 
Example 17
Source File: GeneralRenderer.java    From jdk8u-jdk with GNU General Public License v2.0 5 votes vote down vote up
public static void doDrawRect(PixelWriter pw,
                              SunGraphics2D sg2d, SurfaceData sData,
                              int x, int y, int w, int h)
{
    if (w < 0 || h < 0) {
        return;
    }
    int x2 = Region.dimAdd(Region.dimAdd(x, w), 1);
    int y2 = Region.dimAdd(Region.dimAdd(y, h), 1);
    Region r = sg2d.getCompClip().getBoundsIntersectionXYXY(x, y, x2, y2);
    if (r.isEmpty()) {
        return;
    }
    int cx1 = r.getLoX();
    int cy1 = r.getLoY();
    int cx2 = r.getHiX();
    int cy2 = r.getHiY();

    if (w < 2 || h < 2) {
        doSetRect(sData, pw, cx1, cy1, cx2, cy2);
        return;
    }


    if (cy1 == y) {
        doSetRect(sData, pw,   cx1,   cy1,   cx2, cy1+1);
    }
    if (cx1 == x) {
        doSetRect(sData, pw,   cx1, cy1+1, cx1+1, cy2-1);
    }
    if (cx2 == x2) {
        doSetRect(sData, pw, cx2-1, cy1+1,   cx2, cy2-1);
    }
    if (cy2 == y2) {
        doSetRect(sData, pw,   cx1, cy2-1,   cx2,   cy2);
    }
}
 
Example 18
Source File: SunGraphics2D.java    From openjdk-jdk8u-backup with GNU General Public License v2.0 4 votes vote down vote up
/**
 * Returns a rectangle in image coordinates that may be required
 * in order to draw the given image into the given clipping region
 * through a pair of AffineTransforms.  In addition, horizontal and
 * vertical padding factors for antialising and interpolation may
 * be used.
 */
private static Rectangle getImageRegion(RenderedImage img,
                                        Region compClip,
                                        AffineTransform transform,
                                        AffineTransform xform,
                                        int padX, int padY) {
    Rectangle imageRect =
        new Rectangle(img.getMinX(), img.getMinY(),
                      img.getWidth(), img.getHeight());

    Rectangle result = null;
    try {
        double p[] = new double[8];
        p[0] = p[2] = compClip.getLoX();
        p[4] = p[6] = compClip.getHiX();
        p[1] = p[5] = compClip.getLoY();
        p[3] = p[7] = compClip.getHiY();

        // Inverse transform the output bounding rect
        transform.inverseTransform(p, 0, p, 0, 4);
        xform.inverseTransform(p, 0, p, 0, 4);

        // Determine a bounding box for the inverse transformed region
        double x0,x1,y0,y1;
        x0 = x1 = p[0];
        y0 = y1 = p[1];

        for (int i = 2; i < 8; ) {
            double pt = p[i++];
            if (pt < x0)  {
                x0 = pt;
            } else if (pt > x1) {
                x1 = pt;
            }
            pt = p[i++];
            if (pt < y0)  {
                y0 = pt;
            } else if (pt > y1) {
                y1 = pt;
            }
        }

        // This is padding for anti-aliasing and such.  It may
        // be more than is needed.
        int x = (int)x0 - padX;
        int w = (int)(x1 - x0 + 2*padX);
        int y = (int)y0 - padY;
        int h = (int)(y1 - y0 + 2*padY);

        Rectangle clipRect = new Rectangle(x,y,w,h);
        result = clipRect.intersection(imageRect);
    } catch (NoninvertibleTransformException nte) {
        // Worst case bounds are the bounds of the image.
        result = imageRect;
    }

    return result;
}
 
Example 19
Source File: SunGraphics2D.java    From dragonwell8_jdk with GNU General Public License v2.0 4 votes vote down vote up
/**
 * Returns a rectangle in image coordinates that may be required
 * in order to draw the given image into the given clipping region
 * through a pair of AffineTransforms.  In addition, horizontal and
 * vertical padding factors for antialising and interpolation may
 * be used.
 */
private static Rectangle getImageRegion(RenderedImage img,
                                        Region compClip,
                                        AffineTransform transform,
                                        AffineTransform xform,
                                        int padX, int padY) {
    Rectangle imageRect =
        new Rectangle(img.getMinX(), img.getMinY(),
                      img.getWidth(), img.getHeight());

    Rectangle result = null;
    try {
        double p[] = new double[8];
        p[0] = p[2] = compClip.getLoX();
        p[4] = p[6] = compClip.getHiX();
        p[1] = p[5] = compClip.getLoY();
        p[3] = p[7] = compClip.getHiY();

        // Inverse transform the output bounding rect
        transform.inverseTransform(p, 0, p, 0, 4);
        xform.inverseTransform(p, 0, p, 0, 4);

        // Determine a bounding box for the inverse transformed region
        double x0,x1,y0,y1;
        x0 = x1 = p[0];
        y0 = y1 = p[1];

        for (int i = 2; i < 8; ) {
            double pt = p[i++];
            if (pt < x0)  {
                x0 = pt;
            } else if (pt > x1) {
                x1 = pt;
            }
            pt = p[i++];
            if (pt < y0)  {
                y0 = pt;
            } else if (pt > y1) {
                y1 = pt;
            }
        }

        // This is padding for anti-aliasing and such.  It may
        // be more than is needed.
        int x = (int)x0 - padX;
        int w = (int)(x1 - x0 + 2*padX);
        int y = (int)y0 - padY;
        int h = (int)(y1 - y0 + 2*padY);

        Rectangle clipRect = new Rectangle(x,y,w,h);
        result = clipRect.intersection(imageRect);
    } catch (NoninvertibleTransformException nte) {
        // Worst case bounds are the bounds of the image.
        result = imageRect;
    }

    return result;
}
 
Example 20
Source File: SunGraphics2D.java    From jdk8u60 with GNU General Public License v2.0 4 votes vote down vote up
/**
 * Returns a rectangle in image coordinates that may be required
 * in order to draw the given image into the given clipping region
 * through a pair of AffineTransforms.  In addition, horizontal and
 * vertical padding factors for antialising and interpolation may
 * be used.
 */
private static Rectangle getImageRegion(RenderedImage img,
                                        Region compClip,
                                        AffineTransform transform,
                                        AffineTransform xform,
                                        int padX, int padY) {
    Rectangle imageRect =
        new Rectangle(img.getMinX(), img.getMinY(),
                      img.getWidth(), img.getHeight());

    Rectangle result = null;
    try {
        double p[] = new double[8];
        p[0] = p[2] = compClip.getLoX();
        p[4] = p[6] = compClip.getHiX();
        p[1] = p[5] = compClip.getLoY();
        p[3] = p[7] = compClip.getHiY();

        // Inverse transform the output bounding rect
        transform.inverseTransform(p, 0, p, 0, 4);
        xform.inverseTransform(p, 0, p, 0, 4);

        // Determine a bounding box for the inverse transformed region
        double x0,x1,y0,y1;
        x0 = x1 = p[0];
        y0 = y1 = p[1];

        for (int i = 2; i < 8; ) {
            double pt = p[i++];
            if (pt < x0)  {
                x0 = pt;
            } else if (pt > x1) {
                x1 = pt;
            }
            pt = p[i++];
            if (pt < y0)  {
                y0 = pt;
            } else if (pt > y1) {
                y1 = pt;
            }
        }

        // This is padding for anti-aliasing and such.  It may
        // be more than is needed.
        int x = (int)x0 - padX;
        int w = (int)(x1 - x0 + 2*padX);
        int y = (int)y0 - padY;
        int h = (int)(y1 - y0 + 2*padY);

        Rectangle clipRect = new Rectangle(x,y,w,h);
        result = clipRect.intersection(imageRect);
    } catch (NoninvertibleTransformException nte) {
        // Worst case bounds are the bounds of the image.
        result = imageRect;
    }

    return result;
}