Java Code Examples for sun.java2d.SunGraphics2D#untransformShape()

The following examples show how to use sun.java2d.SunGraphics2D#untransformShape() . 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: TextRenderer.java    From dragonwell8_jdk with GNU General Public License v2.0 4 votes vote down vote up
protected void drawGlyphList(SunGraphics2D sg2d, GlyphList gl) {
    int num = gl.getNumGlyphs();
    Region clipRegion = sg2d.getCompClip();
    int cx1 = clipRegion.getLoX();
    int cy1 = clipRegion.getLoY();
    int cx2 = clipRegion.getHiX();
    int cy2 = clipRegion.getHiY();
    Object ctx = null;
    try {
        int[] bounds = gl.getBounds();
        Rectangle r = new Rectangle(bounds[0], bounds[1],
                                    bounds[2] - bounds[0],
                                    bounds[3] - bounds[1]);
        Shape s = sg2d.untransformShape(r);
        ctx = outpipe.startSequence(sg2d, s, r, bounds);
        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 &&
                outpipe.needTile(ctx, gx1, gy1, gx2 - gx1, gy2 - gy1))
            {
                byte alpha[] = gl.getGrayBits();
                outpipe.renderPathTile(ctx, alpha, off, w,
                                       gx1, gy1, gx2 - gx1, gy2 - gy1);
            } else {
                outpipe.skipTile(ctx, gx1, gy1);
            }
        }
    } finally {
        if (ctx != null) {
            outpipe.endSequence(ctx);
        }
    }
}
 
Example 2
Source File: TextRenderer.java    From TencentKona-8 with GNU General Public License v2.0 4 votes vote down vote up
protected void drawGlyphList(SunGraphics2D sg2d, GlyphList gl) {
    int num = gl.getNumGlyphs();
    Region clipRegion = sg2d.getCompClip();
    int cx1 = clipRegion.getLoX();
    int cy1 = clipRegion.getLoY();
    int cx2 = clipRegion.getHiX();
    int cy2 = clipRegion.getHiY();
    Object ctx = null;
    try {
        int[] bounds = gl.getBounds();
        Rectangle r = new Rectangle(bounds[0], bounds[1],
                                    bounds[2] - bounds[0],
                                    bounds[3] - bounds[1]);
        Shape s = sg2d.untransformShape(r);
        ctx = outpipe.startSequence(sg2d, s, r, bounds);
        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 &&
                outpipe.needTile(ctx, gx1, gy1, gx2 - gx1, gy2 - gy1))
            {
                byte alpha[] = gl.getGrayBits();
                outpipe.renderPathTile(ctx, alpha, off, w,
                                       gx1, gy1, gx2 - gx1, gy2 - gy1);
            } else {
                outpipe.skipTile(ctx, gx1, gy1);
            }
        }
    } finally {
        if (ctx != null) {
            outpipe.endSequence(ctx);
        }
    }
}
 
Example 3
Source File: TextRenderer.java    From jdk8u60 with GNU General Public License v2.0 4 votes vote down vote up
protected void drawGlyphList(SunGraphics2D sg2d, GlyphList gl) {
    int num = gl.getNumGlyphs();
    Region clipRegion = sg2d.getCompClip();
    int cx1 = clipRegion.getLoX();
    int cy1 = clipRegion.getLoY();
    int cx2 = clipRegion.getHiX();
    int cy2 = clipRegion.getHiY();
    Object ctx = null;
    try {
        int[] bounds = gl.getBounds();
        Rectangle r = new Rectangle(bounds[0], bounds[1],
                                    bounds[2] - bounds[0],
                                    bounds[3] - bounds[1]);
        Shape s = sg2d.untransformShape(r);
        ctx = outpipe.startSequence(sg2d, s, r, bounds);
        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 &&
                outpipe.needTile(ctx, gx1, gy1, gx2 - gx1, gy2 - gy1))
            {
                byte alpha[] = gl.getGrayBits();
                outpipe.renderPathTile(ctx, alpha, off, w,
                                       gx1, gy1, gx2 - gx1, gy2 - gy1);
            } else {
                outpipe.skipTile(ctx, gx1, gy1);
            }
        }
    } finally {
        if (ctx != null) {
            outpipe.endSequence(ctx);
        }
    }
}
 
Example 4
Source File: TextRenderer.java    From openjdk-jdk8u with GNU General Public License v2.0 4 votes vote down vote up
protected void drawGlyphList(SunGraphics2D sg2d, GlyphList gl) {
    int num = gl.getNumGlyphs();
    Region clipRegion = sg2d.getCompClip();
    int cx1 = clipRegion.getLoX();
    int cy1 = clipRegion.getLoY();
    int cx2 = clipRegion.getHiX();
    int cy2 = clipRegion.getHiY();
    Object ctx = null;
    try {
        int[] bounds = gl.getBounds();
        Rectangle r = new Rectangle(bounds[0], bounds[1],
                                    bounds[2] - bounds[0],
                                    bounds[3] - bounds[1]);
        Shape s = sg2d.untransformShape(r);
        ctx = outpipe.startSequence(sg2d, s, r, bounds);
        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 &&
                outpipe.needTile(ctx, gx1, gy1, gx2 - gx1, gy2 - gy1))
            {
                byte alpha[] = gl.getGrayBits();
                outpipe.renderPathTile(ctx, alpha, off, w,
                                       gx1, gy1, gx2 - gx1, gy2 - gy1);
            } else {
                outpipe.skipTile(ctx, gx1, gy1);
            }
        }
    } finally {
        if (ctx != null) {
            outpipe.endSequence(ctx);
        }
    }
}
 
Example 5
Source File: TextRenderer.java    From openjdk-jdk8u-backup with GNU General Public License v2.0 4 votes vote down vote up
protected void drawGlyphList(SunGraphics2D sg2d, GlyphList gl) {
    int num = gl.getNumGlyphs();
    Region clipRegion = sg2d.getCompClip();
    int cx1 = clipRegion.getLoX();
    int cy1 = clipRegion.getLoY();
    int cx2 = clipRegion.getHiX();
    int cy2 = clipRegion.getHiY();
    Object ctx = null;
    try {
        int[] bounds = gl.getBounds();
        Rectangle r = new Rectangle(bounds[0], bounds[1],
                                    bounds[2] - bounds[0],
                                    bounds[3] - bounds[1]);
        Shape s = sg2d.untransformShape(r);
        ctx = outpipe.startSequence(sg2d, s, r, bounds);
        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 &&
                outpipe.needTile(ctx, gx1, gy1, gx2 - gx1, gy2 - gy1))
            {
                byte alpha[] = gl.getGrayBits();
                outpipe.renderPathTile(ctx, alpha, off, w,
                                       gx1, gy1, gx2 - gx1, gy2 - gy1);
            } else {
                outpipe.skipTile(ctx, gx1, gy1);
            }
        }
    } finally {
        if (ctx != null) {
            outpipe.endSequence(ctx);
        }
    }
}
 
Example 6
Source File: TextRenderer.java    From Bytecoder with Apache License 2.0 4 votes vote down vote up
protected void drawGlyphList(SunGraphics2D sg2d, GlyphList gl) {
    int num = gl.getNumGlyphs();
    Region clipRegion = sg2d.getCompClip();
    int cx1 = clipRegion.getLoX();
    int cy1 = clipRegion.getLoY();
    int cx2 = clipRegion.getHiX();
    int cy2 = clipRegion.getHiY();
    Object ctx = null;
    try {
        int[] bounds = gl.getBounds();
        Rectangle r = new Rectangle(bounds[0], bounds[1],
                                    bounds[2] - bounds[0],
                                    bounds[3] - bounds[1]);
        Shape s = sg2d.untransformShape(r);
        ctx = outpipe.startSequence(sg2d, s, r, bounds);
        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 &&
                outpipe.needTile(ctx, gx1, gy1, gx2 - gx1, gy2 - gy1))
            {
                byte[] alpha = gl.getGrayBits();
                outpipe.renderPathTile(ctx, alpha, off, w,
                                       gx1, gy1, gx2 - gx1, gy2 - gy1);
            } else {
                outpipe.skipTile(ctx, gx1, gy1);
            }
        }
    } finally {
        if (ctx != null) {
            outpipe.endSequence(ctx);
        }
    }
}
 
Example 7
Source File: TextRenderer.java    From openjdk-jdk9 with GNU General Public License v2.0 4 votes vote down vote up
protected void drawGlyphList(SunGraphics2D sg2d, GlyphList gl) {
    int num = gl.getNumGlyphs();
    Region clipRegion = sg2d.getCompClip();
    int cx1 = clipRegion.getLoX();
    int cy1 = clipRegion.getLoY();
    int cx2 = clipRegion.getHiX();
    int cy2 = clipRegion.getHiY();
    Object ctx = null;
    try {
        int[] bounds = gl.getBounds();
        Rectangle r = new Rectangle(bounds[0], bounds[1],
                                    bounds[2] - bounds[0],
                                    bounds[3] - bounds[1]);
        Shape s = sg2d.untransformShape(r);
        ctx = outpipe.startSequence(sg2d, s, r, bounds);
        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 &&
                outpipe.needTile(ctx, gx1, gy1, gx2 - gx1, gy2 - gy1))
            {
                byte alpha[] = gl.getGrayBits();
                outpipe.renderPathTile(ctx, alpha, off, w,
                                       gx1, gy1, gx2 - gx1, gy2 - gy1);
            } else {
                outpipe.skipTile(ctx, gx1, gy1);
            }
        }
    } finally {
        if (ctx != null) {
            outpipe.endSequence(ctx);
        }
    }
}
 
Example 8
Source File: TextRenderer.java    From jdk8u-jdk with GNU General Public License v2.0 4 votes vote down vote up
protected void drawGlyphList(SunGraphics2D sg2d, GlyphList gl) {
    int num = gl.getNumGlyphs();
    Region clipRegion = sg2d.getCompClip();
    int cx1 = clipRegion.getLoX();
    int cy1 = clipRegion.getLoY();
    int cx2 = clipRegion.getHiX();
    int cy2 = clipRegion.getHiY();
    Object ctx = null;
    try {
        int[] bounds = gl.getBounds();
        Rectangle r = new Rectangle(bounds[0], bounds[1],
                                    bounds[2] - bounds[0],
                                    bounds[3] - bounds[1]);
        Shape s = sg2d.untransformShape(r);
        ctx = outpipe.startSequence(sg2d, s, r, bounds);
        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 &&
                outpipe.needTile(ctx, gx1, gy1, gx2 - gx1, gy2 - gy1))
            {
                byte alpha[] = gl.getGrayBits();
                outpipe.renderPathTile(ctx, alpha, off, w,
                                       gx1, gy1, gx2 - gx1, gy2 - gy1);
            } else {
                outpipe.skipTile(ctx, gx1, gy1);
            }
        }
    } finally {
        if (ctx != null) {
            outpipe.endSequence(ctx);
        }
    }
}
 
Example 9
Source File: TextRenderer.java    From hottub with GNU General Public License v2.0 4 votes vote down vote up
protected void drawGlyphList(SunGraphics2D sg2d, GlyphList gl) {
    int num = gl.getNumGlyphs();
    Region clipRegion = sg2d.getCompClip();
    int cx1 = clipRegion.getLoX();
    int cy1 = clipRegion.getLoY();
    int cx2 = clipRegion.getHiX();
    int cy2 = clipRegion.getHiY();
    Object ctx = null;
    try {
        int[] bounds = gl.getBounds();
        Rectangle r = new Rectangle(bounds[0], bounds[1],
                                    bounds[2] - bounds[0],
                                    bounds[3] - bounds[1]);
        Shape s = sg2d.untransformShape(r);
        ctx = outpipe.startSequence(sg2d, s, r, bounds);
        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 &&
                outpipe.needTile(ctx, gx1, gy1, gx2 - gx1, gy2 - gy1))
            {
                byte alpha[] = gl.getGrayBits();
                outpipe.renderPathTile(ctx, alpha, off, w,
                                       gx1, gy1, gx2 - gx1, gy2 - gy1);
            } else {
                outpipe.skipTile(ctx, gx1, gy1);
            }
        }
    } finally {
        if (ctx != null) {
            outpipe.endSequence(ctx);
        }
    }
}
 
Example 10
Source File: TextRenderer.java    From openjdk-8-source with GNU General Public License v2.0 4 votes vote down vote up
protected void drawGlyphList(SunGraphics2D sg2d, GlyphList gl) {
    int num = gl.getNumGlyphs();
    Region clipRegion = sg2d.getCompClip();
    int cx1 = clipRegion.getLoX();
    int cy1 = clipRegion.getLoY();
    int cx2 = clipRegion.getHiX();
    int cy2 = clipRegion.getHiY();
    Object ctx = null;
    try {
        int[] bounds = gl.getBounds();
        Rectangle r = new Rectangle(bounds[0], bounds[1],
                                    bounds[2] - bounds[0],
                                    bounds[3] - bounds[1]);
        Shape s = sg2d.untransformShape(r);
        ctx = outpipe.startSequence(sg2d, s, r, bounds);
        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 &&
                outpipe.needTile(ctx, gx1, gy1, gx2 - gx1, gy2 - gy1))
            {
                byte alpha[] = gl.getGrayBits();
                outpipe.renderPathTile(ctx, alpha, off, w,
                                       gx1, gy1, gx2 - gx1, gy2 - gy1);
            } else {
                outpipe.skipTile(ctx, gx1, gy1);
            }
        }
    } finally {
        if (ctx != null) {
            outpipe.endSequence(ctx);
        }
    }
}
 
Example 11
Source File: TextRenderer.java    From openjdk-8 with GNU General Public License v2.0 4 votes vote down vote up
protected void drawGlyphList(SunGraphics2D sg2d, GlyphList gl) {
    int num = gl.getNumGlyphs();
    Region clipRegion = sg2d.getCompClip();
    int cx1 = clipRegion.getLoX();
    int cy1 = clipRegion.getLoY();
    int cx2 = clipRegion.getHiX();
    int cy2 = clipRegion.getHiY();
    Object ctx = null;
    try {
        int[] bounds = gl.getBounds();
        Rectangle r = new Rectangle(bounds[0], bounds[1],
                                    bounds[2] - bounds[0],
                                    bounds[3] - bounds[1]);
        Shape s = sg2d.untransformShape(r);
        ctx = outpipe.startSequence(sg2d, s, r, bounds);
        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 &&
                outpipe.needTile(ctx, gx1, gy1, gx2 - gx1, gy2 - gy1))
            {
                byte alpha[] = gl.getGrayBits();
                outpipe.renderPathTile(ctx, alpha, off, w,
                                       gx1, gy1, gx2 - gx1, gy2 - gy1);
            } else {
                outpipe.skipTile(ctx, gx1, gy1);
            }
        }
    } finally {
        if (ctx != null) {
            outpipe.endSequence(ctx);
        }
    }
}
 
Example 12
Source File: TextRenderer.java    From jdk8u_jdk with GNU General Public License v2.0 4 votes vote down vote up
protected void drawGlyphList(SunGraphics2D sg2d, GlyphList gl) {
    int num = gl.getNumGlyphs();
    Region clipRegion = sg2d.getCompClip();
    int cx1 = clipRegion.getLoX();
    int cy1 = clipRegion.getLoY();
    int cx2 = clipRegion.getHiX();
    int cy2 = clipRegion.getHiY();
    Object ctx = null;
    try {
        int[] bounds = gl.getBounds();
        Rectangle r = new Rectangle(bounds[0], bounds[1],
                                    bounds[2] - bounds[0],
                                    bounds[3] - bounds[1]);
        Shape s = sg2d.untransformShape(r);
        ctx = outpipe.startSequence(sg2d, s, r, bounds);
        gl.startGlyphIteration();
        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 && !gl.isColorGlyph(i) &&
                outpipe.needTile(ctx, gx1, gy1, gx2 - gx1, gy2 - gy1))
            {
                byte alpha[] = gl.getGrayBits();
                outpipe.renderPathTile(ctx, alpha, off, w,
                                       gx1, gy1, gx2 - gx1, gy2 - gy1);
            } else {
                outpipe.skipTile(ctx, gx1, gy1);
            }
        }
    } finally {
        if (ctx != null) {
            outpipe.endSequence(ctx);
        }
    }
}
 
Example 13
Source File: TextRenderer.java    From jdk8u-jdk with GNU General Public License v2.0 4 votes vote down vote up
protected void drawGlyphList(SunGraphics2D sg2d, GlyphList gl) {
    int num = gl.getNumGlyphs();
    Region clipRegion = sg2d.getCompClip();
    int cx1 = clipRegion.getLoX();
    int cy1 = clipRegion.getLoY();
    int cx2 = clipRegion.getHiX();
    int cy2 = clipRegion.getHiY();
    Object ctx = null;
    try {
        int[] bounds = gl.getBounds();
        Rectangle r = new Rectangle(bounds[0], bounds[1],
                                    bounds[2] - bounds[0],
                                    bounds[3] - bounds[1]);
        Shape s = sg2d.untransformShape(r);
        ctx = outpipe.startSequence(sg2d, s, r, bounds);
        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 &&
                outpipe.needTile(ctx, gx1, gy1, gx2 - gx1, gy2 - gy1))
            {
                byte alpha[] = gl.getGrayBits();
                outpipe.renderPathTile(ctx, alpha, off, w,
                                       gx1, gy1, gx2 - gx1, gy2 - gy1);
            } else {
                outpipe.skipTile(ctx, gx1, gy1);
            }
        }
    } finally {
        if (ctx != null) {
            outpipe.endSequence(ctx);
        }
    }
}
 
Example 14
Source File: TextRenderer.java    From jdk8u-dev-jdk with GNU General Public License v2.0 4 votes vote down vote up
protected void drawGlyphList(SunGraphics2D sg2d, GlyphList gl) {
    int num = gl.getNumGlyphs();
    Region clipRegion = sg2d.getCompClip();
    int cx1 = clipRegion.getLoX();
    int cy1 = clipRegion.getLoY();
    int cx2 = clipRegion.getHiX();
    int cy2 = clipRegion.getHiY();
    Object ctx = null;
    try {
        int[] bounds = gl.getBounds();
        Rectangle r = new Rectangle(bounds[0], bounds[1],
                                    bounds[2] - bounds[0],
                                    bounds[3] - bounds[1]);
        Shape s = sg2d.untransformShape(r);
        ctx = outpipe.startSequence(sg2d, s, r, bounds);
        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 &&
                outpipe.needTile(ctx, gx1, gy1, gx2 - gx1, gy2 - gy1))
            {
                byte alpha[] = gl.getGrayBits();
                outpipe.renderPathTile(ctx, alpha, off, w,
                                       gx1, gy1, gx2 - gx1, gy2 - gy1);
            } else {
                outpipe.skipTile(ctx, gx1, gy1);
            }
        }
    } finally {
        if (ctx != null) {
            outpipe.endSequence(ctx);
        }
    }
}